@@ -2913,6 +2913,86 @@ Rectangle {
29132913 tryCompare(appDelegate, "state", "maximizedRight");
29142914 }
29152915
2916+
2917+ function test_closeAppsInSpreadWithQ() {
2918+ loadShell("desktop");
2919+ shell.usageScenario = "desktop";
2920+ waitForRendering(shell);
2921+ swipeAwayGreeter();
2922+
2923+ var appSurfaceId = topLevelSurfaceList.nextId;
2924+ var app = ApplicationManager.startApplication("dialer-app")
2925+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2926+
2927+ appSurfaceId = topLevelSurfaceList.nextId;
2928+ app = ApplicationManager.startApplication("calendar-app")
2929+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2930+
2931+ keyPress(Qt.Key_Alt);
2932+ keyClick(Qt.Key_Tab);
2933+
2934+ var stage = findChild(shell, "stage");
2935+ var spread = findChild(stage, "spreadItem");
2936+ var appRepeater = findChild(stage, "appRepeater");
2937+
2938+ tryCompare(stage, "state", "spread");
2939+
2940+ tryCompare(ApplicationManager, "count", 3);
2941+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "dialer-app"}, true);
2942+
2943+ // Close one app with Q while in spread
2944+ keyClick(Qt.Key_Q);
2945+
2946+ tryCompare(ApplicationManager, "count", 2);
2947+
2948+ // Now the dash should be highlighted
2949+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "unity8-dash"}, true);
2950+
2951+ keyClick(Qt.Key_Q);
2952+
2953+ // Dash is not closeable, should still be 2
2954+ tryCompare(ApplicationManager, "count", 2);
2955+
2956+ // Move to the next one, should be closable again
2957+ keyClick(Qt.Key_Tab);
2958+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "calendar-app"}, true);
2959+
2960+ // close it
2961+ keyClick(Qt.Key_Q);
2962+ tryCompare(ApplicationManager, "count", 1);
2963+
2964+ keyRelease(Qt.Key_Alt);
2965+
2966+ // Now start the apps again
2967+ appSurfaceId = topLevelSurfaceList.nextId;
2968+ app = ApplicationManager.startApplication("dialer-app");
2969+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2970+
2971+ appSurfaceId = topLevelSurfaceList.nextId;
2972+ app = ApplicationManager.startApplication("calendar-app");
2973+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2974+
2975+ // First focus the dash so it'll be the leftmost in the spread
2976+ ApplicationManager.requestFocusApplication("unity8-dash");
2977+
2978+ keyPress(Qt.Key_Alt);
2979+ keyClick(Qt.Key_Tab);
2980+ tryCompare(stage, "state", "spread");
2981+
2982+ // Move to the last one
2983+ keyClick(Qt.Key_Tab);
2984+
2985+ // Close the last one, make sure the highlight fixes itself to stick within the list
2986+ tryCompare(spread, "highlightedIndex", ApplicationManager.count - 1);
2987+ var oldHighlighted = spread.highlightedIndex;
2988+
2989+ keyClick(Qt.Key_Q);
2990+ tryCompare(spread, "highlightedIndex", oldHighlighted - 1);
2991+
2992+ keyRelease(Qt.Key_Alt);
2993+
2994+ }
2995+
29162996 function test_altTabToMinimizedApp() {
29172997 loadShell("desktop");
29182998 shell.usageScenario = "desktop";