@@ -414,7 +414,7 @@ Rectangle {
414414 // Open an application and focus
415415 waitUntilApplicationWindowIsFullyVisible(app);
416416 ApplicationManager.focusApplication(app);
417− tryCompare(app.session.surface, "activeFocus", true);
417+ tryCompare(app.session.lastSurface, "activeFocus", true);
418418
419419 notifications.model = mockNotificationsModel;
420420
@@ -436,7 +436,7 @@ Rectangle {
436436 waitForRendering(notification);
437437
438438 // Make sure activeFocus went away from the app window
439− tryCompare(app.session.surface, "activeFocus", false);
439+ tryCompare(app.session.lastSurface, "activeFocus", false);
440440 tryCompare(stage, "interactive", false);
441441
442442 // Clicking the button should dismiss the notification and return focus
@@ -444,7 +444,7 @@ Rectangle {
444444 mouseClick(buttonAccept);
445445
446446 // Make sure we're back to normal
447− tryCompare(app.session.surface, "activeFocus", true);
447+ tryCompare(app.session.lastSurface, "activeFocus", true);
448448 compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
449449 }
450450
@@ -454,8 +454,8 @@ Rectangle {
454454 hints: {"x-canonical-private-affirmative-tint": "true"},
455455 summary: "Tom Ato",
456456 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",
458− secondaryIcon: "../graphics/applicationIcons/facebook.png",
457+ icon: "../../tests/graphics/avatars/funky.png",
458+ secondaryIcon: "../../tests/graphics/applicationIcons/facebook.png",
459459 actions: [{ id: "ok_id", label: "Ok"},
460460 { id: "cancel_id", label: "Cancel"},
461461 { id: "notreally_id", label: "Not really"},
@@ -776,7 +776,7 @@ Rectangle {
776776 var app = ApplicationManager.startApplication("dialer-app");
777777 waitUntilAppWindowIsFullyLoaded(app);
778778
779− tryCompare(app.session.surface, "activeFocus", true);
779+ tryCompare(app.session.lastSurface, "activeFocus", true);
780780
781781 // Drag the indicators panel half-open
782782 var touchX = shell.width / 2;
@@ -787,7 +787,7 @@ Rectangle {
787787 true /* beginTouch */, false /* endTouch */);
788788 verify(indicators.partiallyOpened);
789789
790− tryCompare(app.session.surface, "activeFocus", false);
790+ tryCompare(app.session.lastSurface, "activeFocus", false);
791791
792792 // And finish getting it open
793793 touchFlick(indicators,
@@ -796,11 +796,11 @@ Rectangle {
796796 false /* beginTouch */, true /* endTouch */);
797797 tryCompare(indicators, "fullyOpened", true);
798798
799− tryCompare(app.session.surface, "activeFocus", false);
799+ tryCompare(app.session.lastSurface, "activeFocus", false);
800800
801801 dragToCloseIndicatorsPanel();
802802
803− tryCompare(app.session.surface, "activeFocus", true);
803+ tryCompare(app.session.lastSurface, "activeFocus", true);
804804 }
805805
806806 function test_launchedAppHasActiveFocus_data() {
@@ -821,9 +821,9 @@ Rectangle {
821821 verify(webApp);
822822 waitUntilAppSurfaceShowsUp("webbrowser-app")
823823
824− verify(webApp.session.surface);
824+ verify(webApp.session.lastSurface);
825825
826− tryCompare(webApp.session.surface, "activeFocus", true);
826+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
827827 }
828828
829829 function test_launchedAppKeepsActiveFocusOnUsageModeChange() {
@@ -834,9 +834,9 @@ Rectangle {
834834 verify(webApp);
835835 waitUntilAppSurfaceShowsUp("webbrowser-app")
836836
837− verify(webApp.session.surface);
837+ verify(webApp.session.lastSurface);
838838
839− tryCompare(webApp.session.surface, "activeFocus", true);
839+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
840840
841841 shell.usageScenario = "desktop";
842842
@@ -846,7 +846,7 @@ Rectangle {
846846 verify(desktopWindow);
847847 }
848848
849− tryCompare(webApp.session.surface, "activeFocus", true);
849+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
850850
851851 shell.usageScenario = "tablet";
852852
@@ -856,7 +856,7 @@ Rectangle {
856856 verify(desktopWindow);
857857 }
858858
859− tryCompare(webApp.session.surface, "activeFocus", true);
859+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
860860 }
861861
862862 function waitUntilAppSurfaceShowsUp(appId) {
@@ -977,7 +977,7 @@ Rectangle {
977977
978978 var app = ApplicationManager.startApplication("dialer-app");
979979 // 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);
981981
982982 // Minimize the application we just launched
983983 swipeFromLeftEdge(shell.width * 0.75);
@@ -1414,9 +1414,9 @@ Rectangle {
14141414 waitUntilAppWindowIsFullyLoaded(app3);
14151415
14161416 // Do a quick alt-tab and see if focus changes
1417− tryCompare(app3.session.surface, "activeFocus", true)
1417+ tryCompare(app3.session.lastSurface, "activeFocus", true)
14181418 keyClick(Qt.Key_Tab, Qt.ControlModifier)
1419− tryCompare(app2.session.surface, "activeFocus", true)
1419+ tryCompare(app2.session.lastSurface, "activeFocus", true)
14201420
14211421 var desktopSpread = findChild(shell, "spread")
14221422
@@ -1432,7 +1432,7 @@ Rectangle {
14321432 tryCompare(desktopSpread, "state", "")
14331433
14341434 // Focus should have switched back now
1435− tryCompare(app3.session.surface, "activeFocus", true)
1435+ tryCompare(app3.session.lastSurface, "activeFocus", true)
14361436 }
14371437
14381438 function test_altTabWrapAround() {
@@ -1481,7 +1481,7 @@ Rectangle {
14811481 tryCompare(desktopSpread, "state", "")
14821482
14831483 // 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)
14851485 }
14861486
14871487 function test_altBackTabNavigation() {
@@ -1730,6 +1730,7 @@ Rectangle {
17301730 tryCompare(desktopSpread, "state", "altTab")
17311731
17321732 revealLauncherByEdgePushWithMouse();
1733+ tryCompare(launcher, "x", 0);
17331734 waitForRendering(shell)
17341735
17351736 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
@@ -1857,21 +1858,28 @@ Rectangle {
18571858 loadShell(data.formFactor);
18581859 shell.usageScenario = data.usageScenario;
18591860
1861+ // Add two main stage apps, the second in order to suspend the first.
1862+ // LibreOffice has isTouchApp set to false by our mocks.
18601863 var app1 = ApplicationManager.startApplication("libreoffice");
18611864 waitUntilAppWindowIsFullyLoaded(app1);
1862− var app2 = ApplicationManager.startApplication("dialer-app");
1865+ var app2 = ApplicationManager.startApplication("gallery-app");
18631866 waitUntilAppWindowIsFullyLoaded(app2);
18641867
1865− // Make sure app1 is unfocused but still running
1866− compare(app1.session.surface.activeFocus, false);
1867− compare(app1.isTouchApp, false); // sanity check our mock, which sets this for us
1868− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1868+ // Sanity checking
1869+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1870+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1871+ verify(!app1.isTouchApp);
1872+ verify(!app1.session.lastSurface.activeFocus);
1873+
1874+ // Make sure app1 is exempt with a requested suspend
1875+ verify(app1.exemptFromLifecycle);
1876+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
18691877 }
18701878
18711879 function test_lifecyclePolicyExemption_data() {
18721880 return [
1873− {tag: "phone", formFactor: "phone", usageScenario: "phone", suspendsApps: true},
1874− {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", suspendsApps: true}
1881+ {tag: "phone", formFactor: "phone", usageScenario: "phone"},
1882+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet"}
18751883 ]
18761884 }
18771885
@@ -1881,14 +1889,20 @@ Rectangle {
18811889
18821890 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
18831891
1892+ // Add two main stage apps, the second in order to suspend the first
18841893 var app1 = ApplicationManager.startApplication("webbrowser-app");
18851894 waitUntilAppWindowIsFullyLoaded(app1);
1886− var app2 = ApplicationManager.startApplication("dialer-app");
1895+ var app2 = ApplicationManager.startApplication("gallery-app");
18871896 waitUntilAppWindowIsFullyLoaded(app2);
18881897
1889− // Make sure app1 is unfocused but still running
1890− compare(app1.session.surface.activeFocus, false);
1891− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1898+ // Sanity checking
1899+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1900+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1901+ verify(!app1.session.lastSurface.activeFocus);
1902+
1903+ // Make sure app1 is exempt with a requested suspend
1904+ verify(app1.exemptFromLifecycle);
1905+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
18921906 }
18931907
18941908 function test_switchToStagedForcesLegacyAppClosing_data() {