~mzanetti/unity8/staged-spread-with-kbd

« back to all changes in this revision

Viewing changes to tests/qmltests/tst_Shell.qml

merge prereq

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import Unity.Connectivity 0.1
27
27
import Unity.Indicators 0.1
28
28
import Unity.Notifications 1.0
 
29
import Unity.Launcher 0.1
29
30
import Unity.Test 0.1
30
31
import Powerd 0.1
31
32
import Wizard 0.1 as Wizard
121
122
                    Component.onDestruction: {
122
123
                        shellLoader.itemDestroyed = true;
123
124
                    }
124
 
                    Component.onCompleted: {
125
 
                        var keyMapper = testCase.findChild(__shell, "physicalKeysMapper");
126
 
                        keyMapper.controlInsteadOfAlt = true;
127
 
                    }
128
125
                }
129
126
            }
130
127
        }
213
210
                    checked: true
214
211
                    color: "white"
215
212
                }
 
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
                }
216
238
 
217
239
                Label { text: "Applications"; font.bold: true }
218
240
 
912
934
        function dragLauncherIntoView() {
913
935
            var launcher = findChild(shell, "launcher");
914
936
            var launcherPanel = findChild(launcher, "launcherPanel");
 
937
            waitForRendering(launcher);
915
938
            verify(launcherPanel.x = - launcherPanel.width);
916
939
 
917
940
            var touchStartX = 2;
1449
1472
 
1450
1473
            // Do a quick alt-tab and see if focus changes
1451
1474
            tryCompare(app3.session.lastSurface, "activeFocus", true)
1452
 
            keyClick(Qt.Key_Tab, Qt.ControlModifier)
 
1475
            keyClick(Qt.Key_Tab, Qt.AltModifier)
1453
1476
            tryCompare(app2.session.lastSurface, "activeFocus", true)
1454
1477
 
1455
1478
            // Press Alt+Tab
1456
 
            keyPress(Qt.Key_Control);
 
1479
            keyPress(Qt.Key_Alt);
1457
1480
            keyClick(Qt.Key_Tab);
1458
 
            keyRelease(Qt.Key_Control)
 
1481
            keyRelease(Qt.Key_Alt)
1459
1482
 
1460
1483
            // Focus should have switched back now
1461
1484
            tryCompare(app3.session.lastSurface, "activeFocus", true)
1482
1505
            tryCompare(desktopSpread, "state", "")
1483
1506
 
1484
1507
            // Just press Alt, make sure the spread comes up
1485
 
            keyPress(Qt.Key_Control);
 
1508
            keyPress(Qt.Key_Alt);
1486
1509
            keyClick(Qt.Key_Tab);
1487
1510
            tryCompare(desktopSpread, "state", "altTab")
1488
1511
            tryCompare(spreadRepeater, "highlightedIndex", 1)
1503
1526
            tryCompare(spreadRepeater, "highlightedIndex", 0)
1504
1527
 
1505
1528
            // Release control, check if spread disappears
1506
 
            keyRelease(Qt.Key_Control)
 
1529
            keyRelease(Qt.Key_Alt)
1507
1530
            tryCompare(desktopSpread, "state", "")
1508
1531
 
1509
1532
            // Make sure that after wrapping around once, we have the same one focused as at the beginning
1516
1539
            var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1517
1540
            verify(spreadRepeater !== null);
1518
1541
 
1519
 
            keyPress(Qt.Key_Control)
 
1542
            keyPress(Qt.Key_Alt)
1520
1543
            keyClick(Qt.Key_Tab);
1521
1544
            tryCompare(spreadRepeater, "highlightedIndex", 1);
1522
1545
 
1538
1561
            keyClick(Qt.Key_Backtab);
1539
1562
            tryCompare(spreadRepeater, "highlightedIndex", 1);
1540
1563
 
1541
 
            keyRelease(Qt.Key_Control);
 
1564
            keyRelease(Qt.Key_Alt);
1542
1565
        }
1543
1566
 
1544
1567
        function test_highlightFollowsMouse() {
1547
1570
            var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1548
1571
            verify(spreadRepeater !== null);
1549
1572
 
1550
 
            keyPress(Qt.Key_Control)
 
1573
            keyPress(Qt.Key_Alt)
1551
1574
            keyClick(Qt.Key_Tab);
1552
1575
 
1553
1576
            tryCompare(spreadRepeater, "highlightedIndex", 1);
1566
1589
 
1567
1590
            verify(y < 4000);
1568
1591
 
1569
 
            keyRelease(Qt.Key_Control);
 
1592
            keyRelease(Qt.Key_Alt);
1570
1593
        }
1571
1594
 
1572
1595
        function test_closeFromSpread() {
1575
1598
            var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1576
1599
            verify(spreadRepeater !== null);
1577
1600
 
1578
 
            keyPress(Qt.Key_Control)
 
1601
            keyPress(Qt.Key_Alt)
1579
1602
            keyClick(Qt.Key_Tab);
1580
1603
 
1581
1604
            appRemovedSpy.clear();
1602
1625
            tryCompare(appRemovedSpy, "count", 1)
1603
1626
            compare(appRemovedSpy.signalArguments[0][0], closedAppId);
1604
1627
 
1605
 
            keyRelease(Qt.Key_Control);
 
1628
            keyRelease(Qt.Key_Alt);
1606
1629
        }
1607
1630
 
1608
1631
        function test_selectFromSpreadWithMouse_data() {
1622
1645
            var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1623
1646
            verify(spreadRepeater !== null);
1624
1647
 
1625
 
            keyPress(Qt.Key_Control)
 
1648
            keyPress(Qt.Key_Alt)
1626
1649
            keyClick(Qt.Key_Tab);
1627
1650
 
1628
1651
            var focusAppId = ApplicationManager.get(2).appId;
1649
1672
            tryCompare(stage, "state", "");
1650
1673
            tryCompare(ApplicationManager, "focusedApplicationId", focusAppId);
1651
1674
 
1652
 
            keyRelease(Qt.Key_Control);
 
1675
            keyRelease(Qt.Key_Alt);
1653
1676
        }
1654
1677
 
1655
1678
        function test_progressiveAutoScrolling() {
1658
1681
            var appRepeater = findInvisibleChild(shell, "appRepeater");
1659
1682
            verify(appRepeater !== null);
1660
1683
 
1661
 
            keyPress(Qt.Key_Control)
 
1684
            keyPress(Qt.Key_Alt)
1662
1685
            keyClick(Qt.Key_Tab);
1663
1686
 
1664
1687
            var spreadFlickable = findChild(shell, "spreadFlickable")
1669
1692
            var x = 0;
1670
1693
            var y = shell.height * .5
1671
1694
            mouseMove(shell, x, y)
1672
 
            while (x <= spreadFlickable.width) {
 
1695
            while (x <= shell.width) {
1673
1696
                x+=10;
1674
1697
                mouseMove(shell, x, y)
1675
1698
                wait(0); // spin the loop so bindings get evaluated
1684
1707
            }
1685
1708
            tryCompare(spreadFlickable, "contentX", 0);
1686
1709
 
1687
 
            keyRelease(Qt.Key_Control);
 
1710
            keyRelease(Qt.Key_Alt);
1688
1711
        }
1689
1712
 
1690
1713
        // This makes sure the hoverMouseArea is set to invisible AND disabled
1696
1719
            tryCompare(hoverMouseArea, "enabled", false)
1697
1720
            tryCompare(hoverMouseArea, "visible", false)
1698
1721
 
1699
 
            keyPress(Qt.Key_Control)
 
1722
            keyPress(Qt.Key_Alt)
1700
1723
            keyClick(Qt.Key_Tab);
1701
1724
 
1702
1725
            tryCompare(hoverMouseArea, "enabled", true)
1703
1726
            tryCompare(hoverMouseArea, "visible", true)
1704
1727
 
1705
 
            keyRelease(Qt.Key_Control)
 
1728
            keyRelease(Qt.Key_Alt)
1706
1729
 
1707
1730
            tryCompare(hoverMouseArea, "enabled", false)
1708
1731
            tryCompare(hoverMouseArea, "visible", false)
1719
1742
            var appRepeater = findInvisibleChild(shell, "appRepeater");
1720
1743
            verify(appRepeater !== null);
1721
1744
 
1722
 
            keyPress(Qt.Key_Control)
 
1745
            keyPress(Qt.Key_Alt)
1723
1746
            keyClick(Qt.Key_Tab);
1724
1747
 
1725
1748
            tryCompare(spreadRepeater, "highlightedIndex", 1);
1740
1763
 
1741
1764
            verify(y < 4000);
1742
1765
 
1743
 
            keyRelease(Qt.Key_Control);
1744
 
        }
1745
 
 
1746
 
        function test_focusAppFromLauncherExitsSpread() {
 
1766
            keyRelease(Qt.Key_Alt);
 
1767
        }
 
1768
 
 
1769
        function test_focusAppFromLauncherExitsSpread_data() {
 
1770
            return [
 
1771
                {tag: "autohide launcher", launcherLocked: false },
 
1772
                {tag: "locked launcher", launcherLocked: true }
 
1773
            ]
 
1774
        }
 
1775
 
 
1776
        function test_focusAppFromLauncherExitsSpread(data) {
1747
1777
            loadDesktopShellWithApps()
1748
 
 
 
1778
            var launcher = findChild(shell, "launcher");
1749
1779
            var desktopSpread = findChild(shell, "spread");
1750
 
            var launcher = findChild(shell, "launcher");
1751
1780
            var bfb = findChild(launcher, "buttonShowDashHome");
1752
1781
 
1753
 
            keyPress(Qt.Key_Control)
 
1782
            GSettingsController.setAutohideLauncher(!data.launcherLocked);
 
1783
            waitForRendering(shell);
 
1784
 
 
1785
            keyPress(Qt.Key_Alt)
1754
1786
            keyClick(Qt.Key_Tab);
1755
1787
 
1756
1788
            tryCompare(desktopSpread, "state", "altTab")
1757
1789
 
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
            }
1762
1796
 
1763
1797
            mouseClick(bfb, bfb.width / 2, bfb.height / 2)
1764
 
            tryCompare(launcher, "state", "")
 
1798
            if (!data.launcherLocked) {
 
1799
                tryCompare(launcher, "state", "")
 
1800
            }
1765
1801
            tryCompare(desktopSpread, "state", "")
1766
1802
 
1767
1803
            tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash")
1768
1804
 
1769
 
            keyRelease(Qt.Key_Control);
 
1805
            keyRelease(Qt.Key_Alt);
1770
1806
        }
1771
1807
 
1772
1808
        // regression test for http://pad.lv/1443319
1989
2025
            }
1990
2026
        }
1991
2027
 
 
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
 
1992
2160
        function test_inputEventsOnEdgesEndUpInAppSurface_data() {
1993
2161
            return [
1994
2162
                { tag: "phone", repeaterName: "spreadRepeater" },