@@ -109,6 +109,7 @@ Rectangle {
109 property bool itemDestroyed: false
109 property bool itemDestroyed: false
110 sourceComponent: Component {
110 sourceComponent: Component {
112 property string shellMode: "full-greeter" /* default */
113 property string shellMode: "full-greeter" /* default */
114 usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
115 usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
@@ -118,6 +119,10 @@ Rectangle {
118 Component.onDestruction: {
119 Component.onDestruction: {
119 shellLoader.itemDestroyed = true;
120 shellLoader.itemDestroyed = true;
122+ Component.onCompleted: {
123+ var keyMapper = testCase.findChild(__shell, "physicalKeysMapper");
124+ keyMapper.controlInsteadOfAlt = true;
@@ -327,6 +332,20 @@ Rectangle {
327 waitForGreeterToStabilize();
332 waitForGreeterToStabilize();
335+ function loadDesktopShellWithApps() {
336+ loadShell("desktop");
337+ shell.usageScenario = "desktop"
338+ waitForRendering(root)
339+ var app1 = ApplicationManager.startApplication("dialer-app")
340+ var app2 = ApplicationManager.startApplication("webbrowser-app")
341+ var app3 = ApplicationManager.startApplication("camera-app")
342+ var app4 = ApplicationManager.startApplication("facebook-webapp")
343+ var app5 = ApplicationManager.startApplication("calendar-app")
344+ var app6 = ApplicationManager.startApplication("gallery-app")
345+ var app7 = ApplicationManager.startApplication("camera-app")
346+ waitUntilAppWindowIsFullyLoaded(app7);
330 function waitForGreeterToStabilize() {
349 function waitForGreeterToStabilize() {
331 var greeter = findChild(shell, "greeter");
350 var greeter = findChild(shell, "greeter");
332 verify(greeter);
351 verify(greeter);
@@ -1287,5 +1306,143 @@ Rectangle {
1287 var launcher = findChild(shell, "launcher");
1306 var launcher = findChild(shell, "launcher");
1288 compare(launcher.inverted, data.launcherInverted);
1307 compare(launcher.inverted, data.launcherInverted);
1310+ function test_altTabSwitchesFocus() {
1311+ loadShell("desktop");
1312+ shell.usageScenario = "desktop"
1313+ waitForRendering(root)
1315+ var desktopStage = findChild(shell, "stage");
1316+ verify(desktopStage != null)
1318+ var app1 = ApplicationManager.startApplication("dialer-app")
1319+ waitUntilAppWindowIsFullyLoaded(app1);
1320+ var app2 = ApplicationManager.startApplication("webbrowser-app")
1321+ waitUntilAppWindowIsFullyLoaded(app2);
1322+ var app3 = ApplicationManager.startApplication("camera-app")
1323+ waitUntilAppWindowIsFullyLoaded(app3);
1325+ // Do a quick alt-tab and see if focus changes
1326+ tryCompare(app3.session.surface, "activeFocus", true)
1327+ keyClick(Qt.Key_Tab, Qt.ControlModifier)
1328+ tryCompare(app2.session.surface, "activeFocus", true)
1331+ tryCompare(desktopStage, "state", "")
1333+ // Just press Alt, make sure the spread comes up
1334+ keyPress(Qt.Key_Control);
1335+ keyClick(Qt.Key_Tab);
1336+ tryCompare(desktopStage, "state", "altTab")
1338+ // Release control, check if spread disappears
1339+ keyRelease(Qt.Key_Control)
1340+ tryCompare(desktopStage, "state", "")
1342+ // Focus should have switched back now
1343+ tryCompare(app3.session.surface, "activeFocus", true)
1346+ function test_altTabWrapAround() {
1347+ loadDesktopShellWithApps();
1349+ var desktopStage = findChild(shell, "stage");
1350+ verify(desktopStage !== null)
1352+ var appRepeater = findInvisibleChild(shell, "appRepeater")
1353+ verify(appRepeater !== null)
1355+ // remember the focused appId
1356+ var focused = ApplicationManager.get(ApplicationManager.findApplication(ApplicationManager.focusedApplicationId));
1358+ tryCompare(desktopStage, "state", "")
1360+ // Just press Alt, make sure the spread comes up
1361+ keyPress(Qt.Key_Control);
1362+ keyClick(Qt.Key_Tab);
1363+ tryCompare(desktopStage, "state", "altTab")
1364+ tryCompare(appRepeater, "highlightedIndex", 1)
1365+ waitForRendering(shell)
1367+ // Now press and hold Tab, make sure the highlight moves all the way but stops at the last one
1368+ // We can't simulate a pressed key with keyPress() currently, so let's inject the events
1369+ // at API level. Jump for 10 times, verify that it's still at the last one and didn't wrap around.
1370+ for (var i = 0; i < 10; i++) {
1371+ desktopStage.altTabNext(true);
1372+ wait(0); // Trigger the event loop to make sure all the things happen
1374+ tryCompare(appRepeater, "highlightedIndex", 6)
1376+ // Now release it once, and verify that it does wrap around with an additional Tab press
1377+ keyRelease(Qt.Key_Tab);
1378+ keyClick(Qt.Key_Tab);
1379+ tryCompare(appRepeater, "highlightedIndex", 0)
1381+ // Release control, check if spread disappears
1382+ keyRelease(Qt.Key_Control)
1383+ tryCompare(desktopStage, "state", "")
1385+ // Make sure that after wrapping around once, we have the same one focused as at the beginning
1386+ tryCompare(focused.session.surface, "activeFocus", true)
1389+ function test_altBackTabNavigation() {
1390+ loadDesktopShellWithApps();
1392+ var appRepeater = findInvisibleChild(shell, "appRepeater");
1393+ verify(appRepeater !== null);
1395+ keyPress(Qt.Key_Control)
1396+ keyClick(Qt.Key_Tab);
1397+ tryCompare(appRepeater, "highlightedIndex", 1);
1399+ keyClick(Qt.Key_Tab);
1400+ tryCompare(appRepeater, "highlightedIndex", 2);
1402+ keyClick(Qt.Key_Tab);
1403+ tryCompare(appRepeater, "highlightedIndex", 3);
1405+ keyClick(Qt.Key_Tab);
1406+ tryCompare(appRepeater, "highlightedIndex", 4);
1408+ keyClick(Qt.Key_Backtab);
1409+ tryCompare(appRepeater, "highlightedIndex", 3);
1411+ keyClick(Qt.Key_Backtab);
1412+ tryCompare(appRepeater, "highlightedIndex", 2);
1414+ keyClick(Qt.Key_Backtab);
1415+ tryCompare(appRepeater, "highlightedIndex", 1);
1417+ keyRelease(Qt.Key_Control);
1420+ function test_highlightFollowsMouse() {
1421+ loadDesktopShellWithApps()
1423+ var appRepeater = findInvisibleChild(shell, "appRepeater");
1424+ verify(appRepeater !== null);
1426+ keyPress(Qt.Key_Control)
1427+ keyClick(Qt.Key_Tab);
1429+ tryCompare(appRepeater, "highlightedIndex", 1);
1432+ var y = shell.height * .75;
1433+ mouseMove(shell, x, y)
1435+ for (var i = 0; i < 7; i++) {
1436+ while (appRepeater.highlightedIndex != i && x <= 4000) {
1438+ mouseMove(shell, x, y)
1439+ waitForRendering(shell)
1445+ keyRelease(Qt.Key_Control);