@@ -138,6 +138,9 @@ Rectangle {
138138 }
139139 mode: shellLoader.mode
140140 hasTouchscreen: true
141+ Component.onCompleted: {
142+ ApplicationManager.startApplication("unity8-dash");
143+ }
141144 Component.onDestruction: {
142145 shellLoader.itemDestroyed = true;
143146 }
@@ -598,6 +601,10 @@ Rectangle {
598601 topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
599602 verify(topLevelSurfaceList);
600603 stage = findChild(shell, "stage");
604+
605+ // wait until unity8-dash is fully loaded
606+ tryCompare(topLevelSurfaceList, "count", 1);
607+ waitUntilAppWindowIsFullyLoaded(topLevelSurfaceList.idAt(0));
601608 }
602609
603610 function loadDesktopShellWithApps() {
@@ -605,7 +612,6 @@ Rectangle {
605612 waitForRendering(shell)
606613 shell.usageScenario = "desktop"
607614 waitForRendering(shell)
608− var app0 = ApplicationManager.startApplication("unity8-dash")
609615 var app1 = ApplicationManager.startApplication("dialer-app")
610616 var app2 = ApplicationManager.startApplication("webbrowser-app")
611617 var app3 = ApplicationManager.startApplication("camera-app")
@@ -813,12 +819,6 @@ Rectangle {
813819
814820 function swipeAwayGreeter() {
815821 var greeter = findChild(shell, "greeter");
816−
817− if (!greeter.shown) {
818− console.log("Greeter not shown. Not swiping.");
819− return;
820− }
821−
822822 tryCompare(greeter, "fullyShown", true);
823823 waitForGreeterToStabilize();
824824 removeTimeConstraintsFromSwipeAreas(greeter);
@@ -1245,11 +1245,26 @@ Rectangle {
12451245
12461246 var wizard = findChild(shell, "wizard");
12471247 tryCompare(wizard, "active", true);
1248+ tryCompareFunction(function() { return topLevelSurfaceList.applicationAt(0).appId; }, "unity8-dash");
1249+
1250+ // Make sure we stay running when there's no top level window (can happen for
1251+ // a moment when we restart the dash after switching language)
1252+ var dashApplication = ApplicationManager.findApplication("unity8-dash");
1253+ ApplicationManager.stopApplication(dashApplication.appId);
1254+ // wait until all zombie surfaces are gone. As MirSurfaceItems hold references over them.
1255+ // They won't be gone until those surface items are destroyed.
1256+ tryCompareFunction(function() { return dashApplication.surfaceList.count }, 0);
12481257
12491258 tryCompare(topLevelSurfaceList, "count", 0);
12501259 compare(wizard.shown, true);
12511260
1252− // And make sure we stop when some surface shows app
1261+ // And make sure we stay running when dash comes back again
1262+ var dashSurfaceId = topLevelSurfaceList.nextId;
1263+ ApplicationManager.startApplication(dashApplication.appId);
1264+ waitUntilAppWindowIsFullyLoaded(dashSurfaceId);
1265+ compare(wizard.shown, true);
1266+
1267+ // And make sure we stop when some other surface shows app
12531268 var gallerySurfaceId = topLevelSurfaceList.nextId;
12541269 var galleryApp = ApplicationManager.startApplication("gallery-app");
12551270 waitUntilAppWindowIsFullyLoaded(gallerySurfaceId);
@@ -1299,11 +1314,6 @@ Rectangle {
12991314 function test_tapOnRightEdgeReachesApplicationSurface() {
13001315 loadShell("phone");
13011316 swipeAwayGreeter();
1302−
1303− var appSurfaceId = topLevelSurfaceList.nextId;
1304− var app = ApplicationManager.startApplication("unity8-dash")
1305− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
1306−
13071317 var topmostSpreadDelegate = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
13081318 verify(topmostSpreadDelegate);
13091319
@@ -1333,11 +1343,6 @@ Rectangle {
13331343 function test_rightEdgeDragDoesNotReachApplicationSurface() {
13341344 loadShell("phone");
13351345 swipeAwayGreeter();
1336−
1337− var appSurfaceId = topLevelSurfaceList.nextId;
1338− var app = ApplicationManager.startApplication("unity8-dash")
1339− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
1340−
13411346 var topmostSpreadDelegate = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
13421347 var topmostSurfaceItem = findChild(topmostSpreadDelegate, "surfaceItem");
13431348 var rightEdgeDragArea = findChild(shell, "rightEdgeDragArea");
@@ -1390,15 +1395,15 @@ Rectangle {
13901395 verify(coverPage.shown);
13911396 }
13921397
1393− function test_physicalHomeKeyPressOpensDrawer() {
1398+ function test_physicalHomeKeyPressFocusesDash() {
13941399 loadShell("phone");
1395− swipeAwayGreeter();
1400+
1401+ var galleryApp = ApplicationManager.startApplication("gallery-app");
1402+ tryCompare(ApplicationManager, "focusedApplicationId", "gallery-app");
13961403
13971404 var windowInputMonitor = findInvisibleChild(shell, "windowInputMonitor");
13981405 windowInputMonitor.homeKeyActivated();
1399−
1400− var launcher = findChild(shell, "launcher");
1401− tryCompare(launcher, "drawerShown", true);
1406+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
14021407 }
14031408
14041409 function test_tabletLogin_data() {
@@ -1517,10 +1522,6 @@ Rectangle {
15171522 loadShell("tablet");
15181523 shell.usageScenario = "desktop";
15191524
1520− var appSurfaceId = topLevelSurfaceList.nextId;
1521− var app = ApplicationManager.startApplication("unity8-dash")
1522− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
1523−
15241525 var webBrowserSurfaceId = topLevelSurfaceList.nextId;
15251526 var webBrowserApp = ApplicationManager.startApplication("webbrowser-app");
15261527 waitUntilAppWindowIsFullyLoaded(webBrowserSurfaceId);
@@ -1545,10 +1546,6 @@ Rectangle {
15451546 loadShell("tablet");
15461547 shell.usageScenario = "tablet";
15471548
1548− var appSurfaceId = topLevelSurfaceList.nextId;
1549− var app = ApplicationManager.startApplication("unity8-dash")
1550− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
1551−
15521549 var webBrowserSurfaceId = topLevelSurfaceList.nextId;
15531550 var webBrowserApp = ApplicationManager.startApplication("webbrowser-app");
15541551 waitUntilAppWindowIsFullyLoaded(webBrowserSurfaceId);
@@ -2441,7 +2438,7 @@ Rectangle {
24412438
24422439 tryCompare(broadcastUrlSpy, "count", 1);
24432440 compare(broadcastUrlSpy.signalArguments[0][0], "application:///" + appIcon.appId + ".desktop");
2444− compare(ApplicationManager.count, 0); // confirm no app is open, we didn't start new app
2441+ compare(ApplicationManager.count, 1); // confirm only dash is open, we didn't start new app
24452442
24462443 var coverPage = findChild(shell, "coverPage");
24472444 tryCompare(coverPage, "showProgress", 0);
@@ -2482,7 +2479,7 @@ Rectangle {
24822479
24832480 tryCompare(broadcastUrlSpy, "count", 1);
24842481 compare(broadcastUrlSpy.signalArguments[0][0], "test:");
2485− compare(ApplicationManager.count, 0); // confirm no app is open, we didn't start new app
2482+ compare(ApplicationManager.count, 1); // confirm only dash is open, we didn't start new app
24862483
24872484 var coverPage = findChild(shell, "coverPage");
24882485 tryCompare(coverPage, "showProgress", 0);
@@ -2711,10 +2708,6 @@ Rectangle {
27112708 ensureInputMethodSurface();
27122709 shell.oskEnabled = data.oskEnabled;
27132710
2714− var appSurfaceId = topLevelSurfaceList.nextId;
2715− var app = ApplicationManager.startApplication("unity8-dash")
2716− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2717−
27182711 var oldOSKState = topLevelSurfaceList.inputMethodSurface.state;
27192712 topLevelSurfaceList.inputMethodSurface.requestState(Mir.RestoredState);
27202713 var appRepeater = findChild(shell, "appRepeater");
@@ -2987,11 +2980,7 @@ Rectangle {
29872980 swipeAwayGreeter();
29882981
29892982 var appSurfaceId = topLevelSurfaceList.nextId;
2990− var app = ApplicationManager.startApplication("unity8-dash")
2991− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2992−
2993− appSurfaceId = topLevelSurfaceList.nextId;
2994− app = ApplicationManager.startApplication("dialer-app")
2983+ var app = ApplicationManager.startApplication("dialer-app")
29952984 waitUntilAppWindowIsFullyLoaded(appSurfaceId);
29962985
29972986 appSurfaceId = topLevelSurfaceList.nextId;
@@ -3018,6 +3007,12 @@ Rectangle {
30183007 // Now the dash should be highlighted
30193008 tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "unity8-dash"}, true);
30203009
3010+ keyClick(Qt.Key_Q);
3011+
3012+ // Dash is not closeable, should still be 2
3013+ tryCompare(ApplicationManager, "count", 2);
3014+
3015+ // Move to the next one, should be closable again
30213016 keyClick(Qt.Key_Tab);
30223017 tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "calendar-app"}, true);
30233018
@@ -3204,10 +3199,6 @@ Rectangle {
32043199 waitForRendering(shell);
32053200 swipeAwayGreeter();
32063201
3207− var appSurfaceId = topLevelSurfaceList.nextId;
3208− var app = ApplicationManager.startApplication("unity8-dash")
3209− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
3210−
32113202 var appDelegate = startApplication("music-app")
32123203 verify(appDelegate);
32133204 waitForRendering(shell);