on xenial help sign in
Make findChild stubborn by default
2123eb8Albert Astals Cid
tests/qmltests/Dash/tst_Dash.qml−1
@@ -629,7 +629,6 @@ Item {
629 touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, units.gu(2));
629 touchFlick(dash, dash.width / 2, dash.height - 1, dash.width / 2, units.gu(2));
630 var bottomEdgeController = findInvisibleChild(dash, "bottomEdgeController");
630 var bottomEdgeController = findInvisibleChild(dash, "bottomEdgeController");
631 tryCompare(bottomEdgeController, "progress", 1);
631 tryCompare(bottomEdgeController, "progress", 1);
632− tryCompareFunction(function () { return findChild(dash, "scopesListCategoryother") !== null; }, true);
633 var nonfavScopesListCategory = findChild(dash, "scopesListCategoryother");
632 var nonfavScopesListCategory = findChild(dash, "scopesListCategoryother");
634 var nonfavScopesListCategoryList = findChild(nonfavScopesListCategory, "scopesListCategoryInnerList");
633 var nonfavScopesListCategoryList = findChild(nonfavScopesListCategory, "scopesListCategoryInnerList");
635 tryCompare(nonfavScopesListCategoryList, "currentIndex", 0);
634 tryCompare(nonfavScopesListCategoryList, "currentIndex", 0);
tests/utils/modules/Unity/Test/UnityTestCase.qml+25−4
@@ -175,11 +175,11 @@ TestCase {
175
175
176
176
177 // Find an object with the given name in the children tree of "obj"
177 // Find an object with the given name in the children tree of "obj"
178− function findChild(obj, objectName) {
178+ function findChild(obj, objectName, timeout) {
179 if (!obj)
179 if (!obj)
180 qtest_fail("no obj given", 1);
180 qtest_fail("no obj given", 1);
181
181
182− return findChildIn(obj, "children", objectName);
182+ return findChildInWithTimeout(obj, "children", objectName);
183 }
183 }
184
184
185 // Find an object with the given name in the children tree of "obj"
185 // Find an object with the given name in the children tree of "obj"
@@ -187,11 +187,32 @@ TestCase {
187 // Note: you should use findChild if you're not sure you need this
187 // Note: you should use findChild if you're not sure you need this
188 // as this tree is much bigger and might contain stuff that goes
188 // as this tree is much bigger and might contain stuff that goes
189 // away randomly.
189 // away randomly.
190− function findInvisibleChild(obj, objectName) {
190+ function findInvisibleChild(obj, objectName, timeout) {
191 if (!obj)
191 if (!obj)
192 qtest_fail("no obj given", 1);
192 qtest_fail("no obj given", 1);
193
193
194− return findChildIn(obj, "data", objectName);
194+ return findChildInWithTimeout(obj, "data", objectName, timeout);
195+ }
196+
197+ // Find a child in the named property with timeout
198+ function findChildInWithTimeout(obj, prop, objectName, timeout) {
199+ if (!obj)
200+ qtest_fail("no obj given", 1);
201+
202+ var timeSpent = 0
203+ if (timeout === undefined)
204+ timeout = 5000;
205+
206+ var child = findChildIn(obj, prop, objectName);
207+
208+ while (timeSpent < timeout && !child) {
209+ child = findChildIn(obj, prop, objectName);
210+ if (!child) {
211+ wait(50)
212+ timeSpent += 50
213+ }
214+ }
215+ return child;
195 }
216 }
196
217
197 // Find a child in the named property
218 // Find a child in the named property