@@ -415,7 +415,7 @@ Rectangle {
415415 // Open an application and focus
416416 waitUntilApplicationWindowIsFullyVisible(app);
417417 ApplicationManager.focusApplication(app);
418− tryCompare(app.session.surface, "activeFocus", true);
418+ tryCompare(app.session.lastSurface, "activeFocus", true);
419419
420420 notifications.model = mockNotificationsModel;
421421
@@ -437,7 +437,7 @@ Rectangle {
437437 waitForRendering(notification);
438438
439439 // Make sure activeFocus went away from the app window
440− tryCompare(app.session.surface, "activeFocus", false);
440+ tryCompare(app.session.lastSurface, "activeFocus", false);
441441 tryCompare(stage, "interactive", false);
442442
443443 // Clicking the button should dismiss the notification and return focus
@@ -445,7 +445,7 @@ Rectangle {
445445 mouseClick(buttonAccept);
446446
447447 // Make sure we're back to normal
448− tryCompare(app.session.surface, "activeFocus", true);
448+ tryCompare(app.session.lastSurface, "activeFocus", true);
449449 compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
450450 }
451451
@@ -455,8 +455,8 @@ Rectangle {
455455 hints: {"x-canonical-private-affirmative-tint": "true"},
456456 summary: "Tom Ato",
457457 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.",
458− icon: "../graphics/avatars/funky.png",
459− secondaryIcon: "../graphics/applicationIcons/facebook.png",
458+ icon: "../../tests/graphics/avatars/funky.png",
459+ secondaryIcon: "../../tests/graphics/applicationIcons/facebook.png",
460460 actions: [{ id: "ok_id", label: "Ok"},
461461 { id: "cancel_id", label: "Cancel"},
462462 { id: "notreally_id", label: "Not really"},
@@ -777,7 +777,7 @@ Rectangle {
777777 var app = ApplicationManager.startApplication("dialer-app");
778778 waitUntilAppWindowIsFullyLoaded(app);
779779
780− tryCompare(app.session.surface, "activeFocus", true);
780+ tryCompare(app.session.lastSurface, "activeFocus", true);
781781
782782 // Drag the indicators panel half-open
783783 var touchX = shell.width / 2;
@@ -788,7 +788,7 @@ Rectangle {
788788 true /* beginTouch */, false /* endTouch */);
789789 verify(indicators.partiallyOpened);
790790
791− tryCompare(app.session.surface, "activeFocus", false);
791+ tryCompare(app.session.lastSurface, "activeFocus", false);
792792
793793 // And finish getting it open
794794 touchFlick(indicators,
@@ -797,11 +797,11 @@ Rectangle {
797797 false /* beginTouch */, true /* endTouch */);
798798 tryCompare(indicators, "fullyOpened", true);
799799
800− tryCompare(app.session.surface, "activeFocus", false);
800+ tryCompare(app.session.lastSurface, "activeFocus", false);
801801
802802 dragToCloseIndicatorsPanel();
803803
804− tryCompare(app.session.surface, "activeFocus", true);
804+ tryCompare(app.session.lastSurface, "activeFocus", true);
805805 }
806806
807807 function test_launchedAppHasActiveFocus_data() {
@@ -822,9 +822,9 @@ Rectangle {
822822 verify(webApp);
823823 waitUntilAppSurfaceShowsUp("webbrowser-app")
824824
825− verify(webApp.session.surface);
825+ verify(webApp.session.lastSurface);
826826
827− tryCompare(webApp.session.surface, "activeFocus", true);
827+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
828828 }
829829
830830 function test_launchedAppKeepsActiveFocusOnUsageModeChange() {
@@ -835,9 +835,9 @@ Rectangle {
835835 verify(webApp);
836836 waitUntilAppSurfaceShowsUp("webbrowser-app")
837837
838− verify(webApp.session.surface);
838+ verify(webApp.session.lastSurface);
839839
840− tryCompare(webApp.session.surface, "activeFocus", true);
840+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
841841
842842 shell.usageScenario = "desktop";
843843
@@ -847,7 +847,7 @@ Rectangle {
847847 verify(desktopWindow);
848848 }
849849
850− tryCompare(webApp.session.surface, "activeFocus", true);
850+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
851851
852852 shell.usageScenario = "tablet";
853853
@@ -857,7 +857,7 @@ Rectangle {
857857 verify(desktopWindow);
858858 }
859859
860− tryCompare(webApp.session.surface, "activeFocus", true);
860+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
861861 }
862862
863863 function waitUntilAppSurfaceShowsUp(appId) {
@@ -978,7 +978,7 @@ Rectangle {
978978
979979 var app = ApplicationManager.startApplication("dialer-app");
980980 // wait until the app is fully loaded (ie, real surface replaces splash screen)
981− tryCompareFunction(function() { return app.session !== null && app.session.surface !== null }, true);
981+ tryCompareFunction(function() { return app.session !== null && app.session.lastSurface !== null }, true);
982982
983983 // Minimize the application we just launched
984984 swipeFromLeftEdge(shell.width * 0.75);
@@ -1415,9 +1415,9 @@ Rectangle {
14151415 waitUntilAppWindowIsFullyLoaded(app3);
14161416
14171417 // Do a quick alt-tab and see if focus changes
1418− tryCompare(app3.session.surface, "activeFocus", true)
1418+ tryCompare(app3.session.lastSurface, "activeFocus", true)
14191419 keyClick(Qt.Key_Tab, Qt.ControlModifier)
1420− tryCompare(app2.session.surface, "activeFocus", true)
1420+ tryCompare(app2.session.lastSurface, "activeFocus", true)
14211421
14221422 var desktopSpread = findChild(shell, "spread")
14231423
@@ -1433,7 +1433,7 @@ Rectangle {
14331433 tryCompare(desktopSpread, "state", "")
14341434
14351435 // Focus should have switched back now
1436− tryCompare(app3.session.surface, "activeFocus", true)
1436+ tryCompare(app3.session.lastSurface, "activeFocus", true)
14371437 }
14381438
14391439 function test_altTabWrapAround() {
@@ -1482,7 +1482,7 @@ Rectangle {
14821482 tryCompare(desktopSpread, "state", "")
14831483
14841484 // Make sure that after wrapping around once, we have the same one focused as at the beginning
1485− tryCompare(focused.session.surface, "activeFocus", true)
1485+ tryCompare(focused.session.lastSurface, "activeFocus", true)
14861486 }
14871487
14881488 function test_altBackTabNavigation() {
@@ -1731,6 +1731,7 @@ Rectangle {
17311731 tryCompare(desktopSpread, "state", "altTab")
17321732
17331733 revealLauncherByEdgePushWithMouse();
1734+ tryCompare(launcher, "x", 0);
17341735 waitForRendering(shell)
17351736
17361737 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
@@ -1858,21 +1859,28 @@ Rectangle {
18581859 loadShell(data.formFactor);
18591860 shell.usageScenario = data.usageScenario;
18601861
1862+ // Add two main stage apps, the second in order to suspend the first.
1863+ // LibreOffice has isTouchApp set to false by our mocks.
18611864 var app1 = ApplicationManager.startApplication("libreoffice");
18621865 waitUntilAppWindowIsFullyLoaded(app1);
1863− var app2 = ApplicationManager.startApplication("dialer-app");
1866+ var app2 = ApplicationManager.startApplication("gallery-app");
18641867 waitUntilAppWindowIsFullyLoaded(app2);
18651868
1866− // Make sure app1 is unfocused but still running
1867− compare(app1.session.surface.activeFocus, false);
1868− compare(app1.isTouchApp, false); // sanity check our mock, which sets this for us
1869− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1869+ // Sanity checking
1870+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1871+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1872+ verify(!app1.isTouchApp);
1873+ verify(!app1.session.lastSurface.activeFocus);
1874+
1875+ // Make sure app1 is exempt with a requested suspend
1876+ verify(app1.exemptFromLifecycle);
1877+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
18701878 }
18711879
18721880 function test_lifecyclePolicyExemption_data() {
18731881 return [
1874− {tag: "phone", formFactor: "phone", usageScenario: "phone", suspendsApps: true},
1875− {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", suspendsApps: true}
1882+ {tag: "phone", formFactor: "phone", usageScenario: "phone"},
1883+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet"}
18761884 ]
18771885 }
18781886
@@ -1882,14 +1890,20 @@ Rectangle {
18821890
18831891 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
18841892
1893+ // Add two main stage apps, the second in order to suspend the first
18851894 var app1 = ApplicationManager.startApplication("webbrowser-app");
18861895 waitUntilAppWindowIsFullyLoaded(app1);
1887− var app2 = ApplicationManager.startApplication("dialer-app");
1896+ var app2 = ApplicationManager.startApplication("gallery-app");
18881897 waitUntilAppWindowIsFullyLoaded(app2);
18891898
1890− // Make sure app1 is unfocused but still running
1891− compare(app1.session.surface.activeFocus, false);
1892− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1899+ // Sanity checking
1900+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1901+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1902+ verify(!app1.session.lastSurface.activeFocus);
1903+
1904+ // Make sure app1 is exempt with a requested suspend
1905+ verify(app1.exemptFromLifecycle);
1906+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
18931907 }
18941908
18951909 function test_switchToStagedForcesLegacyAppClosing_data() {