@@ -2513,27 +2513,44 @@ Rectangle {
25132513 tryCompare(app2Surface, "keymap", "fr");
25142514 }
25152515
2516− function test_dragPanelToRestoreMaximizedWindow() {
2516+ function test_dragPanelToRestoreMaximizedWindow_data() {
2517+ return [
2518+ { tag: "with mouse", mouse: true },
2519+ { tag: "with touch", mouse: false }
2520+ ]
2521+ }
2522+
2523+ function test_dragPanelToRestoreMaximizedWindow(data) {
25172524 loadShell("desktop");
25182525 shell.usageScenario = "desktop";
25192526 waitForRendering(shell);
25202527 var panel = findChild(shell, "windowControlArea");
25212528 verify(panel);
25222529
2523− var appSurfaceId = topLevelSurfaceList.nextId;
2524− var app = ApplicationManager.startApplication("dialer-app")
2525− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2526−
25272530 // start dialer, maximize it
2528− var appContainer = findChild(shell, "appContainer");
2529− var appDelegate = findChild(appContainer, "appDelegate_" + appSurfaceId);
2531+ var appDelegate = startApplication("dialer-app");
25302532 verify(appDelegate);
2533+
25312534 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2532− mouseClick(maximizeButton);
2535+ if (data.mouse) {
2536+ mouseClick(maximizeButton);
2537+ } else {
2538+ tap(maximizeButton);
2539+ }
25332540
2541+ waitUntilTransitionsEnd(appDelegate);
25342542 tryCompare(appDelegate, "state", "maximized");
25352543
2536− mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2544+ if (data.mouse) {
2545+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
2546+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
2547+ verify(menuBarLoader);
2548+ tryCompare(menuBarLoader.item, "visible", true);
2549+ mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2550+ } else {
2551+ touchFlick(panel, panel.width/2, panel.panelHeight/2, panel.width/2, shell.height/3);
2552+ }
2553+
25372554 tryCompare(appDelegate, "state", "restored");
25382555 }
25392556
@@ -2848,7 +2865,7 @@ Rectangle {
28482865 loadShell(data.tag);
28492866
28502867 var panel = findChild(shell, "panel"); verify(panel);
2851− var panelTitle = findChild(panel.applicationMenus, "panelTitle"); verify(panelTitle);
2868+ var panelTitle = findChild(panel, "panelTitle"); verify(panelTitle);
28522869 compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
28532870
28542871 swipeAwayGreeter();
@@ -2913,6 +2930,86 @@ Rectangle {
29132930 tryCompare(appDelegate, "state", "maximizedRight");
29142931 }
29152932
2933+
2934+ function test_closeAppsInSpreadWithQ() {
2935+ loadShell("desktop");
2936+ shell.usageScenario = "desktop";
2937+ waitForRendering(shell);
2938+ swipeAwayGreeter();
2939+
2940+ var appSurfaceId = topLevelSurfaceList.nextId;
2941+ var app = ApplicationManager.startApplication("dialer-app")
2942+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2943+
2944+ appSurfaceId = topLevelSurfaceList.nextId;
2945+ app = ApplicationManager.startApplication("calendar-app")
2946+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2947+
2948+ keyPress(Qt.Key_Alt);
2949+ keyClick(Qt.Key_Tab);
2950+
2951+ var stage = findChild(shell, "stage");
2952+ var spread = findChild(stage, "spreadItem");
2953+ var appRepeater = findChild(stage, "appRepeater");
2954+
2955+ tryCompare(stage, "state", "spread");
2956+
2957+ tryCompare(ApplicationManager, "count", 3);
2958+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "dialer-app"}, true);
2959+
2960+ // Close one app with Q while in spread
2961+ keyClick(Qt.Key_Q);
2962+
2963+ tryCompare(ApplicationManager, "count", 2);
2964+
2965+ // Now the dash should be highlighted
2966+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "unity8-dash"}, true);
2967+
2968+ keyClick(Qt.Key_Q);
2969+
2970+ // Dash is not closeable, should still be 2
2971+ tryCompare(ApplicationManager, "count", 2);
2972+
2973+ // Move to the next one, should be closable again
2974+ keyClick(Qt.Key_Tab);
2975+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "calendar-app"}, true);
2976+
2977+ // close it
2978+ keyClick(Qt.Key_Q);
2979+ tryCompare(ApplicationManager, "count", 1);
2980+
2981+ keyRelease(Qt.Key_Alt);
2982+
2983+ // Now start the apps again
2984+ appSurfaceId = topLevelSurfaceList.nextId;
2985+ app = ApplicationManager.startApplication("dialer-app");
2986+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2987+
2988+ appSurfaceId = topLevelSurfaceList.nextId;
2989+ app = ApplicationManager.startApplication("calendar-app");
2990+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2991+
2992+ // First focus the dash so it'll be the leftmost in the spread
2993+ ApplicationManager.requestFocusApplication("unity8-dash");
2994+
2995+ keyPress(Qt.Key_Alt);
2996+ keyClick(Qt.Key_Tab);
2997+ tryCompare(stage, "state", "spread");
2998+
2999+ // Move to the last one
3000+ keyClick(Qt.Key_Tab);
3001+
3002+ // Close the last one, make sure the highlight fixes itself to stick within the list
3003+ tryCompare(spread, "highlightedIndex", ApplicationManager.count - 1);
3004+ var oldHighlighted = spread.highlightedIndex;
3005+
3006+ keyClick(Qt.Key_Q);
3007+ tryCompare(spread, "highlightedIndex", oldHighlighted - 1);
3008+
3009+ keyRelease(Qt.Key_Alt);
3010+
3011+ }
3012+
29163013 function test_altTabToMinimizedApp() {
29173014 loadShell("desktop");
29183015 shell.usageScenario = "desktop";
@@ -2941,6 +3038,61 @@ Rectangle {
29413038 tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
29423039 }
29433040
3041+ function test_touchMenuPosition_data() {
3042+ return [
3043+ { tag: "launcher locked", lockLauncher: true },
3044+ { tag: "launcher not locked", lockLauncher: false }
3045+ ];
3046+ }
3047+
3048+ function test_touchMenuPosition(data) {
3049+ loadShell("desktop");
3050+ shell.usageScenario = "desktop";
3051+ waitForRendering(shell);
3052+ swipeAwayGreeter();
3053+
3054+ var panel = findChild(shell, "panel");
3055+ var launcher = testCase.findChild(shell, "launcher");
3056+ launcher.lockedVisible = data.lockLauncher;
3057+ if (data.lockLauncher) {
3058+ compare(panel.applicationMenus.x, launcher.panelWidth);
3059+ } else {
3060+ compare(panel.applicationMenus.x, 0);
3061+ }
3062+ }
3063+
3064+ function test_touchMenuHidesOnLauncherAppDrawer_data() {
3065+ return [
3066+ { tag: "launcher locked", lockLauncher: true },
3067+ { tag: "launcher not locked", lockLauncher: false }
3068+ ];
3069+ }
3070+
3071+ function test_touchMenuHidesOnLauncherAppDrawer(data) {
3072+ loadShell("desktop");
3073+ shell.usageScenario = "desktop";
3074+ waitForRendering(shell);
3075+ swipeAwayGreeter();
3076+
3077+ var panel = findChild(shell, "panel");
3078+ var launcher = testCase.findChild(shell, "launcher");
3079+ launcher.lockedVisible = data.lockLauncher;
3080+
3081+ waitForRendering(panel.applicationMenus);
3082+
3083+ if (data.lockLauncher) {
3084+ panel.applicationMenus.show();
3085+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3086+ launcher.openDrawer();
3087+ } else {
3088+ tryCompare(launcher, "shown", false);
3089+ panel.applicationMenus.show();
3090+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3091+ launcher.switchToNextState("visible");
3092+ }
3093+ tryCompare(panel.applicationMenus, "fullyClosed", true);
3094+ }
3095+
29443096 function test_doubleClickPanelRestoresWindow() {
29453097 loadShell("desktop");
29463098 shell.usageScenario = "desktop";
@@ -2964,5 +3116,70 @@ Rectangle {
29643116 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
29653117 tryCompare(appDelegate, "state", "restored");
29663118 }
3119+
3120+ function test_noMenusWithActiveCall() {
3121+ loadShell("desktop");
3122+ shell.usageScenario = "desktop";
3123+ waitForRendering(shell);
3124+ swipeAwayGreeter();
3125+
3126+ // start music-app, maximize it
3127+ var appDelegate = startApplication("music-app")
3128+ verify(appDelegate);
3129+ appDelegate.requestMaximize();
3130+
3131+ // move the mouse over panel to reveal the menus
3132+ var panel = findChild(shell, "panel");
3133+ verify(panel);
3134+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3135+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
3136+ verify(menuBarLoader);
3137+ tryCompare(menuBarLoader.item, "visible", true);
3138+
3139+ // place a phone call
3140+ callManager.foregroundCall = phoneCall;
3141+
3142+ // menu bar should be hidden
3143+ tryCompare(menuBarLoader, "active", false);
3144+ tryCompare(menuBarLoader, "item", null);
3145+
3146+ // remove call
3147+ callManager.foregroundCall = null;
3148+
3149+ // menu bar should be revealed
3150+ tryCompare(menuBarLoader, "active", true);
3151+ tryCompare(menuBarLoader.item, "visible", true);
3152+ }
3153+
3154+ function test_maximizedWindowAndMenuInPanel() {
3155+ loadShell("desktop");
3156+ shell.usageScenario = "desktop";
3157+ waitForRendering(shell);
3158+ swipeAwayGreeter();
3159+
3160+ // start music-app, maximize it
3161+ var appDelegate = startApplication("music-app")
3162+ verify(appDelegate);
3163+ appDelegate.requestMaximize();
3164+ tryCompare(appDelegate, "state", "maximized");
3165+
3166+ // move the mouse over panel to reveal the menus
3167+ var panel = findChild(shell, "panel");
3168+ verify(panel);
3169+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3170+ var menuBar = findChild(panel, "menuBar");
3171+ verify(menuBar);
3172+ tryCompare(menuBar, "visible", true);
3173+
3174+ // check that the menu popup appears
3175+ var priv = findInvisibleChild(menuBar, "d");
3176+ var menuItem0 = findChild(menuBar, "menuBar-item0");
3177+ verify(menuItem0);
3178+ mouseMove(menuItem0, menuItem0.width/2, menuItem0.height/2, 200);
3179+ tryCompare(menuItem0, "visible", true);
3180+ mouseClick(menuItem0);
3181+ tryCompare(priv, "currentItem", menuItem0);
3182+ tryCompare(priv.currentItem, "popupVisible", true);
3183+ }
29673184 }
29683185}