diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-11-14 13:00:31 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-14 06:38:57 +0100 |
commit | 21de6faafef6210ffe5082f667e83d2bbc5a8772 (patch) | |
tree | 14e74b5ce1e701708156b1b36cb097d55661bd73 | |
parent | c430ff551d621a4c7a344224ad1964fb4c7e72f6 (diff) |
autotest for setting parent in a component created by Loader.
Change-Id: I1b6850ce5e4a820b5ab7b2d06a877307104478a1
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
-rw-r--r-- | tests/auto/declarative/qquickloader/data/parented.qml | 21 | ||||
-rw-r--r-- | tests/auto/declarative/qquickloader/tst_qquickloader.cpp | 19 |
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/declarative/qquickloader/data/parented.qml b/tests/auto/declarative/qquickloader/data/parented.qml new file mode 100644 index 0000000000..1c19d4d1a5 --- /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 0096bc39b6..96d0d88a84 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<QQuickItem*>(loader)->childItems().count(), 1); } +void tst_QQuickLoader::parented() +{ + QDeclarativeComponent component(&engine, TEST_FILE("parented.qml")); + QQuickItem *root = qobject_cast<QQuickItem*>(component.create()); + QVERIFY(root); + + QQuickItem *item = root->findChild<QQuickItem*>("comp"); + QVERIFY(item); + + QVERIFY(item->parentItem() == root); + + QCOMPARE(item->width(), 300.); + QCOMPARE(item->height(), 300.); + + delete root; +} + QTEST_MAIN(tst_QQuickLoader) |