~mzanetti/unity8/fix-1648251

« back to all changes in this revision

Viewing changes to tests/qmltests/tst_Shell.qml

  • Committer: Michael Zanetti
  • Date: 2016-12-01 12:20:34 UTC
  • mfrom: (2525.1.179 unity8)
  • Revision ID: michael.zanetti@canonical.com-20161201122034-cpvbf7webbhg2wph
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
import "../../qml"
37
37
import "../../qml/Components"
38
38
import "../../qml/Components/PanelState"
39
 
import "Stages"
 
39
import "Stage"
40
40
 
41
41
Rectangle {
42
42
    id: root
51
51
        shellLoader.active = true;
52
52
    }
53
53
 
 
54
    property var shell: shellLoader.item ? shellLoader.item : null
 
55
 
54
56
    Item {
55
57
        id: shellContainer
56
58
        anchors.left: root.left
108
110
            sourceComponent: Component {
109
111
                Shell {
110
112
                    id: __shell
 
113
                    objectName: "shell"
111
114
                    usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
112
115
                    nativeWidth: width
113
116
                    nativeHeight: height
184
187
                            callManager.foregroundCall = callManager.foregroundCall ? null : phoneCall;
185
188
                        }
186
189
                    }
187
 
                }
188
 
                Button {
189
 
                    text: "Show Launcher"
190
 
                    activeFocusOnPress: false
191
 
                    onClicked: {
192
 
                        if (shellLoader.status !== Loader.Ready)
193
 
                            return;
 
190
                    Button {
 
191
                        text: "Show Launcher"
 
192
                        activeFocusOnPress: false
 
193
                        onClicked: {
 
194
                            if (shellLoader.status !== Loader.Ready)
 
195
                                return;
194
196
 
195
 
                        var launcher = testCase.findChild(shellLoader.item, "launcher");
196
 
                        launcher.state = "visible";
 
197
                            var launcher = testCase.findChild(shellLoader.item, "launcher");
 
198
                            launcher.state = "visible";
 
199
                        }
 
200
                    }
 
201
                    Button {
 
202
                        text: "Print focused"
 
203
                        activeFocusOnPress: false
 
204
                        onClicked: {
 
205
                            var childs = new Array(0);
 
206
                            childs.push(shellLoader.item)
 
207
                            while (childs.length > 0) {
 
208
                                if (childs[0].activeFocus && childs[0].focus && childs[0].objectName != "shell") {
 
209
                                    console.log("Active focus is on item:", childs[0]);
 
210
                                    return;
 
211
                                }
 
212
                                for (var i in childs[0].children) {
 
213
                                    childs.push(childs[0].children[i])
 
214
                                }
 
215
                                childs.splice(0, 1);
 
216
                            }
 
217
                            console.log("No active focused item found within shell.")
 
218
                        }
197
219
                    }
198
220
                }
199
 
                ListItem.ItemSelector {
200
 
                    anchors { left: parent.left; right: parent.right }
201
 
                    activeFocusOnPress: false
 
221
                Label {
202
222
                    text: "LightDM mock mode"
 
223
                }
 
224
 
 
225
                ListItem.ItemSelector {
 
226
                    anchors { left: parent.left; right: parent.right }
 
227
                    activeFocusOnPress: false
203
228
                    model: ["single", "single-passphrase", "single-pin", "full"]
204
229
                    onSelectedIndexChanged: {
205
230
                        shellLoader.active = false;
208
233
                        shellLoader.active = true;
209
234
                    }
210
235
                }
211
 
                ListItem.ItemSelector {
212
 
                    anchors { left: parent.left; right: parent.right }
213
 
                    activeFocusOnPress: false
 
236
                Label {
214
237
                    text: "Size"
 
238
                }
 
239
 
 
240
                ListItem.ItemSelector {
 
241
                    id: sizeSelector
 
242
                    anchors { left: parent.left; right: parent.right }
 
243
                    activeFocusOnPress: false
215
244
                    model: ["phone", "tablet", "desktop"]
216
245
                    onSelectedIndexChanged: {
217
 
                        shellLoader.active = false;
218
246
                        shellLoader.state = model[selectedIndex];
219
 
                        shellLoader.active = true;
220
247
                    }
221
248
                }
 
249
                Label {
 
250
                    text: "Usage scenario"
 
251
                }
 
252
 
222
253
                ListItem.ItemSelector {
223
254
                    id: usageScenarioSelector
224
255
                    anchors { left: parent.left; right: parent.right }
225
256
                    activeFocusOnPress: false
226
 
                    text: "Usage scenario"
227
257
                    model: ["phone", "tablet", "desktop"]
228
258
                }
229
259
                MouseTouchEmulationCheckbox {
230
260
                    id: mouseEmulation
231
261
                    checked: true
232
262
                }
 
263
                Label {
 
264
                    text: "Ctrl key as"
 
265
                }
 
266
 
233
267
                ListItem.ItemSelector {
234
268
                    id: ctrlModifier
235
269
                    anchors { left: parent.left; right: parent.right }
236
270
                    activeFocusOnPress: false
237
 
                    text: "Ctrl key as"
238
271
                    model: ["Ctrl", "Alt", "Super"]
239
272
                    onSelectedIndexChanged: {
240
273
                        var keyMapper = testCase.findChild(shellContainer, "physicalKeysMapper");
261
294
                Button {
262
295
                    text: "Start all apps"
263
296
                    width: parent.width
 
297
                    activeFocusOnPress: false
264
298
                    onClicked: {
265
299
                        for (var i = 0; i < ApplicationManager.availableApplications.length; i++) {
266
300
                            var appId = ApplicationManager.availableApplications[i];
270
304
                }
271
305
 
272
306
                Repeater {
273
 
                    id: appRepeater
 
307
                    id: appCheckBoxRepeater
274
308
                    model: ApplicationManager.availableApplications
275
309
                    ApplicationCheckBox {
276
310
                        appId: modelData
571
605
            compare(ApplicationManager.get(0).appId, "unity8-dash");
572
606
        }
573
607
 
 
608
        function test_phoneLeftEdgeDrag_data() {
 
609
            return [
 
610
                {tag: "without launcher",
 
611
                 revealLauncher: false, swipeLength: units.gu(30), appHides: true, focusedApp: "dialer-app",
 
612
                 launcherHides: true, greeterShown: false},
 
613
 
 
614
                {tag: "with launcher",
 
615
                 revealLauncher: true, swipeLength: units.gu(30), appHides: true, focusedApp: "dialer-app",
 
616
                 launcherHides: true, greeterShown: false},
 
617
 
 
618
                {tag: "small swipe",
 
619
                 revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
 
620
                 launcherHides: false, greeterShown: false},
 
621
 
 
622
                {tag: "long swipe",
 
623
                 revealLauncher: false, swipeLength: units.gu(30), appHides: true, focusedApp: "dialer-app",
 
624
                 launcherHides: true, greeterShown: false},
 
625
 
 
626
                {tag: "small swipe with greeter",
 
627
                 revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
 
628
                 launcherHides: false, greeterShown: true},
 
629
 
 
630
                {tag: "long swipe with greeter",
 
631
                 revealLauncher: false, swipeLength: units.gu(30), appHides: true, focusedApp: "dialer-app",
 
632
                 launcherHides: true, greeterShown: true},
 
633
 
 
634
                {tag: "swipe over dash",
 
635
                 revealLauncher: false, swipeLength: units.gu(30), appHides: true, focusedApp: "unity8-dash",
 
636
                 launcherHides: false, greeterShown: false},
 
637
            ];
 
638
        }
 
639
 
574
640
        function test_snapDecisionDismissalReturnsFocus() {
575
641
            loadShell("phone");
576
642
            swipeAwayGreeter();
635
701
            mockNotificationsModel.append(n)
636
702
        }
637
703
 
638
 
        function test_phoneLeftEdgeDrag_data() {
639
 
            return [
640
 
                {tag: "without launcher",
641
 
                 revealLauncher: false, swipeLength: units.gu(30), appHides: true, focusedApp: "dialer-app",
642
 
                 launcherHides: true, greeterShown: false},
643
 
 
644
 
                {tag: "with launcher",
645
 
                 revealLauncher: true, swipeLength: units.gu(30), appHides: true, focusedApp: "dialer-app",
646
 
                 launcherHides: true, greeterShown: false},
647
 
 
648
 
                {tag: "small swipe",
649
 
                 revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
650
 
                 launcherHides: false, greeterShown: false},
651
 
 
652
 
                {tag: "long swipe",
653
 
                 revealLauncher: false, swipeLength: units.gu(30), appHides: true, focusedApp: "dialer-app",
654
 
                 launcherHides: true, greeterShown: false},
655
 
 
656
 
                {tag: "small swipe with greeter",
657
 
                 revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
658
 
                 launcherHides: false, greeterShown: true},
659
 
 
660
 
                {tag: "long swipe with greeter",
661
 
                 revealLauncher: false, swipeLength: units.gu(30), appHides: true, focusedApp: "dialer-app",
662
 
                 launcherHides: true, greeterShown: true},
663
 
 
664
 
                {tag: "swipe over dash",
665
 
                 revealLauncher: false, swipeLength: units.gu(30), appHides: true, focusedApp: "unity8-dash",
666
 
                 launcherHides: false, greeterShown: false},
667
 
            ];
668
 
        }
669
 
 
670
704
        function test_phoneLeftEdgeDrag(data) {
671
705
            loadShell("phone");
672
706
            swipeAwayGreeter();
1365
1399
        function test_tapOnRightEdgeReachesApplicationSurface() {
1366
1400
            loadShell("phone");
1367
1401
            swipeAwayGreeter();
1368
 
            var topmostSpreadDelegate = findChild(shell, "spreadDelegate_" + topLevelSurfaceList.idAt(0));
 
1402
            var topmostSpreadDelegate = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
1369
1403
            verify(topmostSpreadDelegate);
1370
1404
 
1371
1405
            waitUntilFocusedApplicationIsShowingItsSurface();
1373
1407
            var topmostSurfaceItem = findChild(topmostSpreadDelegate, "surfaceItem");
1374
1408
            verify(topmostSurfaceItem);
1375
1409
 
1376
 
            var rightEdgeDragArea = findChild(shell, "spreadDragArea");
 
1410
            var rightEdgeDragArea = findChild(shell, "rightEdgeDragArea");
1377
1411
            topmostSurfaceItem.touchPressCount = 0;
1378
1412
            topmostSurfaceItem.touchReleaseCount = 0;
1379
1413
 
1394
1428
        function test_rightEdgeDragDoesNotReachApplicationSurface() {
1395
1429
            loadShell("phone");
1396
1430
            swipeAwayGreeter();
1397
 
            var topmostSpreadDelegate = findChild(shell, "spreadDelegate_" + topLevelSurfaceList.idAt(0));
 
1431
            var topmostSpreadDelegate = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
1398
1432
            var topmostSurfaceItem = findChild(topmostSpreadDelegate, "surfaceItem");
1399
 
            var rightEdgeDragArea = findChild(shell, "spreadDragArea");
 
1433
            var rightEdgeDragArea = findChild(shell, "rightEdgeDragArea");
1400
1434
 
1401
1435
            topmostSurfaceItem.touchPressCount = 0;
1402
1436
            topmostSurfaceItem.touchReleaseCount = 0;
1414
1448
 
1415
1449
        function waitUntilFocusedApplicationIsShowingItsSurface()
1416
1450
        {
1417
 
            var spreadDelegate = findChild(shell, "spreadDelegate_" + topLevelSurfaceList.idAt(0));
 
1451
            var spreadDelegate = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
1418
1452
            var appState = findInvisibleChild(spreadDelegate, "applicationWindowStateGroup");
1419
1453
            tryCompare(appState, "state", "surface");
1420
1454
            var transitions = appState.transitions;
1433
1467
 
1434
1468
            // check if it's indeed showing the spread
1435
1469
            var stage = findChild(shell, "stage");
1436
 
            var spreadView = findChild(stage, "spreadView");
1437
 
            tryCompare(spreadView, "phase", 2);
 
1470
            tryCompare(stage, "state", "spread");
1438
1471
        }
1439
1472
 
1440
1473
        function test_tapUbuntuIconInLauncherOverAppSpread() {
1470
1503
            // check that the stage has left spread mode.
1471
1504
            {
1472
1505
                var stage = findChild(shell, "stage");
1473
 
                var spreadView = findChild(stage, "spreadView");
1474
 
                tryCompare(spreadView, "phase", 0);
 
1506
                tryCompare(stage, "state", "staged");
1475
1507
            }
1476
1508
 
1477
1509
            // check that the launcher got dismissed
1538
1570
            }
1539
1571
        }
1540
1572
 
1541
 
        function test_stageLoader_data() {
1542
 
            return [
1543
 
                {tag: "phone", source: "Stages/PhoneStage.qml", formFactor: "phone", usageScenario: "phone"},
1544
 
                {tag: "tablet", source: "Stages/TabletStage.qml", formFactor: "tablet", usageScenario: "tablet"},
1545
 
                {tag: "desktop", source: "Stages/DesktopStage.qml", formFactor: "tablet", usageScenario: "desktop"}
1546
 
            ]
1547
 
        }
1548
 
 
1549
 
        function test_stageLoader(data) {
1550
 
            loadShell(data.formFactor);
1551
 
            shell.usageScenario = data.usageScenario;
1552
 
            var stageLoader = findChild(shell, "applicationsDisplayLoader");
1553
 
            verify(String(stageLoader.source).indexOf(data.source) >= 0);
1554
 
        }
1555
 
 
1556
1573
        function test_launcherInverted_data() {
1557
1574
            return [
1558
1575
                {tag: "phone", formFactor: "phone", usageScenario: "phone", launcherInverted: true},
1666
1683
        function test_altTabWrapAround() {
1667
1684
            loadDesktopShellWithApps();
1668
1685
 
1669
 
            var desktopStage = findChild(shell, "stage");
1670
 
            verify(desktopStage !== null)
1671
 
 
1672
 
            var desktopSpread = findChild(shell, "spread");
1673
 
            verify(desktopSpread !== null)
1674
 
 
1675
 
            var spreadContainer = findInvisibleChild(shell, "spreadContainer")
1676
 
            verify(spreadContainer !== null)
1677
 
 
1678
 
            var spreadRepeater = findInvisibleChild(shell, "spreadRepeater")
1679
 
            verify(spreadRepeater !== null)
 
1686
            var stage = findChild(shell, "stage");
 
1687
            verify(stage !== null)
 
1688
 
 
1689
            var spread = findChild(shell, "spreadItem");
 
1690
            verify(spread !== null)
1680
1691
 
1681
1692
            // remember the focused appId
1682
1693
            var focused = ApplicationManager.get(ApplicationManager.findApplication(ApplicationManager.focusedApplicationId));
1683
1694
 
1684
 
            tryCompare(desktopSpread, "state", "")
 
1695
            tryCompare(stage, "state", "windowed")
1685
1696
 
1686
1697
            // Just press Alt, make sure the spread comes up
1687
1698
            keyPress(Qt.Key_Alt);
1688
1699
            keyClick(Qt.Key_Tab);
1689
 
            tryCompare(desktopSpread, "state", "altTab")
1690
 
            tryCompare(spreadRepeater, "highlightedIndex", 1)
 
1700
            tryCompare(stage, "state", "spread")
 
1701
            tryCompare(spread, "highlightedIndex", 1)
1691
1702
            waitForRendering(shell)
1692
1703
 
1693
1704
            // Now press and hold Tab, make sure the highlight moves all the way but stops at the last one
1694
1705
            // We can't simulate a pressed key with keyPress() currently, so let's inject the events
1695
1706
            // at API level. Jump for 10 times, verify that it's still at the last one and didn't wrap around.
1696
1707
            for (var i = 0; i < 10; i++) {
1697
 
                desktopSpread.selectNext(true); // true == isAutoRepeat
 
1708
                spread.selectNext(true); // true == isAutoRepeat
1698
1709
                wait(0); // Trigger the event loop to make sure all the things happen
1699
1710
            }
1700
 
            tryCompare(spreadRepeater, "highlightedIndex", 6)
 
1711
            tryCompare(spread, "highlightedIndex", 6)
1701
1712
 
1702
1713
            // Now release it once, and verify that it does wrap around with an additional Tab press
1703
1714
            keyRelease(Qt.Key_Tab);
1704
1715
            keyClick(Qt.Key_Tab);
1705
 
            tryCompare(spreadRepeater, "highlightedIndex", 0)
 
1716
            tryCompare(spread, "highlightedIndex", 0)
1706
1717
 
1707
1718
            // Release control, check if spread disappears
1708
1719
            keyRelease(Qt.Key_Alt)
1709
 
            tryCompare(desktopSpread, "state", "")
 
1720
            tryCompare(stage, "state", "windowed")
1710
1721
 
1711
1722
            // Make sure that after wrapping around once, we have the same one focused as at the beginning
1712
1723
            var focusedAppSurface = focused.surfaceList.get(0);
1717
1728
        function test_altBackTabNavigation() {
1718
1729
            loadDesktopShellWithApps();
1719
1730
 
1720
 
            var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1721
 
            verify(spreadRepeater !== null);
 
1731
            var spreadItem = findChild(shell, "spreadItem");
 
1732
            verify(spreadItem !== null);
1722
1733
 
1723
1734
            keyPress(Qt.Key_Alt)
1724
1735
            keyClick(Qt.Key_Tab);
1725
 
            tryCompare(spreadRepeater, "highlightedIndex", 1);
1726
 
 
1727
 
            keyClick(Qt.Key_Tab);
1728
 
            tryCompare(spreadRepeater, "highlightedIndex", 2);
1729
 
 
1730
 
            keyClick(Qt.Key_Tab);
1731
 
            tryCompare(spreadRepeater, "highlightedIndex", 3);
1732
 
 
1733
 
            keyClick(Qt.Key_Tab);
1734
 
            tryCompare(spreadRepeater, "highlightedIndex", 4);
1735
 
 
1736
 
            keyClick(Qt.Key_Backtab);
1737
 
            tryCompare(spreadRepeater, "highlightedIndex", 3);
1738
 
 
1739
 
            keyClick(Qt.Key_Backtab);
1740
 
            tryCompare(spreadRepeater, "highlightedIndex", 2);
1741
 
 
1742
 
            keyClick(Qt.Key_Backtab);
1743
 
            tryCompare(spreadRepeater, "highlightedIndex", 1);
 
1736
            tryCompare(spreadItem, "highlightedIndex", 1);
 
1737
 
 
1738
            keyClick(Qt.Key_Tab);
 
1739
            tryCompare(spreadItem, "highlightedIndex", 2);
 
1740
 
 
1741
            keyClick(Qt.Key_Tab);
 
1742
            tryCompare(spreadItem, "highlightedIndex", 3);
 
1743
 
 
1744
            keyClick(Qt.Key_Tab);
 
1745
            tryCompare(spreadItem, "highlightedIndex", 4);
 
1746
 
 
1747
            keyClick(Qt.Key_Backtab);
 
1748
            tryCompare(spreadItem, "highlightedIndex", 3);
 
1749
 
 
1750
            keyClick(Qt.Key_Backtab);
 
1751
            tryCompare(spreadItem, "highlightedIndex", 2);
 
1752
 
 
1753
            keyClick(Qt.Key_Backtab);
 
1754
            tryCompare(spreadItem, "highlightedIndex", 1);
1744
1755
 
1745
1756
            keyRelease(Qt.Key_Alt);
1746
1757
        }
1776
1787
        function test_closeFromSpread() {
1777
1788
            loadDesktopShellWithApps()
1778
1789
 
1779
 
            var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1780
 
            verify(spreadRepeater !== null);
 
1790
            var appRepeater = findInvisibleChild(shell, "appRepeater");
 
1791
            verify(appRepeater !== null);
 
1792
 
 
1793
            var spreadItem = findChild(shell, "spreadItem");
 
1794
            verify(spreadItem !== null);
1781
1795
 
1782
1796
            keyPress(Qt.Key_Alt)
1783
1797
            keyClick(Qt.Key_Tab);
1784
1798
 
1785
1799
            var surfaceId = topLevelSurfaceList.idAt(2);
1786
 
            var spreadDelegate2 = spreadRepeater.itemAt(2);
 
1800
            var spreadDelegate2 = appRepeater.itemAt(2);
1787
1801
            var closeMouseArea = findChild(spreadDelegate2, "closeMouseArea");
1788
1802
 
1789
1803
            // Move the mosue over tile 2 and verify the close button becomes visible
1790
1804
            var x = 0;
1791
1805
            var y = shell.height * .5;
1792
1806
            mouseMove(shell, x, y)
1793
 
            while (spreadRepeater.highlightedIndex !== 2 && x <= 4000) {
 
1807
            while (spreadItem.highlightedIndex !== 2 && x <= 4000) {
1794
1808
                x+=10;
1795
1809
                mouseMove(shell, x, y)
1796
1810
                wait(0); // spin the loop so bindings get evaluated
1820
1834
            loadDesktopShellWithApps()
1821
1835
 
1822
1836
            var stage = findChild(shell, "stage");
1823
 
            var spread = findChild(stage, "spread");
1824
 
            waitForRendering(spread)
 
1837
            var spreadItem = findChild(stage, "spreadItem");
 
1838
//            waitForRendering(spread)
1825
1839
 
1826
 
            var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1827
 
            verify(spreadRepeater !== null);
 
1840
            var appRepeater = findInvisibleChild(shell, "appRepeater");
 
1841
            verify(appRepeater !== null);
1828
1842
 
1829
1843
            keyPress(Qt.Key_Alt)
1830
1844
            keyClick(Qt.Key_Tab);
1831
1845
 
1832
1846
            var surface = topLevelSurfaceList.surfaceAt(2);
1833
 
            var spreadDelegate2 = spreadRepeater.itemAt(2);
1834
 
            var clippedSpreadDelegate = findChild(spreadDelegate2, "clippedSpreadDelegate");
 
1847
            var spreadDelegate2 = appRepeater.itemAt(2);
 
1848
            var decoratedWindow = findChild(spreadDelegate2, "decoratedWindow");
1835
1849
 
1836
 
            tryCompare(spread, "state", "altTab");
 
1850
            tryCompare(stage, "state", "spread");
1837
1851
 
1838
1852
            // Move the mouse over tile 2 and verify the highlight becomes visible
1839
1853
            var x = 0;
1840
 
            var y = shell.height * (data.tileInfo ? .95 : 0.5)
 
1854
            var y = shell.height * (data.tileInfo ? .9 : 0.5)
1841
1855
            mouseMove(shell, x, y)
1842
 
            while (spreadRepeater.highlightedIndex !== 2 && x <= 4000) {
 
1856
            while (spreadItem.highlightedIndex !== 2 && x <= 4000) {
1843
1857
                x+=10;
1844
1858
                mouseMove(shell, x, y)
1845
1859
                wait(0); // spin the loop so bindings get evaluated
1846
1860
            }
1847
 
            tryCompare(clippedSpreadDelegate, "highlightShown", true);
 
1861
            tryCompare(decoratedWindow, "showHighlight", true);
1848
1862
 
1849
1863
            // Click the tile
1850
 
            mouseClick(clippedSpreadDelegate, clippedSpreadDelegate.width / 2, clippedSpreadDelegate.height / 2)
 
1864
            mouseClick(decoratedWindow, units.gu(2), decoratedWindow.height / 2)
1851
1865
 
1852
1866
            // Verify that we left the spread and app2 is the focused one now
1853
 
            tryCompare(stage, "state", "");
 
1867
            tryCompare(stage, "state", "windowed");
1854
1868
            tryCompare(surface, "focused", true);
1855
1869
 
1856
1870
            keyRelease(Qt.Key_Alt);
1912
1926
            tryCompare(hoverMouseArea, "visible", false)
1913
1927
        }
1914
1928
 
1915
 
        function test_workspacePreviewsHighlightedApp() {
1916
 
            loadDesktopShellWithApps()
1917
 
 
1918
 
            var targetZ = topLevelSurfaceList.count + 1;
1919
 
 
1920
 
            var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1921
 
            verify(spreadRepeater !== null);
1922
 
 
1923
 
            var appRepeater = findInvisibleChild(shell, "appRepeater");
1924
 
            verify(appRepeater !== null);
1925
 
 
1926
 
            keyPress(Qt.Key_Alt)
1927
 
            keyClick(Qt.Key_Tab);
1928
 
 
1929
 
            tryCompare(spreadRepeater, "highlightedIndex", 1);
1930
 
            tryCompare(appRepeater.itemAt(1), "z", targetZ)
1931
 
 
1932
 
            var x = 0;
1933
 
            var y = shell.height * .75;
1934
 
            mouseMove(shell, x, y)
1935
 
 
1936
 
            for (var i = 0; i < 7; i++) {
1937
 
                while (spreadRepeater.highlightedIndex != i && x <= 4000) {
1938
 
                    tryCompare(appRepeater.itemAt(spreadRepeater.highlightedIndex), "z", targetZ)
1939
 
                    x+=10;
1940
 
                    mouseMove(shell, x, y)
1941
 
                    wait(0); // spin the loop so bindings get evaluated
1942
 
                }
1943
 
            }
1944
 
 
1945
 
            verify(y < 4000);
1946
 
 
1947
 
            keyRelease(Qt.Key_Alt);
1948
 
        }
1949
 
 
1950
1929
        function test_focusAppFromLauncherExitsSpread_data() {
1951
1930
            return [
1952
1931
                {tag: "autohide launcher", launcherLocked: false },
1957
1936
        function test_focusAppFromLauncherExitsSpread(data) {
1958
1937
            loadDesktopShellWithApps()
1959
1938
            var launcher = findChild(shell, "launcher");
1960
 
            var desktopSpread = findChild(shell, "spread");
 
1939
            var stage = findChild(shell, "stage");
1961
1940
            var bfb = findChild(launcher, "buttonShowDashHome");
1962
1941
 
1963
1942
            GSettingsController.setAutohideLauncher(!data.launcherLocked);
1966
1945
            keyPress(Qt.Key_Alt)
1967
1946
            keyClick(Qt.Key_Tab);
1968
1947
 
1969
 
            tryCompare(desktopSpread, "state", "altTab")
 
1948
            tryCompare(stage, "state", "spread")
1970
1949
 
1971
1950
            if (!data.launcherLocked) {
1972
1951
                revealLauncherByEdgePushWithMouse();
1979
1958
            if (!data.launcherLocked) {
1980
1959
                tryCompare(launcher, "state", "")
1981
1960
            }
1982
 
            tryCompare(desktopSpread, "state", "")
 
1961
            tryCompare(stage, "state", "windowed")
1983
1962
 
1984
1963
            tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash")
1985
1964
 
2147
2126
 
2148
2127
            // Sanity checking
2149
2128
            if (data.usageScenario === "tablet") {
2150
 
                var app1Delegate = findChild(shell, "spreadDelegate_" + app1SurfaceId);
 
2129
                var app1Delegate = findChild(shell, "appDelegate_" + app1SurfaceId);
2151
2130
                compare(app1Delegate.stage, ApplicationInfoInterface.MainStage);
2152
2131
 
2153
 
                var app2Delegate = findChild(shell, "spreadDelegate_" + app2SurfaceId);
 
2132
                var app2Delegate = findChild(shell, "appDelegate_" + app2SurfaceId);
2154
2133
                compare(app2Delegate.stage, ApplicationInfoInterface.MainStage);
2155
2134
            }
2156
2135
            verify(!app1.isTouchApp);
2188
2167
 
2189
2168
            // Sanity checking
2190
2169
            if (data.usageScenario === "tablet") {
2191
 
                var app1Delegate = findChild(shell, "spreadDelegate_" + app1SurfaceId);
 
2170
                var app1Delegate = findChild(shell, "appDelegate_" + app1SurfaceId);
2192
2171
                compare(app1Delegate.stage, ApplicationInfoInterface.MainStage);
2193
2172
 
2194
 
                var app2Delegate = findChild(shell, "spreadDelegate_" + app2SurfaceId);
 
2173
                var app2Delegate = findChild(shell, "appDelegate_" + app2SurfaceId);
2195
2174
                compare(app2Delegate.stage, ApplicationInfoInterface.MainStage);
2196
2175
            }
2197
2176
 
2278
2257
        function test_superTabToCycleLauncher(data) {
2279
2258
            loadShell("desktop");
2280
2259
            shell.usageScenario = "desktop";
 
2260
            waitForRendering(shell);
2281
2261
            GSettingsController.setAutohideLauncher(!data.launcherLocked);
2282
2262
            waitForRendering(shell);
2283
2263
 
 
2264
            var stage = findChild(shell, "stage");
2284
2265
            var launcher = findChild(shell, "launcher");
2285
2266
            var launcherPanel = findChild(launcher, "launcherPanel");
2286
2267
            var firstAppInLauncher = LauncherModel.get(0).appId;
2287
 
 
2288
2268
            compare(launcher.state, data.launcherLocked ? "visible": "");
2289
2269
            compare(launcherPanel.highlightIndex, -2);
2290
2270
            compare(ApplicationManager.focusedApplicationId, "unity8-dash");
2291
2271
 
2292
2272
            // Use Super + Tab Tab to cycle to the first entry in the launcher
2293
 
            wait(1000);
2294
2273
            keyPress(Qt.Key_Super_L, Qt.MetaModifier);
2295
2274
            keyClick(Qt.Key_Tab);
2296
2275
            tryCompare(launcher, "state", "visible");
2311
2290
            tryCompare(launcher, "state", data.launcherLocked ? "visible" : "");
2312
2291
            tryCompare(launcherPanel, "highlightIndex", -2);
2313
2292
            tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
 
2293
            tryCompare(stage, "focus", true)
2314
2294
        }
2315
2295
 
2316
2296
        function test_longpressSuperOpensLauncherAndShortcutsOverlay() {
2371
2351
            waitForRendering(shell);
2372
2352
            var appContainer = findChild(shell, "appContainer");
2373
2353
            var launcher = findChild(shell, "launcher");
 
2354
            var launcherPanel = findChild(launcher, "launcherPanel");
2374
2355
 
2375
2356
            var appSurfaceId = topLevelSurfaceList.nextId;
2376
2357
            var app = ApplicationManager.startApplication("music-app");
2381
2362
            waitForRendering(shell);
2382
2363
 
2383
2364
            GSettingsController.setAutohideLauncher(true);
 
2365
            tryCompare(launcherPanel, "x", -launcher.panelWidth)
2384
2366
            waitForRendering(shell)
2385
2367
            var hiddenSize = appDelegate.width;
2386
2368
 
2387
2369
            GSettingsController.setAutohideLauncher(false);
 
2370
            tryCompare(launcherPanel, "x", 0)
2388
2371
            waitForRendering(shell)
2389
2372
            var shownSize = appDelegate.width;
2390
2373
 
2422
2405
 
2423
2406
        function test_inputEventsOnEdgesEndUpInAppSurface_data() {
2424
2407
            return [
2425
 
                { tag: "phone", repeaterName: "spreadRepeater" },
2426
 
                { tag: "tablet", repeaterName: "spreadRepeater" },
2427
 
                { tag: "desktop", repeaterName: "appRepeater" },
 
2408
                { tag: "phone" },
 
2409
                { tag: "tablet" },
 
2410
                { tag: "desktop" },
2428
2411
            ]
2429
2412
        }
2430
2413
 
2439
2422
            var app = ApplicationManager.startApplication("camera-app");
2440
2423
            waitUntilAppWindowIsFullyLoaded(appSurfaceId);
2441
2424
 
2442
 
            var appRepeater = findChild(shell, data.repeaterName);
 
2425
            var appRepeater = findChild(shell, "appRepeater");
2443
2426
            var topmostAppDelegate = appRepeater.itemAt(0);
2444
2427
            verify(topmostAppDelegate);
2445
2428
 
2714
2697
            tryCompare(topLevelSurfaceList, "count", countBeforeClose - 1);
2715
2698
            tryCompareFunction(function() { return ApplicationManager.focusedApplicationId; }, "calendar-app");
2716
2699
        }
 
2700
 
 
2701
        function test_oskDisplacesWindow_data() {
 
2702
            return [
 
2703
                {tag: "no need to displace", windowHeight: units.gu(10), windowY: units.gu(5), targetDisplacement: units.gu(5), oskEnabled: true},
 
2704
                {tag: "displace to top", windowHeight: units.gu(50), windowY: units.gu(10), targetDisplacement: PanelState.panelHeight, oskEnabled: true},
 
2705
                {tag: "displace to top", windowHeight: units.gu(50), windowY: units.gu(10), targetDisplacement: PanelState.panelHeight, oskEnabled: true},
 
2706
                {tag: "osk not on this screen", windowHeight: units.gu(40), windowY: units.gu(10), targetDisplacement: units.gu(10), oskEnabled: false},
 
2707
            ]
 
2708
        }
 
2709
 
 
2710
        function test_oskDisplacesWindow(data) {
 
2711
            loadShell("desktop");
 
2712
            shell.usageScenario = "desktop";
 
2713
            waitForRendering(shell);
 
2714
            swipeAwayGreeter();
 
2715
            shell.oskEnabled = data.oskEnabled;
 
2716
 
 
2717
            var oldOSKState = SurfaceManager.inputMethodSurface.state;
 
2718
            SurfaceManager.inputMethodSurface.state = Mir.RestoredState;
 
2719
            var appRepeater = findChild(shell, "appRepeater");
 
2720
            var dashAppDelegate = appRepeater.itemAt(0);
 
2721
            verify(dashAppDelegate);
 
2722
            dashAppDelegate.requestedHeight = data.windowHeight;
 
2723
            dashAppDelegate.requestedY = data.windowY;
 
2724
            SurfaceManager.inputMethodSurface.setInputBounds(Qt.rect(0, 0, 0, 0));
 
2725
            var initialY = dashAppDelegate.y;
 
2726
            print("intial", initialY, "panel", PanelState.panelHeight);
 
2727
            verify(initialY > PanelState.panelHeight);
 
2728
 
 
2729
            SurfaceManager.inputMethodSurface.setInputBounds(Qt.rect(0, root.height / 2, root.width, root.height / 2));
 
2730
            tryCompare(dashAppDelegate, "y", data.targetDisplacement);
 
2731
 
 
2732
            SurfaceManager.inputMethodSurface.setInputBounds(Qt.rect(0, 0, 0, 0));
 
2733
            tryCompare(dashAppDelegate, "y", initialY);
 
2734
            SurfaceManager.inputMethodSurface.state = oldOSKState;
 
2735
        }
 
2736
 
 
2737
        function test_cursorHidingWithFullscreenApp() {
 
2738
            loadShell("desktop");
 
2739
            shell.usageScenario = "desktop";
 
2740
            waitForRendering(shell);
 
2741
            swipeAwayGreeter();
 
2742
 
 
2743
            // load some fullscreen app
 
2744
            var cameraSurfaceId = topLevelSurfaceList.nextId;
 
2745
            var cameraApp = ApplicationManager.startApplication("camera-app");
 
2746
            waitUntilAppWindowIsFullyLoaded(cameraSurfaceId);
 
2747
 
 
2748
            var cursor = findChild(shell, "cursor");
 
2749
            verify(cursor);
 
2750
            tryCompare(cursor, "opacity", 1);
 
2751
 
 
2752
            // let the timer kick in and verify the cursor got hidden
 
2753
            wait(3000);
 
2754
            tryCompare(cursor, "opacity", 0);
 
2755
 
 
2756
            // simulate moving the mouse, check the cursor is visible again
 
2757
            cursor.mouseMoved();
 
2758
            tryCompare(cursor, "opacity", 1);
 
2759
 
 
2760
            // let the timer kick in again and verify the cursor got hidden
 
2761
            wait(3000);
 
2762
            tryCompare(cursor, "opacity", 0);
 
2763
        }
 
2764
 
 
2765
        function test_launcherEnabledSetting_data() {
 
2766
            return [
 
2767
                {tag: "launcher enabled", enabled: true},
 
2768
                {tag: "launcher disabled", enabled: false}
 
2769
            ]
 
2770
        }
 
2771
 
 
2772
        function test_launcherEnabledSetting(data) {
 
2773
            loadShell("phone");
 
2774
 
 
2775
            GSettingsController.setEnableLauncher(data.enabled);
 
2776
 
 
2777
            var launcher = findChild(shell, "launcher");
 
2778
            compare(launcher.available, data.enabled);
 
2779
 
 
2780
            GSettingsController.setEnableLauncher(true);
 
2781
        }
2717
2782
    }
2718
2783
}