@@ -2536,27 +2536,44 @@ Rectangle {
25362536 tryCompare(app2Surface, "keymap", "fr");
25372537 }
25382538
2539− function test_dragPanelToRestoreMaximizedWindow() {
2539+ function test_dragPanelToRestoreMaximizedWindow_data() {
2540+ return [
2541+ { tag: "with mouse", mouse: true },
2542+ { tag: "with touch", mouse: false }
2543+ ]
2544+ }
2545+
2546+ function test_dragPanelToRestoreMaximizedWindow(data) {
25402547 loadShell("desktop");
25412548 shell.usageScenario = "desktop";
25422549 waitForRendering(shell);
25432550 var panel = findChild(shell, "windowControlArea");
25442551 verify(panel);
25452552
2546− var appSurfaceId = topLevelSurfaceList.nextId;
2547− var app = ApplicationManager.startApplication("dialer-app")
2548− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2549−
25502553 // start dialer, maximize it
2551− var appContainer = findChild(shell, "appContainer");
2552− var appDelegate = findChild(appContainer, "appDelegate_" + appSurfaceId);
2554+ var appDelegate = startApplication("dialer-app");
25532555 verify(appDelegate);
2556+
25542557 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2555− mouseClick(maximizeButton);
2558+ if (data.mouse) {
2559+ mouseClick(maximizeButton);
2560+ } else {
2561+ tap(maximizeButton);
2562+ }
25562563
2564+ waitUntilTransitionsEnd(appDelegate);
25572565 tryCompare(appDelegate, "state", "maximized");
25582566
2559− mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2567+ if (data.mouse) {
2568+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
2569+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
2570+ verify(menuBarLoader);
2571+ tryCompare(menuBarLoader.item, "visible", true);
2572+ mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2573+ } else {
2574+ touchFlick(panel, panel.width/2, panel.panelHeight/2, panel.width/2, shell.height/3);
2575+ }
2576+
25602577 tryCompare(appDelegate, "state", "restored");
25612578 }
25622579
@@ -2871,7 +2888,7 @@ Rectangle {
28712888 loadShell(data.tag);
28722889
28732890 var panel = findChild(shell, "panel"); verify(panel);
2874− var panelTitle = findChild(panel.applicationMenus, "panelTitle"); verify(panelTitle);
2891+ var panelTitle = findChild(panel, "panelTitle"); verify(panelTitle);
28752892 compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
28762893
28772894 swipeAwayGreeter();
@@ -2936,6 +2953,86 @@ Rectangle {
29362953 tryCompare(appDelegate, "state", "maximizedRight");
29372954 }
29382955
2956+
2957+ function test_closeAppsInSpreadWithQ() {
2958+ loadShell("desktop");
2959+ shell.usageScenario = "desktop";
2960+ waitForRendering(shell);
2961+ swipeAwayGreeter();
2962+
2963+ var appSurfaceId = topLevelSurfaceList.nextId;
2964+ var app = ApplicationManager.startApplication("dialer-app")
2965+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2966+
2967+ appSurfaceId = topLevelSurfaceList.nextId;
2968+ app = ApplicationManager.startApplication("calendar-app")
2969+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2970+
2971+ keyPress(Qt.Key_Alt);
2972+ keyClick(Qt.Key_Tab);
2973+
2974+ var stage = findChild(shell, "stage");
2975+ var spread = findChild(stage, "spreadItem");
2976+ var appRepeater = findChild(stage, "appRepeater");
2977+
2978+ tryCompare(stage, "state", "spread");
2979+
2980+ tryCompare(ApplicationManager, "count", 3);
2981+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "dialer-app"}, true);
2982+
2983+ // Close one app with Q while in spread
2984+ keyClick(Qt.Key_Q);
2985+
2986+ tryCompare(ApplicationManager, "count", 2);
2987+
2988+ // Now the dash should be highlighted
2989+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "unity8-dash"}, true);
2990+
2991+ keyClick(Qt.Key_Q);
2992+
2993+ // Dash is not closeable, should still be 2
2994+ tryCompare(ApplicationManager, "count", 2);
2995+
2996+ // Move to the next one, should be closable again
2997+ keyClick(Qt.Key_Tab);
2998+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "calendar-app"}, true);
2999+
3000+ // close it
3001+ keyClick(Qt.Key_Q);
3002+ tryCompare(ApplicationManager, "count", 1);
3003+
3004+ keyRelease(Qt.Key_Alt);
3005+
3006+ // Now start the apps again
3007+ appSurfaceId = topLevelSurfaceList.nextId;
3008+ app = ApplicationManager.startApplication("dialer-app");
3009+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
3010+
3011+ appSurfaceId = topLevelSurfaceList.nextId;
3012+ app = ApplicationManager.startApplication("calendar-app");
3013+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
3014+
3015+ // First focus the dash so it'll be the leftmost in the spread
3016+ ApplicationManager.requestFocusApplication("unity8-dash");
3017+
3018+ keyPress(Qt.Key_Alt);
3019+ keyClick(Qt.Key_Tab);
3020+ tryCompare(stage, "state", "spread");
3021+
3022+ // Move to the last one
3023+ keyClick(Qt.Key_Tab);
3024+
3025+ // Close the last one, make sure the highlight fixes itself to stick within the list
3026+ tryCompare(spread, "highlightedIndex", ApplicationManager.count - 1);
3027+ var oldHighlighted = spread.highlightedIndex;
3028+
3029+ keyClick(Qt.Key_Q);
3030+ tryCompare(spread, "highlightedIndex", oldHighlighted - 1);
3031+
3032+ keyRelease(Qt.Key_Alt);
3033+
3034+ }
3035+
29393036 function test_altTabToMinimizedApp() {
29403037 loadShell("desktop");
29413038 shell.usageScenario = "desktop";
@@ -2964,6 +3061,61 @@ Rectangle {
29643061 tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
29653062 }
29663063
3064+ function test_touchMenuPosition_data() {
3065+ return [
3066+ { tag: "launcher locked", lockLauncher: true },
3067+ { tag: "launcher not locked", lockLauncher: false }
3068+ ];
3069+ }
3070+
3071+ function test_touchMenuPosition(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+ if (data.lockLauncher) {
3081+ compare(panel.applicationMenus.x, launcher.panelWidth);
3082+ } else {
3083+ compare(panel.applicationMenus.x, 0);
3084+ }
3085+ }
3086+
3087+ function test_touchMenuHidesOnLauncherAppDrawer_data() {
3088+ return [
3089+ { tag: "launcher locked", lockLauncher: true },
3090+ { tag: "launcher not locked", lockLauncher: false }
3091+ ];
3092+ }
3093+
3094+ function test_touchMenuHidesOnLauncherAppDrawer(data) {
3095+ loadShell("desktop");
3096+ shell.usageScenario = "desktop";
3097+ waitForRendering(shell);
3098+ swipeAwayGreeter();
3099+
3100+ var panel = findChild(shell, "panel");
3101+ var launcher = testCase.findChild(shell, "launcher");
3102+ launcher.lockedVisible = data.lockLauncher;
3103+
3104+ waitForRendering(panel.applicationMenus);
3105+
3106+ if (data.lockLauncher) {
3107+ panel.applicationMenus.show();
3108+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3109+ launcher.openDrawer();
3110+ } else {
3111+ tryCompare(launcher, "shown", false);
3112+ panel.applicationMenus.show();
3113+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3114+ launcher.switchToNextState("visible");
3115+ }
3116+ tryCompare(panel.applicationMenus, "fullyClosed", true);
3117+ }
3118+
29673119 function test_doubleClickPanelRestoresWindow() {
29683120 loadShell("desktop");
29693121 shell.usageScenario = "desktop";
@@ -2987,5 +3139,70 @@ Rectangle {
29873139 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
29883140 tryCompare(appDelegate, "state", "restored");
29893141 }
3142+
3143+ function test_noMenusWithActiveCall() {
3144+ loadShell("desktop");
3145+ shell.usageScenario = "desktop";
3146+ waitForRendering(shell);
3147+ swipeAwayGreeter();
3148+
3149+ // start music-app, maximize it
3150+ var appDelegate = startApplication("music-app")
3151+ verify(appDelegate);
3152+ appDelegate.requestMaximize();
3153+
3154+ // move the mouse over panel to reveal the menus
3155+ var panel = findChild(shell, "panel");
3156+ verify(panel);
3157+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3158+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
3159+ verify(menuBarLoader);
3160+ tryCompare(menuBarLoader.item, "visible", true);
3161+
3162+ // place a phone call
3163+ callManager.foregroundCall = phoneCall;
3164+
3165+ // menu bar should be hidden
3166+ tryCompare(menuBarLoader, "active", false);
3167+ tryCompare(menuBarLoader, "item", null);
3168+
3169+ // remove call
3170+ callManager.foregroundCall = null;
3171+
3172+ // menu bar should be revealed
3173+ tryCompare(menuBarLoader, "active", true);
3174+ tryCompare(menuBarLoader.item, "visible", true);
3175+ }
3176+
3177+ function test_maximizedWindowAndMenuInPanel() {
3178+ loadShell("desktop");
3179+ shell.usageScenario = "desktop";
3180+ waitForRendering(shell);
3181+ swipeAwayGreeter();
3182+
3183+ // start music-app, maximize it
3184+ var appDelegate = startApplication("music-app")
3185+ verify(appDelegate);
3186+ appDelegate.requestMaximize();
3187+ tryCompare(appDelegate, "state", "maximized");
3188+
3189+ // move the mouse over panel to reveal the menus
3190+ var panel = findChild(shell, "panel");
3191+ verify(panel);
3192+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3193+ var menuBar = findChild(panel, "menuBar");
3194+ verify(menuBar);
3195+ tryCompare(menuBar, "visible", true);
3196+
3197+ // check that the menu popup appears
3198+ var priv = findInvisibleChild(menuBar, "d");
3199+ var menuItem0 = findChild(menuBar, "menuBar-item0");
3200+ verify(menuItem0);
3201+ mouseMove(menuItem0, menuItem0.width/2, menuItem0.height/2, 200);
3202+ tryCompare(menuItem0, "visible", true);
3203+ mouseClick(menuItem0);
3204+ tryCompare(priv, "currentItem", menuItem0);
3205+ tryCompare(priv.currentItem, "popupVisible", true);
3206+ }
29903207 }
29913208}