aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@digia.com>2014-09-23 10:36:22 +0200
committerMitch Curtis <mitch.curtis@digia.com>2014-09-29 12:24:46 +0200
commit29b77e5e0759472ab1f7da1dd756b857d3b2ddd7 (patch)
tree37a57566d8ebbbd239eb6ad131b54edc2f8920a5 /tests/auto/qmltest
parent2bd7438d77c8544d263c51be432206970eae5ccf (diff)
Also search for visual children in TestCase::findChild().
It previously used QObject::findChild(), which won't work in all cases, because items like ListView don't seem to make their delegate items QObject children, while simple nested Items do. Change-Id: I1a8ed1fb55493212cb25abf595d016437812a80f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests/auto/qmltest')
-rw-r--r--tests/auto/qmltest/selftests/tst_findChild.qml37
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/auto/qmltest/selftests/tst_findChild.qml b/tests/auto/qmltest/selftests/tst_findChild.qml
index 1ed4c94423..69bcb390e9 100644
--- a/tests/auto/qmltest/selftests/tst_findChild.qml
+++ b/tests/auto/qmltest/selftests/tst_findChild.qml
@@ -82,6 +82,33 @@ TestCase {
objectName: "nestedChildItem2"
}
+ Loader {
+ id: loader
+
+ sourceComponent: Item {
+ id: loaderItem
+ objectName: "loaderItem"
+
+ Item {
+ objectName: "nestedLoaderItem"
+ }
+
+ Repeater {
+ model: 5
+ delegate: Item {
+ objectName: "repeaterItem" + index
+ }
+ }
+
+ ListView {
+ model: 5
+ delegate: Item {
+ objectName: "listViewItem" + index
+ }
+ }
+ }
+ }
+
function test_findChild() {
compare(findChild(null, ""), null);
compare(findChild(undefined, ""), null);
@@ -99,6 +126,14 @@ TestCase {
var mostDirectChild = duplicateNestedChildItem2Component.createObject(nestedChildItem0);
compare(nestedChildItem0.children.length, 2);
- compare(findChild(nestedChildrenItem, "nestedChildItem2"), mostDirectChild);
+ compare(findChild(nestedChildrenItem, "nestedChildItem2"), mostDirectChild,
+ "Dynamically created nested child items are found");
+
+ compare(findChild(loader, "loaderItem"), loader.item);
+ verify(findChild(loader, "nestedLoaderItem"));
+
+ // These don't make their delegate items QObject children, only visual.
+ verify(findChild(loader, "repeaterItem0"));
+ verify(findChild(loader, "listViewItem0"));
}
}