@@ -2520,27 +2520,44 @@ Rectangle {
2520 tryCompare(app2Surface, "keymap", "fr");
2520 tryCompare(app2Surface, "keymap", "fr");
2523+ function test_dragPanelToRestoreMaximizedWindow_data() {
2525+ { tag: "with mouse", mouse: true },
2526+ { tag: "with touch", mouse: false }
2523− function test_dragPanelToRestoreMaximizedWindow() {
2530+ function test_dragPanelToRestoreMaximizedWindow(data) {
2524 loadShell("desktop");
2531 loadShell("desktop");
2525 shell.usageScenario = "desktop";
2532 shell.usageScenario = "desktop";
2526 waitForRendering(shell);
2533 waitForRendering(shell);
2527 var panel = findChild(shell, "windowControlArea");
2534 var panel = findChild(shell, "windowControlArea");
2528 verify(panel);
2535 verify(panel);
2530− var appSurfaceId = topLevelSurfaceList.nextId;
2531− var app = ApplicationManager.startApplication("dialer-app")
2532− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2534 // start dialer, maximize it
2537 // start dialer, maximize it
2535− var appContainer = findChild(shell, "appContainer");
2538+ var appDelegate = startApplication("dialer-app");
2536− var appDelegate = findChild(appContainer, "appDelegate_" + appSurfaceId);
2537 verify(appDelegate);
2539 verify(appDelegate);
2538 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2541 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2539− mouseClick(maximizeButton);
2543+ mouseClick(maximizeButton);
2545+ tap(maximizeButton);
2548+ waitUntilTransitionsEnd(appDelegate);
2541 tryCompare(appDelegate, "state", "maximized");
2549 tryCompare(appDelegate, "state", "maximized");
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);
2543− mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2556+ mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2558+ touchFlick(panel, panel.width/2, panel.panelHeight/2, panel.width/2, shell.height/3);
2544 tryCompare(appDelegate, "state", "restored");
2561 tryCompare(appDelegate, "state", "restored");
@@ -2855,7 +2872,7 @@ Rectangle {
2855 loadShell(data.tag);
2872 loadShell(data.tag);
2857 var panel = findChild(shell, "panel"); verify(panel);
2874 var panel = findChild(shell, "panel"); verify(panel);
2858− var panelTitle = findChild(panel.applicationMenus, "panelTitle"); verify(panelTitle);
2875+ var panelTitle = findChild(panel, "panelTitle"); verify(panelTitle);
2859 compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
2876 compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
2861 swipeAwayGreeter();
2878 swipeAwayGreeter();
@@ -2920,6 +2937,86 @@ Rectangle {
2920 tryCompare(appDelegate, "state", "maximizedRight");
2937 tryCompare(appDelegate, "state", "maximizedRight");
2941+ function test_closeAppsInSpreadWithQ() {
2942+ loadShell("desktop");
2943+ shell.usageScenario = "desktop";
2944+ waitForRendering(shell);
2945+ swipeAwayGreeter();
2947+ var appSurfaceId = topLevelSurfaceList.nextId;
2948+ var app = ApplicationManager.startApplication("dialer-app")
2949+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2951+ appSurfaceId = topLevelSurfaceList.nextId;
2952+ app = ApplicationManager.startApplication("calendar-app")
2953+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2955+ keyPress(Qt.Key_Alt);
2956+ keyClick(Qt.Key_Tab);
2958+ var stage = findChild(shell, "stage");
2959+ var spread = findChild(stage, "spreadItem");
2960+ var appRepeater = findChild(stage, "appRepeater");
2962+ tryCompare(stage, "state", "spread");
2964+ tryCompare(ApplicationManager, "count", 3);
2965+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "dialer-app"}, true);
2967+ // Close one app with Q while in spread
2968+ keyClick(Qt.Key_Q);
2970+ tryCompare(ApplicationManager, "count", 2);
2972+ // Now the dash should be highlighted
2973+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "unity8-dash"}, true);
2975+ keyClick(Qt.Key_Q);
2977+ // Dash is not closeable, should still be 2
2978+ tryCompare(ApplicationManager, "count", 2);
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);
2985+ keyClick(Qt.Key_Q);
2986+ tryCompare(ApplicationManager, "count", 1);
2988+ keyRelease(Qt.Key_Alt);
2990+ // Now start the apps again
2991+ appSurfaceId = topLevelSurfaceList.nextId;
2992+ app = ApplicationManager.startApplication("dialer-app");
2993+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2995+ appSurfaceId = topLevelSurfaceList.nextId;
2996+ app = ApplicationManager.startApplication("calendar-app");
2997+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2999+ // First focus the dash so it'll be the leftmost in the spread
3000+ ApplicationManager.requestFocusApplication("unity8-dash");
3002+ keyPress(Qt.Key_Alt);
3003+ keyClick(Qt.Key_Tab);
3004+ tryCompare(stage, "state", "spread");
3006+ // Move to the last one
3007+ keyClick(Qt.Key_Tab);
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;
3013+ keyClick(Qt.Key_Q);
3014+ tryCompare(spread, "highlightedIndex", oldHighlighted - 1);
3016+ keyRelease(Qt.Key_Alt);
2923 function test_altTabToMinimizedApp() {
3020 function test_altTabToMinimizedApp() {
2924 loadShell("desktop");
3021 loadShell("desktop");
2925 shell.usageScenario = "desktop";
3022 shell.usageScenario = "desktop";
@@ -2948,6 +3045,61 @@ Rectangle {
2948 tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
3045 tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
3048+ function test_touchMenuPosition_data() {
3050+ { tag: "launcher locked", lockLauncher: true },
3051+ { tag: "launcher not locked", lockLauncher: false }
3055+ function test_touchMenuPosition(data) {
3056+ loadShell("desktop");
3057+ shell.usageScenario = "desktop";
3058+ waitForRendering(shell);
3059+ swipeAwayGreeter();
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);
3067+ compare(panel.applicationMenus.x, 0);
3071+ function test_touchMenuHidesOnLauncherAppDrawer_data() {
3073+ { tag: "launcher locked", lockLauncher: true },
3074+ { tag: "launcher not locked", lockLauncher: false }
3078+ function test_touchMenuHidesOnLauncherAppDrawer(data) {
3079+ loadShell("desktop");
3080+ shell.usageScenario = "desktop";
3081+ waitForRendering(shell);
3082+ swipeAwayGreeter();
3084+ var panel = findChild(shell, "panel");
3085+ var launcher = testCase.findChild(shell, "launcher");
3086+ launcher.lockedVisible = data.lockLauncher;
3088+ waitForRendering(panel.applicationMenus);
3090+ if (data.lockLauncher) {
3091+ panel.applicationMenus.show();
3092+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3093+ launcher.openDrawer();
3095+ tryCompare(launcher, "shown", false);
3096+ panel.applicationMenus.show();
3097+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3098+ launcher.switchToNextState("visible");
3100+ tryCompare(panel.applicationMenus, "fullyClosed", true);
2951 function test_doubleClickPanelRestoresWindow() {
3103 function test_doubleClickPanelRestoresWindow() {
2952 loadShell("desktop");
3104 loadShell("desktop");
2953 shell.usageScenario = "desktop";
3105 shell.usageScenario = "desktop";
@@ -2971,5 +3123,70 @@ Rectangle {
2971 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
3123 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
2972 tryCompare(appDelegate, "state", "restored");
3124 tryCompare(appDelegate, "state", "restored");
3127+ function test_noMenusWithActiveCall() {
3128+ loadShell("desktop");
3129+ shell.usageScenario = "desktop";
3130+ waitForRendering(shell);
3131+ swipeAwayGreeter();
3133+ // start music-app, maximize it
3134+ var appDelegate = startApplication("music-app")
3135+ verify(appDelegate);
3136+ appDelegate.requestMaximize();
3138+ // move the mouse over panel to reveal the menus
3139+ var panel = findChild(shell, "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);
3146+ // place a phone call
3147+ callManager.foregroundCall = phoneCall;
3149+ // menu bar should be hidden
3150+ tryCompare(menuBarLoader, "active", false);
3151+ tryCompare(menuBarLoader, "item", null);
3154+ callManager.foregroundCall = null;
3156+ // menu bar should be revealed
3157+ tryCompare(menuBarLoader, "active", true);
3158+ tryCompare(menuBarLoader.item, "visible", true);
3161+ function test_maximizedWindowAndMenuInPanel() {
3162+ loadShell("desktop");
3163+ shell.usageScenario = "desktop";
3164+ waitForRendering(shell);
3165+ swipeAwayGreeter();
3167+ // start music-app, maximize it
3168+ var appDelegate = startApplication("music-app")
3169+ verify(appDelegate);
3170+ appDelegate.requestMaximize();
3171+ tryCompare(appDelegate, "state", "maximized");
3173+ // move the mouse over panel to reveal the menus
3174+ var panel = findChild(shell, "panel");
3176+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3177+ var menuBar = findChild(panel, "menuBar");
3179+ tryCompare(menuBar, "visible", true);
3181+ // check that the menu popup appears
3182+ var priv = findInvisibleChild(menuBar, "d");
3183+ var menuItem0 = findChild(menuBar, "menuBar-item0");
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);