on xenial help sign in
Keep refactoring tst_Shell, reduce race conditions

Refactor loadDesktopShellWithApps into loadShell to have a single place to fix problems with shell or app loading in this test case. Use the new refactored function everywhere. I had to shuffle the order of setting up the greeter to cope with the change, and add some more waitForRendering magic to make sure we don't stomp on the Shell while it loads.

commit54de86272ba2d7374fad0cb481d053877a03e886 authorDalton Durst <dalton@ubports.com> dateSat 28 Dec 2019, 18:32 (7 years ago) parentc41130a
1 file changed+53−62
tests/qmltests/tst_Shell.qml+53−62
tests/qmltests/tst_Shell.qml+53−62
@@ -574,7 +574,12 @@ Rectangle {
574574 WindowStateStorage.clear();
575575 }
576576
577− function loadShell(formFactor) {
577+ function loadShell(formFactor, apps) {
578+
579+ if (apps === undefined) {
580+ apps = 0
581+ }
582+
578583 shellLoader.state = formFactor;
579584 shellLoader.active = true;
580585 tryCompare(shellLoader, "status", Loader.Ready);
@@ -582,6 +587,7 @@ Rectangle {
582587 tryCompare(shell, "waitingOnGreeter", false); // reset by greeter when ready
583588
584589 sessionSpy.target = shell.greeter;
590+ shell.usageScenario = formFactor;
585591
586592 var launcher = findChild(shell, "launcher");
587593 verify(!!launcher);
@@ -598,19 +604,8 @@ Rectangle {
598604 topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
599605 verify(topLevelSurfaceList);
600606 stage = findChild(shell, "stage");
601− }
602607
603− function loadDesktopShellWithApps(apps) {
604−
605− if (apps == undefined) {
606− apps = 7
607− }
608−
609− loadShell("desktop");
610− waitForRendering(shell)
611− shell.usageScenario = "desktop"
612− waitForRendering(shell)
613− addApps(apps)
608+ addApps(apps);
614609 }
615610
616611 function addApps(count) {
@@ -781,6 +776,7 @@ Rectangle {
781776
782777 function setLightDMMockMode(mode) {
783778 LightDMController.userMode = mode;
779+ waitForRendering(root);
784780 }
785781
786782 function dragToCloseIndicatorsPanel() {
@@ -1140,7 +1136,7 @@ Rectangle {
11401136 }
11411137
11421138 function test_focusRequestedHidesIndicators() {
1143− loadShell("phone");
1139+ loadShell("phone", 1);
11441140 swipeAwayGreeter();
11451141 var indicators = findChild(shell, "indicators");
11461142
@@ -1298,7 +1294,7 @@ Rectangle {
12981294 }
12991295
13001296 function test_customBackground() {
1301− loadDesktopShellWithApps(0);
1297+ loadShell("desktop", 0);
13021298
13031299 var wallpaperResolver = findInvisibleChild(shell, "wallpaperResolver");
13041300 var greeter = findChild(shell, "greeter");
@@ -1311,7 +1307,7 @@ Rectangle {
13111307 }
13121308
13131309 function test_cachedBackground() {
1314− loadDesktopShellWithApps(0);
1310+ loadShell("desktop", 0);
13151311
13161312 var greeter = findChild(shell, "greeter");
13171313 verify(!greeter.hasCustomBackground);
@@ -1409,8 +1405,8 @@ Rectangle {
14091405 }
14101406
14111407 function test_tabletLogin(data) {
1412− setLightDMMockMode("full");
14131408 loadShell("tablet");
1409+ setLightDMMockMode("full");
14141410
14151411 selectUser(data.user);
14161412
@@ -1433,8 +1429,8 @@ Rectangle {
14331429 }
14341430
14351431 function test_appLaunchDuringGreeter(data) {
1436− setLightDMMockMode("full");
14371432 loadShell("tablet");
1433+ setLightDMMockMode("full");
14381434
14391435 selectUser(data.user)
14401436
@@ -1450,9 +1446,9 @@ Rectangle {
14501446 }
14511447
14521448 function test_manualLoginFlow() {
1449+ loadShell("desktop");
14531450 LightDMController.showManualLoginHint = true;
14541451 setLightDMMockMode("full");
1455− loadShell("desktop");
14561452
14571453 var i = selectUser("*other");
14581454 var greeter = findChild(shell, "greeter");
@@ -1478,7 +1474,7 @@ Rectangle {
14781474 }
14791475
14801476 function test_terminalShortcut() {
1481− loadDesktopShellWithApps(0);
1477+ loadShell("desktop", 0);
14821478
14831479 // not running, should start
14841480 keyClick(Qt.Key_T, Qt.ControlModifier|Qt.AltModifier);
@@ -1575,7 +1571,6 @@ Rectangle {
15751571
15761572 function test_altTabSwitchesFocus(data) {
15771573 loadShell(data.shellType);
1578− shell.usageScenario = data.shellType;
15791574 waitForRendering(root)
15801575
15811576 var desktopStage = findChild(shell, "stage");
@@ -1612,7 +1607,7 @@ Rectangle {
16121607 }
16131608
16141609 function test_altTabWrapAround() {
1615− loadDesktopShellWithApps(7);
1610+ loadShell("desktop", 7);
16161611
16171612 var stage = findChild(shell, "stage");
16181613 verify(stage !== null)
@@ -1657,7 +1652,7 @@ Rectangle {
16571652 }
16581653
16591654 function test_altBackTabNavigation() {
1660− loadDesktopShellWithApps(5);
1655+ loadShell("desktop", 7);
16611656
16621657 var spreadItem = findChild(shell, "spreadItem");
16631658 verify(spreadItem !== null);
@@ -1688,7 +1683,7 @@ Rectangle {
16881683 }
16891684
16901685 function test_highlightFollowsMouse() {
1691− loadDesktopShellWithApps(7)
1686+ loadShell("desktop", 7);
16921687
16931688 var spreadItem = findChild(shell, "spreadItem");
16941689 verify(spreadItem !== null);
@@ -1716,7 +1711,7 @@ Rectangle {
17161711 }
17171712
17181713 function test_closeFromSpread() {
1719− loadDesktopShellWithApps(4)
1714+ loadShell("desktop", 4);
17201715
17211716 var appRepeater = findInvisibleChild(shell, "appRepeater");
17221717 verify(appRepeater !== null);
@@ -1766,7 +1761,7 @@ Rectangle {
17661761 }
17671762
17681763 function test_selectFromSpreadWithMouse(data) {
1769− loadDesktopShellWithApps(4)
1764+ loadShell("desktop", 4);
17701765
17711766 var stage = findChild(shell, "stage");
17721767 var spreadItem = findChild(stage, "spreadItem");
@@ -1805,7 +1800,7 @@ Rectangle {
18051800 }
18061801
18071802 function test_progressiveAutoScrolling() {
1808− loadDesktopShellWithApps(7)
1803+ loadShell("desktop", 7);
18091804
18101805 var appRepeater = findInvisibleChild(shell, "appRepeater");
18111806 var launcherPanel = findChild(shell, "launcherPanel");
@@ -1836,7 +1831,7 @@ Rectangle {
18361831 // This makes sure the hoverMouseArea is set to invisible AND disabled
18371832 // when not needed. Otherwise it'll eat mouse hover events for the rest of the shell/apps
18381833 function test_hoverMouseAreaDisabledAndInvisible() {
1839− loadDesktopShellWithApps(2)
1834+ loadShell("desktop", 2);
18401835
18411836 var hoverMouseArea = findChild(shell, "hoverMouseArea");
18421837 tryCompare(hoverMouseArea, "enabled", false)
@@ -1862,7 +1857,7 @@ Rectangle {
18621857 }
18631858
18641859 function test_focusAppFromLauncherExitsSpread(data) {
1865− loadDesktopShellWithApps(2)
1860+ loadShell("desktop", 2);
18661861 var launcher = findChild(shell, "launcher");
18671862 var stage = findChild(shell, "stage");
18681863 var app1 = findChild(launcher, "launcherDelegate0");
@@ -1895,7 +1890,7 @@ Rectangle {
18951890
18961891 // regression test for http://pad.lv/1443319
18971892 function test_closeMaximizedAndRestart() {
1898− loadDesktopShellWithApps(7);
1893+ loadShell("desktop", 7)
18991894
19001895 var appRepeater = findChild(shell, "appRepeater")
19011896 var application = topLevelSurfaceList.applicationAt(0);
@@ -1922,7 +1917,7 @@ Rectangle {
19221917 }
19231918
19241919 function test_newAppHasValidGeometry() {
1925− loadDesktopShellWithApps(1);
1920+ loadShell("desktop", 1)
19261921 var appRepeater = findChild(shell, "appRepeater");
19271922 var appDelegate = appRepeater.itemAt(0);
19281923
@@ -1935,7 +1930,7 @@ Rectangle {
19351930
19361931 // bug http://pad.lv/1431566
19371932 function test_switchToStagedHidesPanelButtons() {
1938− loadDesktopShellWithApps(1);
1933+ loadShell("desktop", 1)
19391934 var appRepeater = findChild(shell, "appRepeater")
19401935 var appDelegate = appRepeater.itemAt(0);
19411936 var panelButtons = findChild(shell, "panelWindowControlButtons")
@@ -1952,7 +1947,7 @@ Rectangle {
19521947 }
19531948
19541949 function test_lockingGreeterHidesPanelButtons() {
1955− loadDesktopShellWithApps(1);
1950+ loadShell("desktop", 1)
19561951 var appRepeater = findChild(shell, "appRepeater")
19571952 var appDelegate = appRepeater.itemAt(0);
19581953 var panelButtons = findChild(shell, "panelWindowControlButtons")
@@ -1968,7 +1963,7 @@ Rectangle {
19681963 }
19691964
19701965 function test_cantMoveWindowUnderPanel() {
1971− loadDesktopShellWithApps(1);
1966+ loadShell("desktop", 1)
19721967 var appRepeater = findChild(shell, "appRepeater")
19731968 var appDelegate = appRepeater.itemAt(0);
19741969
@@ -1979,7 +1974,7 @@ Rectangle {
19791974 }
19801975
19811976 function test_cantResizeWindowUnderPanel() {
1982− loadDesktopShellWithApps(0);
1977+ loadShell("desktop", 0);
19831978
19841979 var appSurfaceId = topLevelSurfaceList.nextId;
19851980 var app = ApplicationManager.startApplication("dialer-app")
@@ -2005,7 +2000,7 @@ Rectangle {
20052000 }
20062001
20072002 function test_restoreWindowStateFixesIfUnderPanel() {
2008− loadDesktopShellWithApps(2);
2003+ loadShell("desktop", 2)
20092004 var appRepeater = findChild(shell, "appRepeater")
20102005 var application = topLevelSurfaceList.applicationAt(0);
20112006 var appDelegate = appRepeater.itemAt(0);
@@ -2183,7 +2178,7 @@ Rectangle {
21832178 }
21842179
21852180 function test_superTabToCycleLauncher(data) {
2186− loadDesktopShellWithApps(1);
2181+ loadShell("desktop", 1)
21872182 GSettingsController.setAutohideLauncher(!data.launcherLocked);
21882183 waitForRendering(shell);
21892184
@@ -2217,7 +2212,7 @@ Rectangle {
22172212 }
22182213
22192214 function test_longpressSuperOpensLauncherAndShortcutsOverlay() {
2220− loadShell("desktop");
2215+ loadShell("phone", 1);
22212216 var launcher = findChild(shell, "launcher");
22222217 var shortcutHint = findChild(findChild(launcher, "launcherDelegate0"), "shortcutHint")
22232218 var shortcutsOverlay = findChild(shell, "shortcutsOverlay");
@@ -2269,7 +2264,7 @@ Rectangle {
22692264 }
22702265
22712266 function test_lockedOutLauncherAddsMarginsToMaximized() {
2272− loadDesktopShellWithApps(1);
2267+ loadShell("desktop", 1)
22732268 var appContainer = findChild(shell, "appContainer");
22742269 var launcher = findChild(shell, "launcher");
22752270 var launcherPanel = findChild(launcher, "launcherPanel");
@@ -2420,10 +2415,9 @@ Rectangle {
24202415 }
24212416
24222417 function test_greeterModeBroadcastsApp() {
2423− setLightDMMockMode("single-pin");
24242418 shellLoader.mode = "greeter";
2419+ setLightDMMockMode("single-pin");
24252420 loadShell("phone");
2426− shell.usageScenario = "phone";
24272421 waitForRendering(shell);
24282422
24292423 dragLauncherIntoView();
@@ -2439,10 +2433,9 @@ Rectangle {
24392433 }
24402434
24412435 function test_greeterModeBroadcastsHome() {
2442− setLightDMMockMode("single-pin");
24432436 shellLoader.mode = "greeter";
2437+ setLightDMMockMode("single-pin");
24442438 loadShell("phone");
2445− shell.usageScenario = "phone";
24462439 waitForRendering(shell);
24472440
24482441 var gallerySurfaceId = topLevelSurfaceList.nextId;
@@ -2461,10 +2454,9 @@ Rectangle {
24612454 }
24622455
24632456 function test_greeterModeDispatchesURL() {
2464− setLightDMMockMode("single-pin");
24652457 shellLoader.mode = "greeter";
2458+ setLightDMMockMode("single-pin");
24662459 loadShell("phone");
2467− shell.usageScenario = "phone";
24682460 waitForRendering(shell);
24692461
24702462 var urlDispatcher = findInvisibleChild(shell, "urlDispatcher");
@@ -2557,7 +2549,7 @@ Rectangle {
25572549 }
25582550
25592551 function test_dragPanelToRestoreMaximizedWindow(data) {
2560− loadDesktopShellWithApps(0);
2552+ loadShell("desktop", 0);
25612553 var panel = findChild(shell, "windowControlArea");
25622554 verify(panel);
25632555
@@ -2589,10 +2581,9 @@ Rectangle {
25892581 }
25902582
25912583 function test_fullShellModeHasNoInitialGreeter() {
2592− setLightDMMockMode("single-pin");
25932584 shellLoader.mode = "full-shell";
25942585 loadShell("phone");
2595− shell.usageScenario = "phone";
2586+ setLightDMMockMode("single-pin");
25962587 waitForRendering(shell);
25972588
25982589 var greeter = findChild(shell, "greeter");
@@ -2636,7 +2627,7 @@ Rectangle {
26362627 }
26372628
26382629 function test_rightEdgePushWithOpenIndicators() {
2639− loadDesktopShellWithApps(1);
2630+ loadShell("desktop", 1)
26402631
26412632 var stage = findChild(shell, "stage");
26422633 var cursor = findChild(shell, "cursor");
@@ -2684,7 +2675,7 @@ Rectangle {
26842675 }
26852676
26862677 function test_oskDisplacesWindow(data) {
2687− loadDesktopShellWithApps(0);
2678+ loadShell("desktop", 0);
26882679 ensureInputMethodSurface();
26892680 shell.oskEnabled = data.oskEnabled;
26902681
@@ -2891,7 +2882,7 @@ Rectangle {
28912882 }
28922883
28932884 function test_fourFingerTapOpensDrawer(data) {
2894− loadDesktopShellWithApps(1);
2885+ loadShell("desktop", 1)
28952886
28962887 var stage = findChild(shell, "stage");
28972888 var drawer = findChild(shell, "drawer")
@@ -2907,7 +2898,7 @@ Rectangle {
29072898 }
29082899
29092900 function test_restoreFromFullscreen() {
2910− loadDesktopShellWithApps(0);
2901+ loadShell("desktop", 0);
29112902
29122903 var appSurfaceId = topLevelSurfaceList.nextId;
29132904 var app = ApplicationManager.startApplication("dialer-app")
@@ -2934,7 +2925,7 @@ Rectangle {
29342925
29352926
29362927 function test_closeAppsInSpreadWithQ() {
2937− loadDesktopShellWithApps(0);
2928+ loadShell("desktop", 0);
29382929
29392930 var appSurfaceId = topLevelSurfaceList.nextId;
29402931 var app = ApplicationManager.startApplication("unity8-dash")
@@ -3008,7 +2999,7 @@ Rectangle {
30082999 }
30093000
30103001 function test_altTabToMinimizedApp() {
3011− loadDesktopShellWithApps(0);
3002+ loadShell("desktop", 0);
30123003
30133004 var appSurfaceId = topLevelSurfaceList.nextId;
30143005 var app = ApplicationManager.startApplication("dialer-app")
@@ -3040,7 +3031,7 @@ Rectangle {
30403031 }
30413032
30423033 function test_touchMenuPosition(data) {
3043− loadDesktopShellWithApps(0);
3034+ loadShell("desktop", 0);
30443035
30453036 var panel = findChild(shell, "panel");
30463037 var launcher = testCase.findChild(shell, "launcher");
@@ -3060,7 +3051,7 @@ Rectangle {
30603051 }
30613052
30623053 function test_touchMenuHidesOnLauncherAppDrawer(data) {
3063− loadDesktopShellWithApps(1);
3054+ loadShell("desktop", 1)
30643055
30653056 var panel = findChild(shell, "panel");
30663057 var launcher = testCase.findChild(shell, "launcher");
@@ -3082,7 +3073,7 @@ Rectangle {
30823073 }
30833074
30843075 function test_doubleClickPanelRestoresWindow() {
3085− loadDesktopShellWithApps(0);
3076+ loadShell("desktop", 0);
30863077
30873078 // start dialer
30883079 var appDelegate = startApplication("dialer-app")
@@ -3103,7 +3094,7 @@ Rectangle {
31033094 }
31043095
31053096 function test_noMenusWithActiveCall() {
3106− loadDesktopShellWithApps(0);
3097+ loadShell("desktop", 0);
31073098
31083099 // start music-app, maximize it
31093100 var appDelegate = startApplication("music-app")
@@ -3134,7 +3125,7 @@ Rectangle {
31343125 }
31353126
31363127 function test_enforceFocusOnStageOnAltTab() {
3137− loadDesktopShellWithApps(0);
3128+ loadShell("desktop", 0);
31383129
31393130 var appSurfaceId = topLevelSurfaceList.nextId;
31403131 var app = ApplicationManager.startApplication("unity8-dash")
@@ -3174,7 +3165,7 @@ Rectangle {
31743165 }
31753166
31763167 function test_maximizedWindowMenuThenAltTab(data) {
3177− loadDesktopShellWithApps(0);
3168+ loadShell("desktop", 0);
31783169
31793170 var appDelegate = startApplication("gmail-webapp");
31803171 var appDelegate2 = startApplication("dialer-app");
@@ -3218,7 +3209,7 @@ Rectangle {
32183209 }
32193210
32203211 function test_launchFromDrawerPutsFocusOnStage() {
3221− loadDesktopShellWithApps(1);
3212+ loadShell("desktop", 1)
32223213
32233214 keyClick(Qt.Key_A, Qt.MetaModifier);
32243215 typeString("browser");
@@ -3229,7 +3220,7 @@ Rectangle {
32293220 }
32303221
32313222 function test_maximizedWindowAndMenuInPanel() {
3232− loadDesktopShellWithApps(0);
3223+ loadShell("desktop", 0);
32333224
32343225 // start music-app, maximize it
32353226 var appDelegate = startApplication("music-app")