2 * Copyright 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 MeeGo.QOfono 0.2
22import Ubuntu.Components 1.3
23import Ubuntu.SystemSettings.SecurityPrivacy 1.0
24import Ubuntu.SystemSettings.TimeDate 1.1
25import Unity.Test 0.1 as UT
27import Unity.InputInfo 0.1
28import "../../../qml/Wizard"
39 property bool itemDestroyed: false
40 sourceComponent: Component {
45 Component.onCompleted: {
46 MockInputDeviceBackend.addMockDevice("/test", InputInfo.Keyboard);
49 Component.onDestruction: {
50 MockInputDeviceBackend.removeDevice("/test");
51 wizardLoader.itemDestroyed = true;
58 id: updateSessionLanguageSpy
60 signalName: "updateSessionLocaleCalled"
65 signalName: "setSecurityCalled"
69 id: activateLocationSpy
70 signalName: "activated"
75 signalName: "activated"
80 signalName: "timeZoneChangedCalled"
85 target: AccountsService
86 signalName: "keymapsChanged"
90 AccountsService.hereEnabled = false;
91 AccountsService.hereLicensePath = Qt.resolvedUrl("licenses");
93 MockQOfono.setModems(["sim1"], [false], []);
94 MockQOfono.available = true;
95 MockQOfono.ready = true;
96 System.wizardEnabled = true;
98 updateSessionLanguageSpy.clear();
99 setSecuritySpy.clear();
100 activateLocationSpy.clear();
101 activateGPSSpy.clear();
103 kbdLayoutSpy.clear();
106 "location-detection-enabled": {
110 "gps-detection-enabled": {
117 Component.onCompleted: {
126 property Item wizard: wizardLoader.status === Loader.Ready ? wizardLoader.item : null
129 wizardLoader.itemDestroyed = false;
131 wizardLoader.active = false;
133 tryCompare(wizardLoader, "status", Loader.Null);
134 tryCompare(wizardLoader, "item", null);
135 // Loader.status might be Loader.Null and Loader.item might be null but the Loader
136 // item might still be alive. So if we set Loader.active back to true
137 // again right now we will get the very same Shell instance back. So no reload
138 // actually took place. Likely because Loader waits until the next event loop
139 // iteration to do its work. So to ensure the reload, we will wait until the
140 // Shell instance gets destroyed.
141 tryCompare(wizardLoader, "itemDestroyed", true);
143 // reload our test subject to get it in a fresh state once again
144 wizardLoader.active = true;
146 tryCompare(wizardLoader, "status", Loader.Ready);
148 var pages = findChild(wizard, "wizardPages");
149 var security = findInvisibleChild(pages, "securityPrivacy");
150 security.setSecurity("", "", UbuntuSecurityPrivacyPanel.Swipe);
151 setSecuritySpy.target = security;
156 function waitForPage(name) {
157 var pages = findChild(wizard, "wizardPages");
158 var stack = findChild(pages, "pageStack");
159 // don't simply call tryCompare here, because stack.currentPage will be swapped out itself
160 tryCompareFunction(function() { return stack.currentPage.objectName; }, name, 15000);
161 var contentAnimation = findInvisibleChild(stack.currentPage, "contentAnimation");
162 tryCompareFunction(function() { return contentAnimation.running; }, false);
163 tryCompare(stack.currentPage, "opacity", 1.0);
164 tryCompare(stack.currentPage, "enabled", true);
165 tryCompare(stack.currentPage, "skipValid", true);
166 tryCompare(stack.currentPage, "skip", false);
167 waitForRendering(stack.currentPage);
168 return stack.currentPage;
171 function goToPage(name, skipSim, skipLocation) {
172 if (skipSim === undefined) {
175 if (skipLocation === undefined) {
176 skipLocation = false;
179 var page = waitForPage("languagePage");
180 if (name === page.objectName) return page;
181 tap(findChild(page, "forwardButton"));
184 page = waitForPage("simPage");
185 if (name === page.objectName) return page;
186 tap(findChild(page, "forwardButton"));
189 page = waitForPage("keyboardPage");
190 if (name === page.objectName) return page;
191 tap(findChild(page, "forwardButton"));
193 page = waitForPage("wifiPage");
194 if (name === page.objectName) return page;
195 tap(findChild(page, "forwardButton"));
198 page = waitForPage("locationPage");
199 if (name === page.objectName) return page;
200 tap(findChild(page, "forwardButton"));
203 page = waitForPage("tzPage");
204 if (name === page.objectName) return page;
205 waitUntilTransitionsEnd(page);
206 var tzList = findChild(page, "tzList");
208 waitForRendering(tzList);
209 page.selectedTimeZone = "Pacific/Honolulu";
210 tap(findChild(page, "forwardButton"));
212 page = waitForPage("accountPage");
213 if (name === page.objectName) return page;
214 tap(findChild(page, "nameInput"));
215 typeString("foobar");
216 tap(findChild(page, "forwardButton"));
218 page = waitForPage("passwdPage");
219 if (name === page.objectName) return page;
220 tap(findChild(page, "forwardButton"));
222 page = waitForPage("finishedPage");
223 if (name === page.objectName) return page;
224 waitUntilTransitionsEnd(page);
225 tap(findChild(page, "finishButton"));
227 tryCompare(wizard, "shown", false);
232 function test_languageChange() {
233 var page = goToPage("languagePage");
234 tap(findChild(page, "languageDelegate_french_(france)")); // should invoke "fr" lang
236 tryCompare(i18n, "language", "fr_FR");
237 tap(findChild(page, "forwardButton"));
238 tryCompare(updateSessionLanguageSpy, "count", 1);
239 compare(updateSessionLanguageSpy.signalArguments[0][0], "fr_FR");
242 function test_languageNoChange() {
243 var page = goToPage("languagePage");
244 tap(findChild(page, "forwardButton"));
245 compare(updateSessionLanguageSpy.count, 0);
248 function test_simUnavailableSkip() {
249 MockQOfono.available = false;
250 goToPage("wifiPage", true);
253 function test_simNoModemsSkip() {
254 MockQOfono.setModems([], [], []);
255 goToPage("wifiPage", true);
258 function test_simFirstSkip() {
259 MockQOfono.setModems(["a", "b"], [true, false], []);
260 goToPage("wifiPage", true);
263 function test_simSecondSkip() {
264 MockQOfono.setModems(["a", "b"], [false, true], []);
265 goToPage("wifiPage", true);
268 function test_simBothSkip() {
269 MockQOfono.setModems(["a", "b"], [true, true], []);
270 goToPage("wifiPage", true);
273 function enterPasscode(passcode) {
274 for (var i = 0; i < passcode.length; ++i) {
275 var character = passcode.charAt(i);
276 var button = findChild(wizard, "pinPadButton" + character);
281 function test_passwdSkipIfSet() {
282 var page = goToPage("simPage");
284 // Set password type to non-swipe
285 var pages = findChild(wizard, "wizardPages");
286 var security = findInvisibleChild(pages, "securityPrivacy");
287 security.setSecurity("", "", UbuntuSecurityPrivacyPanel.Passphrase);
288 compare(security.securityType, UbuntuSecurityPrivacyPanel.Passphrase);
290 // Make sure that moving from sim page lands on wifi page
291 tap(findChild(page, "forwardButton"));
292 waitForPage("keyboardPage"); // thus skipping passwdPage
295 function verifyAnimationsNotRunning(page) {
296 var contentAnimation = findInvisibleChild(page, "contentAnimation");
297 var secondaryAnimation = findInvisibleChild(page, "secondaryAnimation");
298 tryCompare(contentAnimation, "running", false);
299 tryCompare(secondaryAnimation, "running", false);
302 function test_passwdPasscode() {
303 var page = goToPage("passwdPage");
304 tap(findChild(page, "passwdDelegate1")); // passcode option
305 tap(findChild(page, "forwardButton"));
306 page = waitForPage("passcodeSetPage");
307 verifyAnimationsNotRunning(page);
309 enterPasscode("1111");
310 page = waitForPage("passcodeConfirmPage");
311 verifyAnimationsNotRunning(page);
313 tap(findChild(page, "backButton"));
314 page = waitForPage("passcodeSetPage");
315 verifyAnimationsNotRunning(page);
317 enterPasscode("1111");
318 page = waitForPage("passcodeConfirmPage");
319 verifyAnimationsNotRunning(page);
321 enterPasscode("1112");
322 var error = findChild(page, "wrongNoticeLabel");
323 tryCompareFunction(function() { return error.text !== ""; }, true);
325 enterPasscode("1111");
328 page = waitForPage("finishedPage");
329 waitUntilTransitionsEnd(page);
330 tap(findChild(page, "finishButton"));
332 tryCompare(setSecuritySpy, "count", 1);
333 compare(setSecuritySpy.signalArguments[0][0], "");
334 compare(setSecuritySpy.signalArguments[0][1], "1111");
335 compare(setSecuritySpy.signalArguments[0][2], UbuntuSecurityPrivacyPanel.Passcode);
338 function test_passwdPassphrase() {
339 var page = goToPage("passwdPage");
340 tap(findChild(page, "passwdDelegate0")); // password option
341 tap(findChild(page, "forwardButton"));
342 page = waitForPage("passwdSetPage");
344 var passwdField = findChild(page, "passwordField");
347 verifyAnimationsNotRunning(page);
349 var continueButton = findChild(page, "forwardButton");
350 tryCompare(page, "passwordsMatching", false);
353 verifyAnimationsNotRunning(page);
354 passwdField.selectAll(); // overwrite the text
355 typeString("12345678");
356 tryCompare(page, "passwordsMatching", false);
358 var passwd2Field = findChild(page, "password2Field");
360 verifyAnimationsNotRunning(page);
361 typeString("12345678");
362 tryCompare(continueButton, "enabled", true);
366 page = waitForPage("finishedPage");
367 waitUntilTransitionsEnd(page);
368 tap(findChild(page, "finishButton"));
370 tryCompare(setSecuritySpy, "count", 1);
371 compare(setSecuritySpy.signalArguments[0][0], "");
372 compare(setSecuritySpy.signalArguments[0][1], "12345678");
373 compare(setSecuritySpy.signalArguments[0][2], UbuntuSecurityPrivacyPanel.Passphrase);
376 function test_passwdSwipe() {
377 var page = goToPage("passwdPage");
378 tap(findChild(page, "passwdDelegate2")); // swipe option
381 tap(findChild(page, "forwardButton"));
382 page = waitForPage("finishedPage");
383 waitUntilTransitionsEnd(page);
384 tap(findChild(page, "finishButton"));
386 tryCompare(setSecuritySpy, "count", 0); // not called for swipe method
389 function test_locationGpsOnly() {
390 var page = goToPage("locationPage");
391 var gpsCheck = findChild(page, "gpsCheckLabel");
392 var hereCheck = findChild(page, "hereCheckLabel");
393 var nopeCheck = findChild(page, "nopeCheckLabel");
395 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
396 activateLocationSpy.target = locationActionGroup.location;
397 activateGPSSpy.target = locationActionGroup.gps;
400 tryCompare(gpsCheck, "checked", true);
401 tryCompare(hereCheck, "checked", false);
402 tryCompare(nopeCheck, "checked", false);
404 tap(findChild(page, "forwardButton"));
405 tryCompare(AccountsService, "hereEnabled", false);
406 tryCompare(activateLocationSpy, "count", 1)
407 tryCompare(activateGPSSpy, "count", 1)
410 function test_locationNope() {
411 var page = goToPage("locationPage");
412 var gpsCheck = findChild(page, "gpsCheckLabel");
413 var hereCheck = findChild(page, "hereCheckLabel");
414 var nopeCheck = findChild(page, "nopeCheckLabel");
416 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
417 activateLocationSpy.target = locationActionGroup.location;
418 activateGPSSpy.target = locationActionGroup.gps;
421 tryCompare(gpsCheck, "checked", false);
422 tryCompare(hereCheck, "checked", false);
423 tryCompare(nopeCheck, "checked", true);
425 tap(findChild(page, "forwardButton"));
426 tryCompare(AccountsService, "hereEnabled", false);
427 tryCompare(activateLocationSpy, "count", 0);
428 tryCompare(activateGPSSpy, "count", 0);
431 function test_locationHere() {
432 var page = goToPage("locationPage");
433 var gpsCheck = findChild(page, "gpsCheckLabel");
434 var hereCheck = findChild(page, "hereCheckLabel");
435 var nopeCheck = findChild(page, "nopeCheckLabel");
437 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
438 activateLocationSpy.target = locationActionGroup.location;
439 activateGPSSpy.target = locationActionGroup.gps;
441 // no tap because HERE is the default
442 tryCompare(gpsCheck, "checked", false);
443 tryCompare(hereCheck, "checked", true);
444 tryCompare(nopeCheck, "checked", false);
446 tap(findChild(page, "forwardButton"));
447 tryCompare(AccountsService, "hereEnabled", true);
448 tryCompare(activateLocationSpy, "count", 1);
449 tryCompare(activateGPSSpy, "count", 1);
452 function test_timezonePage() {
453 var page = goToPage("tzPage");
455 timezoneSpy.target = page.tdModule;
457 var tzFilter = findChild(page, "tzFilter");
462 var tzList = findChild(page, "tzList");
465 // test filtering works and returns some results
466 tryCompareFunction(function() { return tzList.count > 0; }, true);
468 // just tap the first one
469 tap(findChild(page, "tz0"));
471 // go next and verify the (mock) signal got fired
472 tap(findChild(page, "forwardButton"));
473 tryCompare(timezoneSpy, "count", 1);
474 compare(timezoneSpy.signalArguments[0][0], "Europe/London");
475 compare(timezoneSpy.signalArguments[0][1], "Belfast");
478 function test_accountPage() {
479 var page = goToPage("accountPage");
480 var forwardButton = findChild(page, "forwardButton");
482 tap(findChild(page, "nameInput"));
483 typeString("foobar");
486 function test_keyboardPage() {
487 var page = goToPage("keyboardPage");
488 var forwardButton = findChild(page, "forwardButton");
491 var langSelector = findChild(page, "langSelector");
492 verify(langSelector);
493 langSelector.selectedIndex = 1; // should be fr_FR
494 print("Selected language:", page.selectedLanguage);
497 var kbdDelegate = findChild(page, "kbdDelegate1");
499 mouseClick(kbdDelegate);
500 verify(kbdDelegate.isCurrent);
501 print("Selected keymap:", page.selectedKeymap);
503 // verify the keymapsChanged signal got fired
504 tap(findChild(page, "forwardButton"));
505 tryCompare(kbdLayoutSpy, "count", 1);
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