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
20import LightDM 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
115 AccountsService.demoEdges = false;
116 AccountsService.demoEdges = true;
121 shellLoader.itemDestroyed = false;
123 shellLoader.active = false;
125 tryCompare(shellLoader, "status", Loader.Null);
126 tryCompare(shellLoader, "item", null);
127 // Loader.status might be Loader.Null and Loader.item might be null but the Loader
128 // item might still be alive. So if we set Loader.active back to true
129 // again right now we will get the very same Shell instance back. So no reload
130 // actually took place. Likely because Loader waits until the next event loop
131 // iteration to do its work. So to ensure the reload, we will wait until the
132 // Shell instance gets destroyed.
133 tryCompare(shellLoader, "itemDestroyed", true);
135 // kill all (fake) running apps
138 // reload our test subject to get it in a fresh state once again
139 shellLoader.active = true;
141 tryCompare(shellLoader, "status", Loader.Ready);
142 removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
145 function killApps() {
146 while (ApplicationManager.count > 1) {
147 var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
148 ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
150 compare(ApplicationManager.count, 1)
153 function swipeAwayGreeter() {
154 var coverPage = findChild(shell, "coverPage");
155 tryCompare(coverPage, "showProgress", 1);
157 touchFlick(shell, halfWidth, halfHeight, shell.width, halfHeight);
159 // wait until the animation has finished
160 var greeter = findChild(shell, "greeter");
161 tryCompare(greeter, "required", false);
162 waitForRendering(greeter);
165 function waitForPage(name) {
166 waitForRendering(findChild(shell, name));
167 var page = findChild(shell, name);
168 tryCompare(page, "shown", true);
169 tryCompare(page.showAnimation, "running", false);
173 function checkTopEdge() {
174 touchFlick(shell, halfWidth, 0, halfWidth, halfHeight);
176 var panel = findChild(shell, "panel");
177 tryCompare(panel.indicators, "fullyClosed", true);
180 function checkLeftEdge() {
181 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
183 var launcher = findChild(shell, "launcher");
184 tryCompare(launcher, "state", "");
187 function checkRightEdge() {
188 touchFlick(shell, shell.width, halfHeight, halfWidth, halfHeight);
190 var stage = findChild(shell, "stage");
191 var spreadView = findChild(stage, "spreadView");
192 tryCompare(spreadView, "phase", 0);
195 function checkBottomEdge() {
196 // Can't actually check effect of swipe, since dash isn't really loaded
197 var applicationsDisplayLoader = findChild(shell, "applicationsDisplayLoader");
198 tryCompare(applicationsDisplayLoader.item, "interactive", false);
201 function checkFinished() {
202 tryCompare(AccountsService, "demoEdges", false);
204 var tutorial = findChild(shell, "tutorial");
205 tryCompare(tutorial, "running", false);
207 var launcher = findChild(shell, "launcher");
208 tryCompare(launcher, "shown", false);
211 function goToPage(name) {
212 var page = waitForPage("tutorialLeft");
216 if (name === "tutorialLeft") return page;
217 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight);
219 page = waitForPage("tutorialLeftFinish");
220 if (name === "tutorialLeftFinish") return page;
221 var tick = findChild(page, "tick");
224 page = waitForPage("tutorialRight");
228 if (name === "tutorialRight") return page;
229 touchFlick(shell, shell.width, halfHeight, halfWidth, halfHeight);
230 var overlay = findChild(page, "overlay");
231 tryCompare(overlay, "shown", true);
232 var tick = findChild(page, "tick");
235 var page = waitForPage("tutorialBottom");
239 if (name === "tutorialBottom") return page;
240 touchFlick(shell, halfWidth, shell.height, halfWidth, halfHeight);
242 var page = waitForPage("tutorialBottomFinish");
247 if (name === "tutorialBottomFinish") return page;
248 var tick = findChild(page, "tick");
255 function test_walkthrough() {
259 function test_launcherShortDrag() {
260 // goToPage does a normal launcher pull. But here we want to test
261 // just barely pulling the launcher out and letting go (i.e. not
262 // triggering the "progress" property of Launcher).
264 var left = goToPage("tutorialLeft");
266 // Make sure we don't do anything if we don't pull the launcher
268 var launcher = findChild(shell, "launcher");
269 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.4, halfHeight);
270 tryCompare(launcher, "state", ""); // should remain hidden
271 tryCompare(left, "shown", true); // and we should still be on left
273 // Now drag out but not past launcher itself
274 touchFlick(shell, 0, halfHeight, launcher.panelWidth * 0.9, halfHeight);
276 waitForPage("tutorialLeftFinish");
279 function test_launcherLongDrag() {
280 // goToPage does a normal launcher pull. But here we want to test
281 // a full pull across the page.
283 var left = goToPage("tutorialLeft");
285 var launcher = findChild(shell, "launcher");
286 touchFlick(shell, 0, halfHeight, shell.width, halfHeight);
288 var errorTextLabel = findChild(left, "errorTextLabel");
289 var errorTitleLabel = findChild(left, "errorTitleLabel");
290 tryCompare(launcher, "state", ""); // launcher goes away
291 tryCompare(left, "shown", true); // still on left page
292 tryCompare(errorTextLabel, "opacity", 1); // show error
293 tryCompare(errorTitleLabel, "opacity", 1); // show error
296 function test_launcherDragBack() {
297 // goToPage does a full launcher pull. But here we test pulling
298 // all the way out, then dragging back into place.
300 var left = goToPage("tutorialLeft");
301 touchFlick(shell, 0, halfHeight, halfWidth, halfHeight, true, false);
302 touchFlick(shell, halfWidth, halfHeight, 0, halfHeight, false, true);
304 tryCompare(left, "shown", true); // and we should still be on left
307 function test_spread() {
308 // Unfortunately, most of what we want to test of the spread is
309 // "did it render correctly?" but that's hard to test. So instead,
310 // just poke and prod it a little bit to see if some of the values
311 // we'd expect to be correct, are so.
313 var right = goToPage("tutorialRight");
314 var stage = findChild(right, "stage");
315 var delegate0 = findChild(right, "appDelegate0");
317 tryCompare(stage, "dragProgress", 0);
318 touchFlick(shell, shell.width, halfHeight, shell.width * 0.8, halfHeight, true, false);
319 verify(stage.dragProgress > 0);
320 compare(stage.dragProgress, -delegate0.xTranslate);
321 touchFlick(shell, shell.width * 0.8, halfHeight, shell.width, halfHeight, false, true);
322 tryCompare(stage, "dragProgress", 0);
324 tryCompare(delegate0, "x", shell.width);
326 var screenshotImage = findChild(right, "screenshotImage");
327 tryCompare(screenshotImage, "source", Qt.resolvedUrl("../../../qml/Tutorial/graphics/facebook.png"));
328 tryCompare(screenshotImage, "visible", true);
331 function test_bottomShortDrag() {
332 var bottom = goToPage("tutorialBottom");
334 touchFlick(shell, halfWidth, shell.height, halfWidth, shell.height * 0.8);
336 var errorTextLabel = findChild(bottom, "errorTextLabel");
337 var errorTitleLabel = findChild(bottom, "errorTitleLabel");
338 tryCompare(bottom, "shown", true); // still on bottom page
339 tryCompare(errorTextLabel, "opacity", 1); // show error
340 tryCompare(errorTitleLabel, "opacity", 1); // show error
343 function test_interrupted() {
344 goToPage("tutorialLeft");
345 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