@@ -436,7 +436,7 @@ Rectangle {
436436 // Open an application and focus
437437 waitUntilApplicationWindowIsFullyVisible(app);
438438 ApplicationManager.focusApplication(app);
439− tryCompare(app.session.surface, "activeFocus", true);
439+ tryCompare(app.session.lastSurface, "activeFocus", true);
440440
441441 notifications.model = mockNotificationsModel;
442442
@@ -458,7 +458,7 @@ Rectangle {
458458 waitForRendering(notification);
459459
460460 // Make sure activeFocus went away from the app window
461− tryCompare(app.session.surface, "activeFocus", false);
461+ tryCompare(app.session.lastSurface, "activeFocus", false);
462462 tryCompare(stage, "interactive", false);
463463
464464 // Clicking the button should dismiss the notification and return focus
@@ -466,7 +466,7 @@ Rectangle {
466466 mouseClick(buttonAccept);
467467
468468 // Make sure we're back to normal
469− tryCompare(app.session.surface, "activeFocus", true);
469+ tryCompare(app.session.lastSurface, "activeFocus", true);
470470 compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
471471 }
472472
@@ -476,8 +476,8 @@ Rectangle {
476476 hints: {"x-canonical-private-affirmative-tint": "true"},
477477 summary: "Tom Ato",
478478 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.",
479− icon: "../graphics/avatars/funky.png",
480− secondaryIcon: "../graphics/applicationIcons/facebook.png",
479+ icon: "../../tests/graphics/avatars/funky.png",
480+ secondaryIcon: "../../tests/graphics/applicationIcons/facebook.png",
481481 actions: [{ id: "ok_id", label: "Ok"},
482482 { id: "cancel_id", label: "Cancel"},
483483 { id: "notreally_id", label: "Not really"},
@@ -798,7 +798,7 @@ Rectangle {
798798 var app = ApplicationManager.startApplication("dialer-app");
799799 waitUntilAppWindowIsFullyLoaded(app);
800800
801− tryCompare(app.session.surface, "activeFocus", true);
801+ tryCompare(app.session.lastSurface, "activeFocus", true);
802802
803803 // Drag the indicators panel half-open
804804 var touchX = shell.width / 2;
@@ -809,7 +809,7 @@ Rectangle {
809809 true /* beginTouch */, false /* endTouch */);
810810 verify(indicators.partiallyOpened);
811811
812− tryCompare(app.session.surface, "activeFocus", false);
812+ tryCompare(app.session.lastSurface, "activeFocus", false);
813813
814814 // And finish getting it open
815815 touchFlick(indicators,
@@ -818,11 +818,11 @@ Rectangle {
818818 false /* beginTouch */, true /* endTouch */);
819819 tryCompare(indicators, "fullyOpened", true);
820820
821− tryCompare(app.session.surface, "activeFocus", false);
821+ tryCompare(app.session.lastSurface, "activeFocus", false);
822822
823823 dragToCloseIndicatorsPanel();
824824
825− tryCompare(app.session.surface, "activeFocus", true);
825+ tryCompare(app.session.lastSurface, "activeFocus", true);
826826 }
827827
828828 function test_launchedAppHasActiveFocus_data() {
@@ -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
851851 function test_launchedAppKeepsActiveFocusOnUsageModeChange() {
@@ -856,9 +856,9 @@ Rectangle {
856856 verify(webApp);
857857 waitUntilAppSurfaceShowsUp("webbrowser-app")
858858
859− verify(webApp.session.surface);
859+ verify(webApp.session.lastSurface);
860860
861− tryCompare(webApp.session.surface, "activeFocus", true);
861+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
862862
863863 shell.usageScenario = "desktop";
864864
@@ -868,7 +868,7 @@ Rectangle {
868868 verify(desktopWindow);
869869 }
870870
871− tryCompare(webApp.session.surface, "activeFocus", true);
871+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
872872
873873 shell.usageScenario = "tablet";
874874
@@ -878,7 +878,7 @@ Rectangle {
878878 verify(desktopWindow);
879879 }
880880
881− tryCompare(webApp.session.surface, "activeFocus", true);
881+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
882882 }
883883
884884 function waitUntilAppSurfaceShowsUp(appId) {
@@ -999,7 +999,7 @@ Rectangle {
999999
10001000 var app = ApplicationManager.startApplication("dialer-app");
10011001 // wait until the app is fully loaded (ie, real surface replaces splash screen)
1002− tryCompareFunction(function() { return app.session !== null && app.session.surface !== null }, true);
1002+ tryCompareFunction(function() { return app.session !== null && app.session.lastSurface !== null }, true);
10031003
10041004 // Minimize the application we just launched
10051005 swipeFromLeftEdge(shell.width * 0.75);
@@ -1436,9 +1436,9 @@ Rectangle {
14361436 waitUntilAppWindowIsFullyLoaded(app3);
14371437
14381438 // Do a quick alt-tab and see if focus changes
1439− tryCompare(app3.session.surface, "activeFocus", true)
1439+ tryCompare(app3.session.lastSurface, "activeFocus", true)
14401440 keyClick(Qt.Key_Tab, Qt.AltModifier)
1441− tryCompare(app2.session.surface, "activeFocus", true)
1441+ tryCompare(app2.session.lastSurface, "activeFocus", true)
14421442
14431443 var desktopSpread = findChild(shell, "spread")
14441444
@@ -1454,7 +1454,7 @@ Rectangle {
14541454 tryCompare(desktopSpread, "state", "")
14551455
14561456 // Focus should have switched back now
1457− tryCompare(app3.session.surface, "activeFocus", true)
1457+ tryCompare(app3.session.lastSurface, "activeFocus", true)
14581458 }
14591459
14601460 function test_altTabWrapAround() {
@@ -1503,7 +1503,7 @@ Rectangle {
15031503 tryCompare(desktopSpread, "state", "")
15041504
15051505 // Make sure that after wrapping around once, we have the same one focused as at the beginning
1506− tryCompare(focused.session.surface, "activeFocus", true)
1506+ tryCompare(focused.session.lastSurface, "activeFocus", true)
15071507 }
15081508
15091509 function test_altBackTabNavigation() {
@@ -1762,6 +1762,7 @@ Rectangle {
17621762
17631763 if (!data.launcherLocked) {
17641764 revealLauncherByEdgePushWithMouse();
1765+ tryCompare(launcher, "x", 0);
17651766 waitForRendering(shell)
17661767 }
17671768
@@ -1892,21 +1893,28 @@ Rectangle {
18921893 loadShell(data.formFactor);
18931894 shell.usageScenario = data.usageScenario;
18941895
1896+ // Add two main stage apps, the second in order to suspend the first.
1897+ // LibreOffice has isTouchApp set to false by our mocks.
18951898 var app1 = ApplicationManager.startApplication("libreoffice");
18961899 waitUntilAppWindowIsFullyLoaded(app1);
1897− var app2 = ApplicationManager.startApplication("dialer-app");
1900+ var app2 = ApplicationManager.startApplication("gallery-app");
18981901 waitUntilAppWindowIsFullyLoaded(app2);
18991902
1900− // Make sure app1 is unfocused but still running
1901− compare(app1.session.surface.activeFocus, false);
1902− compare(app1.isTouchApp, false); // sanity check our mock, which sets this for us
1903− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1903+ // Sanity checking
1904+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1905+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1906+ verify(!app1.isTouchApp);
1907+ verify(!app1.session.lastSurface.activeFocus);
1908+
1909+ // Make sure app1 is exempt with a requested suspend
1910+ verify(app1.exemptFromLifecycle);
1911+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
19041912 }
19051913
19061914 function test_lifecyclePolicyExemption_data() {
19071915 return [
1908− {tag: "phone", formFactor: "phone", usageScenario: "phone", suspendsApps: true},
1909− {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", suspendsApps: true}
1916+ {tag: "phone", formFactor: "phone", usageScenario: "phone"},
1917+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet"}
19101918 ]
19111919 }
19121920
@@ -1916,14 +1924,20 @@ Rectangle {
19161924
19171925 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
19181926
1927+ // Add two main stage apps, the second in order to suspend the first
19191928 var app1 = ApplicationManager.startApplication("webbrowser-app");
19201929 waitUntilAppWindowIsFullyLoaded(app1);
1921− var app2 = ApplicationManager.startApplication("dialer-app");
1930+ var app2 = ApplicationManager.startApplication("gallery-app");
19221931 waitUntilAppWindowIsFullyLoaded(app2);
19231932
1924− // Make sure app1 is unfocused but still running
1925− compare(app1.session.surface.activeFocus, false);
1926− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1933+ // Sanity checking
1934+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1935+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1936+ verify(!app1.session.lastSurface.activeFocus);
1937+
1938+ // Make sure app1 is exempt with a requested suspend
1939+ verify(app1.exemptFromLifecycle);
1940+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
19271941 }
19281942
19291943 function test_switchToStagedForcesLegacyAppClosing_data() {