on xenial help sign in
fix test flakiness
commit0db7ccba56cbe13ad07617632f0771d71dbaec6d authorMichael Zanetti <michael.zanetti@canonical.com> dateSat 8 Oct 2016, 18:45 (10 years ago) parent6e6c5ce
3 files changed+17−3
qml/Stage/Stage.qml+6 tests/qmltests/Stage/tst_PhoneStage.qml+5 tests/qmltests/Stage/tst_TabletStage.qml+6−3
qml/Stage/Stage.qml+6
@@ -264,6 +264,12 @@ FocusScope {
264264
265265 for (var i = 0; i < appRepeater.count && (!choseMainStage || !choseSideStage); ++i) {
266266 var appDelegate = appRepeater.itemAt(i);
267+ if (!appDelegate) {
268+ // This might happen during startup phase... If the delegate appears and claims focus
269+ // things are updated and appRepeater.itemAt(x) still returns null while appRepeater.count >= x
270+ // Lets just skip it, on startup it will be generated at a later point too...
271+ continue;
272+ }
267273 if (sideStage.shown && appDelegate.stage == ApplicationInfoInterface.SideStage
268274 && !choseSideStage) {
269275 priv.sideStageDelegate = appDelegate
tests/qmltests/Stage/tst_PhoneStage.qml+5
@@ -156,6 +156,11 @@ Item {
156156 true /* beginTouch */, true /* endTouch */, units.gu(10), 50);
157157
158158 tryCompare(stage, "state", "spread");
159+ // Make sure all the transitions have finished
160+ var appRepeater = findChild(stage, "appRepeater");
161+ for (var i = 0; i < appRepeater.count; i++) {
162+ waitUntilTransitionsEnd(appRepeater.itemAt(i));
163+ }
159164 waitForRendering(stage);
160165 }
161166
tests/qmltests/Stage/tst_TabletStage.qml+6−3
@@ -581,7 +581,6 @@ Rectangle {
581581
582582 function test_loadSideStageByDraggingFromMainStage() {
583583 sideStage.showNow();
584− print("sidestage now shown. launching browser")
585584 var webbrowserSurfaceId = topSurfaceList.nextId;
586585 webbrowserCheckBox.checked = true;
587586 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
@@ -589,7 +588,7 @@ Rectangle {
589588 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
590589 verify(appDelegate);
591590 waitForRendering(stage);
592− compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
591+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.MainStage);
593592
594593 dragToSideStage(webbrowserSurfaceId);
595594
@@ -599,6 +598,10 @@ Rectangle {
599598 function test_unloadSideStageByDraggingFromSideStage() {
600599 sideStage.showNow();
601600 WindowStateStorage.saveStage(webbrowserCheckBox.appId, ApplicationInfoInterface.SideStage)
601+ // WindowStateStorage is async... Lets wait for it to be fully processed...
602+ tryCompareFunction(function() {
603+ return WindowStateStorage.getStage(webbrowserCheckBox.appId, ApplicationInfoInterface.MainStage) === ApplicationInfoInterface.SideStage
604+ }, true);
602605 var webbrowserSurfaceId = topSurfaceList.nextId;
603606 webbrowserCheckBox.checked = true;
604607 waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
@@ -606,7 +609,7 @@ Rectangle {
606609 var appDelegate = findChild(stage, "appDelegate_" + webbrowserSurfaceId);
607610 verify(appDelegate);
608611 waitForRendering(stage);
609− compare(appDelegate.stage, ApplicationInfoInterface.SideStage);
612+ tryCompare(appDelegate, "stage", ApplicationInfoInterface.SideStage);
610613
611614 dragToMainStage(webbrowserSurfaceId);
612615