on xenial help sign in
Improve findChild calls inside tryCompareFunction.

findChild has a timeout retry since a while ago. This means that if we have a findChild inside a tryCompareFunction the retries multiply and it takes around 30 minutes for the tryCompareFunction to fail if the findChild is failing, so what we do is set the timeout of findChild to 0. In other cases we just had a tryCompareFunction that made sure the findChild after it would succeed, since now findChild has a retry mechanism we can just remove that tryCompareFunction altogether. Approved by: Michał Sawicz, Unity8 CI Bot

commit8c0d380f5204ce48230cf9997b75e039692d3945 authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 13 Sep 2016, 06:51 (10 years ago) parent3d4e2d5ed1a770
10 files changed+28−47
tests/qmltests/Components/tst_Carousel.qml−1 tests/qmltests/Components/tst_Lockscreen.qml+1−2 tests/qmltests/Dash/Previews/tst_Preview.qml−2 tests/qmltests/Dash/Previews/tst_PreviewHeader.qml−4 tests/qmltests/Dash/tst_CardTool.qml+4−4 tests/qmltests/Dash/tst_Dash.qml+8−8 tests/qmltests/Dash/tst_DashContent.qml+5−7 tests/qmltests/Dash/tst_GenericScopeView.qml+9−15 tests/qmltests/Panel/tst_IndicatorPage.qml−2 tests/qmltests/tst_ShellWithPin.qml+1−2
tests/qmltests/Components/tst_Carousel.qml−1
@@ -268,7 +268,6 @@ Item {
268268
269269 function test_activate() {
270270 var carouselList = findChild(carousel, "listView");
271− tryCompareFunction(function() { return findChild(carouselList, "carouselDelegate3") ? true : false; }, true);
272271 var carouselItem = findChild(carousel, "carouselDelegate3")
273272 verify(carouselItem, "Could not find delegate");
274273
tests/qmltests/Components/tst_Lockscreen.qml+1−2
@@ -422,7 +422,6 @@ Rectangle {
422422 function test_infoPopup() {
423423 verify(findChild(root, "infoPopup") === null);
424424 lockscreen.showInfoPopup("foo", "bar");
425− tryCompareFunction(function() { return findChild(root, "infoPopup") !== null}, true);
426425
427426 var infoPopup = findChild(root, "infoPopup");
428427 compare(infoPopup.title, "foo");
@@ -434,7 +433,7 @@ Rectangle {
434433 var okButton = findChild(root, "infoPopupOkButton");
435434 mouseClick(okButton);
436435
437− tryCompareFunction(function() { return findChild(root, "infoPopup") === null}, true);
436+ tryCompareFunction(function() { return findChild(root, "infoPopup", 0 /* timeout */) === null}, true);
438437
439438 tryCompare(signalSpy, "count", 1);
440439 }
tests/qmltests/Dash/Previews/tst_Preview.qml−2
@@ -78,7 +78,6 @@ Rectangle {
7878
7979 function test_containOnFocus() {
8080 waitForRendering(preview);
81− tryCompareFunction(function () { return findChild(preview, "widget-10") != null }, true);
8281 var widget = findChild(preview, "widget-10");
8382
8483 var bottomLeft = preview.mapFromItem(widget, 0, widget.height);
@@ -94,7 +93,6 @@ Rectangle {
9493
9594 function test_containOnGrow() {
9695 waitForRendering(preview);
97− tryCompareFunction(function () { return findChild(preview, "widget-13") != null }, true);
9896 var widget = findChild(preview, "widget-13");
9997
10098 var bottomLeft = preview.mapFromItem(widget, 0, widget.height);
tests/qmltests/Dash/Previews/tst_PreviewHeader.qml−4
@@ -116,7 +116,6 @@ Rectangle {
116116
117117 tryCompare(testCase.mascotShapeLoader, "visible", data.loaderVisible);
118118 if (data.loaderVisible) {
119− tryCompareFunction(function() { return findChild(previewHeader, "mascotShape") != null }, true);
120119 var mascot = findChild(previewHeader, "mascotShape")
121120 tryCompare(mascot, "visible", data.visible);
122121 }
@@ -165,20 +164,17 @@ Rectangle {
165164
166165 function test_fallback() {
167166 previewHeader.widgetData = brokenheaderjson;
168− tryCompareFunction(function() { return findChild(previewHeader, "mascotShape") != null }, true);
169167 var mascot = findChild(previewHeader, "mascotShape");
170168 compare(mascot.visible, false);
171169
172170 previewHeader.widgetData = {};
173171 previewHeader.widgetData = fallbackheaderjson;
174− tryCompareFunction(function() { return findChild(previewHeader, "mascotShape") != null }, true);
175172 var mascot = findChild(previewHeader, "mascotShape");
176173 tryCompare(mascot, "visible", true);
177174 tryCompare(mascot.source, "status", Image.Ready);
178175
179176 previewHeader.widgetData = {};
180177 previewHeader.widgetData = emptyfallbackheaderjson;
181− tryCompareFunction(function() { return findChild(previewHeader, "mascotShape") != null }, true);
182178 var mascot = findChild(previewHeader, "mascotShape");
183179 tryCompare(mascot, "visible", true);
184180 tryCompare(mascot.source, "status", Image.Ready);
tests/qmltests/Dash/tst_CardTool.qml+4−4
@@ -339,22 +339,22 @@ Rectangle {
339339 function test_card_title_alignment(data) {
340340 selector.selectedIndex = data.index;
341341
342− tryCompareFunction(function() { return findChild(internalCard, "titleLabel").horizontalAlignment == Text.AlignLeft; }, true);
342+ tryCompareFunction(function() { return findChild(internalCard, "titleLabel", 0 /* timeout */).horizontalAlignment == Text.AlignLeft; }, true);
343343
344344 cardTool.components['title'] = { "field": "title", "align": "center" };
345345 cardTool.componentsChanged();
346346
347− tryCompareFunction(function() { return findChild(internalCard, "titleLabel").horizontalAlignment == data.value; }, true);
347+ tryCompareFunction(function() { return findChild(internalCard, "titleLabel", 0 /* timeout */).horizontalAlignment == data.value; }, true);
348348
349349 cardTool.components['title'] = { "field": "title" };
350350 cardTool.componentsChanged();
351351
352− tryCompareFunction(function() { return findChild(internalCard, "titleLabel").horizontalAlignment == data.value; }, true);
352+ tryCompareFunction(function() { return findChild(internalCard, "titleLabel", 0 /* timeout */).horizontalAlignment == data.value; }, true);
353353
354354 cardTool.components['title'] = { "field": "title", "align": "left" };
355355 cardTool.componentsChanged();
356356
357− tryCompareFunction(function() { return findChild(internalCard, "titleLabel").horizontalAlignment == Text.AlignLeft; }, true);
357+ tryCompareFunction(function() { return findChild(internalCard, "titleLabel", 0 /* timeout */).horizontalAlignment == Text.AlignLeft; }, true);
358358 }
359359
360360 function test_categoryLayout_data() {
tests/qmltests/Dash/tst_Dash.qml+8−8
@@ -76,7 +76,7 @@ Item {
7676 var genericScopeView = dashContentList.currentItem;
7777 var categoryListView = findChild(genericScopeView, "categoryListView");
7878 tryCompareFunction(function() {
79− var category = findChild(genericScopeView, categoryName);
79+ var category = findChild(genericScopeView, categoryName, 0 /* timeout */);
8080 if (category && category.y > 0 && category.y < genericScopeView.height) return true;
8181 touchFlick(genericScopeView, genericScopeView.width/2, units.gu(20),
8282 genericScopeView.width/2, genericScopeView.y)
@@ -84,7 +84,7 @@ Item {
8484 return false;
8585 }, true);
8686
87− tryCompareFunction(function() { return findChild(genericScopeView, "delegate0") !== null; }, true);
87+ tryCompareFunction(function() { return findChild(genericScopeView, "delegate0", 0 /* timeout */) !== null; }, true);
8888 return findChild(genericScopeView, categoryName);
8989 }
9090
@@ -94,9 +94,9 @@ Item {
9494 if (category === undefined) category = 0;
9595 if (delegate === undefined) delegate = 0;
9696 tryCompareFunction(function() {
97− var cardGrid = findChild(genericScopeView, "dashCategory"+category);
97+ var cardGrid = findChild(genericScopeView, "dashCategory"+category, 0 /* timeout */);
9898 if (cardGrid != null) {
99− var tile = findChild(cardGrid, "delegate"+delegate);
99+ var tile = findChild(cardGrid, "delegate"+delegate, 0 /* timeout */);
100100 return tile != null;
101101 }
102102 return false;
@@ -475,9 +475,9 @@ Item {
475475 compare(dashContentList.currentItem.scopeId, "MockScope1");
476476
477477 tryCompareFunction(function() {
478− var cardGrid = findChild(dashContentList, "dashCategory0");
478+ var cardGrid = findChild(dashContentList, "dashCategory0", 0 /* timeout */);
479479 if (cardGrid != null) {
480− var tile = findChild(cardGrid, "delegate0");
480+ var tile = findChild(cardGrid, "delegate0", 0 /* timeout */);
481481 return tile != null;
482482 }
483483 return false;
@@ -522,9 +522,9 @@ Item {
522522 var categoryListView = findChild(dashTempScopeItem, "categoryListView");
523523 categoryListView.positionAtBeginning();
524524 tryCompareFunction(function() {
525− var cardGrid = findChild(dashTempScopeItem, "dashCategory0");
525+ var cardGrid = findChild(dashTempScopeItem, "dashCategory0", 0 /* timeout */);
526526 if (cardGrid != null) {
527− var tile = findChild(cardGrid, "delegate0");
527+ var tile = findChild(cardGrid, "delegate0", 0 /* timeout */);
528528 return tile != null;
529529 }
530530 return false;
tests/qmltests/Dash/tst_DashContent.qml+5−7
@@ -261,11 +261,11 @@ Item {
261261
262262 function test_carouselAspectRatio() {
263263 tryCompareFunction(function() {
264− var scope = findChild(dashContent, "scopeLoader0");
264+ var scope = findChild(dashContent, "scopeLoader0", 0 /* timeout */);
265265 if (scope != null) {
266− var dashCategory1 = findChild(scope, "dashCategory1");
266+ var dashCategory1 = findChild(scope, "dashCategory1", 0 /* timeout */);
267267 if (dashCategory1 != null) {
268− var tile = findChild(dashCategory1, "carouselDelegate1");
268+ var tile = findChild(dashCategory1, "carouselDelegate1", 0 /* timeout */);
269269 return tile != null;
270270 }
271271 }
@@ -282,7 +282,6 @@ Item {
282282
283283 function test_mainNavigation() {
284284 var dashContentList = findChild(dashContent, "dashContentList");
285− tryCompareFunction(function() { return findChild(dashContentList.currentItem, "dashNavigation") != null; }, true);
286285 var dashNavigation = findChild(dashContentList.currentItem, "dashNavigation");
287286 var peExtraPanel = findChild(dashContentList.currentItem, "peExtraPanel");
288287 var searchButton = findChild(dashContentList.currentItem, "search_button");
@@ -405,7 +404,6 @@ Item {
405404
406405 function goToSecondLevel() {
407406 var dashContentList = findChild(dashContent, "dashContentList");
408− tryCompareFunction(function() { return findChild(dashContentList.currentItem, "dashNavigation") != null; }, true);
409407 var dashNavigation = findChild(dashContentList.currentItem, "dashNavigation");
410408 var peExtraPanel = findChild(dashContentList.currentItem, "peExtraPanel");
411409 var searchButton = findChild(dashContentList.currentItem, "search_button");
@@ -580,7 +578,7 @@ Item {
580578
581579 function test_primaryFilter() {
582580 var dashContentList = findChild(dashContent, "dashContentList");
583− tryCompareFunction(function() { return findChild(dashContentList.currentItem, "dashNavigation") != null; }, true);
581+ tryCompareFunction(function() { return findChild(dashContentList.currentItem, "dashNavigation", 0 /* timeout */) != null; }, true);
584582 dashContentList.currentItem.item.scope.setHasNavigation(false);
585583 var peExtraPanel = findChild(dashContentList.currentItem, "peExtraPanel");
586584 var searchButton = findChild(dashContentList.currentItem, "search_button");
@@ -589,7 +587,7 @@ Item {
589587 mouseClick(searchButton);
590588 tryCompare(peExtraPanel, "visible", true);
591589
592− tryCompareFunction(function() { return findChild(peExtraPanel, "OSF3") != null; }, true);
590+ tryCompareFunction(function() { return findChild(peExtraPanel, "OSF3", 0 /* timeout */) != null; }, true);
593591 }
594592
595593 function test_searchHint() {
tests/qmltests/Dash/tst_GenericScopeView.qml+9−15
@@ -98,7 +98,7 @@ Item {
9898 function scrollToCategory(categoryName) {
9999 var categoryListView = findChild(genericScopeView, "categoryListView");
100100 tryCompareFunction(function() {
101− var category = findChild(genericScopeView, categoryName);
101+ var category = findChild(genericScopeView, categoryName, 0 /* timeout */);
102102 if (category && category.y > 0 && category.y < genericScopeView.height) return true;
103103 touchFlick(genericScopeView, genericScopeView.width/2, units.gu(20),
104104 genericScopeView.width/2, genericScopeView.y)
@@ -106,7 +106,7 @@ Item {
106106 return false;
107107 }, true);
108108
109− tryCompareFunction(function() { return findChild(genericScopeView, "delegate0") !== null; }, true);
109+ tryCompareFunction(function() { return findChild(genericScopeView, "delegate0", 0 /* timeout */) !== null; }, true);
110110 return findChild(genericScopeView, categoryName);
111111 }
112112
@@ -169,7 +169,7 @@ Item {
169169 }
170170
171171 function test_expand_collapse() {
172− tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0") != null; }, true);
172+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader0", 0 /* timeout */) != null; }, true);
173173
174174 var category = findChild(genericScopeView, "dashCategory0")
175175 var seeAll = findChild(category, "seeAll")
@@ -190,7 +190,7 @@ Item {
190190
191191 function test_expand_expand_collapse() {
192192 // wait for the item to be there
193− tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader2") != null; }, true);
193+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader2", 0 /* timeout */) != null; }, true);
194194
195195 var categoryListView = findChild(genericScopeView, "categoryListView");
196196 categoryListView.contentY = categoryListView.height;
@@ -218,7 +218,6 @@ Item {
218218 }
219219
220220 function test_headerLink() {
221− tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader1") != null; }, true);
222221 var header = findChild(genericScopeView, "dashSectionHeader1");
223222
224223 spy.target = genericScopeView.scope;
@@ -237,7 +236,7 @@ Item {
237236 categoryListView.contentY = categoryListView.height * 2;
238237
239238 // wait for the item to be there
240− tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader4") != null; }, true);
239+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader4", 0 /* timeout */) != null; }, true);
241240
242241 var categoryView = findChild(genericScopeView, "dashCategory4");
243242 verify(categoryView, "Can't find the category view.");
@@ -249,7 +248,6 @@ Item {
249248 }
250249
251250 function test_narrow_delegate_ranges_expand() {
252− tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") !== null; }, true);
253251 var category = findChild(genericScopeView, "dashCategory0")
254252 tryCompare(category, "expanded", false);
255253
@@ -281,7 +279,6 @@ Item {
281279 function test_single_category_expansion() {
282280 genericScopeView.scope = scopes.getScope(3);
283281
284− tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") != undefined; }, true);
285282 var category = findChild(genericScopeView, "dashCategory0")
286283 compare(category.expandable, false, "Only category should not be expandable.");
287284
@@ -295,9 +292,9 @@ Item {
295292 if (category === undefined) category = 0;
296293 if (delegate === undefined) delegate = 0;
297294 tryCompareFunction(function() {
298− var cardGrid = findChild(genericScopeView, "dashCategory"+category);
295+ var cardGrid = findChild(genericScopeView, "dashCategory"+category, 0 /* timeout */);
299296 if (cardGrid != null) {
300− var tile = findChild(cardGrid, "delegate"+delegate);
297+ var tile = findChild(cardGrid, "delegate"+delegate, 0 /* timeout */);
301298 return tile != null;
302299 }
303300 return false;
@@ -338,9 +335,9 @@ Item {
338335 genericScopeView.scope = scopes.getScope("NullPreviewScope");
339336
340337 tryCompareFunction(function() {
341− var cardGrid = findChild(genericScopeView, 0);
338+ var cardGrid = findChild(genericScopeView, 0, 0 /* timeout */);
342339 if (cardGrid != null) {
343− var tile = findChild(cardGrid, 0);
340+ var tile = findChild(cardGrid, 0, 0 /* timeout */);
344341 return tile != null;
345342 }
346343 return false;
@@ -391,7 +388,6 @@ Item {
391388
392389 tryCompare(testCase.subPageLoader, "open", false);
393390
394− tryCompareFunction(function() { return findChild(category, "delegate1") != null; }, true);
395391 var tile = findChild(category, "delegate1");
396392
397393 mouseClick(tile);
@@ -493,7 +489,6 @@ Item {
493489
494490 scrollToEnd();
495491
496− tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory1") !== null; }, true);
497492 var category1 = findChild(genericScopeView, "dashCategory1")
498493 var seeAll1 = findChild(category1, "seeAll")
499494 verify(category1.expandable);
@@ -672,7 +667,6 @@ Item {
672667 function test_carousel_borderSource() {
673668 var category = scrollToCategory("dashCategory1");
674669 var tile = findChild(category, "carouselDelegate0");
675− tryCompareFunction(function() { return findChild(tile, "artShapeLoader") !== null; }, true);
676670 var artShapeLoader = findChild(tile, "artShapeLoader");
677671 var shape = findChildsByType(artShapeLoader, "UCUbuntuShape");
678672 compare(shape.borderSource, undefined);
tests/qmltests/Panel/tst_IndicatorPage.qml−2
@@ -177,8 +177,6 @@ Item {
177177 initializeMenuData(fullMenuData);
178178
179179 var menuId = "menu"+data.remove
180−
181− tryCompareFunction(function() { return findChild(page, menuId) !== null;}, true);
182180 var menu = findChild(page, menuId);
183181
184182 menu.menuSelected();
tests/qmltests/tst_ShellWithPin.qml+1−2
@@ -363,12 +363,11 @@ Item {
363363
364364 enterPin("1111")
365365 enterPin("1111")
366− tryCompareFunction(function() {return findChild(root, "infoPopup") !== null}, true)
367366
368367 var dialog = findChild(root, "infoPopup")
369368 var button = findChild(dialog, "infoPopupOkButton")
370369 tap(button)
371− tryCompareFunction(function() {return findChild(root, "infoPopup")}, null)
370+ tryCompareFunction(function() {return findChild(root, "infoPopup", 0 /* timeout */)}, null)
372371
373372 tryCompare(resetSpy, "count", 0)
374373 enterPin("1111")