@@ -423,7 +423,7 @@ Rectangle {
423423 // Open an application and focus
424424 waitUntilApplicationWindowIsFullyVisible(app);
425425 ApplicationManager.focusApplication(app);
426− tryCompare(app.session.surface, "activeFocus", true);
426+ tryCompare(app.session.lastSurface, "activeFocus", true);
427427
428428 notifications.model = mockNotificationsModel;
429429
@@ -445,7 +445,7 @@ Rectangle {
445445 waitForRendering(notification);
446446
447447 // Make sure activeFocus went away from the app window
448− tryCompare(app.session.surface, "activeFocus", false);
448+ tryCompare(app.session.lastSurface, "activeFocus", false);
449449 tryCompare(stage, "interactive", false);
450450
451451 // Clicking the button should dismiss the notification and return focus
@@ -453,7 +453,7 @@ Rectangle {
453453 mouseClick(buttonAccept);
454454
455455 // Make sure we're back to normal
456− tryCompare(app.session.surface, "activeFocus", true);
456+ tryCompare(app.session.lastSurface, "activeFocus", true);
457457 compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
458458 }
459459
@@ -463,8 +463,8 @@ Rectangle {
463463 hints: {"x-canonical-private-affirmative-tint": "true"},
464464 summary: "Tom Ato",
465465 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",
467− secondaryIcon: "../graphics/applicationIcons/facebook.png",
466+ icon: "../../tests/graphics/avatars/funky.png",
467+ secondaryIcon: "../../tests/graphics/applicationIcons/facebook.png",
468468 actions: [{ id: "ok_id", label: "Ok"},
469469 { id: "cancel_id", label: "Cancel"},
470470 { id: "notreally_id", label: "Not really"},
@@ -785,7 +785,7 @@ Rectangle {
785785 var app = ApplicationManager.startApplication("dialer-app");
786786 waitUntilAppWindowIsFullyLoaded(app);
787787
788− tryCompare(app.session.surface, "activeFocus", true);
788+ tryCompare(app.session.lastSurface, "activeFocus", true);
789789
790790 // Drag the indicators panel half-open
791791 var touchX = shell.width / 2;
@@ -796,7 +796,7 @@ Rectangle {
796796 true /* beginTouch */, false /* endTouch */);
797797 verify(indicators.partiallyOpened);
798798
799− tryCompare(app.session.surface, "activeFocus", false);
799+ tryCompare(app.session.lastSurface, "activeFocus", false);
800800
801801 // And finish getting it open
802802 touchFlick(indicators,
@@ -805,11 +805,11 @@ Rectangle {
805805 false /* beginTouch */, true /* endTouch */);
806806 tryCompare(indicators, "fullyOpened", true);
807807
808− tryCompare(app.session.surface, "activeFocus", false);
808+ tryCompare(app.session.lastSurface, "activeFocus", false);
809809
810810 dragToCloseIndicatorsPanel();
811811
812− tryCompare(app.session.surface, "activeFocus", true);
812+ tryCompare(app.session.lastSurface, "activeFocus", true);
813813 }
814814
815815 function test_launchedAppHasActiveFocus_data() {
@@ -830,9 +830,9 @@ Rectangle {
830830 verify(webApp);
831831 waitUntilAppSurfaceShowsUp("webbrowser-app")
832832
833− verify(webApp.session.surface);
833+ verify(webApp.session.lastSurface);
834834
835− tryCompare(webApp.session.surface, "activeFocus", true);
835+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
836836 }
837837
838838 function test_launchedAppKeepsActiveFocusOnUsageModeChange() {
@@ -843,9 +843,9 @@ Rectangle {
843843 verify(webApp);
844844 waitUntilAppSurfaceShowsUp("webbrowser-app")
845845
846− verify(webApp.session.surface);
846+ verify(webApp.session.lastSurface);
847847
848− tryCompare(webApp.session.surface, "activeFocus", true);
848+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
849849
850850 shell.usageScenario = "desktop";
851851
@@ -855,7 +855,7 @@ Rectangle {
855855 verify(desktopWindow);
856856 }
857857
858− tryCompare(webApp.session.surface, "activeFocus", true);
858+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
859859
860860 shell.usageScenario = "tablet";
861861
@@ -865,7 +865,7 @@ Rectangle {
865865 verify(desktopWindow);
866866 }
867867
868− tryCompare(webApp.session.surface, "activeFocus", true);
868+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
869869 }
870870
871871 function waitUntilAppSurfaceShowsUp(appId) {
@@ -986,7 +986,7 @@ Rectangle {
986986
987987 var app = ApplicationManager.startApplication("dialer-app");
988988 // 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);
990990
991991 // Minimize the application we just launched
992992 swipeFromLeftEdge(shell.width * 0.75);
@@ -1423,9 +1423,9 @@ Rectangle {
14231423 waitUntilAppWindowIsFullyLoaded(app3);
14241424
14251425 // Do a quick alt-tab and see if focus changes
1426− tryCompare(app3.session.surface, "activeFocus", true)
1426+ tryCompare(app3.session.lastSurface, "activeFocus", true)
14271427 keyClick(Qt.Key_Tab, Qt.AltModifier)
1428− tryCompare(app2.session.surface, "activeFocus", true)
1428+ tryCompare(app2.session.lastSurface, "activeFocus", true)
14291429
14301430 var desktopSpread = findChild(shell, "spread")
14311431
@@ -1441,7 +1441,7 @@ Rectangle {
14411441 tryCompare(desktopSpread, "state", "")
14421442
14431443 // Focus should have switched back now
1444− tryCompare(app3.session.surface, "activeFocus", true)
1444+ tryCompare(app3.session.lastSurface, "activeFocus", true)
14451445 }
14461446
14471447 function test_altTabWrapAround() {
@@ -1490,7 +1490,7 @@ Rectangle {
14901490 tryCompare(desktopSpread, "state", "")
14911491
14921492 // 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)
14941494 }
14951495
14961496 function test_altBackTabNavigation() {
@@ -1739,6 +1739,7 @@ Rectangle {
17391739 tryCompare(desktopSpread, "state", "altTab")
17401740
17411741 revealLauncherByEdgePushWithMouse();
1742+ tryCompare(launcher, "x", 0);
17421743 waitForRendering(shell)
17431744
17441745 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
@@ -1866,21 +1867,28 @@ Rectangle {
18661867 loadShell(data.formFactor);
18671868 shell.usageScenario = data.usageScenario;
18681869
1870+ // Add two main stage apps, the second in order to suspend the first.
1871+ // LibreOffice has isTouchApp set to false by our mocks.
18691872 var app1 = ApplicationManager.startApplication("libreoffice");
18701873 waitUntilAppWindowIsFullyLoaded(app1);
1871− var app2 = ApplicationManager.startApplication("dialer-app");
1874+ var app2 = ApplicationManager.startApplication("gallery-app");
18721875 waitUntilAppWindowIsFullyLoaded(app2);
18731876
1874− // Make sure app1 is unfocused but still running
1875− compare(app1.session.surface.activeFocus, false);
1876− compare(app1.isTouchApp, false); // sanity check our mock, which sets this for us
1877− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1877+ // Sanity checking
1878+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1879+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1880+ verify(!app1.isTouchApp);
1881+ verify(!app1.session.lastSurface.activeFocus);
1882+
1883+ // Make sure app1 is exempt with a requested suspend
1884+ verify(app1.exemptFromLifecycle);
1885+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
18781886 }
18791887
18801888 function test_lifecyclePolicyExemption_data() {
18811889 return [
1882− {tag: "phone", formFactor: "phone", usageScenario: "phone", suspendsApps: true},
1883− {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", suspendsApps: true}
1890+ {tag: "phone", formFactor: "phone", usageScenario: "phone"},
1891+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet"}
18841892 ]
18851893 }
18861894
@@ -1890,14 +1898,20 @@ Rectangle {
18901898
18911899 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
18921900
1901+ // Add two main stage apps, the second in order to suspend the first
18931902 var app1 = ApplicationManager.startApplication("webbrowser-app");
18941903 waitUntilAppWindowIsFullyLoaded(app1);
1895− var app2 = ApplicationManager.startApplication("dialer-app");
1904+ var app2 = ApplicationManager.startApplication("gallery-app");
18961905 waitUntilAppWindowIsFullyLoaded(app2);
18971906
1898− // Make sure app1 is unfocused but still running
1899− compare(app1.session.surface.activeFocus, false);
1900− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1907+ // Sanity checking
1908+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1909+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1910+ verify(!app1.session.lastSurface.activeFocus);
1911+
1912+ // Make sure app1 is exempt with a requested suspend
1913+ verify(app1.exemptFromLifecycle);
1914+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
19011915 }
19021916
19031917 function test_switchToStagedForcesLegacyAppClosing_data() {