@@ -2520,27 +2520,44 @@ Rectangle {
25202520 tryCompare(app2Surface, "keymap", "fr");
25212521 }
25222522
2523− function test_dragPanelToRestoreMaximizedWindow() {
2523+ function test_dragPanelToRestoreMaximizedWindow_data() {
2524+ return [
2525+ { tag: "with mouse", mouse: true },
2526+ { tag: "with touch", mouse: false }
2527+ ]
2528+ }
2529+
2530+ function test_dragPanelToRestoreMaximizedWindow(data) {
25242531 loadShell("desktop");
25252532 shell.usageScenario = "desktop";
25262533 waitForRendering(shell);
25272534 var panel = findChild(shell, "windowControlArea");
25282535 verify(panel);
25292536
2530− var appSurfaceId = topLevelSurfaceList.nextId;
2531− var app = ApplicationManager.startApplication("dialer-app")
2532− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2533−
25342537 // start dialer, maximize it
2535− var appContainer = findChild(shell, "appContainer");
2536− var appDelegate = findChild(appContainer, "appDelegate_" + appSurfaceId);
2538+ var appDelegate = startApplication("dialer-app");
25372539 verify(appDelegate);
2540+
25382541 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2539− mouseClick(maximizeButton);
2542+ if (data.mouse) {
2543+ mouseClick(maximizeButton);
2544+ } else {
2545+ tap(maximizeButton);
2546+ }
25402547
2548+ waitUntilTransitionsEnd(appDelegate);
25412549 tryCompare(appDelegate, "state", "maximized");
25422550
2543− mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2551+ if (data.mouse) {
2552+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
2553+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
2554+ verify(menuBarLoader);
2555+ tryCompare(menuBarLoader.item, "visible", true);
2556+ mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2557+ } else {
2558+ touchFlick(panel, panel.width/2, panel.panelHeight/2, panel.width/2, shell.height/3);
2559+ }
2560+
25442561 tryCompare(appDelegate, "state", "restored");
25452562 }
25462563
@@ -2855,7 +2872,7 @@ Rectangle {
28552872 loadShell(data.tag);
28562873
28572874 var panel = findChild(shell, "panel"); verify(panel);
2858− var panelTitle = findChild(panel.applicationMenus, "panelTitle"); verify(panelTitle);
2875+ var panelTitle = findChild(panel, "panelTitle"); verify(panelTitle);
28592876 compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
28602877
28612878 swipeAwayGreeter();
@@ -2920,6 +2937,86 @@ Rectangle {
29202937 tryCompare(appDelegate, "state", "maximizedRight");
29212938 }
29222939
2940+
2941+ function test_closeAppsInSpreadWithQ() {
2942+ loadShell("desktop");
2943+ shell.usageScenario = "desktop";
2944+ waitForRendering(shell);
2945+ swipeAwayGreeter();
2946+
2947+ var appSurfaceId = topLevelSurfaceList.nextId;
2948+ var app = ApplicationManager.startApplication("dialer-app")
2949+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2950+
2951+ appSurfaceId = topLevelSurfaceList.nextId;
2952+ app = ApplicationManager.startApplication("calendar-app")
2953+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2954+
2955+ keyPress(Qt.Key_Alt);
2956+ keyClick(Qt.Key_Tab);
2957+
2958+ var stage = findChild(shell, "stage");
2959+ var spread = findChild(stage, "spreadItem");
2960+ var appRepeater = findChild(stage, "appRepeater");
2961+
2962+ tryCompare(stage, "state", "spread");
2963+
2964+ tryCompare(ApplicationManager, "count", 3);
2965+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "dialer-app"}, true);
2966+
2967+ // Close one app with Q while in spread
2968+ keyClick(Qt.Key_Q);
2969+
2970+ tryCompare(ApplicationManager, "count", 2);
2971+
2972+ // Now the dash should be highlighted
2973+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "unity8-dash"}, true);
2974+
2975+ keyClick(Qt.Key_Q);
2976+
2977+ // Dash is not closeable, should still be 2
2978+ tryCompare(ApplicationManager, "count", 2);
2979+
2980+ // Move to the next one, should be closable again
2981+ keyClick(Qt.Key_Tab);
2982+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "calendar-app"}, true);
2983+
2984+ // close it
2985+ keyClick(Qt.Key_Q);
2986+ tryCompare(ApplicationManager, "count", 1);
2987+
2988+ keyRelease(Qt.Key_Alt);
2989+
2990+ // Now start the apps again
2991+ appSurfaceId = topLevelSurfaceList.nextId;
2992+ app = ApplicationManager.startApplication("dialer-app");
2993+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2994+
2995+ appSurfaceId = topLevelSurfaceList.nextId;
2996+ app = ApplicationManager.startApplication("calendar-app");
2997+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2998+
2999+ // First focus the dash so it'll be the leftmost in the spread
3000+ ApplicationManager.requestFocusApplication("unity8-dash");
3001+
3002+ keyPress(Qt.Key_Alt);
3003+ keyClick(Qt.Key_Tab);
3004+ tryCompare(stage, "state", "spread");
3005+
3006+ // Move to the last one
3007+ keyClick(Qt.Key_Tab);
3008+
3009+ // Close the last one, make sure the highlight fixes itself to stick within the list
3010+ tryCompare(spread, "highlightedIndex", ApplicationManager.count - 1);
3011+ var oldHighlighted = spread.highlightedIndex;
3012+
3013+ keyClick(Qt.Key_Q);
3014+ tryCompare(spread, "highlightedIndex", oldHighlighted - 1);
3015+
3016+ keyRelease(Qt.Key_Alt);
3017+
3018+ }
3019+
29233020 function test_altTabToMinimizedApp() {
29243021 loadShell("desktop");
29253022 shell.usageScenario = "desktop";
@@ -2948,6 +3045,61 @@ Rectangle {
29483045 tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
29493046 }
29503047
3048+ function test_touchMenuPosition_data() {
3049+ return [
3050+ { tag: "launcher locked", lockLauncher: true },
3051+ { tag: "launcher not locked", lockLauncher: false }
3052+ ];
3053+ }
3054+
3055+ function test_touchMenuPosition(data) {
3056+ loadShell("desktop");
3057+ shell.usageScenario = "desktop";
3058+ waitForRendering(shell);
3059+ swipeAwayGreeter();
3060+
3061+ var panel = findChild(shell, "panel");
3062+ var launcher = testCase.findChild(shell, "launcher");
3063+ launcher.lockedVisible = data.lockLauncher;
3064+ if (data.lockLauncher) {
3065+ compare(panel.applicationMenus.x, launcher.panelWidth);
3066+ } else {
3067+ compare(panel.applicationMenus.x, 0);
3068+ }
3069+ }
3070+
3071+ function test_touchMenuHidesOnLauncherAppDrawer_data() {
3072+ return [
3073+ { tag: "launcher locked", lockLauncher: true },
3074+ { tag: "launcher not locked", lockLauncher: false }
3075+ ];
3076+ }
3077+
3078+ function test_touchMenuHidesOnLauncherAppDrawer(data) {
3079+ loadShell("desktop");
3080+ shell.usageScenario = "desktop";
3081+ waitForRendering(shell);
3082+ swipeAwayGreeter();
3083+
3084+ var panel = findChild(shell, "panel");
3085+ var launcher = testCase.findChild(shell, "launcher");
3086+ launcher.lockedVisible = data.lockLauncher;
3087+
3088+ waitForRendering(panel.applicationMenus);
3089+
3090+ if (data.lockLauncher) {
3091+ panel.applicationMenus.show();
3092+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3093+ launcher.openDrawer();
3094+ } else {
3095+ tryCompare(launcher, "shown", false);
3096+ panel.applicationMenus.show();
3097+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3098+ launcher.switchToNextState("visible");
3099+ }
3100+ tryCompare(panel.applicationMenus, "fullyClosed", true);
3101+ }
3102+
29513103 function test_doubleClickPanelRestoresWindow() {
29523104 loadShell("desktop");
29533105 shell.usageScenario = "desktop";
@@ -2971,5 +3123,70 @@ Rectangle {
29713123 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
29723124 tryCompare(appDelegate, "state", "restored");
29733125 }
3126+
3127+ function test_noMenusWithActiveCall() {
3128+ loadShell("desktop");
3129+ shell.usageScenario = "desktop";
3130+ waitForRendering(shell);
3131+ swipeAwayGreeter();
3132+
3133+ // start music-app, maximize it
3134+ var appDelegate = startApplication("music-app")
3135+ verify(appDelegate);
3136+ appDelegate.requestMaximize();
3137+
3138+ // move the mouse over panel to reveal the menus
3139+ var panel = findChild(shell, "panel");
3140+ verify(panel);
3141+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3142+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
3143+ verify(menuBarLoader);
3144+ tryCompare(menuBarLoader.item, "visible", true);
3145+
3146+ // place a phone call
3147+ callManager.foregroundCall = phoneCall;
3148+
3149+ // menu bar should be hidden
3150+ tryCompare(menuBarLoader, "active", false);
3151+ tryCompare(menuBarLoader, "item", null);
3152+
3153+ // remove call
3154+ callManager.foregroundCall = null;
3155+
3156+ // menu bar should be revealed
3157+ tryCompare(menuBarLoader, "active", true);
3158+ tryCompare(menuBarLoader.item, "visible", true);
3159+ }
3160+
3161+ function test_maximizedWindowAndMenuInPanel() {
3162+ loadShell("desktop");
3163+ shell.usageScenario = "desktop";
3164+ waitForRendering(shell);
3165+ swipeAwayGreeter();
3166+
3167+ // start music-app, maximize it
3168+ var appDelegate = startApplication("music-app")
3169+ verify(appDelegate);
3170+ appDelegate.requestMaximize();
3171+ tryCompare(appDelegate, "state", "maximized");
3172+
3173+ // move the mouse over panel to reveal the menus
3174+ var panel = findChild(shell, "panel");
3175+ verify(panel);
3176+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3177+ var menuBar = findChild(panel, "menuBar");
3178+ verify(menuBar);
3179+ tryCompare(menuBar, "visible", true);
3180+
3181+ // check that the menu popup appears
3182+ var priv = findInvisibleChild(menuBar, "d");
3183+ var menuItem0 = findChild(menuBar, "menuBar-item0");
3184+ verify(menuItem0);
3185+ mouseMove(menuItem0, menuItem0.width/2, menuItem0.height/2, 200);
3186+ tryCompare(menuItem0, "visible", true);
3187+ mouseClick(menuItem0);
3188+ tryCompare(priv, "currentItem", menuItem0);
3189+ tryCompare(priv.currentItem, "popupVisible", true);
3190+ }
29743191 }
29753192}