@@ -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,30 @@ 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
67 // kill all (fake) running apps
69− ApplicationManager.mainStageApplications.clear();
68+ killApps(ApplicationManager.mainStageApplications);
70− ApplicationManager.sideStageApplications.clear();
69+ killApps(ApplicationManager.sideStageApplications);
72 var dashHome = findChild(shell, "DashHome");
71 var dashHome = findChild(shell, "DashHome");
73 swipeUntilScopeViewIsReached(dashHome);
72 swipeUntilScopeViewIsReached(dashHome);
75+ function killApps(apps) {
76+ while (apps.count > 0) {
77+ ApplicationManager.stopProcess(apps.get(0));
77 Test the effect of a right-edge drag on the dash in 3 situations:
82 Test the effect of a right-edge drag on the dash in 3 situations:
78 1 - when no application has been launched yet
83 1 - when no application has been launched yet
@@ -100,15 +105,48 @@ Item {
100 // Minimize that application once again
105 // Minimize that application once again
101 swipeFromLeftEdge();
106 swipeFromLeftEdge();
103− // kill it
108+ // Right edge behavior should now be the same as before that app,
104− ApplicationManager.mainStageApplications.clear();
109+ // was launched. Manually cleanup beforehand to get to initial
106 waitForUIToSettle();
112 waitForUIToSettle();
108− // Right edge behavior should now be the same as before that app was launched
109 checkRightEdgeDragWithNoRunningApps();
113 checkRightEdgeDragWithNoRunningApps();
116+ function test_suspend() {
117+ var greeter = findChild(shell, "greeter");
119+ // Launch an app from the launcher
120+ dragLauncherIntoView();
121+ tapOnAppIconInLauncher();
122+ waitUntilApplicationWindowIsFullyVisible();
124+ var mainApp = ApplicationManager.mainStageFocusedApplication;
125+ tryCompareFunction(function() { return mainApp != null; }, true);
128+ Powerd.powerStateChange(0);
129+ tryCompare(greeter, "showProgress", 1);
130+ tryCompare(ApplicationManager, "mainStageFocusedApplication", null);
133+ Powerd.powerStateChange(1);
134+ tryCompare(ApplicationManager, "mainStageFocusedApplication", mainApp);
135+ tryCompare(greeter, "showProgress", 1);
138+ function swipeAwayGreeter() {
139+ var greeter = findChild(shell, "greeter");
140+ tryCompare(greeter, "showProgress", 1);
142+ var touchX = shell.width - (shell.edgeSize / 2);
143+ var touchY = shell.height / 2;
144+ touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY);
146+ // wait until the animation has finished
147+ tryCompare(greeter, "showProgress", 0);
113 Perform a right-edge drag when the Dash is being show and there are
151 Perform a right-edge drag when the Dash is being show and there are
114 no running/minimized apps to be restored.
152 no running/minimized apps to be restored.
@@ -123,8 +161,8 @@ Item {
124 var dash = findChild(shell, "dash");
162 var dash = findChild(shell, "dash");
125 // check that dash has normal scale and opacity
163 // check that dash has normal scale and opacity
126− compare(dash.contentScale, 1.0);
164+ tryCompare(dash.contentScale, 1.0);
127− compare(dash.opacity, 1.0);
165+ tryCompare(dash.opacity, 1.0);
129 touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
167 touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY,
130 true /* beginTouch */, false /* endTouch */);
168 true /* beginTouch */, false /* endTouch */);