@@ -414,7 +414,7 @@ Rectangle {
414 // Open an application and focus
414 // Open an application and focus
415 waitUntilApplicationWindowIsFullyVisible(app);
415 waitUntilApplicationWindowIsFullyVisible(app);
416 ApplicationManager.focusApplication(app);
416 ApplicationManager.focusApplication(app);
417− tryCompare(app.session.surface, "activeFocus", true);
417+ tryCompare(app.session.lastSurface, "activeFocus", true);
419 notifications.model = mockNotificationsModel;
419 notifications.model = mockNotificationsModel;
@@ -436,7 +436,7 @@ Rectangle {
436 waitForRendering(notification);
436 waitForRendering(notification);
438 // Make sure activeFocus went away from the app window
438 // Make sure activeFocus went away from the app window
439− tryCompare(app.session.surface, "activeFocus", false);
439+ tryCompare(app.session.lastSurface, "activeFocus", false);
440 tryCompare(stage, "interactive", false);
440 tryCompare(stage, "interactive", false);
442 // Clicking the button should dismiss the notification and return focus
442 // Clicking the button should dismiss the notification and return focus
@@ -444,7 +444,7 @@ Rectangle {
444 mouseClick(buttonAccept);
444 mouseClick(buttonAccept);
446 // Make sure we're back to normal
446 // Make sure we're back to normal
447− tryCompare(app.session.surface, "activeFocus", true);
447+ tryCompare(app.session.lastSurface, "activeFocus", true);
448 compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
448 compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
@@ -454,8 +454,8 @@ Rectangle {
454 hints: {"x-canonical-private-affirmative-tint": "true"},
454 hints: {"x-canonical-private-affirmative-tint": "true"},
455 summary: "Tom Ato",
455 summary: "Tom Ato",
456 body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
456 body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
457− icon: "../graphics/avatars/funky.png",
457+ icon: "../../tests/graphics/avatars/funky.png",
458− secondaryIcon: "../graphics/applicationIcons/facebook.png",
458+ secondaryIcon: "../../tests/graphics/applicationIcons/facebook.png",
459 actions: [{ id: "ok_id", label: "Ok"},
459 actions: [{ id: "ok_id", label: "Ok"},
460 { id: "cancel_id", label: "Cancel"},
460 { id: "cancel_id", label: "Cancel"},
461 { id: "notreally_id", label: "Not really"},
461 { id: "notreally_id", label: "Not really"},
@@ -776,7 +776,7 @@ Rectangle {
776 var app = ApplicationManager.startApplication("dialer-app");
776 var app = ApplicationManager.startApplication("dialer-app");
777 waitUntilAppWindowIsFullyLoaded(app);
777 waitUntilAppWindowIsFullyLoaded(app);
779− tryCompare(app.session.surface, "activeFocus", true);
779+ tryCompare(app.session.lastSurface, "activeFocus", true);
781 // Drag the indicators panel half-open
781 // Drag the indicators panel half-open
782 var touchX = shell.width / 2;
782 var touchX = shell.width / 2;
@@ -787,7 +787,7 @@ Rectangle {
787 true /* beginTouch */, false /* endTouch */);
787 true /* beginTouch */, false /* endTouch */);
788 verify(indicators.partiallyOpened);
788 verify(indicators.partiallyOpened);
790− tryCompare(app.session.surface, "activeFocus", false);
790+ tryCompare(app.session.lastSurface, "activeFocus", false);
792 // And finish getting it open
792 // And finish getting it open
793 touchFlick(indicators,
793 touchFlick(indicators,
@@ -796,11 +796,11 @@ Rectangle {
796 false /* beginTouch */, true /* endTouch */);
796 false /* beginTouch */, true /* endTouch */);
797 tryCompare(indicators, "fullyOpened", true);
797 tryCompare(indicators, "fullyOpened", true);
799− tryCompare(app.session.surface, "activeFocus", false);
799+ tryCompare(app.session.lastSurface, "activeFocus", false);
801 dragToCloseIndicatorsPanel();
801 dragToCloseIndicatorsPanel();
803− tryCompare(app.session.surface, "activeFocus", true);
803+ tryCompare(app.session.lastSurface, "activeFocus", true);
806 function test_launchedAppHasActiveFocus_data() {
806 function test_launchedAppHasActiveFocus_data() {
@@ -821,9 +821,9 @@ Rectangle {
821 verify(webApp);
821 verify(webApp);
822 waitUntilAppSurfaceShowsUp("webbrowser-app")
822 waitUntilAppSurfaceShowsUp("webbrowser-app")
824− verify(webApp.session.surface);
824+ verify(webApp.session.lastSurface);
826− tryCompare(webApp.session.surface, "activeFocus", true);
826+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
829 function test_launchedAppKeepsActiveFocusOnUsageModeChange() {
829 function test_launchedAppKeepsActiveFocusOnUsageModeChange() {
@@ -834,9 +834,9 @@ Rectangle {
834 verify(webApp);
834 verify(webApp);
835 waitUntilAppSurfaceShowsUp("webbrowser-app")
835 waitUntilAppSurfaceShowsUp("webbrowser-app")
837− verify(webApp.session.surface);
837+ verify(webApp.session.lastSurface);
839− tryCompare(webApp.session.surface, "activeFocus", true);
839+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
841 shell.usageScenario = "desktop";
841 shell.usageScenario = "desktop";
@@ -846,7 +846,7 @@ Rectangle {
846 verify(desktopWindow);
846 verify(desktopWindow);
849− tryCompare(webApp.session.surface, "activeFocus", true);
849+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
851 shell.usageScenario = "tablet";
851 shell.usageScenario = "tablet";
@@ -856,7 +856,7 @@ Rectangle {
856 verify(desktopWindow);
856 verify(desktopWindow);
859− tryCompare(webApp.session.surface, "activeFocus", true);
859+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
862 function waitUntilAppSurfaceShowsUp(appId) {
862 function waitUntilAppSurfaceShowsUp(appId) {
@@ -977,7 +977,7 @@ Rectangle {
978 var app = ApplicationManager.startApplication("dialer-app");
978 var app = ApplicationManager.startApplication("dialer-app");
979 // wait until the app is fully loaded (ie, real surface replaces splash screen)
979 // wait until the app is fully loaded (ie, real surface replaces splash screen)
980− tryCompareFunction(function() { return app.session !== null && app.session.surface !== null }, true);
980+ tryCompareFunction(function() { return app.session !== null && app.session.lastSurface !== null }, true);
982 // Minimize the application we just launched
982 // Minimize the application we just launched
983 swipeFromLeftEdge(shell.width * 0.75);
983 swipeFromLeftEdge(shell.width * 0.75);
@@ -1414,9 +1414,9 @@ Rectangle {
1414 waitUntilAppWindowIsFullyLoaded(app3);
1414 waitUntilAppWindowIsFullyLoaded(app3);
1416 // Do a quick alt-tab and see if focus changes
1416 // Do a quick alt-tab and see if focus changes
1417− tryCompare(app3.session.surface, "activeFocus", true)
1417+ tryCompare(app3.session.lastSurface, "activeFocus", true)
1418 keyClick(Qt.Key_Tab, Qt.ControlModifier)
1418 keyClick(Qt.Key_Tab, Qt.ControlModifier)
1419− tryCompare(app2.session.surface, "activeFocus", true)
1419+ tryCompare(app2.session.lastSurface, "activeFocus", true)
1421 var desktopSpread = findChild(shell, "spread")
1421 var desktopSpread = findChild(shell, "spread")
@@ -1432,7 +1432,7 @@ Rectangle {
1432 tryCompare(desktopSpread, "state", "")
1432 tryCompare(desktopSpread, "state", "")
1434 // Focus should have switched back now
1434 // Focus should have switched back now
1435− tryCompare(app3.session.surface, "activeFocus", true)
1435+ tryCompare(app3.session.lastSurface, "activeFocus", true)
1438 function test_altTabWrapAround() {
1438 function test_altTabWrapAround() {
@@ -1481,7 +1481,7 @@ Rectangle {
1481 tryCompare(desktopSpread, "state", "")
1481 tryCompare(desktopSpread, "state", "")
1483 // Make sure that after wrapping around once, we have the same one focused as at the beginning
1483 // Make sure that after wrapping around once, we have the same one focused as at the beginning
1484− tryCompare(focused.session.surface, "activeFocus", true)
1484+ tryCompare(focused.session.lastSurface, "activeFocus", true)
1487 function test_altBackTabNavigation() {
1487 function test_altBackTabNavigation() {
@@ -1730,6 +1730,7 @@ Rectangle {
1730 tryCompare(desktopSpread, "state", "altTab")
1730 tryCompare(desktopSpread, "state", "altTab")
1732 revealLauncherByEdgePushWithMouse();
1732 revealLauncherByEdgePushWithMouse();
1733+ tryCompare(launcher, "x", 0);
1733 waitForRendering(shell)
1734 waitForRendering(shell)
1735 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
1736 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
@@ -1857,21 +1858,28 @@ Rectangle {
1857 loadShell(data.formFactor);
1858 loadShell(data.formFactor);
1858 shell.usageScenario = data.usageScenario;
1859 shell.usageScenario = data.usageScenario;
1861+ // Add two main stage apps, the second in order to suspend the first.
1862+ // LibreOffice has isTouchApp set to false by our mocks.
1860 var app1 = ApplicationManager.startApplication("libreoffice");
1863 var app1 = ApplicationManager.startApplication("libreoffice");
1861 waitUntilAppWindowIsFullyLoaded(app1);
1864 waitUntilAppWindowIsFullyLoaded(app1);
1862− var app2 = ApplicationManager.startApplication("dialer-app");
1865+ var app2 = ApplicationManager.startApplication("gallery-app");
1863 waitUntilAppWindowIsFullyLoaded(app2);
1866 waitUntilAppWindowIsFullyLoaded(app2);
1865− // Make sure app1 is unfocused but still running
1868+ // Sanity checking
1866− compare(app1.session.surface.activeFocus, false);
1869+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1867− compare(app1.isTouchApp, false); // sanity check our mock, which sets this for us
1870+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1871+ verify(!app1.isTouchApp);
1872+ verify(!app1.session.lastSurface.activeFocus);
1874+ // Make sure app1 is exempt with a requested suspend
1875+ verify(app1.exemptFromLifecycle);
1868− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1876+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
1871 function test_lifecyclePolicyExemption_data() {
1879 function test_lifecyclePolicyExemption_data() {
1872 return [
1880 return [
1873− {tag: "phone", formFactor: "phone", usageScenario: "phone", suspendsApps: true},
1881+ {tag: "phone", formFactor: "phone", usageScenario: "phone"},
1874− {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", suspendsApps: true}
1882+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet"}
@@ -1881,14 +1889,20 @@ Rectangle {
1882 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
1890 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
1892+ // Add two main stage apps, the second in order to suspend the first
1884 var app1 = ApplicationManager.startApplication("webbrowser-app");
1893 var app1 = ApplicationManager.startApplication("webbrowser-app");
1885 waitUntilAppWindowIsFullyLoaded(app1);
1894 waitUntilAppWindowIsFullyLoaded(app1);
1886− var app2 = ApplicationManager.startApplication("dialer-app");
1895+ var app2 = ApplicationManager.startApplication("gallery-app");
1887 waitUntilAppWindowIsFullyLoaded(app2);
1896 waitUntilAppWindowIsFullyLoaded(app2);
1889− // Make sure app1 is unfocused but still running
1898+ // Sanity checking
1890− compare(app1.session.surface.activeFocus, false);
1899+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1900+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1901+ verify(!app1.session.lastSurface.activeFocus);
1903+ // Make sure app1 is exempt with a requested suspend
1904+ verify(app1.exemptFromLifecycle);
1891− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1905+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
1894 function test_switchToStagedForcesLegacyAppClosing_data() {
1908 function test_switchToStagedForcesLegacyAppClosing_data() {