From: Martin Jones Date: Mon, 14 Nov 2011 03:00:31 +0000 (+1000) Subject: autotest for setting parent in a component created by Loader. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=21de6faafef6210ffe5082f667e83d2bbc5a8772;p=konrad%2Fqtdeclarative.git autotest for setting parent in a component created by Loader. Change-Id: I1b6850ce5e4a820b5ab7b2d06a877307104478a1 Reviewed-by: Alan Alpert --- diff --git a/tests/auto/declarative/qquickloader/data/parented.qml b/tests/auto/declarative/qquickloader/data/parented.qml new file mode 100644 index 0000000..1c19d4d --- /dev/null +++ b/tests/auto/declarative/qquickloader/data/parented.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Item { + id: root + width: 300; height: 300 + + Component { + id: comp + Rectangle { + objectName: "comp" + parent: root + anchors.fill: parent + color: "blue" + } + } + + Loader { + width: 200; height: 200 + sourceComponent: comp + } +} diff --git a/tests/auto/declarative/qquickloader/tst_qquickloader.cpp b/tests/auto/declarative/qquickloader/tst_qquickloader.cpp index 0096bc3..96d0d88 100644 --- a/tests/auto/declarative/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/declarative/qquickloader/tst_qquickloader.cpp @@ -108,6 +108,8 @@ private slots: void asynchronous(); void asynchronous_clear(); + void parented(); + private: QDeclarativeEngine engine; }; @@ -944,6 +946,23 @@ void tst_QQuickLoader::asynchronous_clear() QCOMPARE(static_cast(loader)->childItems().count(), 1); } +void tst_QQuickLoader::parented() +{ + QDeclarativeComponent component(&engine, TEST_FILE("parented.qml")); + QQuickItem *root = qobject_cast(component.create()); + QVERIFY(root); + + QQuickItem *item = root->findChild("comp"); + QVERIFY(item); + + QVERIFY(item->parentItem() == root); + + QCOMPARE(item->width(), 300.); + QCOMPARE(item->height(), 300.); + + delete root; +} + QTEST_MAIN(tst_QQuickLoader)