@@ -2513,27 +2513,44 @@ Rectangle {
2513 tryCompare(app2Surface, "keymap", "fr");
2513 tryCompare(app2Surface, "keymap", "fr");
2516+ function test_dragPanelToRestoreMaximizedWindow_data() {
2518+ { tag: "with mouse", mouse: true },
2519+ { tag: "with touch", mouse: false }
2516− function test_dragPanelToRestoreMaximizedWindow() {
2523+ function test_dragPanelToRestoreMaximizedWindow(data) {
2517 loadShell("desktop");
2524 loadShell("desktop");
2518 shell.usageScenario = "desktop";
2525 shell.usageScenario = "desktop";
2519 waitForRendering(shell);
2526 waitForRendering(shell);
2520 var panel = findChild(shell, "windowControlArea");
2527 var panel = findChild(shell, "windowControlArea");
2521 verify(panel);
2528 verify(panel);
2523− var appSurfaceId = topLevelSurfaceList.nextId;
2524− var app = ApplicationManager.startApplication("dialer-app")
2525− waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2527 // start dialer, maximize it
2530 // start dialer, maximize it
2528− var appContainer = findChild(shell, "appContainer");
2531+ var appDelegate = startApplication("dialer-app");
2529− var appDelegate = findChild(appContainer, "appDelegate_" + appSurfaceId);
2530 verify(appDelegate);
2532 verify(appDelegate);
2531 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2534 var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
2532− mouseClick(maximizeButton);
2536+ mouseClick(maximizeButton);
2538+ tap(maximizeButton);
2541+ waitUntilTransitionsEnd(appDelegate);
2534 tryCompare(appDelegate, "state", "maximized");
2542 tryCompare(appDelegate, "state", "maximized");
2545+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
2546+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
2547+ verify(menuBarLoader);
2548+ tryCompare(menuBarLoader.item, "visible", true);
2536− mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2549+ mouseDrag(panel, panel.width/2, panel.height/2, 0, shell.height/3, Qt.LeftButton, Qt.NoModifier, 500);
2551+ touchFlick(panel, panel.width/2, panel.panelHeight/2, panel.width/2, shell.height/3);
2537 tryCompare(appDelegate, "state", "restored");
2554 tryCompare(appDelegate, "state", "restored");
@@ -2848,7 +2865,7 @@ Rectangle {
2848 loadShell(data.tag);
2865 loadShell(data.tag);
2850 var panel = findChild(shell, "panel"); verify(panel);
2867 var panel = findChild(shell, "panel"); verify(panel);
2851− var panelTitle = findChild(panel.applicationMenus, "panelTitle"); verify(panelTitle);
2868+ var panelTitle = findChild(panel, "panelTitle"); verify(panelTitle);
2852 compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
2869 compare(panelTitle.visible, false, "Panel title should not be visible when greeter is shown");
2854 swipeAwayGreeter();
2871 swipeAwayGreeter();
@@ -2913,6 +2930,86 @@ Rectangle {
2913 tryCompare(appDelegate, "state", "maximizedRight");
2930 tryCompare(appDelegate, "state", "maximizedRight");
2934+ function test_closeAppsInSpreadWithQ() {
2935+ loadShell("desktop");
2936+ shell.usageScenario = "desktop";
2937+ waitForRendering(shell);
2938+ swipeAwayGreeter();
2940+ var appSurfaceId = topLevelSurfaceList.nextId;
2941+ var app = ApplicationManager.startApplication("dialer-app")
2942+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2944+ appSurfaceId = topLevelSurfaceList.nextId;
2945+ app = ApplicationManager.startApplication("calendar-app")
2946+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2948+ keyPress(Qt.Key_Alt);
2949+ keyClick(Qt.Key_Tab);
2951+ var stage = findChild(shell, "stage");
2952+ var spread = findChild(stage, "spreadItem");
2953+ var appRepeater = findChild(stage, "appRepeater");
2955+ tryCompare(stage, "state", "spread");
2957+ tryCompare(ApplicationManager, "count", 3);
2958+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "dialer-app"}, true);
2960+ // Close one app with Q while in spread
2961+ keyClick(Qt.Key_Q);
2963+ tryCompare(ApplicationManager, "count", 2);
2965+ // Now the dash should be highlighted
2966+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "unity8-dash"}, true);
2968+ keyClick(Qt.Key_Q);
2970+ // Dash is not closeable, should still be 2
2971+ tryCompare(ApplicationManager, "count", 2);
2973+ // Move to the next one, should be closable again
2974+ keyClick(Qt.Key_Tab);
2975+ tryCompareFunction(function() {return appRepeater.itemAt(spread.highlightedIndex).appId == "calendar-app"}, true);
2978+ keyClick(Qt.Key_Q);
2979+ tryCompare(ApplicationManager, "count", 1);
2981+ keyRelease(Qt.Key_Alt);
2983+ // Now start the apps again
2984+ appSurfaceId = topLevelSurfaceList.nextId;
2985+ app = ApplicationManager.startApplication("dialer-app");
2986+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2988+ appSurfaceId = topLevelSurfaceList.nextId;
2989+ app = ApplicationManager.startApplication("calendar-app");
2990+ waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2992+ // First focus the dash so it'll be the leftmost in the spread
2993+ ApplicationManager.requestFocusApplication("unity8-dash");
2995+ keyPress(Qt.Key_Alt);
2996+ keyClick(Qt.Key_Tab);
2997+ tryCompare(stage, "state", "spread");
2999+ // Move to the last one
3000+ keyClick(Qt.Key_Tab);
3002+ // Close the last one, make sure the highlight fixes itself to stick within the list
3003+ tryCompare(spread, "highlightedIndex", ApplicationManager.count - 1);
3004+ var oldHighlighted = spread.highlightedIndex;
3006+ keyClick(Qt.Key_Q);
3007+ tryCompare(spread, "highlightedIndex", oldHighlighted - 1);
3009+ keyRelease(Qt.Key_Alt);
2916 function test_altTabToMinimizedApp() {
3013 function test_altTabToMinimizedApp() {
2917 loadShell("desktop");
3014 loadShell("desktop");
2918 shell.usageScenario = "desktop";
3015 shell.usageScenario = "desktop";
@@ -2941,6 +3038,61 @@ Rectangle {
2941 tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
3038 tryCompare(topLevelSurfaceList.applicationAt(0), "appId", "dialer-app");
3041+ function test_touchMenuPosition_data() {
3043+ { tag: "launcher locked", lockLauncher: true },
3044+ { tag: "launcher not locked", lockLauncher: false }
3048+ function test_touchMenuPosition(data) {
3049+ loadShell("desktop");
3050+ shell.usageScenario = "desktop";
3051+ waitForRendering(shell);
3052+ swipeAwayGreeter();
3054+ var panel = findChild(shell, "panel");
3055+ var launcher = testCase.findChild(shell, "launcher");
3056+ launcher.lockedVisible = data.lockLauncher;
3057+ if (data.lockLauncher) {
3058+ compare(panel.applicationMenus.x, launcher.panelWidth);
3060+ compare(panel.applicationMenus.x, 0);
3064+ function test_touchMenuHidesOnLauncherAppDrawer_data() {
3066+ { tag: "launcher locked", lockLauncher: true },
3067+ { tag: "launcher not locked", lockLauncher: false }
3071+ function test_touchMenuHidesOnLauncherAppDrawer(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;
3081+ waitForRendering(panel.applicationMenus);
3083+ if (data.lockLauncher) {
3084+ panel.applicationMenus.show();
3085+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3086+ launcher.openDrawer();
3088+ tryCompare(launcher, "shown", false);
3089+ panel.applicationMenus.show();
3090+ tryCompare(panel.applicationMenus, "fullyOpened", true);
3091+ launcher.switchToNextState("visible");
3093+ tryCompare(panel.applicationMenus, "fullyClosed", true);
2944 function test_doubleClickPanelRestoresWindow() {
3096 function test_doubleClickPanelRestoresWindow() {
2945 loadShell("desktop");
3097 loadShell("desktop");
2946 shell.usageScenario = "desktop";
3098 shell.usageScenario = "desktop";
@@ -2964,5 +3116,70 @@ Rectangle {
2964 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
3116 mouseDoubleClickSequence(panel, panel.width/2, PanelState.panelHeight/2, Qt.LeftButton, Qt.NoModifier, 300);
2965 tryCompare(appDelegate, "state", "restored");
3117 tryCompare(appDelegate, "state", "restored");
3120+ function test_noMenusWithActiveCall() {
3121+ loadShell("desktop");
3122+ shell.usageScenario = "desktop";
3123+ waitForRendering(shell);
3124+ swipeAwayGreeter();
3126+ // start music-app, maximize it
3127+ var appDelegate = startApplication("music-app")
3128+ verify(appDelegate);
3129+ appDelegate.requestMaximize();
3131+ // move the mouse over panel to reveal the menus
3132+ var panel = findChild(shell, "panel");
3134+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3135+ var menuBarLoader = findInvisibleChild(panel, "menuBarLoader");
3136+ verify(menuBarLoader);
3137+ tryCompare(menuBarLoader.item, "visible", true);
3139+ // place a phone call
3140+ callManager.foregroundCall = phoneCall;
3142+ // menu bar should be hidden
3143+ tryCompare(menuBarLoader, "active", false);
3144+ tryCompare(menuBarLoader, "item", null);
3147+ callManager.foregroundCall = null;
3149+ // menu bar should be revealed
3150+ tryCompare(menuBarLoader, "active", true);
3151+ tryCompare(menuBarLoader.item, "visible", true);
3154+ function test_maximizedWindowAndMenuInPanel() {
3155+ loadShell("desktop");
3156+ shell.usageScenario = "desktop";
3157+ waitForRendering(shell);
3158+ swipeAwayGreeter();
3160+ // start music-app, maximize it
3161+ var appDelegate = startApplication("music-app")
3162+ verify(appDelegate);
3163+ appDelegate.requestMaximize();
3164+ tryCompare(appDelegate, "state", "maximized");
3166+ // move the mouse over panel to reveal the menus
3167+ var panel = findChild(shell, "panel");
3169+ mouseMove(panel, panel.width/2, panel.panelHeight/2); // to reveal the menus
3170+ var menuBar = findChild(panel, "menuBar");
3172+ tryCompare(menuBar, "visible", true);
3174+ // check that the menu popup appears
3175+ var priv = findInvisibleChild(menuBar, "d");
3176+ var menuItem0 = findChild(menuBar, "menuBar-item0");
3178+ mouseMove(menuItem0, menuItem0.width/2, menuItem0.height/2, 200);
3179+ tryCompare(menuItem0, "visible", true);
3180+ mouseClick(menuItem0);
3181+ tryCompare(priv, "currentItem", menuItem0);
3182+ tryCompare(priv.currentItem, "popupVisible", true);