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