@@ -21,6 +21,7 @@ import QtQuick 2.0
21import QtTest 1.0
21import QtTest 1.0
22import Ubuntu.Application 0.1
22import Ubuntu.Application 0.1
23import Unity.Test 0.1 as UT
23import Unity.Test 0.1 as UT
25import "../.."
26import "../.."
@@ -53,26 +54,29 @@ Item {
53 when: windowShown
54 when: windowShown
55 function initTestCase() {
56 function initTestCase() {
56− // swipe away the greeter/lockscreen
57+ swipeAwayGreeter();
57− var touchX = shell.width - (shell.edgeSize / 2);
58− var touchY = shell.height / 2;
59− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY);
61− var dash = findChild(shell, "dash");
62− // wait until the animation has finished
63− tryCompare(dash, "contentScale", 1.0);
64− tryCompare(dash, "opacity", 1.0);
67 function cleanup() {
60 function cleanup() {
61+ // If a test invoked the greeter, make sure we swipe it away again
62+ var greeter = findChild(shell, "greeter");
68 // kill all (fake) running apps
66 // kill all (fake) running apps
69− ApplicationManager.mainStageApplications.clear();
67+ killApps(ApplicationManager.mainStageApplications);
70− ApplicationManager.sideStageApplications.clear();
68+ killApps(ApplicationManager.sideStageApplications);
72 var dashHome = findChild(shell, "DashHome");
70 var dashHome = findChild(shell, "DashHome");
73 swipeUntilScopeViewIsReached(dashHome);
71 swipeUntilScopeViewIsReached(dashHome);
74+ function killApps(apps) {
75+ while (apps.count > 0) {
76+ ApplicationManager.stopProcess(apps.get(0));
77 Test the effect of a right-edge drag on the dash in 3 situations:
81 Test the effect of a right-edge drag on the dash in 3 situations:
78 1 - when no application has been launched yet
82 1 - when no application has been launched yet
@@ -100,15 +104,48 @@ Item {
100 // Minimize that application once again
104 // Minimize that application once again
101 swipeFromLeftEdge();
105 swipeFromLeftEdge();
103− // kill it
107+ // Right edge behavior should now be the same as before that app,
104− ApplicationManager.mainStageApplications.clear();
108+ // was launched. Manually cleanup beforehand to get to initial
106 waitForUIToSettle();
111 waitForUIToSettle();
108− // Right edge behavior should now be the same as before that app was launched
109 checkRightEdgeDragWithNoRunningApps();
112 checkRightEdgeDragWithNoRunningApps();
115+ function test_suspend() {
116+ var greeter = findChild(shell, "greeter");
118+ // Launch an app from the launcher
119+ dragLauncherIntoView();
120+ tapOnAppIconInLauncher();
121+ waitUntilApplicationWindowIsFullyVisible();
123+ var mainApp = ApplicationManager.mainStageFocusedApplication;
124+ tryCompareFunction(function() { return mainApp != null; }, true);
127+ Powerd.powerStateChange(0);
128+ tryCompare(greeter, "showProgress", 1);
129+ tryCompare(ApplicationManager, "mainStageFocusedApplication", null);
132+ Powerd.powerStateChange(1);
133+ tryCompare(ApplicationManager, "mainStageFocusedApplication", mainApp);
134+ tryCompare(greeter, "showProgress", 1);
137+ function swipeAwayGreeter() {
138+ var greeter = findChild(shell, "greeter");
139+ tryCompare(greeter, "showProgress", 1);
141+ var touchX = shell.width - (shell.edgeSize / 2);
142+ var touchY = shell.height / 2;
143+ touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY);
145+ // wait until the animation has finished
146+ tryCompare(greeter, "showProgress", 0);
113 Perform a right-edge drag when the Dash is being show and there are
150 Perform a right-edge drag when the Dash is being show and there are
114 no running/minimized apps to be restored.
151 no running/minimized apps to be restored.
@@ -123,8 +160,8 @@ Item {
124 var dash = findChild(shell, "dash");
161 var dash = findChild(shell, "dash");
125 // check that dash has normal scale and opacity
162 // check that dash has normal scale and opacity
126− compare(dash.contentScale, 1.0);
163+ tryCompare(dash.contentScale, 1.0);
127− compare(dash.opacity, 1.0);
164+ tryCompare(dash.opacity, 1.0);
129 touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
166 touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
130 true /* beginTouch */, false /* endTouch */);
167 true /* beginTouch */, false /* endTouch */);