@@ -138,9 +138,6 @@ Rectangle {
138138 }
139139 mode: shellLoader.mode
140140 hasTouchscreen: true
141− Component.onCompleted: {
142− ApplicationManager.startApplication("unity8-dash");
143− }
144141 Component.onDestruction: {
145142 shellLoader.itemDestroyed = true;
146143 }
@@ -601,10 +598,6 @@ Rectangle {
601598 topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
602599 verify(topLevelSurfaceList);
603600 stage = findChild(shell, "stage");
604−
605− // wait until unity8-dash is fully loaded
606− tryCompare(topLevelSurfaceList, "count", 1);
607− waitUntilAppWindowIsFullyLoaded(topLevelSurfaceList.idAt(0));
608601 }
609602
610603 function loadDesktopShellWithApps() {
@@ -612,6 +605,7 @@ Rectangle {
612605 waitForRendering(shell)
613606 shell.usageScenario = "desktop"
614607 waitForRendering(shell)
608+ var app0 = ApplicationManager.startApplication("unity8-dash")
615609 var app1 = ApplicationManager.startApplication("dialer-app")
616610 var app2 = ApplicationManager.startApplication("webbrowser-app")
617611 var app3 = ApplicationManager.startApplication("camera-app")
@@ -794,8 +788,37 @@ Rectangle {
794788 tryCompare(ApplicationManager, "focusedApplicationId", mainAppId);
795789 }
796790
791+ function test_greeterStartsCorrectSession() {
792+ loadShell("desktop");
793+ setLightDMMockMode("full");
794+
795+ LightDMController.sessionMode = "full"
796+ LightDMController.numSessions = LightDMController.numAvailableSessions;
797+ var greeter = findChild(shell, "greeter");
798+ var view = findChild(greeter, "WideView");
799+ verify(view, "This test requires WideView to be loaded");
800+
801+ var loginList = findChild(view, "loginList");
802+
803+ compare(view.sessionToStart, greeter.sessionToStart());
804+
805+ // Ensure another session can actually be selected
806+ compare(LightDMController.numSessions > 1, true);
807+ loginList.currentSession = LightDM.Sessions.data(1, LightDM.SessionRoles.KeyRole);
808+
809+ compare(view.sessionToStart, greeter.sessionToStart());
810+
811+ }
812+
813+
797814 function swipeAwayGreeter() {
798815 var greeter = findChild(shell, "greeter");
816+
817+ if (!greeter.shown) {
818+ console.log("Greeter not shown. Not swiping.");
819+ return;
820+ }
821+
799822 tryCompare(greeter, "fullyShown", true);
800823 waitForGreeterToStabilize();
801824 removeTimeConstraintsFromSwipeAreas(greeter);
@@ -1222,26 +1245,11 @@ Rectangle {
12221245
12231246 var wizard = findChild(shell, "wizard");
12241247 tryCompare(wizard, "active", true);
1225− tryCompareFunction(function() { return topLevelSurfaceList.applicationAt(0).appId; }, "unity8-dash");
1226−
1227− // Make sure we stay running when there's no top level window (can happen for
1228− // a moment when we restart the dash after switching language)
1229− var dashApplication = ApplicationManager.findApplication("unity8-dash");
1230− ApplicationManager.stopApplication(dashApplication.appId);
1231− // wait until all zombie surfaces are gone. As MirSurfaceItems hold references over them.
1232− // They won't be gone until those surface items are destroyed.
1233− tryCompareFunction(function() { return dashApplication.surfaceList.count }, 0);
12341248
12351249 tryCompare(topLevelSurfaceList, "count", 0);
12361250 compare(wizard.shown, true);
12371251
1238− // And make sure we stay running when dash comes back again
1239− var dashSurfaceId = topLevelSurfaceList.nextId;
1240− ApplicationManager.startApplication(dashApplication.appId);
1241− waitUntilAppWindowIsFullyLoaded(dashSurfaceId);
1242− compare(wizard.shown, true);
1243−
1244− // And make sure we stop when some other surface shows app
1252+ // And make sure we stop when some surface shows app
12451253 var gallerySurfaceId = topLevelSurfaceList.nextId;
12461254 var galleryApp = ApplicationManager.startApplication("gallery-app");
12471255 waitUntilAppWindowIsFullyLoaded(gallerySurfaceId);
@@ -1291,6 +1299,11 @@ Rectangle {
12911299 function test_tapOnRightEdgeReachesApplicationSurface() {
12921300 loadShell("phone");
12931301 swipeAwayGreeter();
1302+
1303+ var appSurfaceId = topLevelSurfaceList.nextId;
1304+ var app = ApplicationManager.startApplication("unity8-dash")
1305+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
1306+
12941307 var topmostSpreadDelegate = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
12951308 verify(topmostSpreadDelegate);
12961309
@@ -1320,6 +1333,11 @@ Rectangle {
13201333 function test_rightEdgeDragDoesNotReachApplicationSurface() {
13211334 loadShell("phone");
13221335 swipeAwayGreeter();
1336+
1337+ var appSurfaceId = topLevelSurfaceList.nextId;
1338+ var app = ApplicationManager.startApplication("unity8-dash")
1339+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
1340+
13231341 var topmostSpreadDelegate = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
13241342 var topmostSurfaceItem = findChild(topmostSpreadDelegate, "surfaceItem");
13251343 var rightEdgeDragArea = findChild(shell, "rightEdgeDragArea");
@@ -1372,15 +1390,15 @@ Rectangle {
13721390 verify(coverPage.shown);
13731391 }
13741392
1375− function test_physicalHomeKeyPressFocusesDash() {
1393+ function test_physicalHomeKeyPressOpensDrawer() {
13761394 loadShell("phone");
1377−
1378− var galleryApp = ApplicationManager.startApplication("gallery-app");
1379− tryCompare(ApplicationManager, "focusedApplicationId", "gallery-app");
1395+ swipeAwayGreeter();
13801396
13811397 var windowInputMonitor = findInvisibleChild(shell, "windowInputMonitor");
13821398 windowInputMonitor.homeKeyActivated();
1383− tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
1399+
1400+ var launcher = findChild(shell, "launcher");
1401+ tryCompare(launcher, "drawerShown", true);
13841402 }
13851403
13861404 function test_tabletLogin_data() {
@@ -1499,6 +1517,10 @@ Rectangle {
14991517 loadShell("tablet");
15001518 shell.usageScenario = "desktop";
15011519
1520+ var appSurfaceId = topLevelSurfaceList.nextId;
1521+ var app = ApplicationManager.startApplication("unity8-dash")
1522+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
1523+
15021524 var webBrowserSurfaceId = topLevelSurfaceList.nextId;
15031525 var webBrowserApp = ApplicationManager.startApplication("webbrowser-app");
15041526 waitUntilAppWindowIsFullyLoaded(webBrowserSurfaceId);
@@ -1523,6 +1545,10 @@ Rectangle {
15231545 loadShell("tablet");
15241546 shell.usageScenario = "tablet";
15251547
1548+ var appSurfaceId = topLevelSurfaceList.nextId;
1549+ var app = ApplicationManager.startApplication("unity8-dash")
1550+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
1551+
15261552 var webBrowserSurfaceId = topLevelSurfaceList.nextId;
15271553 var webBrowserApp = ApplicationManager.startApplication("webbrowser-app");
15281554 waitUntilAppWindowIsFullyLoaded(webBrowserSurfaceId);
@@ -2415,7 +2441,7 @@ Rectangle {
24152441
24162442 tryCompare(broadcastUrlSpy, "count", 1);
24172443 compare(broadcastUrlSpy.signalArguments[0][0], "application:///" + appIcon.appId + ".desktop");
2418− compare(ApplicationManager.count, 1); // confirm only dash is open, we didn't start new app
2444+ compare(ApplicationManager.count, 0); // confirm no app is open, we didn't start new app
24192445
24202446 var coverPage = findChild(shell, "coverPage");
24212447 tryCompare(coverPage, "showProgress", 0);
@@ -2456,7 +2482,7 @@ Rectangle {
24562482
24572483 tryCompare(broadcastUrlSpy, "count", 1);
24582484 compare(broadcastUrlSpy.signalArguments[0][0], "test:");
2459− compare(ApplicationManager.count, 1); // confirm only dash is open, we didn't start new app
2485+ compare(ApplicationManager.count, 0); // confirm no app is open, we didn't start new app
24602486
24612487 var coverPage = findChild(shell, "coverPage");
24622488 tryCompare(coverPage, "showProgress", 0);
@@ -2685,6 +2711,10 @@ Rectangle {
26852711 ensureInputMethodSurface();
26862712 shell.oskEnabled = data.oskEnabled;
26872713
2714+ var appSurfaceId = topLevelSurfaceList.nextId;
2715+ var app = ApplicationManager.startApplication("unity8-dash")
2716+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2717+
26882718 var oldOSKState = topLevelSurfaceList.inputMethodSurface.state;
26892719 topLevelSurfaceList.inputMethodSurface.requestState(Mir.RestoredState);
26902720 var appRepeater = findChild(shell, "appRepeater");
@@ -2957,7 +2987,11 @@ Rectangle {
29572987 swipeAwayGreeter();
29582988
29592989 var appSurfaceId = topLevelSurfaceList.nextId;
2960− var app = ApplicationManager.startApplication("dialer-app")
2990+ var app = ApplicationManager.startApplication("unity8-dash")
2991+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2992+
2993+ appSurfaceId = topLevelSurfaceList.nextId;
2994+ app = ApplicationManager.startApplication("dialer-app")
29612995 waitUntilAppWindowIsFullyLoaded(appSurfaceId);
29622996
29632997 appSurfaceId = topLevelSurfaceList.nextId;
@@ -2984,12 +3018,6 @@ Rectangle {
29843018 // Now the dash should be highlighted
29853019 tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "unity8-dash"}, true);
29863020
2987− keyClick(Qt.Key_Q);
2988−
2989− // Dash is not closeable, should still be 2
2990− tryCompare(ApplicationManager, "count", 2);
2991−
2992− // Move to the next one, should be closable again
29933021 keyClick(Qt.Key_Tab);
29943022 tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "calendar-app"}, true);
29953023
@@ -3170,6 +3198,96 @@ Rectangle {
31703198 tryCompare(menuBarLoader.item, "visible", true);
31713199 }
31723200
3201+ function test_enforceFocusOnStageOnAltTab() {
3202+ loadShell("desktop");
3203+ shell.usageScenario = "desktop";
3204+ waitForRendering(shell);
3205+ swipeAwayGreeter();
3206+
3207+ var appSurfaceId = topLevelSurfaceList.nextId;
3208+ var app = ApplicationManager.startApplication("unity8-dash")
3209+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
3210+
3211+ var appDelegate = startApplication("music-app")
3212+ verify(appDelegate);
3213+ waitForRendering(shell);
3214+
3215+ var launcher = findChild(shell, "launcher");
3216+ launcher.focus = true;
3217+
3218+ var stage = findChild(shell, "stage");
3219+
3220+ var spreadItem = findChild(shell, "spreadItem");
3221+
3222+ compare(spreadItem.highlightedIndex, -1);
3223+
3224+ keyPress(Qt.Key_Alt);
3225+ keyClick(Qt.Key_Tab);
3226+
3227+ tryCompare(spreadItem, "highlightedIndex", 1);
3228+ tryCompare(stage, "focus", true);
3229+
3230+ keyClick(Qt.Key_Tab);
3231+
3232+ tryCompare(spreadItem, "highlightedIndex", 0);
3233+
3234+ keyRelease(Qt.Key_Alt);
3235+ }
3236+
3237+ function test_maximizedWindowMenuThenAltTab_data() {
3238+ return [
3239+ { tag: "show spread", showSpread: true },
3240+ { tag: "do not show spread", showSpread: false },
3241+ ];
3242+ }
3243+
3244+ function test_maximizedWindowMenuThenAltTab(data) {
3245+ loadShell("desktop");
3246+ shell.usageScenario = "desktop";
3247+ waitForRendering(shell);
3248+ swipeAwayGreeter();
3249+
3250+ var appDelegate = startApplication("gmail-webapp");
3251+ var appDelegate2 = startApplication("dialer-app");
3252+
3253+ tryCompare(appDelegate2.surface, "activeFocus", true);
3254+
3255+ var maximizeButton = findChild(appDelegate2, "maximizeWindowButton");
3256+ mouseClick(maximizeButton);
3257+ tryCompare(appDelegate2, "state", "maximized");
3258+
3259+ var panel = findChild(shell, "panel");
3260+ var panelMouse = findChild(panel, "windowControlArea");
3261+ mouseMove(panelMouse);
3262+ var panelMenu = findChild(panel, "menuBar");
3263+ var menuBarLoader = findChild(panel, "menuBarLoader");
3264+ mouseMove(panelMenu);
3265+ var panelMenuItem = findChild(panelMenu, "menuBar-item0");
3266+ tryCompare(panelMenuItem, "visible", true);
3267+ Util.waitForBehaviors(shell);
3268+ mouseClick(panelMenuItem);
3269+ var panelMenuItemItem = findChild(panelMenu, "menuBar-item0-menu-item0-actionItem");
3270+ mouseMove(panelMenuItemItem, panelMenuItemItem.width/2, panelMenuItemItem.height/2);
3271+ verify(panelMenuItemItem.activeFocus);
3272+ verify(panelMenuItem.__popup);
3273+
3274+ keyPress(Qt.Key_Alt);
3275+ keyClick(Qt.Key_Tab);
3276+ if (data.showSpread) {
3277+ tryCompare(stage, "spreadShown", true);
3278+ }
3279+ tryCompareFunction(function() { return menuBarLoader.active === false; }, true);
3280+ keyRelease(Qt.Key_Alt)
3281+
3282+ tryCompare(appDelegate.surface, "activeFocus", true);
3283+
3284+ keyPress(Qt.Key_Alt);
3285+ keyClick(Qt.Key_Tab);
3286+ keyRelease(Qt.Key_Alt)
3287+
3288+ tryCompare(appDelegate2.surface, "activeFocus", true);
3289+ }
3290+
31733291 function test_maximizedWindowAndMenuInPanel() {
31743292 loadShell("desktop");
31753293 shell.usageScenario = "desktop";