From 0eac16fbda846c951f9b3887199e72b66f5aacd7 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Wed, 12 Oct 2016 12:08:26 +0200 Subject: NodeInstantiator created nodes go to its parent Currently, elements created by the NodeInstantiator are children of the instantiator itself. Change that to parent them in the instantiator parent instead. Rationale for that is that it will behave similarly to Repeater this way, and gives a chance of using NodeInstantiator in frame graphs. Indeed, anything which is not a FrameGraphNode gets pruned in that context that would include branches starting from NodeInstantiator. Change-Id: I651a51471d92fcf466c9abd5dbbbfa2960ef1247 Task-Id: QTBUG-55908 Reviewed-by: Sean Harmer --- .../tst_quick3dnodeinstantiator.cpp | 34 +++++++++++++++------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp') diff --git a/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp b/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp index fd7f0eb0c..acaba6690 100644 --- a/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp +++ b/tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp @@ -60,7 +60,9 @@ void tst_quick3dnodeinstantiator::createNone() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("createNone.qml")); - Quick3DNodeInstantiator *instantiator = qobject_cast(component.create()); + const auto root = qobject_cast(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild(); QVERIFY(instantiator != 0); QCOMPARE(instantiator->isActive(), true); QCOMPARE(instantiator->count(), 0); @@ -72,7 +74,9 @@ void tst_quick3dnodeinstantiator::createSingle() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("createSingle.qml")); - Quick3DNodeInstantiator *instantiator = qobject_cast(component.create()); + const auto root = qobject_cast(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild(); QVERIFY(instantiator != 0); QCOMPARE(instantiator->isActive(), true); QCOMPARE(instantiator->count(), 1); @@ -80,7 +84,7 @@ void tst_quick3dnodeinstantiator::createSingle() QObject *object = instantiator->object(); QVERIFY(object); - QCOMPARE(object->parent(), instantiator); + QCOMPARE(object->parent(), root); QCOMPARE(object->property("success").toBool(), true); QCOMPARE(object->property("idx").toInt(), 0); } @@ -89,7 +93,9 @@ void tst_quick3dnodeinstantiator::createMultiple() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("createMultiple.qml")); - Quick3DNodeInstantiator *instantiator = qobject_cast(component.create()); + const auto root = qobject_cast(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild(); QVERIFY(instantiator != 0); QCOMPARE(instantiator->isActive(), true); QCOMPARE(instantiator->count(), 10); @@ -97,7 +103,7 @@ void tst_quick3dnodeinstantiator::createMultiple() for (int i = 0; i < 10; i++) { QObject *object = instantiator->objectAt(i); QVERIFY(object); - QCOMPARE(object->parent(), instantiator); + QCOMPARE(object->parent(), root); QCOMPARE(object->property("success").toBool(), true); QCOMPARE(object->property("idx").toInt(), i); } @@ -107,7 +113,9 @@ void tst_quick3dnodeinstantiator::stringModel() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("stringModel.qml")); - Quick3DNodeInstantiator *instantiator = qobject_cast(component.create()); + const auto root = qobject_cast(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild(); QVERIFY(instantiator != 0); QCOMPARE(instantiator->isActive(), true); QCOMPARE(instantiator->count(), 4); @@ -115,7 +123,7 @@ void tst_quick3dnodeinstantiator::stringModel() for (int i = 0; i < 4; i++) { QObject *object = instantiator->objectAt(i); QVERIFY(object); - QCOMPARE(object->parent(), instantiator); + QCOMPARE(object->parent(), root); QCOMPARE(object->property("success").toBool(), true); } } @@ -124,7 +132,9 @@ void tst_quick3dnodeinstantiator::activeProperty() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("inactive.qml")); - Quick3DNodeInstantiator *instantiator = qobject_cast(component.create()); + const auto root = qobject_cast(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild(); QVERIFY(instantiator != 0); QSignalSpy activeSpy(instantiator, SIGNAL(activeChanged())); QSignalSpy countSpy(instantiator, SIGNAL(countChanged())); @@ -150,7 +160,7 @@ void tst_quick3dnodeinstantiator::activeProperty() QObject *object = instantiator->object(); QVERIFY(object); - QCOMPARE(object->parent(), instantiator); + QCOMPARE(object->parent(), root); QCOMPARE(object->property("success").toBool(), true); QCOMPARE(object->property("idx").toInt(), 0); } @@ -159,7 +169,9 @@ void tst_quick3dnodeinstantiator::intModelChange() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("createMultiple.qml")); - Quick3DNodeInstantiator *instantiator = qobject_cast(component.create()); + const auto root = qobject_cast(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild(); QVERIFY(instantiator != 0); QSignalSpy activeSpy(instantiator, SIGNAL(activeChanged())); QSignalSpy countSpy(instantiator, SIGNAL(countChanged())); @@ -183,7 +195,7 @@ void tst_quick3dnodeinstantiator::intModelChange() for (int i = 0; i < 2; i++) { QObject *object = instantiator->objectAt(i); QVERIFY(object); - QCOMPARE(object->parent(), instantiator); + QCOMPARE(object->parent(), root); QCOMPARE(object->property("success").toBool(), true); QCOMPARE(object->property("idx").toInt(), i); } -- cgit v1.2.3