@@ -26,6 +26,7 @@ import Unity.Application 0.1
2626import Unity.Connectivity 0.1
2727import Unity.Indicators 0.1
2828import Unity.Notifications 1.0
29+import Unity.Launcher 0.1
2930import Unity.Test 0.1
3031import Powerd 0.1
3132import Wizard 0.1 as Wizard
@@ -121,10 +122,6 @@ Rectangle {
121122 Component.onDestruction: {
122123 shellLoader.itemDestroyed = true;
123124 }
124− Component.onCompleted: {
125− var keyMapper = testCase.findChild(__shell, "physicalKeysMapper");
126− keyMapper.controlInsteadOfAlt = true;
127− }
128125 }
129126 }
130127 }
@@ -213,6 +210,31 @@ Rectangle {
213210 checked: true
214211 color: "white"
215212 }
213+ ListItem.ItemSelector {
214+ id: ctrlModifier
215+ anchors { left: parent.left; right: parent.right }
216+ activeFocusOnPress: false
217+ text: "Ctrl key as"
218+ model: ["Ctrl", "Alt", "Super"]
219+ onSelectedIndexChanged: {
220+ var keyMapper = testCase.findChild(shellContainer, "physicalKeysMapper");
221+ keyMapper.controlInsteadOfAlt = selectedIndex == 1;
222+ keyMapper.controlInsteadOfSuper = selectedIndex == 2;
223+ }
224+ }
225+
226+ Row {
227+ anchors { left: parent.left; right: parent.right }
228+ CheckBox {
229+ id: autohideLauncherCheckbox
230+ onCheckedChanged: {
231+ GSettingsController.setAutohideLauncher(checked)
232+ }
233+ }
234+ Label {
235+ text: "Autohide launcher"
236+ }
237+ }
216238
217239 Label { text: "Applications"; font.bold: true }
218240
@@ -912,6 +934,7 @@ Rectangle {
912934 function dragLauncherIntoView() {
913935 var launcher = findChild(shell, "launcher");
914936 var launcherPanel = findChild(launcher, "launcherPanel");
937+ waitForRendering(launcher);
915938 verify(launcherPanel.x = - launcherPanel.width);
916939
917940 var touchStartX = 2;
@@ -1441,7 +1464,7 @@ Rectangle {
14411464
14421465 // Do a quick alt-tab and see if focus changes
14431466 tryCompare(app3.session.lastSurface, "activeFocus", true)
1444− keyClick(Qt.Key_Tab, Qt.ControlModifier)
1467+ keyClick(Qt.Key_Tab, Qt.AltModifier)
14451468 tryCompare(app2.session.lastSurface, "activeFocus", true)
14461469
14471470 var desktopSpread = findChild(shell, "spread")
@@ -1449,12 +1472,12 @@ Rectangle {
14491472 tryCompare(desktopSpread, "state", "")
14501473
14511474 // Just press Alt, make sure the spread comes up
1452− keyPress(Qt.Key_Control);
1475+ keyPress(Qt.Key_Alt);
14531476 keyClick(Qt.Key_Tab);
14541477 tryCompare(desktopSpread, "state", "altTab")
14551478
14561479 // Release control, check if spread disappears
1457− keyRelease(Qt.Key_Control)
1480+ keyRelease(Qt.Key_Alt)
14581481 tryCompare(desktopSpread, "state", "")
14591482
14601483 // Focus should have switched back now
@@ -1482,7 +1505,7 @@ Rectangle {
14821505 tryCompare(desktopSpread, "state", "")
14831506
14841507 // Just press Alt, make sure the spread comes up
1485− keyPress(Qt.Key_Control);
1508+ keyPress(Qt.Key_Alt);
14861509 keyClick(Qt.Key_Tab);
14871510 tryCompare(desktopSpread, "state", "altTab")
14881511 tryCompare(spreadRepeater, "highlightedIndex", 1)
@@ -1503,7 +1526,7 @@ Rectangle {
15031526 tryCompare(spreadRepeater, "highlightedIndex", 0)
15041527
15051528 // Release control, check if spread disappears
1506− keyRelease(Qt.Key_Control)
1529+ keyRelease(Qt.Key_Alt)
15071530 tryCompare(desktopSpread, "state", "")
15081531
15091532 // Make sure that after wrapping around once, we have the same one focused as at the beginning
@@ -1516,7 +1539,7 @@ Rectangle {
15161539 var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
15171540 verify(spreadRepeater !== null);
15181541
1519− keyPress(Qt.Key_Control)
1542+ keyPress(Qt.Key_Alt)
15201543 keyClick(Qt.Key_Tab);
15211544 tryCompare(spreadRepeater, "highlightedIndex", 1);
15221545
@@ -1538,7 +1561,7 @@ Rectangle {
15381561 keyClick(Qt.Key_Backtab);
15391562 tryCompare(spreadRepeater, "highlightedIndex", 1);
15401563
1541− keyRelease(Qt.Key_Control);
1564+ keyRelease(Qt.Key_Alt);
15421565 }
15431566
15441567 function test_highlightFollowsMouse() {
@@ -1547,7 +1570,7 @@ Rectangle {
15471570 var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
15481571 verify(spreadRepeater !== null);
15491572
1550− keyPress(Qt.Key_Control)
1573+ keyPress(Qt.Key_Alt)
15511574 keyClick(Qt.Key_Tab);
15521575
15531576 tryCompare(spreadRepeater, "highlightedIndex", 1);
@@ -1566,7 +1589,7 @@ Rectangle {
15661589
15671590 verify(y < 4000);
15681591
1569− keyRelease(Qt.Key_Control);
1592+ keyRelease(Qt.Key_Alt);
15701593 }
15711594
15721595 function test_closeFromSpread() {
@@ -1575,7 +1598,7 @@ Rectangle {
15751598 var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
15761599 verify(spreadRepeater !== null);
15771600
1578− keyPress(Qt.Key_Control)
1601+ keyPress(Qt.Key_Alt)
15791602 keyClick(Qt.Key_Tab);
15801603
15811604 appRemovedSpy.clear();
@@ -1602,7 +1625,7 @@ Rectangle {
16021625 tryCompare(appRemovedSpy, "count", 1)
16031626 compare(appRemovedSpy.signalArguments[0][0], closedAppId);
16041627
1605− keyRelease(Qt.Key_Control);
1628+ keyRelease(Qt.Key_Alt);
16061629 }
16071630
16081631 function test_selectFromSpreadWithMouse_data() {
@@ -1622,7 +1645,7 @@ Rectangle {
16221645 var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
16231646 verify(spreadRepeater !== null);
16241647
1625− keyPress(Qt.Key_Control)
1648+ keyPress(Qt.Key_Alt)
16261649 keyClick(Qt.Key_Tab);
16271650
16281651 var focusAppId = ApplicationManager.get(2).appId;
@@ -1649,7 +1672,7 @@ Rectangle {
16491672 tryCompare(stage, "state", "");
16501673 tryCompare(ApplicationManager, "focusedApplicationId", focusAppId);
16511674
1652− keyRelease(Qt.Key_Control);
1675+ keyRelease(Qt.Key_Alt);
16531676 }
16541677
16551678 function test_progressiveAutoScrolling() {
@@ -1658,7 +1681,7 @@ Rectangle {
16581681 var appRepeater = findInvisibleChild(shell, "appRepeater");
16591682 verify(appRepeater !== null);
16601683
1661− keyPress(Qt.Key_Control)
1684+ keyPress(Qt.Key_Alt)
16621685 keyClick(Qt.Key_Tab);
16631686
16641687 var spreadFlickable = findChild(shell, "spreadFlickable")
@@ -1669,7 +1692,7 @@ Rectangle {
16691692 var x = 0;
16701693 var y = shell.height * .5
16711694 mouseMove(shell, x, y)
1672− while (x <= spreadFlickable.width) {
1695+ while (x <= shell.width) {
16731696 x+=10;
16741697 mouseMove(shell, x, y)
16751698 wait(0); // spin the loop so bindings get evaluated
@@ -1684,7 +1707,7 @@ Rectangle {
16841707 }
16851708 tryCompare(spreadFlickable, "contentX", 0);
16861709
1687− keyRelease(Qt.Key_Control);
1710+ keyRelease(Qt.Key_Alt);
16881711 }
16891712
16901713 // This makes sure the hoverMouseArea is set to invisible AND disabled
@@ -1696,13 +1719,13 @@ Rectangle {
16961719 tryCompare(hoverMouseArea, "enabled", false)
16971720 tryCompare(hoverMouseArea, "visible", false)
16981721
1699− keyPress(Qt.Key_Control)
1722+ keyPress(Qt.Key_Alt)
17001723 keyClick(Qt.Key_Tab);
17011724
17021725 tryCompare(hoverMouseArea, "enabled", true)
17031726 tryCompare(hoverMouseArea, "visible", true)
17041727
1705− keyRelease(Qt.Key_Control)
1728+ keyRelease(Qt.Key_Alt)
17061729
17071730 tryCompare(hoverMouseArea, "enabled", false)
17081731 tryCompare(hoverMouseArea, "visible", false)
@@ -1719,7 +1742,7 @@ Rectangle {
17191742 var appRepeater = findInvisibleChild(shell, "appRepeater");
17201743 verify(appRepeater !== null);
17211744
1722− keyPress(Qt.Key_Control)
1745+ keyPress(Qt.Key_Alt)
17231746 keyClick(Qt.Key_Tab);
17241747
17251748 tryCompare(spreadRepeater, "highlightedIndex", 1);
@@ -1740,33 +1763,46 @@ Rectangle {
17401763
17411764 verify(y < 4000);
17421765
1743− keyRelease(Qt.Key_Control);
1766+ keyRelease(Qt.Key_Alt);
17441767 }
17451768
1746− function test_focusAppFromLauncherExitsSpread() {
1747− loadDesktopShellWithApps()
1769+ function test_focusAppFromLauncherExitsSpread_data() {
1770+ return [
1771+ {tag: "autohide launcher", launcherLocked: false },
1772+ {tag: "locked launcher", launcherLocked: true }
1773+ ]
1774+ }
17481775
1749− var desktopSpread = findChild(shell, "spread");
1776+ function test_focusAppFromLauncherExitsSpread(data) {
1777+ loadDesktopShellWithApps()
17501778 var launcher = findChild(shell, "launcher");
1779+ var desktopSpread = findChild(shell, "spread");
17511780 var bfb = findChild(launcher, "buttonShowDashHome");
17521781
1753− keyPress(Qt.Key_Control)
1782+ GSettingsController.setAutohideLauncher(!data.launcherLocked);
1783+ waitForRendering(shell);
1784+
1785+ keyPress(Qt.Key_Alt)
17541786 keyClick(Qt.Key_Tab);
17551787
17561788 tryCompare(desktopSpread, "state", "altTab")
17571789
1758− revealLauncherByEdgePushWithMouse();
1759− tryCompare(launcher, "x", 0);
1760− mouseMove(bfb, bfb.width / 2, bfb.height / 2)
1761− waitForRendering(shell)
1790+ if (!data.launcherLocked) {
1791+ revealLauncherByEdgePushWithMouse();
1792+ tryCompare(launcher, "x", 0);
1793+ mouseMove(bfb, bfb.width / 2, bfb.height / 2)
1794+ waitForRendering(shell)
1795+ }
17621796
17631797 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
1764− tryCompare(launcher, "state", "")
1798+ if (!data.launcherLocked) {
1799+ tryCompare(launcher, "state", "")
1800+ }
17651801 tryCompare(desktopSpread, "state", "")
17661802
17671803 tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash")
17681804
1769− keyRelease(Qt.Key_Control);
1805+ keyRelease(Qt.Key_Alt);
17701806 }
17711807
17721808 // regression test for http://pad.lv/1443319
@@ -1989,6 +2025,138 @@ Rectangle {
19892025 }
19902026 }
19912027
2028+ function test_superTabToCycleLauncher_data() {
2029+ return [
2030+ {tag: "autohide launcher", launcherLocked: false},
2031+ {tag: "locked launcher", launcherLocked: true}
2032+ ]
2033+ }
2034+
2035+ function test_superTabToCycleLauncher(data) {
2036+ loadShell("desktop");
2037+ shell.usageScenario = "desktop";
2038+ GSettingsController.setAutohideLauncher(!data.launcherLocked);
2039+ waitForRendering(shell);
2040+
2041+ var launcher = findChild(shell, "launcher");
2042+ var launcherPanel = findChild(launcher, "launcherPanel");
2043+ var firstAppInLauncher = LauncherModel.get(0).appId;
2044+
2045+ compare(launcher.state, data.launcherLocked ? "visible": "");
2046+ compare(launcherPanel.highlightIndex, -2);
2047+ compare(ApplicationManager.focusedApplicationId, "unity8-dash");
2048+
2049+ // Use Super + Tab Tab to cycle to the first entry in the launcher
2050+ keyPress(Qt.Key_Super_L, Qt.MetaModifier);
2051+ keyClick(Qt.Key_Tab);
2052+ tryCompare(launcher, "state", "visible");
2053+ tryCompare(launcherPanel, "highlightIndex", -1);
2054+ keyClick(Qt.Key_Tab);
2055+ tryCompare(launcherPanel, "highlightIndex", 0);
2056+ keyRelease(Qt.Key_Super_L, Qt.MetaModifier);
2057+ tryCompare(launcher, "state", data.launcherLocked ? "visible" : "");
2058+ tryCompare(launcherPanel, "highlightIndex", -2);
2059+ tryCompare(ApplicationManager, "focusedApplicationId", firstAppInLauncher);
2060+
2061+ // Now go back to the dash
2062+ keyPress(Qt.Key_Super_L, Qt.MetaModifier);
2063+ keyClick(Qt.Key_Tab);
2064+ tryCompare(launcher, "state", "visible");
2065+ tryCompare(launcherPanel, "highlightIndex", -1);
2066+ keyRelease(Qt.Key_Super_L, Qt.MetaModifier);
2067+ tryCompare(launcher, "state", data.launcherLocked ? "visible" : "");
2068+ tryCompare(launcherPanel, "highlightIndex", -2);
2069+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
2070+ }
2071+
2072+ function test_longpressSuperOpensLauncher() {
2073+ loadShell("desktop");
2074+ var launcher = findChild(shell, "launcher");
2075+ var shortcutHint = findChild(findChild(launcher, "launcherDelegate0"), "shortcutHint")
2076+
2077+ compare(launcher.state, "");
2078+ keyPress(Qt.Key_Super_L, Qt.MetaModifier);
2079+ tryCompare(launcher, "state", "visible");
2080+ tryCompare(shortcutHint, "visible", true);
2081+
2082+ keyRelease(Qt.Key_Super_L, Qt.MetaModifier);
2083+ tryCompare(launcher, "state", "");
2084+ tryCompare(shortcutHint, "visible", false);
2085+ }
2086+
2087+ function test_metaNumberLaunchesFromLauncher_data() {
2088+ return [
2089+ {tag: "Meta+1", key: Qt.Key_1, index: 0},
2090+ {tag: "Meta+2", key: Qt.Key_2, index: 1},
2091+ {tag: "Meta+4", key: Qt.Key_5, index: 4},
2092+ {tag: "Meta+0", key: Qt.Key_0, index: 9},
2093+ ]
2094+ }
2095+
2096+ function test_metaNumberLaunchesFromLauncher(data) {
2097+ loadShell("desktop");
2098+ var launcher = findChild(shell, "launcher");
2099+ var appId = LauncherModel.get(data.index).appId;
2100+ waitForRendering(shell);
2101+
2102+ keyClick(data.key, Qt.MetaModifier);
2103+ tryCompare(ApplicationManager, "focusedApplicationId", appId);
2104+ }
2105+
2106+ function test_altF1OpensLauncherForKeyboardNavigation() {
2107+ loadShell("desktop");
2108+ waitForRendering(shell);
2109+ var launcher = findChild(shell, "launcher");
2110+
2111+ keyClick(Qt.Key_F1, Qt.AltModifier);
2112+ tryCompare(launcher, "state", "visible");
2113+ tryCompare(launcher, "focus", true)
2114+ }
2115+
2116+ function test_lockedOutLauncherAddsMarginsToMaximized() {
2117+ loadShell("desktop");
2118+ shell.usageScenario = "desktop";
2119+ waitForRendering(shell);
2120+ var appContainer = findChild(shell, "appContainer");
2121+ var launcher = findChild(shell, "launcher");
2122+
2123+ var app = ApplicationManager.startApplication("music-app");
2124+ waitUntilAppWindowIsFullyLoaded(app);
2125+ var appDelegate = findChild(appContainer, "appDelegate_music-app");
2126+ appDelegate.maximize();
2127+ tryCompare(appDelegate, "visuallyMaximized", true);
2128+ waitForRendering(shell);
2129+
2130+ GSettingsController.setAutohideLauncher(true);
2131+ waitForRendering(shell)
2132+ var hiddenSize = appDelegate.width;
2133+
2134+ GSettingsController.setAutohideLauncher(false);
2135+ waitForRendering(shell)
2136+ var shownSize = appDelegate.width;
2137+
2138+ compare(shownSize + launcher.panelWidth, hiddenSize);
2139+ }
2140+
2141+ function test_fullscreenAppHidesLockedOutLauncher() {
2142+ loadShell("desktop");
2143+ shell.usageScenario = "desktop";
2144+
2145+ var launcher = findChild(shell, "launcher");
2146+ var launcherPanel = findChild(launcher, "launcherPanel");
2147+
2148+ GSettingsController.setAutohideLauncher(false);
2149+ waitForRendering(shell)
2150+
2151+ tryCompare(launcher, "lockedVisible", true);
2152+
2153+ var cameraApp = ApplicationManager.startApplication("camera-app");
2154+ waitUntilAppWindowIsFullyLoaded(cameraApp);
2155+
2156+ tryCompare(launcher, "lockedVisible", false);
2157+ }
2158+
2159+
19922160 function test_inputEventsOnEdgesEndUpInAppSurface_data() {
19932161 return [
19942162 { tag: "phone", repeaterName: "spreadRepeater" },