@@ -322,8 +322,9 @@ Rectangle {
323 function loadDesktopShellWithApps() {
323 function loadDesktopShellWithApps() {
324 loadShell("desktop");
324 loadShell("desktop");
325+ waitForRendering(shell)
325 shell.usageScenario = "desktop"
326 shell.usageScenario = "desktop"
326− waitForRendering(root)
327+ waitForRendering(shell)
327 var app1 = ApplicationManager.startApplication("dialer-app")
328 var app1 = ApplicationManager.startApplication("dialer-app")
328 var app2 = ApplicationManager.startApplication("webbrowser-app")
329 var app2 = ApplicationManager.startApplication("webbrowser-app")
329 var app3 = ApplicationManager.startApplication("camera-app")
330 var app3 = ApplicationManager.startApplication("camera-app")
@@ -376,6 +377,8 @@ Rectangle {
376 LightDM.Greeter.authenticate(""); // reset greeter
377 LightDM.Greeter.authenticate(""); // reset greeter
378 sessionSpy.clear();
379 sessionSpy.clear();
381+ GSettingsController.setLifecycleExemptAppids([]);
381 function killApps() {
384 function killApps() {
@@ -1407,17 +1410,18 @@ Rectangle {
1407 keyClick(Qt.Key_Tab, Qt.ControlModifier)
1410 keyClick(Qt.Key_Tab, Qt.ControlModifier)
1408 tryCompare(app2.session.surface, "activeFocus", true)
1411 tryCompare(app2.session.surface, "activeFocus", true)
1413+ var desktopSpread = findChild(shell, "spread")
1411− tryCompare(desktopStage, "state", "")
1415+ tryCompare(desktopSpread, "state", "")
1413 // Just press Alt, make sure the spread comes up
1417 // Just press Alt, make sure the spread comes up
1414 keyPress(Qt.Key_Control);
1418 keyPress(Qt.Key_Control);
1415 keyClick(Qt.Key_Tab);
1419 keyClick(Qt.Key_Tab);
1416− tryCompare(desktopStage, "state", "altTab")
1420+ tryCompare(desktopSpread, "state", "altTab")
1418 // Release control, check if spread disappears
1422 // Release control, check if spread disappears
1419 keyRelease(Qt.Key_Control)
1423 keyRelease(Qt.Key_Control)
1420− tryCompare(desktopStage, "state", "")
1424+ tryCompare(desktopSpread, "state", "")
1422 // Focus should have switched back now
1426 // Focus should have switched back now
1423 tryCompare(app3.session.surface, "activeFocus", true)
1427 tryCompare(app3.session.surface, "activeFocus", true)
@@ -1429,41 +1433,44 @@ Rectangle {
1429 var desktopStage = findChild(shell, "stage");
1433 var desktopStage = findChild(shell, "stage");
1430 verify(desktopStage !== null)
1434 verify(desktopStage !== null)
1436+ var desktopSpread = findChild(shell, "spread");
1437+ verify(desktopSpread !== null)
1432− var appContainer = findInvisibleChild(shell, "appContainer")
1439+ var spreadContainer = findInvisibleChild(shell, "spreadContainer")
1433− verify(appContainer !== null)
1440+ verify(spreadContainer !== null)
1435− var appRepeater = findInvisibleChild(shell, "appRepeater")
1442+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater")
1436− verify(appRepeater !== null)
1443+ verify(spreadRepeater !== null)
1438 // remember the focused appId
1445 // remember the focused appId
1439 var focused = ApplicationManager.get(ApplicationManager.findApplication(ApplicationManager.focusedApplicationId));
1446 var focused = ApplicationManager.get(ApplicationManager.findApplication(ApplicationManager.focusedApplicationId));
1441− tryCompare(desktopStage, "state", "")
1448+ tryCompare(desktopSpread, "state", "")
1443 // Just press Alt, make sure the spread comes up
1450 // Just press Alt, make sure the spread comes up
1444 keyPress(Qt.Key_Control);
1451 keyPress(Qt.Key_Control);
1445 keyClick(Qt.Key_Tab);
1452 keyClick(Qt.Key_Tab);
1446− tryCompare(desktopStage, "state", "altTab")
1453+ tryCompare(desktopSpread, "state", "altTab")
1447− tryCompare(appRepeater, "highlightedIndex", 1)
1454+ tryCompare(spreadRepeater, "highlightedIndex", 1)
1448 waitForRendering(shell)
1455 waitForRendering(shell)
1450 // Now press and hold Tab, make sure the highlight moves all the way but stops at the last one
1457 // Now press and hold Tab, make sure the highlight moves all the way but stops at the last one
1451 // We can't simulate a pressed key with keyPress() currently, so let's inject the events
1458 // We can't simulate a pressed key with keyPress() currently, so let's inject the events
1452 // at API level. Jump for 10 times, verify that it's still at the last one and didn't wrap around.
1459 // at API level. Jump for 10 times, verify that it's still at the last one and didn't wrap around.
1453 for (var i = 0; i < 10; i++) {
1460 for (var i = 0; i < 10; i++) {
1454− appContainer.selectNext(true); // true == isAutoRepeat
1461+ desktopSpread.selectNext(true); // true == isAutoRepeat
1455 wait(0); // Trigger the event loop to make sure all the things happen
1462 wait(0); // Trigger the event loop to make sure all the things happen
1457− tryCompare(appRepeater, "highlightedIndex", 6)
1464+ tryCompare(spreadRepeater, "highlightedIndex", 6)
1459 // Now release it once, and verify that it does wrap around with an additional Tab press
1466 // Now release it once, and verify that it does wrap around with an additional Tab press
1460 keyRelease(Qt.Key_Tab);
1467 keyRelease(Qt.Key_Tab);
1461 keyClick(Qt.Key_Tab);
1468 keyClick(Qt.Key_Tab);
1462− tryCompare(appRepeater, "highlightedIndex", 0)
1469+ tryCompare(spreadRepeater, "highlightedIndex", 0)
1464 // Release control, check if spread disappears
1471 // Release control, check if spread disappears
1465 keyRelease(Qt.Key_Control)
1472 keyRelease(Qt.Key_Control)
1466− tryCompare(desktopStage, "state", "")
1473+ tryCompare(desktopSpread, "state", "")
1468 // Make sure that after wrapping around once, we have the same one focused as at the beginning
1475 // Make sure that after wrapping around once, we have the same one focused as at the beginning
1469 tryCompare(focused.session.surface, "activeFocus", true)
1476 tryCompare(focused.session.surface, "activeFocus", true)
@@ -1472,30 +1479,30 @@ Rectangle {
1472 function test_altBackTabNavigation() {
1479 function test_altBackTabNavigation() {
1473 loadDesktopShellWithApps();
1480 loadDesktopShellWithApps();
1475− var appRepeater = findInvisibleChild(shell, "appRepeater");
1482+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1476− verify(appRepeater !== null);
1483+ verify(spreadRepeater !== null);
1478 keyPress(Qt.Key_Control)
1485 keyPress(Qt.Key_Control)
1479 keyClick(Qt.Key_Tab);
1486 keyClick(Qt.Key_Tab);
1480− tryCompare(appRepeater, "highlightedIndex", 1);
1487+ tryCompare(spreadRepeater, "highlightedIndex", 1);
1482 keyClick(Qt.Key_Tab);
1489 keyClick(Qt.Key_Tab);
1483− tryCompare(appRepeater, "highlightedIndex", 2);
1490+ tryCompare(spreadRepeater, "highlightedIndex", 2);
1485 keyClick(Qt.Key_Tab);
1492 keyClick(Qt.Key_Tab);
1486− tryCompare(appRepeater, "highlightedIndex", 3);
1493+ tryCompare(spreadRepeater, "highlightedIndex", 3);
1488 keyClick(Qt.Key_Tab);
1495 keyClick(Qt.Key_Tab);
1489− tryCompare(appRepeater, "highlightedIndex", 4);
1496+ tryCompare(spreadRepeater, "highlightedIndex", 4);
1491 keyClick(Qt.Key_Backtab);
1498 keyClick(Qt.Key_Backtab);
1492− tryCompare(appRepeater, "highlightedIndex", 3);
1499+ tryCompare(spreadRepeater, "highlightedIndex", 3);
1494 keyClick(Qt.Key_Backtab);
1501 keyClick(Qt.Key_Backtab);
1495− tryCompare(appRepeater, "highlightedIndex", 2);
1502+ tryCompare(spreadRepeater, "highlightedIndex", 2);
1497 keyClick(Qt.Key_Backtab);
1504 keyClick(Qt.Key_Backtab);
1498− tryCompare(appRepeater, "highlightedIndex", 1);
1505+ tryCompare(spreadRepeater, "highlightedIndex", 1);
1500 keyRelease(Qt.Key_Control);
1507 keyRelease(Qt.Key_Control);
@@ -1503,20 +1510,20 @@ Rectangle {
1503 function test_highlightFollowsMouse() {
1510 function test_highlightFollowsMouse() {
1504 loadDesktopShellWithApps()
1511 loadDesktopShellWithApps()
1506− var appRepeater = findInvisibleChild(shell, "appRepeater");
1513+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1507− verify(appRepeater !== null);
1514+ verify(spreadRepeater !== null);
1509 keyPress(Qt.Key_Control)
1516 keyPress(Qt.Key_Control)
1510 keyClick(Qt.Key_Tab);
1517 keyClick(Qt.Key_Tab);
1512− tryCompare(appRepeater, "highlightedIndex", 1);
1519+ tryCompare(spreadRepeater, "highlightedIndex", 1);
1514 var x = 0;
1521 var x = 0;
1515 var y = shell.height * .75;
1522 var y = shell.height * .75;
1516 mouseMove(shell, x, y)
1523 mouseMove(shell, x, y)
1518 for (var i = 0; i < 7; i++) {
1525 for (var i = 0; i < 7; i++) {
1519− while (appRepeater.highlightedIndex != i && x <= 4000) {
1526+ while (spreadRepeater.highlightedIndex != i && x <= 4000) {
1521 mouseMove(shell, x, y)
1528 mouseMove(shell, x, y)
1522 wait(0); // spin the loop so bindings get evaluated
1529 wait(0); // spin the loop so bindings get evaluated
@@ -1531,8 +1538,8 @@ Rectangle {
1531 function test_closeFromSpread() {
1538 function test_closeFromSpread() {
1532 loadDesktopShellWithApps()
1539 loadDesktopShellWithApps()
1534− var appRepeater = findInvisibleChild(shell, "appRepeater");
1541+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1535− verify(appRepeater !== null);
1542+ verify(spreadRepeater !== null);
1537 keyPress(Qt.Key_Control)
1544 keyPress(Qt.Key_Control)
1538 keyClick(Qt.Key_Tab);
1545 keyClick(Qt.Key_Tab);
@@ -1540,14 +1547,14 @@ Rectangle {
1540 appRemovedSpy.clear();
1547 appRemovedSpy.clear();
1542 var closedAppId = ApplicationManager.get(2).appId;
1549 var closedAppId = ApplicationManager.get(2).appId;
1543− var appDelegate2 = appRepeater.itemAt(2);
1550+ var spreadDelegate2 = spreadRepeater.itemAt(2);
1544− var closeMouseArea = findChild(appDelegate2, "closeMouseArea");
1551+ var closeMouseArea = findChild(spreadDelegate2, "closeMouseArea");
1546 // Move the mosue over tile 2 and verify the close button becomes visible
1553 // Move the mosue over tile 2 and verify the close button becomes visible
1547 var x = 0;
1554 var x = 0;
1548 var y = shell.height * .5;
1555 var y = shell.height * .5;
1549 mouseMove(shell, x, y)
1556 mouseMove(shell, x, y)
1550− while (appRepeater.highlightedIndex !== 2 && x <= 4000) {
1557+ while (spreadRepeater.highlightedIndex !== 2 && x <= 4000) {
1552 mouseMove(shell, x, y)
1559 mouseMove(shell, x, y)
1553 wait(0); // spin the loop so bindings get evaluated
1560 wait(0); // spin the loop so bindings get evaluated
@@ -1574,32 +1581,35 @@ Rectangle {
1574 function test_selectFromSpreadWithMouse(data) {
1581 function test_selectFromSpreadWithMouse(data) {
1575 loadDesktopShellWithApps()
1582 loadDesktopShellWithApps()
1584+ var stage = findChild(shell, "stage");
1585+ var spread = findChild(stage, "spread");
1586+ waitForRendering(spread)
1577− var appRepeater = findInvisibleChild(shell, "appRepeater");
1588+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1578− verify(appRepeater !== null);
1589+ verify(spreadRepeater !== null);
1580 keyPress(Qt.Key_Control)
1591 keyPress(Qt.Key_Control)
1581 keyClick(Qt.Key_Tab);
1592 keyClick(Qt.Key_Tab);
1583 var focusAppId = ApplicationManager.get(2).appId;
1594 var focusAppId = ApplicationManager.get(2).appId;
1584− var appDelegate2 = appRepeater.itemAt(2);
1595+ var spreadDelegate2 = spreadRepeater.itemAt(2);
1585− var decoratedWindow = findChild(appDelegate2, "decoratedWindow");
1596+ var clippedSpreadDelegate = findChild(spreadDelegate2, "clippedSpreadDelegate");
1586− var stage = findChild(shell, "stage");
1588− tryCompare(stage, "state", "altTab");
1598+ tryCompare(spread, "state", "altTab");
1590 // Move the mouse over tile 2 and verify the highlight becomes visible
1600 // Move the mouse over tile 2 and verify the highlight becomes visible
1591 var x = 0;
1601 var x = 0;
1592 var y = shell.height * (data.tileInfo ? .95 : 0.5)
1602 var y = shell.height * (data.tileInfo ? .95 : 0.5)
1593 mouseMove(shell, x, y)
1603 mouseMove(shell, x, y)
1594− while (appRepeater.highlightedIndex !== 2 && x <= 4000) {
1604+ while (spreadRepeater.highlightedIndex !== 2 && x <= 4000) {
1596 mouseMove(shell, x, y)
1606 mouseMove(shell, x, y)
1597 wait(0); // spin the loop so bindings get evaluated
1607 wait(0); // spin the loop so bindings get evaluated
1599− tryCompare(decoratedWindow, "highlightShown", true);
1609+ tryCompare(clippedSpreadDelegate, "highlightShown", true);
1601 // Click the tile
1611 // Click the tile
1602− mouseClick(decoratedWindow, decoratedWindow.width / 2, decoratedWindow.height / 2)
1612+ mouseClick(clippedSpreadDelegate, clippedSpreadDelegate.width / 2, clippedSpreadDelegate.height / 2)
1604 // Verify that we left the spread and app2 is the focused one now
1614 // Verify that we left the spread and app2 is the focused one now
1605 tryCompare(stage, "state", "");
1615 tryCompare(stage, "state", "");
@@ -1618,7 +1628,6 @@ Rectangle {
1618 keyClick(Qt.Key_Tab);
1628 keyClick(Qt.Key_Tab);
1620 var spreadFlickable = findChild(shell, "spreadFlickable")
1630 var spreadFlickable = findChild(shell, "spreadFlickable")
1621− print("have flickable", spreadFlickable, spreadFlickable.contentX)
1623 compare(spreadFlickable.contentX, 0);
1632 compare(spreadFlickable.contentX, 0);
@@ -1643,5 +1652,102 @@ Rectangle {
1644 keyRelease(Qt.Key_Control);
1653 keyRelease(Qt.Key_Control);
1656+ // This makes sure the hoverMouseArea is set to invisible AND disabled
1657+ // when not needed. Otherwise it'll eat mouse hover events for the rest of the shell/apps
1658+ function test_hoverMouseAreaDisabledAndInvisible() {
1659+ loadDesktopShellWithApps()
1661+ var hoverMouseArea = findChild(shell, "hoverMouseArea");
1662+ tryCompare(hoverMouseArea, "enabled", false)
1663+ tryCompare(hoverMouseArea, "visible", false)
1665+ keyPress(Qt.Key_Control)
1666+ keyClick(Qt.Key_Tab);
1668+ tryCompare(hoverMouseArea, "enabled", true)
1669+ tryCompare(hoverMouseArea, "visible", true)
1671+ keyRelease(Qt.Key_Control)
1673+ tryCompare(hoverMouseArea, "enabled", false)
1674+ tryCompare(hoverMouseArea, "visible", false)
1677+ function test_workspacePreviewsHighlightedApp() {
1678+ loadDesktopShellWithApps()
1680+ var targetZ = ApplicationManager.count + 1;
1682+ var spreadRepeater = findInvisibleChild(shell, "spreadRepeater");
1683+ verify(spreadRepeater !== null);
1685+ var appRepeater = findInvisibleChild(shell, "appRepeater");
1686+ verify(appRepeater !== null);
1688+ keyPress(Qt.Key_Control)
1689+ keyClick(Qt.Key_Tab);
1691+ tryCompare(spreadRepeater, "highlightedIndex", 1);
1692+ tryCompare(appRepeater.itemAt(1), "z", targetZ)
1695+ var y = shell.height * .75;
1696+ mouseMove(shell, x, y)
1698+ for (var i = 0; i < 7; i++) {
1699+ while (spreadRepeater.highlightedIndex != i && x <= 4000) {
1700+ tryCompare(appRepeater.itemAt(spreadRepeater.highlightedIndex), "z", targetZ)
1702+ mouseMove(shell, x, y)
1703+ wait(0); // spin the loop so bindings get evaluated
1709+ keyRelease(Qt.Key_Control);
1712+ function test_focusAppFromLauncherExitsSpread() {
1713+ loadDesktopShellWithApps()
1715+ var desktopSpread = findChild(shell, "spread");
1716+ var launcher = findChild(shell, "launcher");
1717+ var bfb = findChild(launcher, "buttonShowDashHome");
1719+ keyPress(Qt.Key_Control)
1720+ keyClick(Qt.Key_Tab);
1723+ tryCompare(desktopSpread, "state", "altTab")
1725+ mouseMove(shell, 0, 0);
1726+ tryCompare(launcher, "state", "visibleTemporary")
1728+ mouseClick(bfb, bfb.width / 2, bfb.height / 2)
1729+ tryCompare(launcher, "state", "")
1730+ tryCompare(desktopSpread, "state", "")
1732+ tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash")
1734+ keyRelease(Qt.Key_Control);
1737+ function test_lifecyclePolicy() {
1738+ loadShell("desktop");
1740+ GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
1742+ var app1 = ApplicationManager.startApplication("camera-app");
1743+ tryCompare(app1, "canSuspend", true);
1745+ var app2 = ApplicationManager.startApplication("webbrowser-app");
1746+ tryCompare(app2, "canSuspend", false);
1748+ var app3 = ApplicationManager.startApplication("libreoffice");
1749+ compare(app3.isTouchApp, false); // sanity check our mock, which sets this for us
1750+ tryCompare(app3, "canSuspend", false);