@@ -415,7 +415,7 @@ Rectangle {
415 // Open an application and focus
415 // Open an application and focus
416 waitUntilApplicationWindowIsFullyVisible(app);
416 waitUntilApplicationWindowIsFullyVisible(app);
417 ApplicationManager.focusApplication(app);
417 ApplicationManager.focusApplication(app);
418− tryCompare(app.session.surface, "activeFocus", true);
418+ tryCompare(app.session.lastSurface, "activeFocus", true);
420 notifications.model = mockNotificationsModel;
420 notifications.model = mockNotificationsModel;
@@ -437,7 +437,7 @@ Rectangle {
437 waitForRendering(notification);
437 waitForRendering(notification);
439 // Make sure activeFocus went away from the app window
439 // Make sure activeFocus went away from the app window
440− tryCompare(app.session.surface, "activeFocus", false);
440+ tryCompare(app.session.lastSurface, "activeFocus", false);
441 tryCompare(stage, "interactive", false);
441 tryCompare(stage, "interactive", false);
443 // Clicking the button should dismiss the notification and return focus
443 // Clicking the button should dismiss the notification and return focus
@@ -445,7 +445,7 @@ Rectangle {
445 mouseClick(buttonAccept);
445 mouseClick(buttonAccept);
447 // Make sure we're back to normal
447 // Make sure we're back to normal
448− tryCompare(app.session.surface, "activeFocus", true);
448+ tryCompare(app.session.lastSurface, "activeFocus", true);
449 compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
449 compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
@@ -455,8 +455,8 @@ Rectangle {
455 hints: {"x-canonical-private-affirmative-tint": "true"},
455 hints: {"x-canonical-private-affirmative-tint": "true"},
456 summary: "Tom Ato",
456 summary: "Tom Ato",
457 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 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",
458+ icon: "../../tests/graphics/avatars/funky.png",
459− secondaryIcon: "../graphics/applicationIcons/facebook.png",
459+ secondaryIcon: "../../tests/graphics/applicationIcons/facebook.png",
460 actions: [{ id: "ok_id", label: "Ok"},
460 actions: [{ id: "ok_id", label: "Ok"},
461 { id: "cancel_id", label: "Cancel"},
461 { id: "cancel_id", label: "Cancel"},
462 { id: "notreally_id", label: "Not really"},
462 { id: "notreally_id", label: "Not really"},
@@ -777,7 +777,7 @@ Rectangle {
777 var app = ApplicationManager.startApplication("dialer-app");
777 var app = ApplicationManager.startApplication("dialer-app");
778 waitUntilAppWindowIsFullyLoaded(app);
778 waitUntilAppWindowIsFullyLoaded(app);
780− tryCompare(app.session.surface, "activeFocus", true);
780+ tryCompare(app.session.lastSurface, "activeFocus", true);
782 // Drag the indicators panel half-open
782 // Drag the indicators panel half-open
783 var touchX = shell.width / 2;
783 var touchX = shell.width / 2;
@@ -788,7 +788,7 @@ Rectangle {
788 true /* beginTouch */, false /* endTouch */);
788 true /* beginTouch */, false /* endTouch */);
789 verify(indicators.partiallyOpened);
789 verify(indicators.partiallyOpened);
791− tryCompare(app.session.surface, "activeFocus", false);
791+ tryCompare(app.session.lastSurface, "activeFocus", false);
793 // And finish getting it open
793 // And finish getting it open
794 touchFlick(indicators,
794 touchFlick(indicators,
@@ -797,11 +797,11 @@ Rectangle {
797 false /* beginTouch */, true /* endTouch */);
797 false /* beginTouch */, true /* endTouch */);
798 tryCompare(indicators, "fullyOpened", true);
798 tryCompare(indicators, "fullyOpened", true);
800− tryCompare(app.session.surface, "activeFocus", false);
800+ tryCompare(app.session.lastSurface, "activeFocus", false);
802 dragToCloseIndicatorsPanel();
802 dragToCloseIndicatorsPanel();
804− tryCompare(app.session.surface, "activeFocus", true);
804+ tryCompare(app.session.lastSurface, "activeFocus", true);
807 function test_launchedAppHasActiveFocus_data() {
807 function test_launchedAppHasActiveFocus_data() {
@@ -822,9 +822,9 @@ Rectangle {
822 verify(webApp);
822 verify(webApp);
823 waitUntilAppSurfaceShowsUp("webbrowser-app")
823 waitUntilAppSurfaceShowsUp("webbrowser-app")
825− verify(webApp.session.surface);
825+ verify(webApp.session.lastSurface);
827− tryCompare(webApp.session.surface, "activeFocus", true);
827+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
830 function test_launchedAppKeepsActiveFocusOnUsageModeChange() {
830 function test_launchedAppKeepsActiveFocusOnUsageModeChange() {
@@ -835,9 +835,9 @@ Rectangle {
835 verify(webApp);
835 verify(webApp);
836 waitUntilAppSurfaceShowsUp("webbrowser-app")
836 waitUntilAppSurfaceShowsUp("webbrowser-app")
838− verify(webApp.session.surface);
838+ verify(webApp.session.lastSurface);
840− tryCompare(webApp.session.surface, "activeFocus", true);
840+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
842 shell.usageScenario = "desktop";
842 shell.usageScenario = "desktop";
@@ -847,7 +847,7 @@ Rectangle {
847 verify(desktopWindow);
847 verify(desktopWindow);
850− tryCompare(webApp.session.surface, "activeFocus", true);
850+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
852 shell.usageScenario = "tablet";
852 shell.usageScenario = "tablet";
@@ -857,7 +857,7 @@ Rectangle {
857 verify(desktopWindow);
857 verify(desktopWindow);
860− tryCompare(webApp.session.surface, "activeFocus", true);
860+ tryCompare(webApp.session.lastSurface, "activeFocus", true);
863 function waitUntilAppSurfaceShowsUp(appId) {
863 function waitUntilAppSurfaceShowsUp(appId) {
@@ -978,7 +978,7 @@ Rectangle {
979 var app = ApplicationManager.startApplication("dialer-app");
979 var app = ApplicationManager.startApplication("dialer-app");
980 // wait until the app is fully loaded (ie, real surface replaces splash screen)
980 // 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);
983 // Minimize the application we just launched
983 // Minimize the application we just launched
984 swipeFromLeftEdge(shell.width * 0.75);
984 swipeFromLeftEdge(shell.width * 0.75);
@@ -1415,9 +1415,9 @@ Rectangle {
1415 waitUntilAppWindowIsFullyLoaded(app3);
1415 waitUntilAppWindowIsFullyLoaded(app3);
1417 // Do a quick alt-tab and see if focus changes
1417 // Do a quick alt-tab and see if focus changes
1418− tryCompare(app3.session.surface, "activeFocus", true)
1418+ tryCompare(app3.session.lastSurface, "activeFocus", true)
1419 keyClick(Qt.Key_Tab, Qt.ControlModifier)
1419 keyClick(Qt.Key_Tab, Qt.ControlModifier)
1420− tryCompare(app2.session.surface, "activeFocus", true)
1420+ tryCompare(app2.session.lastSurface, "activeFocus", true)
1422 var desktopSpread = findChild(shell, "spread")
1422 var desktopSpread = findChild(shell, "spread")
@@ -1433,7 +1433,7 @@ Rectangle {
1433 tryCompare(desktopSpread, "state", "")
1433 tryCompare(desktopSpread, "state", "")
1435 // Focus should have switched back now
1435 // Focus should have switched back now
1436− tryCompare(app3.session.surface, "activeFocus", true)
1436+ tryCompare(app3.session.lastSurface, "activeFocus", true)
1439 function test_altTabWrapAround() {
1439 function test_altTabWrapAround() {
@@ -1482,7 +1482,7 @@ Rectangle {
1482 tryCompare(desktopSpread, "state", "")
1482 tryCompare(desktopSpread, "state", "")
1484 // Make sure that after wrapping around once, we have the same one focused as at the beginning
1484 // 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)
1488 function test_altBackTabNavigation() {
1488 function test_altBackTabNavigation() {
@@ -1731,6 +1731,7 @@ Rectangle {
1731 tryCompare(desktopSpread, "state", "altTab")
1731 tryCompare(desktopSpread, "state", "altTab")
1733 revealLauncherByEdgePushWithMouse();
1733 revealLauncherByEdgePushWithMouse();
1734+ tryCompare(launcher, "x", 0);
1734 waitForRendering(shell)
1735 waitForRendering(shell)
1736 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
1737 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
@@ -1858,21 +1859,28 @@ Rectangle {
1858 loadShell(data.formFactor);
1859 loadShell(data.formFactor);
1859 shell.usageScenario = data.usageScenario;
1860 shell.usageScenario = data.usageScenario;
1862+ // Add two main stage apps, the second in order to suspend the first.
1863+ // LibreOffice has isTouchApp set to false by our mocks.
1861 var app1 = ApplicationManager.startApplication("libreoffice");
1864 var app1 = ApplicationManager.startApplication("libreoffice");
1862 waitUntilAppWindowIsFullyLoaded(app1);
1865 waitUntilAppWindowIsFullyLoaded(app1);
1863− var app2 = ApplicationManager.startApplication("dialer-app");
1866+ var app2 = ApplicationManager.startApplication("gallery-app");
1864 waitUntilAppWindowIsFullyLoaded(app2);
1867 waitUntilAppWindowIsFullyLoaded(app2);
1866− // Make sure app1 is unfocused but still running
1869+ // Sanity checking
1867− compare(app1.session.surface.activeFocus, false);
1870+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1868− compare(app1.isTouchApp, false); // sanity check our mock, which sets this for us
1871+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1872+ verify(!app1.isTouchApp);
1873+ verify(!app1.session.lastSurface.activeFocus);
1875+ // Make sure app1 is exempt with a requested suspend
1876+ verify(app1.exemptFromLifecycle);
1869− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1877+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
1872 function test_lifecyclePolicyExemption_data() {
1880 function test_lifecyclePolicyExemption_data() {
1873 return [
1881 return [
1874− {tag: "phone", formFactor: "phone", usageScenario: "phone", suspendsApps: true},
1882+ {tag: "phone", formFactor: "phone", usageScenario: "phone"},
1875− {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", suspendsApps: true}
1883+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet"}
@@ -1882,14 +1890,20 @@ Rectangle {
1883 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
1891 GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
1893+ // Add two main stage apps, the second in order to suspend the first
1885 var app1 = ApplicationManager.startApplication("webbrowser-app");
1894 var app1 = ApplicationManager.startApplication("webbrowser-app");
1886 waitUntilAppWindowIsFullyLoaded(app1);
1895 waitUntilAppWindowIsFullyLoaded(app1);
1887− var app2 = ApplicationManager.startApplication("dialer-app");
1896+ var app2 = ApplicationManager.startApplication("gallery-app");
1888 waitUntilAppWindowIsFullyLoaded(app2);
1897 waitUntilAppWindowIsFullyLoaded(app2);
1890− // Make sure app1 is unfocused but still running
1899+ // Sanity checking
1891− compare(app1.session.surface.activeFocus, false);
1900+ compare(app1.stage, ApplicationInfoInterface.MainStage);
1901+ compare(app2.stage, ApplicationInfoInterface.MainStage);
1902+ verify(!app1.session.lastSurface.activeFocus);
1904+ // Make sure app1 is exempt with a requested suspend
1905+ verify(app1.exemptFromLifecycle);
1892− compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1906+ compare(app1.requestedState, ApplicationInfoInterface.RequestedSuspended);
1895 function test_switchToStagedForcesLegacyAppClosing_data() {
1909 function test_switchToStagedForcesLegacyAppClosing_data() {