@@ -29,8 +29,11 @@ import Unity.Notifications 1.0
2929import Unity.Test 0.1
3030import Powerd 0.1
3131import Wizard 0.1 as Wizard
32+import Utils 0.1
3233
3334import "../../qml"
35+import "../../qml/Components"
36+import "../../qml/Components/PanelState"
3437import "Stages"
3538
3639Rectangle {
@@ -97,8 +100,7 @@ Rectangle {
97100 id: __shell
98101 usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
99102 orientation: Qt.PortraitOrientation
100− primaryOrientation: Qt.PortraitOrientation
101− nativeOrientation: Qt.PortraitOrientation
103+ orientations: Orientations{} // Defaults are fine for testing
102104 Component.onDestruction: {
103105 shellLoader.itemDestroyed = true;
104106 }
@@ -302,6 +304,7 @@ Rectangle {
302304 mouseEmulation.checked = true;
303305 tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
304306 tearDown();
307+ WindowStateStorage.clear();
305308 }
306309
307310 function loadShell(formFactor) {
@@ -377,6 +380,8 @@ Rectangle {
377380 LightDM.Greeter.authenticate(""); // reset greeter
378381
379382 sessionSpy.clear();
383+
384+ GSettingsController.setLifecycleExemptAppids([]);
380385 }
381386
382387 function killApps() {
@@ -1707,5 +1712,177 @@ Rectangle {
17071712
17081713 keyRelease(Qt.Key_Control);
17091714 }
1715+
1716+ // regression test for http://pad.lv/1443319
1717+ function test_closeMaximizedAndRestart() {
1718+ loadDesktopShellWithApps();
1719+
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");
1724+
1725+ wait(5000)
1726+ tryCompare(appDelegate, "state", "normal");
1727+ tryCompare(PanelState, "buttonsVisible", false)
1728+
1729+ wait(5000)
1730+ mouseClick(maximizeButton, maximizeButton.width / 2, maximizeButton.height / 2);
1731+ tryCompare(appDelegate, "state", "maximized");
1732+ tryCompare(PanelState, "buttonsVisible", true)
1733+
1734+ ApplicationManager.stopApplication(appId);
1735+ tryCompare(PanelState, "buttonsVisible", false)
1736+
1737+ ApplicationManager.startApplication(appId);
1738+ tryCompare(PanelState, "buttonsVisible", true)
1739+ }
1740+
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")
1748+
1749+ tryCompare(appDelegate, "state", "normal");
1750+ tryCompare(panelButtons, "visible", false);
1751+
1752+ appDelegate.maximize(false);
1753+ tryCompare(panelButtons, "visible", true);
1754+
1755+ shell.usageScenario = "phone";
1756+ waitForRendering(shell);
1757+ tryCompare(panelButtons, "visible", false);
1758+
1759+ shell.usageScenario = "desktop";
1760+ waitForRendering(shell);
1761+ tryCompare(panelButtons, "visible", true);
1762+ }
1763+
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")
1770+
1771+ tryCompare(appDelegate, "state", "normal");
1772+ tryCompare(panelButtons, "visible", false);
1773+
1774+ appDelegate.maximize(false);
1775+ tryCompare(panelButtons, "visible", true);
1776+
1777+ LightDM.Greeter.showGreeter();
1778+ waitForRendering(shell);
1779+ tryCompare(panelButtons, "visible", false);
1780+
1781+ LightDM.Greeter.hideGreeter();
1782+ waitForRendering(shell);
1783+ tryCompare(panelButtons, "visible", true);
1784+ }
1785+
1786+ function test_lifecyclePolicyForNonTouchApp_data() {
1787+ return [
1788+ {tag: "phone", formFactor: "phone", usageScenario: "phone"},
1789+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet"}
1790+ ]
1791+ }
1792+
1793+ function test_lifecyclePolicyForNonTouchApp(data) {
1794+ loadShell(data.formFactor);
1795+ shell.usageScenario = data.usageScenario;
1796+
1797+ var app1 = ApplicationManager.startApplication("libreoffice");
1798+ waitUntilAppWindowIsFullyLoaded(app1);
1799+ var app2 = ApplicationManager.startApplication("dialer-app");
1800+ waitUntilAppWindowIsFullyLoaded(app2);
1801+
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);
1806+ }
1807+
1808+ function test_lifecyclePolicyExemption_data() {
1809+ return [
1810+ {tag: "phone", formFactor: "phone", usageScenario: "phone", suspendsApps: true},
1811+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", suspendsApps: true}
1812+ ]
1813+ }
1814+
1815+ function test_lifecyclePolicyExemption(data) {
1816+ loadShell(data.formFactor);
1817+ shell.usageScenario = data.usageScenario;
1818+
1819+ GSettingsController.setLifecycleExemptAppids(["webbrowser-app"]);
1820+
1821+ var app1 = ApplicationManager.startApplication("webbrowser-app");
1822+ waitUntilAppWindowIsFullyLoaded(app1);
1823+ var app2 = ApplicationManager.startApplication("dialer-app");
1824+ waitUntilAppWindowIsFullyLoaded(app2);
1825+
1826+ // Make sure app1 is unfocused but still running
1827+ compare(app1.session.surface.activeFocus, false);
1828+ compare(app1.requestedState, ApplicationInfoInterface.RequestedRunning);
1829+ }
1830+
1831+ function test_switchToStagedForcesLegacyAppClosing_data() {
1832+ return [
1833+ {tag: "forceClose", replug: false },
1834+ {tag: "replug", replug: true }
1835+ ];
1836+ }
1837+
1838+ function test_switchToStagedForcesLegacyAppClosing(data) {
1839+ loadShell("desktop")
1840+ shell.usageScenario = "desktop"
1841+ waitForRendering(shell);
1842+
1843+ ApplicationManager.startApplication("camera-app")
1844+
1845+ shell.usageScenario = "phone"
1846+ waitForRendering(shell);
1847+
1848+ // No legacy app running yet... Popup must *not* show.
1849+ var popup = findChild(root, "modeSwitchWarningDialog");
1850+ compare(popup, null);
1851+
1852+ shell.usageScenario = "desktop"
1853+ waitForRendering(shell);
1854+
1855+ // Now start a legacy app
1856+ ApplicationManager.startApplication("libreoffice")
1857+
1858+ shell.usageScenario = "phone"
1859+ waitForRendering(shell);
1860+
1861+ // The popup must appear now
1862+ popup = findChild(root, "modeSwitchWarningDialog");
1863+ compare(popup !== null, true);
1864+
1865+ if (data.replug) {
1866+ shell.usageScenario = "desktop"
1867+ waitForRendering(shell);
1868+
1869+ } else {
1870+ var forceCloseButton = findChild(popup, "forceCloseButton");
1871+ mouseClick(forceCloseButton, forceCloseButton.width / 2, forceCloseButton.height / 2);
1872+ waitForRendering(root);
1873+ }
1874+
1875+ // Popup must be gone now
1876+ popup = findChild(root, "modeSwitchWarningDialog");
1877+ compare(popup === null, true);
1878+
1879+ if (data.replug) {
1880+ // Libreoffice must still be running
1881+ compare(ApplicationManager.findApplication("libreoffice") !== null, true);
1882+ } else {
1883+ // Libreoffice must be gone now
1884+ compare(ApplicationManager.findApplication("libreoffice") === null, true);
1885+ }
1886+ }
17101887 }
17111888}