@@ -423,7 +423,7 @@ Rectangle {
423 // Open an application and focus
423 // Open an application and focus
424 waitUntilApplicationWindowIsFullyVisible(app);
424 waitUntilApplicationWindowIsFullyVisible(app);
425 ApplicationManager.focusApplication(app);
425 ApplicationManager.focusApplication(app);
426− tryCompare(app.session.surface, "activeFocus", true);
426+ tryCompare(app.session.lastSurface, "activeFocus", true);
428 notifications.model = mockNotificationsModel;
428 notifications.model = mockNotificationsModel;
@@ -445,7 +445,7 @@ Rectangle {
445 waitForRendering(notification);
445 waitForRendering(notification);
447 // Make sure activeFocus went away from the app window
447 // Make sure activeFocus went away from the app window
448− tryCompare(app.session.surface, "activeFocus", false);
448+ tryCompare(app.session.lastSurface, "activeFocus", false);
449 tryCompare(stage, "interactive", false);
449 tryCompare(stage, "interactive", false);
451 // Clicking the button should dismiss the notification and return focus
451 // Clicking the button should dismiss the notification and return focus
@@ -453,7 +453,7 @@ Rectangle {
453 mouseClick(buttonAccept);
453 mouseClick(buttonAccept);
455 // Make sure we're back to normal
455 // Make sure we're back to normal
456− tryCompare(app.session.surface, "activeFocus", true);
456+ tryCompare(app.session.lastSurface, "activeFocus", true);
457 compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
457 compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
@@ -463,8 +463,8 @@ Rectangle {
463 hints: {"x-canonical-private-affirmative-tint": "true"},
463 hints: {"x-canonical-private-affirmative-tint": "true"},
464 summary: "Tom Ato",
464 summary: "Tom Ato",
465 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.",
465 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.",
466− icon: "../graphics/avatars/funky.png",
466+ icon: "../../tests/graphics/avatars/funky.png",
467− secondaryIcon: "../graphics/applicationIcons/facebook.png",
467+ secondaryIcon: "../../tests/graphics/applicationIcons/facebook.png",
468 actions: [{ id: "ok_id", label: "Ok"},
468 actions: [{ id: "ok_id", label: "Ok"},
469 { id: "cancel_id", label: "Cancel"},
469 { id: "cancel_id", label: "Cancel"},
470 { id: "notreally_id", label: "Not really"},
470 { id: "notreally_id", label: "Not really"},
@@ -785,7 +785,7 @@ Rectangle {
785 var app = ApplicationManager.startApplication("dialer-app");
785 var app = ApplicationManager.startApplication("dialer-app");
786 waitUntilAppWindowIsFullyLoaded(app);
786 waitUntilAppWindowIsFullyLoaded(app);
788− tryCompare(app.session.surface, "activeFocus", true);
788+ tryCompare(app.session.lastSurface, "activeFocus", true);
790 // Drag the indicators panel half-open
790 // Drag the indicators panel half-open
791 var touchX = shell.width / 2;
791 var touchX = shell.width / 2;
@@ -796,7 +796,7 @@ Rectangle {
796 true /* beginTouch */, false /* endTouch */);
796 true /* beginTouch */, false /* endTouch */);
797 verify(indicators.partiallyOpened);
797 verify(indicators.partiallyOpened);
799− tryCompare(app.session.surface, "activeFocus", false);
799+ tryCompare(app.session.lastSurface, "activeFocus", false);
801 // And finish getting it open
801 // And finish getting it open
802 touchFlick(indicators,
802 touchFlick(indicators,
@@ -805,11 +805,11 @@ Rectangle {
805 false /* beginTouch */, true /* endTouch */);
805 false /* beginTouch */, true /* endTouch */);
806 tryCompare(indicators, "fullyOpened", true);
806 tryCompare(indicators, "fullyOpened", true);
808− tryCompare(app.session.surface, "activeFocus", false);
808+ tryCompare(app.session.lastSurface, "activeFocus", false);
810 dragToCloseIndicatorsPanel();
810 dragToCloseIndicatorsPanel();
812− tryCompare(app.session.surface, "activeFocus", true);
812+ tryCompare(app.session.lastSurface, "activeFocus", true);
815 function test_launchedAppHasActiveFocus_data() {
815 function test_launchedAppHasActiveFocus_data() {
@@ -830,9 +830,9 @@ Rectangle {
830 verify(webApp);
830 verify(webApp);
831 waitUntilAppSurfaceShowsUp("webbrowser-app")
831 waitUntilAppSurfaceShowsUp("webbrowser-app")
833− verify(webApp.session.surface);
833+ verify(webApp.session.lastSurface);
835− tryCompare(webApp.session.surface, "activeFocus", true);
835+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
838 function test_launchedAppKeepsActiveFocusOnUsageModeChange() {
838 function test_launchedAppKeepsActiveFocusOnUsageModeChange() {
@@ -843,9 +843,9 @@ Rectangle {
843 verify(webApp);
843 verify(webApp);
844 waitUntilAppSurfaceShowsUp("webbrowser-app")
844 waitUntilAppSurfaceShowsUp("webbrowser-app")
846− verify(webApp.session.surface);
846+ verify(webApp.session.lastSurface);
848− tryCompare(webApp.session.surface, "activeFocus", true);
848+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
850 shell.usageScenario = "desktop";
850 shell.usageScenario = "desktop";
@@ -855,7 +855,7 @@ Rectangle {
855 verify(desktopWindow);
855 verify(desktopWindow);
858− tryCompare(webApp.session.surface, "activeFocus", true);
858+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
860 shell.usageScenario = "tablet";
860 shell.usageScenario = "tablet";
@@ -865,7 +865,7 @@ Rectangle {
865 verify(desktopWindow);
865 verify(desktopWindow);
868− tryCompare(webApp.session.surface, "activeFocus", true);
868+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
871 function waitUntilAppSurfaceShowsUp(appId) {
871 function waitUntilAppSurfaceShowsUp(appId) {
@@ -986,7 +986,7 @@ Rectangle {
987 var app = ApplicationManager.startApplication("dialer-app");
987 var app = ApplicationManager.startApplication("dialer-app");
988 // wait until the app is fully loaded (ie, real surface replaces splash screen)
988 // wait until the app is fully loaded (ie, real surface replaces splash screen)
989− tryCompareFunction(function() { return app.session !== null && app.session.surface !== null }, true);
989+ tryCompareFunction(function() { return app.session !== null && app.session.lastSurface !== null }, true);
991 // Minimize the application we just launched
991 // Minimize the application we just launched
992 swipeFromLeftEdge(shell.width * 0.75);
992 swipeFromLeftEdge(shell.width * 0.75);
@@ -1423,9 +1423,9 @@ Rectangle {
1423 waitUntilAppWindowIsFullyLoaded(app3);
1423 waitUntilAppWindowIsFullyLoaded(app3);
1425 // Do a quick alt-tab and see if focus changes
1425 // Do a quick alt-tab and see if focus changes
1426− tryCompare(app3.session.surface, "activeFocus", true)
1426+ tryCompare(app3.session.lastSurface, "activeFocus", true)
1427 keyClick(Qt.Key_Tab, Qt.AltModifier)
1427 keyClick(Qt.Key_Tab, Qt.AltModifier)
1428− tryCompare(app2.session.surface, "activeFocus", true)
1428+ tryCompare(app2.session.lastSurface, "activeFocus", true)
1430 var desktopSpread = findChild(shell, "spread")
1430 var desktopSpread = findChild(shell, "spread")
@@ -1441,7 +1441,7 @@ Rectangle {
1441 tryCompare(desktopSpread, "state", "")
1441 tryCompare(desktopSpread, "state", "")
1443 // Focus should have switched back now
1443 // Focus should have switched back now
1444− tryCompare(app3.session.surface, "activeFocus", true)
1444+ tryCompare(app3.session.lastSurface, "activeFocus", true)
1447 function test_altTabWrapAround() {
1447 function test_altTabWrapAround() {
@@ -1490,7 +1490,7 @@ Rectangle {
1490 tryCompare(desktopSpread, "state", "")
1490 tryCompare(desktopSpread, "state", "")
1492 // Make sure that after wrapping around once, we have the same one focused as at the beginning
1492 // Make sure that after wrapping around once, we have the same one focused as at the beginning
1493− tryCompare(focused.session.surface, "activeFocus", true)
1493+ tryCompare(focused.session.lastSurface, "activeFocus", true)
1496 function test_altBackTabNavigation() {
1496 function test_altBackTabNavigation() {
@@ -1739,6 +1739,7 @@ Rectangle {
1739 tryCompare(desktopSpread, "state", "altTab")
1739 tryCompare(desktopSpread, "state", "altTab")
1741 revealLauncherByEdgePushWithMouse();
1741 revealLauncherByEdgePushWithMouse();
1742+ tryCompare(launcher, "x", 0);
1742 waitForRendering(shell)
1743 waitForRendering(shell)
1744 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
1745 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
@@ -1866,21 +1867,28 @@ Rectangle {
1866 loadShell(data.formFactor);
1867 loadShell(data.formFactor);
1867 shell.usageScenario = data.usageScenario;
1868 shell.usageScenario = data.usageScenario;
1870+ // Add two main stage apps, the second in order to suspend the first.
1871+ // LibreOffice has isTouchApp set to false by our mocks.
1869 var app1 = ApplicationManager.startApplication("libreoffice");
1872 var app1 = ApplicationManager.startApplication("libreoffice");
1870 waitUntilAppWindowIsFullyLoaded(app1);
1873 waitUntilAppWindowIsFullyLoaded(app1);
1871− var app2 = ApplicationManager.startApplication("dialer-app");
1874+ var app2 = ApplicationManager.startApplication("gallery-app");
1872 waitUntilAppWindowIsFullyLoaded(app2);
1875 waitUntilAppWindowIsFullyLoaded(app2);
1874− // Make sure app1 is unfocused but still running
1877+ // Sanity checking
1875− compare(app1.session.surface.activeFocus, false);
1878+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1876− compare(app1.isTouchApp, false); // sanity check our mock, which sets this for us
1879+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1880+ verify(!app1.isTouchApp);
1881+ verify(!app1.session.lastSurface.activeFocus);
1883+ // Make sure app1 is exempt with a requested suspend
1884+ verify(app1.exemptFromLifecycle);
1877− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1885+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
1880 function test_lifecyclePolicyExemption_data() {
1888 function test_lifecyclePolicyExemption_data() {
1881 return [
1889 return [
1882− {tag: "phone", formFactor: "phone", usageScenario: "phone", suspendsApps: true},
1890+ {tag: "phone", formFactor: "phone", usageScenario: "phone"},
1883− {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", suspendsApps: true}
1891+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet"}
@@ -1890,14 +1898,20 @@ Rectangle {
1891 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
1899 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
1901+ // Add two main stage apps, the second in order to suspend the first
1893 var app1 = ApplicationManager.startApplication("webbrowser-app");
1902 var app1 = ApplicationManager.startApplication("webbrowser-app");
1894 waitUntilAppWindowIsFullyLoaded(app1);
1903 waitUntilAppWindowIsFullyLoaded(app1);
1895− var app2 = ApplicationManager.startApplication("dialer-app");
1904+ var app2 = ApplicationManager.startApplication("gallery-app");
1896 waitUntilAppWindowIsFullyLoaded(app2);
1905 waitUntilAppWindowIsFullyLoaded(app2);
1898− // Make sure app1 is unfocused but still running
1907+ // Sanity checking
1899− compare(app1.session.surface.activeFocus, false);
1908+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1909+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1910+ verify(!app1.session.lastSurface.activeFocus);
1912+ // Make sure app1 is exempt with a requested suspend
1913+ verify(app1.exemptFromLifecycle);
1900− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1914+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
1903 function test_switchToStagedForcesLegacyAppClosing_data() {
1917 function test_switchToStagedForcesLegacyAppClosing_data() {