@@ -0,0 +1,287 @@
2+ * Copyright (C) 2013,2014 Canonical, Ltd.
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+import AccountsService 0.1
20+import LightDM 0.1 as LightDM
21+import Ubuntu.Components 1.1
22+import Unity.Application 0.1
23+import Unity.Test 0.1 as UT
29+ width: shellLoader.width + buttons.width
30+ height: shellLoader.height
33+ id: applicationArguments
35+ function hasGeometry() {
58+ property bool itemDestroyed: false
59+ sourceComponent: Component {
61+ property string indicatorProfile: "phone"
63+ Component.onDestruction: {
64+ shellLoader.itemDestroyed = true;
74+ height: shellLoader.height
77+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
80+ anchors { left: parent.left; right: parent.right }
82+ text: "Restart Tutorial"
84+ if (shellLoader.status !== Loader.Ready)
87+ AccountsService.demoEdges = false;
88+ AccountsService.demoEdges = true;
101+ property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
102+ property real halfWidth: shell ? shell.width / 2 : 0
103+ property real halfHeight: shell ? shell.height / 2 : 0
107+ AccountsService.demoEdges = false;
108+ AccountsService.demoEdges = true;
110+ var tutorial = findChild(shell, "tutorial");
111+ tutorial.readingDelay = 1;
114+ function cleanup() {
115+ shellLoader.itemDestroyed = false;
117+ shellLoader.active = false;
119+ tryCompare(shellLoader, "status", Loader.Null);
120+ tryCompare(shellLoader, "item", null);
121+ // Loader.status might be Loader.Null and Loader.item might be null but the Loader
122+ // item might still be alive. So if we set Loader.active back to true
123+ // again right now we will get the very same Shell instance back. So no reload
124+ // actually took place. Likely because Loader waits until the next event loop
125+ // iteration to do its work. So to ensure the reload, we will wait until the
126+ // Shell instance gets destroyed.
127+ tryCompare(shellLoader, "itemDestroyed", true);
129+ // kill all (fake) running apps
132+ // reload our test subject to get it in a fresh state once again
133+ shellLoader.active = true;
135+ tryCompare(shellLoader, "status", Loader.Ready);
136+ removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
139+ function killApps() {
140+ while (ApplicationManager.count > 1) {
141+ var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
142+ ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
144+ compare(ApplicationManager.count, 1)
147+ function swipeAwayGreeter() {
148+ var greeter = findChild(shell, "greeter");
149+ tryCompare(greeter, "showProgress", 1);
151+ touchFlick(shell, halfWidth, halfHeight, shell.width, halfHeight);
153+ // wait until the animation has finished
154+ tryCompare(greeter, "showProgress", 0);
155+ waitForRendering(greeter);
158+ function waitForPage(name) {
159+ tryCompareFunction(function() { return findChild(shell, name) !== null; }, true);
160+ return findChild(shell, name);
163+ function checkTopEdge() {
164+ touchFlick(shell, halfWidth, 0, halfWidth, halfHeight);
166+ var panel = findChild(shell, "panel");
167+ tryCompare(panel.indicators, "fullyClosed", true);
170+ function checkLeftEdge() {
171+ touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
173+ var launcher = findChild(shell, "launcher");
174+ tryCompare(launcher, "state", "");
177+ function checkRightEdge() {
178+ touchFlick(shell, shell.width, halfHeight, halfWidth, halfHeight);
180+ var stage = findChild(shell, "stage");
181+ var spreadView = findChild(stage, "spreadView");
182+ tryCompare(spreadView, "phase", 0);
185+ function checkBottomEdge() {
186+ // Can't actually check effect of swipe, since dash isn't really loaded
187+ var applicationsDisplayLoader = findChild(shell, "applicationsDisplayLoader");
188+ tryCompare(applicationsDisplayLoader.item, "interactive", false);
191+ function checkFinished() {
192+ tryCompare(AccountsService, "demoEdges", false);
194+ var tutorial = findChild(shell, "tutorial");
195+ tryCompare(tutorial, "running", false);
197+ var launcher = findChild(shell, "launcher");
198+ tryCompare(launcher, "shown", false);
201+ function goToPage(name) {
202+ var page = waitForPage("tutorialIntro");
203+ if (name === "tutorialIntro") return page;
204+ // Intro page will pass by itself
206+ page = waitForPage("tutorialTop");
210+ if (name === "tutorialTop") return page;
211+ touchFlick(shell, halfWidth, 0, halfWidth, shell.height);
213+ page = waitForPage("tutorialTopFinish");
217+ if (name === "tutorialTopFinish") return page;
218+ touchFlick(shell, halfWidth, shell.height, halfWidth, 0);
220+ page = waitForPage("tutorialLeft");
224+ if (name === "tutorialLeft") return page;
225+ touchFlick(shell, 0, halfHeight, halfWidth, halfHeight, true, false);
227+ page = waitForPage("tutorialLeftFinish");
228+ if (name === "tutorialLeftFinish") return page;
229+ touchFlick(shell, halfWidth, halfHeight, halfWidth, halfHeight, false, true);
235+ function test_skippable() {
236+ var top = goToPage("tutorialTop");
238+ var skipLabel = findChild(top, "skipLabel");
244+ function test_walkthrough() {
248+ function test_launcherShortDrags() {
249+ // goToPage does a full launcher pull. But here we want to test
250+ // just barely pulling the launcher out and letting go (i.e. not
251+ // triggering the "progress" property of Launcher).
253+ var left = goToPage("tutorialLeft");
255+ // Make sure we don't do anything if we don't pull the launcher
257+ var launcher = findChild(shell, "launcher");
258+ touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.6, halfHeight);
259+ tryCompare(launcher, "state", ""); // should remain hidden
260+ tryCompare(left, "shown", true); // and we should still be on left
262+ // Now drag out but not past launcher itself
263+ touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.9, halfHeight);
265+ // That actually finishes the launcher tutorial (drag is already
266+ // over, it would be silly to show LeftFinish page that asks for a
271+ function test_launcherDragBack() {
272+ // goToPage does a full launcher pull. But here we test pulling
273+ // all the way out, then dragging back into place.
275+ goToPage("tutorialLeftFinish");
276+ touchFlick(shell, halfWidth, halfHeight, 0, halfHeight, false, true);
281+ function test_interrupted() {
282+ goToPage("tutorialTop");
283+ ApplicationManager.startApplication("dialer-app");