@@ -2536,27 +2536,44 @@ Rectangle {
2536 tryCompare(app2Surface, "keymap", "fr");
2536 tryCompare(app2Surface, "keymap", "fr");
2539+ function test_dragPanelToRestoreMaximizedWindow_data() {
2541+ { tag: "with mouse", mouse: true },
2542+ { tag: "with touch", mouse: false }
2539− function test_dragPanelToRestoreMaximizedWindow() {
2546+ function test_dragPanelToRestoreMaximizedWindow(data) {
2540 loadShell("desktop");
2547 loadShell("desktop");
2541 shell.usageScenario = "desktop";
2548 shell.usageScenario = "desktop";
2542 waitForRendering(shell);
2549 waitForRendering(shell);
2543 var panel = findChild(shell, "windowControlArea");
2550 var panel = findChild(shell, "windowControlArea");
2544 verify(panel);
2551 verify(panel);
2546− var appSurfaceId = topLevelSurfaceList.nextId;
2547− var app = ApplicationManager.startApplication("dialer-app")
2548− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2550 // start dialer, maximize it
2553 // start dialer, maximize it
2551− var appContainer = findChild(shell, "appContainer");
2554+ var appDelegate = startApplication("dialer-app");
2552− var appDelegate = findChild(appContainer, "appDelegate_" + appSurfaceId);
2553 verify(appDelegate);
2555 verify(appDelegate);
2554 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2557 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2555− mouseClick(maximizeButton);
2559+ mouseClick(maximizeButton);
2561+ tap(maximizeButton);
2564+ waitUntilTransitionsEnd(appDelegate);
2557 tryCompare(appDelegate, "state", "maximized");
2565 tryCompare(appDelegate, "state", "maximized");
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);
2559− mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2572+ mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2574+ touchFlick(panel, panel.width/2, panel.panelHeight/2, panel.width/2, shell.height/3);
2560 tryCompare(appDelegate, "state", "restored");
2577 tryCompare(appDelegate, "state", "restored");
@@ -2871,7 +2888,7 @@ Rectangle {
2871 loadShell(data.tag);
2888 loadShell(data.tag);
2873 var panel = findChild(shell, "panel"); verify(panel);
2890 var panel = findChild(shell, "panel"); verify(panel);
2874− var panelTitle = findChild(panel.applicationMenus, "panelTitle"); verify(panelTitle);
2891+ var panelTitle = findChild(panel, "panelTitle"); verify(panelTitle);
2875 compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
2892 compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
2877 swipeAwayGreeter();
2894 swipeAwayGreeter();
@@ -2936,6 +2953,86 @@ Rectangle {
2936 tryCompare(appDelegate, "state", "maximizedRight");
2953 tryCompare(appDelegate, "state", "maximizedRight");
2957+ function test_closeAppsInSpreadWithQ() {
2958+ loadShell("desktop");
2959+ shell.usageScenario = "desktop";
2960+ waitForRendering(shell);
2961+ swipeAwayGreeter();
2963+ var appSurfaceId = topLevelSurfaceList.nextId;
2964+ var app = ApplicationManager.startApplication("dialer-app")
2965+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2967+ appSurfaceId = topLevelSurfaceList.nextId;
2968+ app = ApplicationManager.startApplication("calendar-app")
2969+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2971+ keyPress(Qt.Key_Alt);
2972+ keyClick(Qt.Key_Tab);
2974+ var stage = findChild(shell, "stage");
2975+ var spread = findChild(stage, "spreadItem");
2976+ var appRepeater = findChild(stage, "appRepeater");
2978+ tryCompare(stage, "state", "spread");
2980+ tryCompare(ApplicationManager, "count", 3);
2981+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "dialer-app"}, true);
2983+ // Close one app with Q while in spread
2984+ keyClick(Qt.Key_Q);
2986+ tryCompare(ApplicationManager, "count", 2);
2988+ // Now the dash should be highlighted
2989+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "unity8-dash"}, true);
2991+ keyClick(Qt.Key_Q);
2993+ // Dash is not closeable, should still be 2
2994+ tryCompare(ApplicationManager, "count", 2);
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);
3001+ keyClick(Qt.Key_Q);
3002+ tryCompare(ApplicationManager, "count", 1);
3004+ keyRelease(Qt.Key_Alt);
3006+ // Now start the apps again
3007+ appSurfaceId = topLevelSurfaceList.nextId;
3008+ app = ApplicationManager.startApplication("dialer-app");
3009+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
3011+ appSurfaceId = topLevelSurfaceList.nextId;
3012+ app = ApplicationManager.startApplication("calendar-app");
3013+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
3015+ // First focus the dash so it'll be the leftmost in the spread
3016+ ApplicationManager.requestFocusApplication("unity8-dash");
3018+ keyPress(Qt.Key_Alt);
3019+ keyClick(Qt.Key_Tab);
3020+ tryCompare(stage, "state", "spread");
3022+ // Move to the last one
3023+ keyClick(Qt.Key_Tab);
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;
3029+ keyClick(Qt.Key_Q);
3030+ tryCompare(spread, "highlightedIndex", oldHighlighted - 1);
3032+ keyRelease(Qt.Key_Alt);
2939 function test_altTabToMinimizedApp() {
3036 function test_altTabToMinimizedApp() {
2940 loadShell("desktop");
3037 loadShell("desktop");
2941 shell.usageScenario = "desktop";
3038 shell.usageScenario = "desktop";
@@ -2964,6 +3061,61 @@ Rectangle {
2964 tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
3061 tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
3064+ function test_touchMenuPosition_data() {
3066+ { tag: "launcher locked", lockLauncher: true },
3067+ { tag: "launcher not locked", lockLauncher: false }
3071+ function test_touchMenuPosition(data) {
3072+ loadShell("desktop");
3073+ shell.usageScenario = "desktop";
3074+ waitForRendering(shell);
3075+ swipeAwayGreeter();
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);
3083+ compare(panel.applicationMenus.x, 0);
3087+ function test_touchMenuHidesOnLauncherAppDrawer_data() {
3089+ { tag: "launcher locked", lockLauncher: true },
3090+ { tag: "launcher not locked", lockLauncher: false }
3094+ function test_touchMenuHidesOnLauncherAppDrawer(data) {
3095+ loadShell("desktop");
3096+ shell.usageScenario = "desktop";
3097+ waitForRendering(shell);
3098+ swipeAwayGreeter();
3100+ var panel = findChild(shell, "panel");
3101+ var launcher = testCase.findChild(shell, "launcher");
3102+ launcher.lockedVisible = data.lockLauncher;
3104+ waitForRendering(panel.applicationMenus);
3106+ if (data.lockLauncher) {
3107+ panel.applicationMenus.show();
3108+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3109+ launcher.openDrawer();
3111+ tryCompare(launcher, "shown", false);
3112+ panel.applicationMenus.show();
3113+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3114+ launcher.switchToNextState("visible");
3116+ tryCompare(panel.applicationMenus, "fullyClosed", true);
2967 function test_doubleClickPanelRestoresWindow() {
3119 function test_doubleClickPanelRestoresWindow() {
2968 loadShell("desktop");
3120 loadShell("desktop");
2969 shell.usageScenario = "desktop";
3121 shell.usageScenario = "desktop";
@@ -2987,5 +3139,70 @@ Rectangle {
2987 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
3139 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
2988 tryCompare(appDelegate, "state", "restored");
3140 tryCompare(appDelegate, "state", "restored");
3143+ function test_noMenusWithActiveCall() {
3144+ loadShell("desktop");
3145+ shell.usageScenario = "desktop";
3146+ waitForRendering(shell);
3147+ swipeAwayGreeter();
3149+ // start music-app, maximize it
3150+ var appDelegate = startApplication("music-app")
3151+ verify(appDelegate);
3152+ appDelegate.requestMaximize();
3154+ // move the mouse over panel to reveal the menus
3155+ var panel = findChild(shell, "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);
3162+ // place a phone call
3163+ callManager.foregroundCall = phoneCall;
3165+ // menu bar should be hidden
3166+ tryCompare(menuBarLoader, "active", false);
3167+ tryCompare(menuBarLoader, "item", null);
3170+ callManager.foregroundCall = null;
3172+ // menu bar should be revealed
3173+ tryCompare(menuBarLoader, "active", true);
3174+ tryCompare(menuBarLoader.item, "visible", true);
3177+ function test_maximizedWindowAndMenuInPanel() {
3178+ loadShell("desktop");
3179+ shell.usageScenario = "desktop";
3180+ waitForRendering(shell);
3181+ swipeAwayGreeter();
3183+ // start music-app, maximize it
3184+ var appDelegate = startApplication("music-app")
3185+ verify(appDelegate);
3186+ appDelegate.requestMaximize();
3187+ tryCompare(appDelegate, "state", "maximized");
3189+ // move the mouse over panel to reveal the menus
3190+ var panel = findChild(shell, "panel");
3192+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3193+ var menuBar = findChild(panel, "menuBar");
3195+ tryCompare(menuBar, "visible", true);
3197+ // check that the menu popup appears
3198+ var priv = findInvisibleChild(menuBar, "d");
3199+ var menuItem0 = findChild(menuBar, "menuBar-item0");
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);