@@ -2532,27 +2532,44 @@ Rectangle {
25322532 tryCompare(app2Surface, "keymap", "fr");
25332533 }
25342534
2535− function test_dragPanelToRestoreMaximizedWindow() {
2535+ function test_dragPanelToRestoreMaximizedWindow_data() {
2536+ return [
2537+ { tag: "with mouse", mouse: true },
2538+ { tag: "with touch", mouse: false }
2539+ ]
2540+ }
2541+
2542+ function test_dragPanelToRestoreMaximizedWindow(data) {
25362543 loadShell("desktop");
25372544 shell.usageScenario = "desktop";
25382545 waitForRendering(shell);
25392546 var panel = findChild(shell, "windowControlArea");
25402547 verify(panel);
25412548
2542− var appSurfaceId = topLevelSurfaceList.nextId;
2543− var app = ApplicationManager.startApplication("dialer-app")
2544− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2545−
25462549 // start dialer, maximize it
2547− var appContainer = findChild(shell, "appContainer");
2548− var appDelegate = findChild(appContainer, "appDelegate_" + appSurfaceId);
2550+ var appDelegate = startApplication("dialer-app");
25492551 verify(appDelegate);
2552+
25502553 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2551− mouseClick(maximizeButton);
2554+ if (data.mouse) {
2555+ mouseClick(maximizeButton);
2556+ } else {
2557+ tap(maximizeButton);
2558+ }
25522559
2560+ waitUntilTransitionsEnd(appDelegate);
25532561 tryCompare(appDelegate, "state", "maximized");
25542562
2555− mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2563+ if (data.mouse) {
2564+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
2565+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
2566+ verify(menuBarLoader);
2567+ tryCompare(menuBarLoader.item, "visible", true);
2568+ mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2569+ } else {
2570+ touchFlick(panel, panel.width/2, panel.panelHeight/2, panel.width/2, shell.height/3);
2571+ }
2572+
25562573 tryCompare(appDelegate, "state", "restored");
25572574 }
25582575
@@ -2867,7 +2884,7 @@ Rectangle {
28672884 loadShell(data.tag);
28682885
28692886 var panel = findChild(shell, "panel"); verify(panel);
2870− var panelTitle = findChild(panel.applicationMenus, "panelTitle"); verify(panelTitle);
2887+ var panelTitle = findChild(panel, "panelTitle"); verify(panelTitle);
28712888 compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
28722889
28732890 swipeAwayGreeter();
@@ -2932,6 +2949,86 @@ Rectangle {
29322949 tryCompare(appDelegate, "state", "maximizedRight");
29332950 }
29342951
2952+
2953+ function test_closeAppsInSpreadWithQ() {
2954+ loadShell("desktop");
2955+ shell.usageScenario = "desktop";
2956+ waitForRendering(shell);
2957+ swipeAwayGreeter();
2958+
2959+ var appSurfaceId = topLevelSurfaceList.nextId;
2960+ var app = ApplicationManager.startApplication("dialer-app")
2961+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2962+
2963+ appSurfaceId = topLevelSurfaceList.nextId;
2964+ app = ApplicationManager.startApplication("calendar-app")
2965+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2966+
2967+ keyPress(Qt.Key_Alt);
2968+ keyClick(Qt.Key_Tab);
2969+
2970+ var stage = findChild(shell, "stage");
2971+ var spread = findChild(stage, "spreadItem");
2972+ var appRepeater = findChild(stage, "appRepeater");
2973+
2974+ tryCompare(stage, "state", "spread");
2975+
2976+ tryCompare(ApplicationManager, "count", 3);
2977+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "dialer-app"}, true);
2978+
2979+ // Close one app with Q while in spread
2980+ keyClick(Qt.Key_Q);
2981+
2982+ tryCompare(ApplicationManager, "count", 2);
2983+
2984+ // Now the dash should be highlighted
2985+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "unity8-dash"}, true);
2986+
2987+ keyClick(Qt.Key_Q);
2988+
2989+ // Dash is not closeable, should still be 2
2990+ tryCompare(ApplicationManager, "count", 2);
2991+
2992+ // Move to the next one, should be closable again
2993+ keyClick(Qt.Key_Tab);
2994+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "calendar-app"}, true);
2995+
2996+ // close it
2997+ keyClick(Qt.Key_Q);
2998+ tryCompare(ApplicationManager, "count", 1);
2999+
3000+ keyRelease(Qt.Key_Alt);
3001+
3002+ // Now start the apps again
3003+ appSurfaceId = topLevelSurfaceList.nextId;
3004+ app = ApplicationManager.startApplication("dialer-app");
3005+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
3006+
3007+ appSurfaceId = topLevelSurfaceList.nextId;
3008+ app = ApplicationManager.startApplication("calendar-app");
3009+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
3010+
3011+ // First focus the dash so it'll be the leftmost in the spread
3012+ ApplicationManager.requestFocusApplication("unity8-dash");
3013+
3014+ keyPress(Qt.Key_Alt);
3015+ keyClick(Qt.Key_Tab);
3016+ tryCompare(stage, "state", "spread");
3017+
3018+ // Move to the last one
3019+ keyClick(Qt.Key_Tab);
3020+
3021+ // Close the last one, make sure the highlight fixes itself to stick within the list
3022+ tryCompare(spread, "highlightedIndex", ApplicationManager.count - 1);
3023+ var oldHighlighted = spread.highlightedIndex;
3024+
3025+ keyClick(Qt.Key_Q);
3026+ tryCompare(spread, "highlightedIndex", oldHighlighted - 1);
3027+
3028+ keyRelease(Qt.Key_Alt);
3029+
3030+ }
3031+
29353032 function test_altTabToMinimizedApp() {
29363033 loadShell("desktop");
29373034 shell.usageScenario = "desktop";
@@ -2960,6 +3057,61 @@ Rectangle {
29603057 tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
29613058 }
29623059
3060+ function test_touchMenuPosition_data() {
3061+ return [
3062+ { tag: "launcher locked", lockLauncher: true },
3063+ { tag: "launcher not locked", lockLauncher: false }
3064+ ];
3065+ }
3066+
3067+ function test_touchMenuPosition(data) {
3068+ loadShell("desktop");
3069+ shell.usageScenario = "desktop";
3070+ waitForRendering(shell);
3071+ swipeAwayGreeter();
3072+
3073+ var panel = findChild(shell, "panel");
3074+ var launcher = testCase.findChild(shell, "launcher");
3075+ launcher.lockedVisible = data.lockLauncher;
3076+ if (data.lockLauncher) {
3077+ compare(panel.applicationMenus.x, launcher.panelWidth);
3078+ } else {
3079+ compare(panel.applicationMenus.x, 0);
3080+ }
3081+ }
3082+
3083+ function test_touchMenuHidesOnLauncherAppDrawer_data() {
3084+ return [
3085+ { tag: "launcher locked", lockLauncher: true },
3086+ { tag: "launcher not locked", lockLauncher: false }
3087+ ];
3088+ }
3089+
3090+ function test_touchMenuHidesOnLauncherAppDrawer(data) {
3091+ loadShell("desktop");
3092+ shell.usageScenario = "desktop";
3093+ waitForRendering(shell);
3094+ swipeAwayGreeter();
3095+
3096+ var panel = findChild(shell, "panel");
3097+ var launcher = testCase.findChild(shell, "launcher");
3098+ launcher.lockedVisible = data.lockLauncher;
3099+
3100+ waitForRendering(panel.applicationMenus);
3101+
3102+ if (data.lockLauncher) {
3103+ panel.applicationMenus.show();
3104+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3105+ launcher.openDrawer();
3106+ } else {
3107+ tryCompare(launcher, "shown", false);
3108+ panel.applicationMenus.show();
3109+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3110+ launcher.switchToNextState("visible");
3111+ }
3112+ tryCompare(panel.applicationMenus, "fullyClosed", true);
3113+ }
3114+
29633115 function test_doubleClickPanelRestoresWindow() {
29643116 loadShell("desktop");
29653117 shell.usageScenario = "desktop";
@@ -2983,5 +3135,70 @@ Rectangle {
29833135 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
29843136 tryCompare(appDelegate, "state", "restored");
29853137 }
3138+
3139+ function test_noMenusWithActiveCall() {
3140+ loadShell("desktop");
3141+ shell.usageScenario = "desktop";
3142+ waitForRendering(shell);
3143+ swipeAwayGreeter();
3144+
3145+ // start music-app, maximize it
3146+ var appDelegate = startApplication("music-app")
3147+ verify(appDelegate);
3148+ appDelegate.requestMaximize();
3149+
3150+ // move the mouse over panel to reveal the menus
3151+ var panel = findChild(shell, "panel");
3152+ verify(panel);
3153+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3154+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
3155+ verify(menuBarLoader);
3156+ tryCompare(menuBarLoader.item, "visible", true);
3157+
3158+ // place a phone call
3159+ callManager.foregroundCall = phoneCall;
3160+
3161+ // menu bar should be hidden
3162+ tryCompare(menuBarLoader, "active", false);
3163+ tryCompare(menuBarLoader, "item", null);
3164+
3165+ // remove call
3166+ callManager.foregroundCall = null;
3167+
3168+ // menu bar should be revealed
3169+ tryCompare(menuBarLoader, "active", true);
3170+ tryCompare(menuBarLoader.item, "visible", true);
3171+ }
3172+
3173+ function test_maximizedWindowAndMenuInPanel() {
3174+ loadShell("desktop");
3175+ shell.usageScenario = "desktop";
3176+ waitForRendering(shell);
3177+ swipeAwayGreeter();
3178+
3179+ // start music-app, maximize it
3180+ var appDelegate = startApplication("music-app")
3181+ verify(appDelegate);
3182+ appDelegate.requestMaximize();
3183+ tryCompare(appDelegate, "state", "maximized");
3184+
3185+ // move the mouse over panel to reveal the menus
3186+ var panel = findChild(shell, "panel");
3187+ verify(panel);
3188+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3189+ var menuBar = findChild(panel, "menuBar");
3190+ verify(menuBar);
3191+ tryCompare(menuBar, "visible", true);
3192+
3193+ // check that the menu popup appears
3194+ var priv = findInvisibleChild(menuBar, "d");
3195+ var menuItem0 = findChild(menuBar, "menuBar-item0");
3196+ verify(menuItem0);
3197+ mouseMove(menuItem0, menuItem0.width/2, menuItem0.height/2, 200);
3198+ tryCompare(menuItem0, "visible", true);
3199+ mouseClick(menuItem0);
3200+ tryCompare(priv, "currentItem", menuItem0);
3201+ tryCompare(priv.currentItem, "popupVisible", true);
3202+ }
29863203 }
29873204}