2 * Copyright (C) 2013,2014,2015 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
20import IntegratedLightDM 0.1 as LightDM
21import Ubuntu.Components 1.1
22import Unity.Application 0.1
23import Unity.Test 0.1 as UT
29 width: shellLoader.width + buttons.width
30 height: shellLoader.height
33 id: applicationArguments
35 function hasGeometry() {
48 Component.onCompleted: {
49 // must set the mock mode before loading the Shell
50 LightDM.Greeter.mockMode = "single-pin";
51 LightDM.Users.mockMode = "single-pin";
52 shellLoader.active = true;
66 property bool itemDestroyed: false
67 sourceComponent: Component {
69 property string indicatorProfile: "phone"
71 Component.onDestruction: {
72 shellLoader.itemDestroyed = true;
82 height: shellLoader.height
85 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
88 anchors { left: parent.left; right: parent.right }
90 text: "Restart Tutorial"
92 if (shellLoader.status !== Loader.Ready)
95 AccountsService.demoEdges = false;
96 AccountsService.demoEdges = true;
109 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
110 property real halfWidth: shell ? shell.width / 2 : 0
111 property real halfHeight: shell ? shell.height / 2 : 0
114 tryCompare(shell, "enabled", true); // enabled by greeter when ready
116 AccountsService.demoEdges = false;
117 AccountsService.demoEdges = true;
122 shellLoader.itemDestroyed = false;
124 shellLoader.active = false;
126 tryCompare(shellLoader, "status", Loader.Null);
127 tryCompare(shellLoader, "item", null);
128 // Loader.status might be Loader.Null and Loader.item might be null but the Loader
129 // item might still be alive. So if we set Loader.active back to true
130 // again right now we will get the very same Shell instance back. So no reload
131 // actually took place. Likely because Loader waits until the next event loop
132 // iteration to do its work. So to ensure the reload, we will wait until the
133 // Shell instance gets destroyed.
134 tryCompare(shellLoader, "itemDestroyed", true);
136 // kill all (fake) running apps
139 // reload our test subject to get it in a fresh state once again
140 shellLoader.active = true;
142 tryCompare(shellLoader, "status", Loader.Ready);
143 removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
146 function killApps() {
147 while (ApplicationManager.count > 1) {
148 var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
149 ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
151 compare(ApplicationManager.count, 1)
154 function swipeAwayGreeter() {
155 var coverPage = findChild(shell, "coverPage");
156 tryCompare(coverPage, "showProgress", 1);
158 touchFlick(shell, halfWidth, halfHeight, shell.width, halfHeight);
160 // wait until the animation has finished
161 var greeter = findChild(shell, "greeter");
162 tryCompare(greeter, "required", false);
163 waitForRendering(greeter);
166 function waitForPage(name) {
167 waitForRendering(findChild(shell, name));
168 var page = findChild(shell, name);
169 tryCompare(page, "shown", true);
170 tryCompare(page.showAnimation, "running", false);
174 function checkTopEdge() {
175 touchFlick(shell, halfWidth, 0, halfWidth, halfHeight);
177 var panel = findChild(shell, "panel");
178 tryCompare(panel.indicators, "fullyClosed", true);
181 function checkLeftEdge() {
182 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
184 var launcher = findChild(shell, "launcher");
185 tryCompare(launcher, "state", "");
188 function checkRightEdge() {
189 if (shell.usageScenario === "phone") {
190 touchFlick(shell, shell.width, halfHeight, halfWidth, halfHeight);
192 var stage = findChild(shell, "stage");
193 var spreadView = findChild(stage, "spreadView");
194 tryCompare(spreadView, "phase", 0);
198 function checkBottomEdge() {
199 // Can't actually check effect of swipe, since dash isn't really loaded
200 var applicationsDisplayLoader = findChild(shell, "applicationsDisplayLoader");
201 tryCompare(applicationsDisplayLoader, "interactive", false);
204 function checkFinished() {
205 tryCompare(AccountsService, "demoEdges", false);
207 var tutorial = findChild(shell, "tutorial");
208 tryCompare(tutorial, "running", false);
210 var launcher = findChild(shell, "launcher");
211 tryCompare(launcher, "shown", false);
214 function goToPage(name) {
215 var page = waitForPage("tutorialLeft");
219 if (name === "tutorialLeft") return page;
220 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
222 page = waitForPage("tutorialLeftFinish");
223 if (name === "tutorialLeftFinish") return page;
224 var tick = findChild(page, "tick");
227 page = waitForPage("tutorialRight");
231 if (name === "tutorialRight") return page;
233 shell.width, halfHeight,
234 halfWidth, halfHeight,
235 true /* beginTouch */, true /* endTouch */,
236 20 /* speed */, 50 /* iterations */);
237 var overlay = findChild(page, "overlay");
238 tryCompare(overlay, "shown", true);
239 var tick = findChild(page, "tick");
242 var page = waitForPage("tutorialBottom");
246 if (name === "tutorialBottom") return page;
247 touchFlick(shell, halfWidth, shell.height, halfWidth, halfHeight);
249 var page = waitForPage("tutorialBottomFinish");
254 if (name === "tutorialBottomFinish") return page;
255 var tick = findChild(page, "tick");
262 function test_walkthrough() {
266 function test_skipOnDesktop() {
267 var tutorial = findChild(shell, "tutorial");
268 tryCompare(tutorial, "active", true);
269 tryCompare(tutorial, "running", true);
271 shell.usageScenario = "desktop";
272 tryCompare(tutorial, "active", false);
273 tryCompare(tutorial, "running", false);
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_launcherNoDragGap() {
325 // See bug 1454882, where if you dragged the launcher while it was
326 // visible, you could pull it further than the edge of the screen.
328 var left = goToPage("tutorialLeft");
329 var launcher = findChild(shell, "launcher");
330 var teaseAnimation = findInvisibleChild(left, "teaseAnimation");
332 // Wait for launcher to be really out there
333 tryCompareFunction(function() {return launcher.x > teaseAnimation.maxBounce/2}, true);
334 verify(teaseAnimation.running);
336 // Start a drag, make sure animation stops
337 touchFlick(shell, 0, halfHeight, units.gu(4), halfHeight, true, false);
338 verify(!teaseAnimation.running);
339 verify(launcher.visibleWidth > 0);
340 verify(launcher.x > 0);
341 compare(launcher.x, teaseAnimation.bounce);
343 // Continue drag, make sure we don't create a gap on the left hand side
344 touchFlick(shell, units.gu(4), halfHeight, shell.width, halfHeight, false, false);
345 verify(!teaseAnimation.running);
346 compare(launcher.visibleWidth, launcher.panelWidth);
347 compare(launcher.x, 0);
349 // Finish and make sure we continue animation
350 touchFlick(shell, shell.width, halfHeight, shell.width, halfHeight, false, true);
351 tryCompare(teaseAnimation, "running", true);
354 function test_spread() {
355 // Unfortunately, most of what we want to test of the spread is
356 // "did it render correctly?" but that's hard to test. So instead,
357 // just poke and prod it a little bit to see if some of the values
358 // we'd expect to be correct, are so.
360 var right = goToPage("tutorialRight");
361 var stage = findChild(right, "stage");
362 var delegate0 = findChild(right, "appDelegate0");
364 tryCompare(stage, "dragProgress", 0);
365 touchFlick(shell, shell.width, halfHeight, shell.width * 0.8, halfHeight, true, false);
366 verify(stage.dragProgress > 0);
367 compare(stage.dragProgress, -delegate0.xTranslate);
368 touchFlick(shell, shell.width * 0.8, halfHeight, shell.width, halfHeight, false, true);
369 tryCompare(stage, "dragProgress", 0);
371 tryCompare(delegate0, "x", shell.width);
373 var screenshotImage = findChild(right, "screenshotImage");
374 tryCompare(screenshotImage, "source", Qt.resolvedUrl("../../../qml/Tutorial/graphics/facebook.png"));
375 tryCompare(screenshotImage, "visible", true);
378 function test_bottomShortDrag() {
379 var bottom = goToPage("tutorialBottom");
381 touchFlick(shell, halfWidth, shell.height, halfWidth, shell.height * 0.8);
383 var errorTextLabel = findChild(bottom, "errorTextLabel");
384 var errorTitleLabel = findChild(bottom, "errorTitleLabel");
385 tryCompare(bottom, "shown", true); // still on bottom page
386 tryCompare(errorTextLabel, "opacity", 1); // show error
387 tryCompare(errorTitleLabel, "opacity", 1); // show error
390 function test_interrupted() {
391 goToPage("tutorialLeft");
392 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