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/>.
19import AccountsService 0.1
21import LightDM 0.1 as LightDM
22import Ubuntu.Components 1.1
23import Unity.Application 0.1
24import Unity.Test 0.1 as UT
30 width: shellLoader.width + buttons.width
31 height: shellLoader.height
34 id: applicationArguments
36 function hasGeometry() {
51 schema.id: "com.canonical.Unity8"
54 Component.onCompleted: {
55 // must set the mock mode before loading the Shell
56 LightDM.Greeter.mockMode = "single-pin";
57 LightDM.Users.mockMode = "single-pin";
58 shellLoader.active = true;
72 property bool itemDestroyed: false
73 sourceComponent: Component {
75 property string indicatorProfile: "phone"
77 Component.onDestruction: {
78 shellLoader.itemDestroyed = true;
88 height: shellLoader.height
91 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
94 anchors { left: parent.left; right: parent.right }
96 text: "Restart Tutorial"
98 if (shellLoader.status !== Loader.Ready)
101 AccountsService.demoEdges = false;
102 AccountsService.demoEdges = true;
115 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
116 property real halfWidth: shell ? shell.width / 2 : 0
117 property real halfHeight: shell ? shell.height / 2 : 0
120 tryCompare(shell, "enabled", true); // enabled by greeter when ready
121 unity8Settings.usageMode = "Staged";
122 AccountsService.demoEdges = false;
123 AccountsService.demoEdges = true;
128 shellLoader.itemDestroyed = false;
130 shellLoader.active = false;
132 tryCompare(shellLoader, "status", Loader.Null);
133 tryCompare(shellLoader, "item", null);
134 // Loader.status might be Loader.Null and Loader.item might be null but the Loader
135 // item might still be alive. So if we set Loader.active back to true
136 // again right now we will get the very same Shell instance back. So no reload
137 // actually took place. Likely because Loader waits until the next event loop
138 // iteration to do its work. So to ensure the reload, we will wait until the
139 // Shell instance gets destroyed.
140 tryCompare(shellLoader, "itemDestroyed", true);
142 // kill all (fake) running apps
145 // reload our test subject to get it in a fresh state once again
146 shellLoader.active = true;
148 tryCompare(shellLoader, "status", Loader.Ready);
149 removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
152 function killApps() {
153 while (ApplicationManager.count > 1) {
154 var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
155 ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
157 compare(ApplicationManager.count, 1)
160 function swipeAwayGreeter() {
161 var coverPage = findChild(shell, "coverPage");
162 tryCompare(coverPage, "showProgress", 1);
164 touchFlick(shell, halfWidth, halfHeight, shell.width, halfHeight);
166 // wait until the animation has finished
167 var greeter = findChild(shell, "greeter");
168 tryCompare(greeter, "required", false);
169 waitForRendering(greeter);
172 function waitForPage(name) {
173 waitForRendering(findChild(shell, name));
174 var page = findChild(shell, name);
175 tryCompare(page, "shown", true);
176 tryCompare(page.showAnimation, "running", false);
180 function checkTopEdge() {
181 touchFlick(shell, halfWidth, 0, halfWidth, halfHeight);
183 var panel = findChild(shell, "panel");
184 tryCompare(panel.indicators, "fullyClosed", true);
187 function checkLeftEdge() {
188 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
190 var launcher = findChild(shell, "launcher");
191 tryCompare(launcher, "state", "");
194 function checkRightEdge() {
195 if (unity8Settings.usageMode === "Staged") {
196 touchFlick(shell, shell.width, halfHeight, halfWidth, halfHeight);
198 var stage = findChild(shell, "stage");
199 var spreadView = findChild(stage, "spreadView");
200 tryCompare(spreadView, "phase", 0);
204 function checkBottomEdge() {
205 // Can't actually check effect of swipe, since dash isn't really loaded
206 var applicationsDisplayLoader = findChild(shell, "applicationsDisplayLoader");
207 tryCompare(applicationsDisplayLoader, "interactive", false);
210 function checkFinished() {
211 tryCompare(AccountsService, "demoEdges", false);
213 var tutorial = findChild(shell, "tutorial");
214 tryCompare(tutorial, "running", false);
216 var launcher = findChild(shell, "launcher");
217 tryCompare(launcher, "shown", false);
220 function goToPage(name) {
221 var page = waitForPage("tutorialLeft");
225 if (name === "tutorialLeft") return page;
226 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
228 page = waitForPage("tutorialLeftFinish");
229 if (name === "tutorialLeftFinish") return page;
230 var tick = findChild(page, "tick");
233 page = waitForPage("tutorialRight");
237 if (name === "tutorialRight") return page;
238 touchFlick(shell, shell.width, halfHeight, halfWidth, halfHeight);
239 var overlay = findChild(page, "overlay");
240 tryCompare(overlay, "shown", true);
241 var tick = findChild(page, "tick");
244 var page = waitForPage("tutorialBottom");
248 if (name === "tutorialBottom") return page;
249 touchFlick(shell, halfWidth, shell.height, halfWidth, halfHeight);
251 var page = waitForPage("tutorialBottomFinish");
256 if (name === "tutorialBottomFinish") return page;
257 var tick = findChild(page, "tick");
264 function test_walkthrough() {
268 function test_walkthroughOnDesktop() {
269 unity8Settings.usageMode = "Windowed";
270 var page = goToPage("tutorialLeftFinish");
271 var tick = findChild(page, "tick");
276 function test_launcherShortDrag() {
277 // goToPage does a normal launcher pull. But here we want to test
278 // just barely pulling the launcher out and letting go (i.e. not
279 // triggering the "progress" property of Launcher).
281 var left = goToPage("tutorialLeft");
283 // Make sure we don't do anything if we don't pull the launcher
285 var launcher = findChild(shell, "launcher");
286 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.4, halfHeight);
287 tryCompare(launcher, "state", ""); // should remain hidden
288 tryCompare(left, "shown", true); // and we should still be on left
290 // Now drag out but not past launcher itself
291 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.9, halfHeight);
293 waitForPage("tutorialLeftFinish");
296 function test_launcherLongDrag() {
297 // goToPage does a normal launcher pull. But here we want to test
298 // a full pull across the page.
300 var left = goToPage("tutorialLeft");
302 var launcher = findChild(shell, "launcher");
303 touchFlick(shell, 0, halfHeight, shell.width, halfHeight);
305 var errorTextLabel = findChild(left, "errorTextLabel");
306 var errorTitleLabel = findChild(left, "errorTitleLabel");
307 tryCompare(launcher, "state", ""); // launcher goes away
308 tryCompare(left, "shown", true); // still on left page
309 tryCompare(errorTextLabel, "opacity", 1); // show error
310 tryCompare(errorTitleLabel, "opacity", 1); // show error
313 function test_launcherDragBack() {
314 // goToPage does a full launcher pull. But here we test pulling
315 // all the way out, then dragging back into place.
317 var left = goToPage("tutorialLeft");
318 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight, true, false);
319 touchFlick(shell, halfWidth, halfHeight, 0, halfHeight, false, true);
321 tryCompare(left, "shown", true); // and we should still be on left
324 function test_spread() {
325 // Unfortunately, most of what we want to test of the spread is
326 // "did it render correctly?" but that's hard to test. So instead,
327 // just poke and prod it a little bit to see if some of the values
328 // we'd expect to be correct, are so.
330 var right = goToPage("tutorialRight");
331 var stage = findChild(right, "stage");
332 var delegate0 = findChild(right, "appDelegate0");
334 tryCompare(stage, "dragProgress", 0);
335 touchFlick(shell, shell.width, halfHeight, shell.width * 0.8, halfHeight, true, false);
336 verify(stage.dragProgress > 0);
337 compare(stage.dragProgress, -delegate0.xTranslate);
338 touchFlick(shell, shell.width * 0.8, halfHeight, shell.width, halfHeight, false, true);
339 tryCompare(stage, "dragProgress", 0);
341 tryCompare(delegate0, "x", shell.width);
343 var screenshotImage = findChild(right, "screenshotImage");
344 tryCompare(screenshotImage, "source", Qt.resolvedUrl("../../../qml/Tutorial/graphics/facebook.png"));
345 tryCompare(screenshotImage, "visible", true);
348 function test_bottomShortDrag() {
349 var bottom = goToPage("tutorialBottom");
351 touchFlick(shell, halfWidth, shell.height, halfWidth, shell.height * 0.8);
353 var errorTextLabel = findChild(bottom, "errorTextLabel");
354 var errorTitleLabel = findChild(bottom, "errorTitleLabel");
355 tryCompare(bottom, "shown", true); // still on bottom page
356 tryCompare(errorTextLabel, "opacity", 1); // show error
357 tryCompare(errorTitleLabel, "opacity", 1); // show error
360 function test_interrupted() {
361 goToPage("tutorialLeft");
362 ApplicationManager.startApplication("dialer-app");
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list