@@ -29,8 +29,11 @@ import Unity.Notifications 1.0
29import Unity.Test 0.1
29import Unity.Test 0.1
30import Powerd 0.1
30import Powerd 0.1
31import Wizard 0.1 as Wizard
31import Wizard 0.1 as Wizard
33import "../../qml"
34import "../../qml"
35+import "../../qml/Components"
36+import "../../qml/Components/PanelState"
34import "Stages"
37import "Stages"
36Rectangle {
39Rectangle {
@@ -97,8 +100,7 @@ Rectangle {
97 id: __shell
100 id: __shell
98 usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
101 usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
99 orientation: Qt.PortraitOrientation
102 orientation: Qt.PortraitOrientation
100− primaryOrientation: Qt.PortraitOrientation
103+ orientations: Orientations{} // Defaults are fine for testing
101− nativeOrientation: Qt.PortraitOrientation
102 Component.onDestruction: {
104 Component.onDestruction: {
103 shellLoader.itemDestroyed = true;
105 shellLoader.itemDestroyed = true;
@@ -302,6 +304,7 @@ Rectangle {
302 mouseEmulation.checked = true;
304 mouseEmulation.checked = true;
303 tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
305 tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
304 tearDown();
306 tearDown();
307+ WindowStateStorage.clear();
307 function loadShell(formFactor) {
310 function loadShell(formFactor) {
@@ -377,6 +380,8 @@ Rectangle {
377 LightDM.Greeter.authenticate(""); // reset greeter
380 LightDM.Greeter.authenticate(""); // reset greeter
379 sessionSpy.clear();
382 sessionSpy.clear();
384+ GSettingsController.setLifecycleExemptAppids([]);
382 function killApps() {
387 function killApps() {
@@ -1707,5 +1712,177 @@ Rectangle {
1708 keyRelease(Qt.Key_Control);
1713 keyRelease(Qt.Key_Control);
1716+ // regression test for http://pad.lv/1443319
1717+ function test_closeMaximizedAndRestart() {
1718+ loadDesktopShellWithApps();
1720+ var appRepeater = findChild(shell, "appRepeater")
1721+ var appId = ApplicationManager.get(0).appId;
1722+ var appDelegate = appRepeater.itemAt(0);
1723+ var maximizeButton = findChild(appDelegate, "maximizeWindowButton");
1726+ tryCompare(appDelegate, "state", "normal");
1727+ tryCompare(PanelState, "buttonsVisible", false)
1730+ mouseClick(maximizeButton, maximizeButton.width / 2, maximizeButton.height / 2);
1731+ tryCompare(appDelegate, "state", "maximized");
1732+ tryCompare(PanelState, "buttonsVisible", true)
1734+ ApplicationManager.stopApplication(appId);
1735+ tryCompare(PanelState, "buttonsVisible", false)
1737+ ApplicationManager.startApplication(appId);
1738+ tryCompare(PanelState, "buttonsVisible", true)
1741+ // bug http://pad.lv/1431566
1742+ function test_switchToStagedHidesPanelButtons() {
1743+ loadDesktopShellWithApps();
1744+ var appRepeater = findChild(shell, "appRepeater")
1745+ var appId = ApplicationManager.get(0).appId;
1746+ var appDelegate = appRepeater.itemAt(0);
1747+ var panelButtons = findChild(shell, "panelWindowControlButtons")
1749+ tryCompare(appDelegate, "state", "normal");
1750+ tryCompare(panelButtons, "visible", false);
1752+ appDelegate.maximize(false);
1753+ tryCompare(panelButtons, "visible", true);
1755+ shell.usageScenario = "phone";
1756+ waitForRendering(shell);
1757+ tryCompare(panelButtons, "visible", false);
1759+ shell.usageScenario = "desktop";
1760+ waitForRendering(shell);
1761+ tryCompare(panelButtons, "visible", true);
1764+ function test_lockingGreeterHidesPanelButtons() {
1765+ loadDesktopShellWithApps();
1766+ var appRepeater = findChild(shell, "appRepeater")
1767+ var appId = ApplicationManager.get(0).appId;
1768+ var appDelegate = appRepeater.itemAt(0);
1769+ var panelButtons = findChild(shell, "panelWindowControlButtons")
1771+ tryCompare(appDelegate, "state", "normal");
1772+ tryCompare(panelButtons, "visible", false);
1774+ appDelegate.maximize(false);
1775+ tryCompare(panelButtons, "visible", true);
1777+ LightDM.Greeter.showGreeter();
1778+ waitForRendering(shell);
1779+ tryCompare(panelButtons, "visible", false);
1781+ LightDM.Greeter.hideGreeter();
1782+ waitForRendering(shell);
1783+ tryCompare(panelButtons, "visible", true);
1786+ function test_lifecyclePolicyForNonTouchApp_data() {
1788+ {tag: "phone", formFactor: "phone", usageScenario: "phone"},
1789+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet"}
1793+ function test_lifecyclePolicyForNonTouchApp(data) {
1794+ loadShell(data.formFactor);
1795+ shell.usageScenario = data.usageScenario;
1797+ var app1 = ApplicationManager.startApplication("libreoffice");
1798+ waitUntilAppWindowIsFullyLoaded(app1);
1799+ var app2 = ApplicationManager.startApplication("dialer-app");
1800+ waitUntilAppWindowIsFullyLoaded(app2);
1802+ // Make sure app1 is unfocused but still running
1803+ compare(app1.session.surface.activeFocus, false);
1804+ compare(app1.isTouchApp, false); // sanity check our mock, which sets this for us
1805+ compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1808+ function test_lifecyclePolicyExemption_data() {
1810+ {tag: "phone", formFactor: "phone", usageScenario: "phone", suspendsApps: true},
1811+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", suspendsApps: true}
1815+ function test_lifecyclePolicyExemption(data) {
1816+ loadShell(data.formFactor);
1817+ shell.usageScenario = data.usageScenario;
1819+ GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
1821+ var app1 = ApplicationManager.startApplication("webbrowser-app");
1822+ waitUntilAppWindowIsFullyLoaded(app1);
1823+ var app2 = ApplicationManager.startApplication("dialer-app");
1824+ waitUntilAppWindowIsFullyLoaded(app2);
1826+ // Make sure app1 is unfocused but still running
1827+ compare(app1.session.surface.activeFocus, false);
1828+ compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1831+ function test_switchToStagedForcesLegacyAppClosing_data() {
1833+ {tag: "forceClose", replug: false },
1834+ {tag: "replug", replug: true }
1838+ function test_switchToStagedForcesLegacyAppClosing(data) {
1839+ loadShell("desktop")
1840+ shell.usageScenario = "desktop"
1841+ waitForRendering(shell);
1843+ ApplicationManager.startApplication("camera-app")
1845+ shell.usageScenario = "phone"
1846+ waitForRendering(shell);
1848+ // No legacy app running yet... Popup must *not* show.
1849+ var popup = findChild(root, "modeSwitchWarningDialog");
1850+ compare(popup, null);
1852+ shell.usageScenario = "desktop"
1853+ waitForRendering(shell);
1855+ // Now start a legacy app
1856+ ApplicationManager.startApplication("libreoffice")
1858+ shell.usageScenario = "phone"
1859+ waitForRendering(shell);
1861+ // The popup must appear now
1862+ popup = findChild(root, "modeSwitchWarningDialog");
1863+ compare(popup !== null, true);
1866+ shell.usageScenario = "desktop"
1867+ waitForRendering(shell);
1870+ var forceCloseButton = findChild(popup, "forceCloseButton");
1871+ mouseClick(forceCloseButton, forceCloseButton.width / 2, forceCloseButton.height / 2);
1872+ waitForRendering(root);
1875+ // Popup must be gone now
1876+ popup = findChild(root, "modeSwitchWarningDialog");
1877+ compare(popup === null, true);
1880+ // Libreoffice must still be running
1881+ compare(ApplicationManager.findApplication("libreoffice") !== null, true);
1883+ // Libreoffice must be gone now
1884+ compare(ApplicationManager.findApplication("libreoffice") === null, true);