diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2016-10-12 12:08:26 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2016-10-14 10:01:26 +0000 |
commit | 0eac16fbda846c951f9b3887199e72b66f5aacd7 (patch) | |
tree | 31e5e7133326ed358a5d132fc1587dfc7b7ca4f8 /tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp | |
parent | 2c147f2be69ada6aa896e7fb753c3c05fbf46730 (diff) |
NodeInstantiator created nodes go to its parentv5.7.1
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 <sean.harmer@kdab.com>
Diffstat (limited to 'tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp')
-rw-r--r-- | tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
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<Quick3DNodeInstantiator*>(component.create()); + const auto root = qobject_cast<Qt3DCore::QNode*>(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild<Quick3DNodeInstantiator*>(); 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<Quick3DNodeInstantiator*>(component.create()); + const auto root = qobject_cast<Qt3DCore::QNode*>(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild<Quick3DNodeInstantiator*>(); 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<Quick3DNodeInstantiator*>(component.create()); + const auto root = qobject_cast<Qt3DCore::QNode*>(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild<Quick3DNodeInstantiator*>(); 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<Quick3DNodeInstantiator*>(component.create()); + const auto root = qobject_cast<Qt3DCore::QNode*>(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild<Quick3DNodeInstantiator*>(); 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<Quick3DNodeInstantiator*>(component.create()); + const auto root = qobject_cast<Qt3DCore::QNode*>(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild<Quick3DNodeInstantiator*>(); 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<Quick3DNodeInstantiator*>(component.create()); + const auto root = qobject_cast<Qt3DCore::QNode*>(component.create()); + QVERIFY(root != 0); + const auto instantiator = root->findChild<Quick3DNodeInstantiator*>(); 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); } |