@@ -21,6 +21,7 @@ import MeeGo.QOfono 0.2
2121import QMenuModel 0.1
2222import Ubuntu.Components 1.3
2323import Ubuntu.SystemSettings.SecurityPrivacy 1.0
24+import Ubuntu.SystemSettings.TimeDate 1.0
2425import Unity.Test 0.1 as UT
2526import Wizard 0.1
2627import "../../../qml/Wizard"
@@ -39,7 +40,6 @@ Item {
3940 Wizard {
4041 id: wizard
4142 anchors.fill: parent
42− background: Qt.resolvedUrl("../../../qml/graphics/phone_background.jpg")
4343
4444 Component.onDestruction: {
4545 wizardLoader.itemDestroyed = true;
@@ -51,7 +51,7 @@ Item {
5151 SignalSpy {
5252 id: updateSessionLanguageSpy
5353 target: System
54− signalName: "updateSessionLanguageCalled"
54+ signalName: "updateSessionLocaleCalled"
5555 }
5656
5757 SignalSpy {
@@ -69,6 +69,11 @@ Item {
6969 signalName: "activated"
7070 }
7171
72+ SignalSpy {
73+ id: timezoneSpy
74+ signalName: "timeZoneChangedCalled"
75+ }
76+
7277 function setup() {
7378 AccountsService.hereEnabled = false;
7479 AccountsService.hereLicensePath = Qt.resolvedUrl("licenses");
@@ -82,6 +87,7 @@ Item {
8287 setSecuritySpy.clear();
8388 activateLocationSpy.clear();
8489 activateGPSSpy.clear();
90+ timezoneSpy.clear();
8591
8692 ActionData.data = {
8793 "location-detection-enabled": {
@@ -180,11 +186,6 @@ Item {
180186 tap(findChild(page, "forwardButton"));
181187 }
182188
183− page = waitForPage("passwdPage");
184− if (name === page.objectName) return page;
185− tap(findChild(page, "passwdDelegate0"));
186− tap(findChild(page, "forwardButton"));
187−
188189 page = waitForPage("wifiPage");
189190 if (name === page.objectName) return page;
190191 tap(findChild(page, "forwardButton"));
@@ -195,6 +196,31 @@ Item {
195196 tap(findChild(page, "forwardButton"));
196197 }
197198
199+ page = waitForPage("tzPage");
200+ if (name === page.objectName) return page;
201+ var tzList = findChild(page, "tzList");
202+ verify(tzList);
203+ waitForRendering(tzList);
204+ page.selectedTimeZone = "Pacific/Honolulu";
205+ tap(findChild(page, "forwardButton"));
206+
207+ page = waitForPage("accountPage");
208+ if (name === page.objectName) return page;
209+ tap(findChild(page, "nameInput"));
210+ typeString("foobar");
211+ tap(findChild(page, "passInput"));
212+ typeString("12345678");
213+ var pass2Input = findChild(page, "pass2Input");
214+ // give it a bit of time to finish the scroll-into-view animation
215+ tryCompareFunction(function() { return pass2Input !== null; }, true);
216+ tap(pass2Input);
217+ typeString("12345678");
218+ tap(findChild(page, "forwardButton"));
219+
220+ page = waitForPage("passwdPage");
221+ if (name === page.objectName) return page;
222+ tap(findChild(page, "forwardButton"));
223+
198224 if (!skipReporting) {
199225 page = waitForPage("reportingPage");
200226 if (name === page.objectName) return page;
@@ -203,7 +229,8 @@ Item {
203229
204230 page = waitForPage("finishedPage");
205231 if (name === page.objectName) return page;
206− tap(findChild(page, "forwardButton"));
232+ waitUntilTransitionsEnd(page);
233+ tap(findChild(page, "finishButton"));
207234
208235 tryCompare(wizard, "shown", false);
209236 compare(name, null);
@@ -212,100 +239,43 @@ Item {
212239
213240 function test_languageChange() {
214241 var page = goToPage("languagePage");
215− tap(findChild(page, "languageCombo"));
216− waitForRendering(findChild(page, "languageDelegate1"));
217−
218− // For some reason, the delegate *sometimes* (like 1 in 10 maybe)
219− // needs more time before it can process a tap() call. I can't
220− // find a rhyme or reason, its properties all seem the same in
221− // cases where it works and does not. This failure to receive a
222− // tap() call below does *not* happen when running in xvfb, so
223− // jenkins is unaffected (and we don't have to worry about 100 not
224− // being enough time in its slow environment). This wait() call is
225− // just to help local runs not trip up.
226− wait(100);
227− tap(findChild(page, "languageDelegate1"));
228−
229− tryCompare(i18n, "language", "fr");
242+ tap(findChild(page, "languageDelegate1")); // should invoke "fr" lang
243+
244+ tryCompare(i18n, "language", "fr_FR");
230245 tap(findChild(page, "forwardButton"));
231246 tryCompare(updateSessionLanguageSpy, "count", 1);
232− compare(updateSessionLanguageSpy.signalArguments[0][0], "fr");
247+ compare(updateSessionLanguageSpy.signalArguments[0][0], "fr_FR");
233248 }
234249
235250 function test_languageNoChange() {
236− goToPage("simPage"); // one past language page
251+ var page = goToPage("languagePage");
252+ tap(findChild(page, "forwardButton"));
237253 compare(updateSessionLanguageSpy.count, 0);
238254 }
239255
240256 function test_simUnavailableSkip() {
241257 MockQOfono.available = false;
242− goToPage("passwdPage", true);
258+ goToPage("wifiPage", true);
243259 }
244260
245261 function test_simNoModemsSkip() {
246262 MockQOfono.setModems([], [], []);
247− goToPage("passwdPage", true);
263+ goToPage("wifiPage", true);
248264 }
249265
250266 function test_simFirstSkip() {
251267 MockQOfono.setModems(["a", "b"], [true, false], []);
252− goToPage("passwdPage", true);
268+ goToPage("wifiPage", true);
253269 }
254270
255271 function test_simSecondSkip() {
256272 MockQOfono.setModems(["a", "b"], [false, true], []);
257− goToPage("passwdPage", true);
273+ goToPage("wifiPage", true);
258274 }
259275
260276 function test_simBothSkip() {
261277 MockQOfono.setModems(["a", "b"], [true, true], []);
262− goToPage("passwdPage", true);
263− }
264−
265− function test_simWaitOnManagerAsync() {
266− MockQOfono.ready = false;
267− MockQOfono.setModems(["a"], [false], []);
268−
269− // Go to SIM page, which will be waiting for skip to be valid
270− var page = goToPage("languagePage");
271− tap(findChild(page, "forwardButton"));
272− verifyPageIsBlocked("simPage");
273−
274− // Now release QOfono from blocking the page
275− MockQOfono.ready = true;
276−
277− waitForPage("simPage");
278− }
279−
280− function test_simWaitOnCardAsync() {
281− MockQOfono.setModems(["a"], [false], [false]);
282−
283− // Go to SIM page, which will be waiting for skip to be valid
284− var page = goToPage("languagePage");
285− tap(findChild(page, "forwardButton"));
286− verifyPageIsBlocked("simPage");
287−
288− // Now release QOfono from blocking the page
289− MockQOfono.setModems(["a"], [false], [true]);
290−
291− waitForPage("simPage");
292− }
293−
294− function test_simWaitTimeout() {
295− MockQOfono.setModems(["a"], [false], [false]);
296−
297− // Go to SIM page, which will be waiting for skip to be valid
298− var page = goToPage("languagePage");
299− tap(findChild(page, "forwardButton"));
300− verifyPageIsBlocked("simPage");
301−
302− var timeout = findInvisibleChild(wizard, "timeout");
303− timeout.interval = 100; // reduce our delay
304−
305− // Now just wait for timeout
306− compare(timeout.running, true);
307− waitForPage("passwdPage");
308− compare(timeout.running, false);
278+ goToPage("wifiPage", true);
309279 }
310280
311281 function enterPasscode(passcode) {
@@ -332,33 +302,32 @@ Item {
332302
333303 function test_passwdPasscode() {
334304 var page = goToPage("passwdPage");
335−
305+ tap(findChild(page, "passwdDelegate2")); // passcode option
336306 tap(findChild(page, "forwardButton"));
337− page = waitForPage("passwdSetPage");
307+ page = waitForPage("passcodeSetPage");
338308
339309 enterPasscode("1111");
340− page = waitForPage("passwdConfirmPage");
310+ page = waitForPage("passcodeConfirmPage");
341311
342312 // make sure we go back to 'set' page not 'type' page
343313 tap(findChild(page, "backButton"));
344− page = waitForPage("passwdSetPage");
314+ page = waitForPage("passcodeSetPage");
345315
346316 enterPasscode("1111");
347− page = waitForPage("passwdConfirmPage");
317+ page = waitForPage("passcodeConfirmPage");
348318
349319 enterPasscode("1112");
350320 var error = findChild(page, "wrongNoticeLabel");
351321 tryCompareFunction(function() { return error.text !== ""; }, true);
352322
353323 enterPasscode("1111");
354− page = waitForPage("wifiPage");
355324
356325 // now finish up
357− tap(findChild(page, "forwardButton"));
358− page = waitForPage("locationPage");
326+ page = waitForPage("reportingPage");
359327 tap(findChild(page, "forwardButton"));
360328 page = waitForPage("finishedPage");
361− tap(findChild(page, "forwardButton"));
329+ waitUntilTransitionsEnd(page);
330+ tap(findChild(page, "finishButton"));
362331
363332 tryCompare(setSecuritySpy, "count", 1);
364333 compare(setSecuritySpy.signalArguments[0][0], "");
@@ -368,96 +337,85 @@ Item {
368337
369338 function test_passwdPassphrase() {
370339 var page = goToPage("passwdPage");
371− tap(findChild(page, "passwdDelegate2"));
372−
340+ tap(findChild(page, "passwdDelegate1")); // password option
373341 tap(findChild(page, "forwardButton"));
374342 page = waitForPage("passwdSetPage");
375343
344+ var passwdField = findChild(page, "passwordField");
345+ verify(passwdField);
346+ tap(passwdField);
376347 typeString("aaa");
377− var continueButton = findChild(page, "forwardButton");
378− tryCompare(continueButton.item, "enabled", false);
379− keyClick(Qt.Key_Enter);
380− var error = findChild(page, "wrongNoticeLabel");
381− tryCompareFunction(function() { return error.text !== ""; }, true);
348+ var continueButton = findChild(page, "okButton");
349+ tryCompare(continueButton, "enabled", false);
382350
383− typeString("aaaa");
351+ tap(passwdField);
352+ passwdField.selectAll(); // overwrite the text
353+ typeString("12345678");
384354 tap(continueButton);
385− page = waitForPage("passwdConfirmPage");
355+ wait(200);
386356
387357 // make sure we go back to 'set' page not 'type' page
388− var back = findChild(page, "backButton");
358+ var back = findChild(page, "cancelButton");
389359 tap(back);
390− page = waitForPage("passwdSetPage");
391−
392− typeString("aaaa");
393− keyClick(Qt.Key_Enter);
394− page = waitForPage("passwdConfirmPage");
360+ wait(200);
395361
396− continueButton = findChild(page, "forwardButton");
362+ passwdField = findChild(page, "passwordField");
363+ tryCompareFunction(function() {return !!passwdField}, true);
364+ tap(passwdField);
397365 typeString("aaab");
398− tryCompare(continueButton.item, "enabled", false);
399− keyClick(Qt.Key_Enter);
400− var error = findChild(page, "wrongNoticeLabel");
366+
367+ continueButton = findChild(page, "okButton");
368+ tryCompare(continueButton, "enabled", false);
369+ var error = findChild(page, "infoLabel");
401370 tryCompareFunction(function() { return error.text !== ""; }, true);
402371
403− typeString("aaaa");
372+ tap(passwdField);
373+ passwdField.selectAll(); // overwrite the text
374+ typeString("12345678");
375+ tap(continueButton);
376+ wait(200);
377+
378+ tap(passwdField);
379+ passwdField.selectAll(); // overwrite the text
380+ typeString("12345678");
404381 tap(continueButton);
405− page = waitForPage("wifiPage");
406382
407383 // now finish up
408− tap(findChild(page, "forwardButton"));
409− page = waitForPage("locationPage");
384+ page = waitForPage("reportingPage");
410385 tap(findChild(page, "forwardButton"));
411386 page = waitForPage("finishedPage");
412− tap(findChild(page, "forwardButton"));
387+ waitUntilTransitionsEnd(page);
388+ tap(findChild(page, "finishButton"));
413389
414390 tryCompare(setSecuritySpy, "count", 1);
415391 compare(setSecuritySpy.signalArguments[0][0], "");
416− compare(setSecuritySpy.signalArguments[0][1], "aaaa");
392+ compare(setSecuritySpy.signalArguments[0][1], "12345678");
417393 compare(setSecuritySpy.signalArguments[0][2], UbuntuSecurityPrivacyPanel.Passphrase);
418394 }
419395
420396 function test_passwdSwipe() {
421− goToPage(null, false, false, true);
422−
423− tryCompare(setSecuritySpy, "count", 1);
424− compare(setSecuritySpy.signalArguments[0][0], "");
425− compare(setSecuritySpy.signalArguments[0][1], "");
426− compare(setSecuritySpy.signalArguments[0][2], UbuntuSecurityPrivacyPanel.Swipe);
427− }
428−
429− function test_locationSkipNoPath() {
430− AccountsService.hereLicensePath = "";
431− goToPage("finishedPage", false, true, true);
432− }
433−
434− function test_locationSkipNoFiles() {
435− AccountsService.hereLicensePath = Qt.resolvedUrl("nolicenses");
436− goToPage("finishedPage", false, true, true);
437− }
438−
439− function test_locationWaitOnPath() {
440− AccountsService.hereLicensePath = " "; // means we're still getting the path from dbus
441−
442− var page = goToPage("wifiPage");
397+ var page = goToPage("passwdPage");
398+ tap(findChild(page, "passwdDelegate3")); // swipe option
443399
444− var pages = findChild(wizard, "wizardPages");
445− var stack = findChild(pages, "pageStack");
400+ // now finish up
446401 tap(findChild(page, "forwardButton"));
447− // don't simply call tryCompare here, because stack.currentPage will be swapped out itself
448− tryCompareFunction(function() { return stack.currentPage.objectName; }, "locationPage");
449− compare(stack.currentPage.enabled, false);
450− compare(stack.currentPage.skipValid, false);
402+ page = waitForPage("reportingPage");
403+ tap(findChild(page, "forwardButton"));
404+ page = waitForPage("finishedPage");
405+ waitUntilTransitionsEnd(page);
406+ tap(findChild(page, "finishButton"));
451407
452− AccountsService.hereLicensePath = "";
453− waitForPage("finishedPage", false, false, true);
408+ tryCompare(setSecuritySpy, "count", 1);
409+ //compare(setSecuritySpy.signalArguments[0][0], ""); // FIXME the swipe method collides with the account password
410+ //compare(setSecuritySpy.signalArguments[0][1], "");
411+ compare(setSecuritySpy.signalArguments[0][2], UbuntuSecurityPrivacyPanel.Swipe);
454412 }
455413
456414 function test_locationGpsOnly() {
457415 var page = goToPage("locationPage");
458− var gpsCheck = findChild(page, "gpsCheck");
459− var hereCheck = findChild(page, "hereCheck");
460− var nopeCheck = findChild(page, "nopeCheck");
416+ var gpsCheck = findChild(page, "gpsCheckLabel");
417+ var hereCheck = findChild(page, "hereCheckLabel");
418+ var nopeCheck = findChild(page, "nopeCheckLabel");
461419
462420 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
463421 activateLocationSpy.target = locationActionGroup.location;
@@ -476,9 +434,9 @@ Item {
476434
477435 function test_locationNope() {
478436 var page = goToPage("locationPage");
479− var gpsCheck = findChild(page, "gpsCheck");
480− var hereCheck = findChild(page, "hereCheck");
481− var nopeCheck = findChild(page, "nopeCheck");
437+ var gpsCheck = findChild(page, "gpsCheckLabel");
438+ var hereCheck = findChild(page, "hereCheckLabel");
439+ var nopeCheck = findChild(page, "nopeCheckLabel");
482440
483441 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
484442 activateLocationSpy.target = locationActionGroup.location;
@@ -491,15 +449,15 @@ Item {
491449
492450 tap(findChild(page, "forwardButton"));
493451 tryCompare(AccountsService, "hereEnabled", false);
494− tryCompare(activateLocationSpy, "count", 0)
495− tryCompare(activateGPSSpy, "count", 0)
452+ tryCompare(activateLocationSpy, "count", 0);
453+ tryCompare(activateGPSSpy, "count", 0);
496454 }
497455
498456 function test_locationHere() {
499457 var page = goToPage("locationPage");
500− var gpsCheck = findChild(page, "gpsCheck");
501− var hereCheck = findChild(page, "hereCheck");
502− var nopeCheck = findChild(page, "nopeCheck");
458+ var gpsCheck = findChild(page, "gpsCheckLabel");
459+ var hereCheck = findChild(page, "hereCheckLabel");
460+ var nopeCheck = findChild(page, "nopeCheckLabel");
503461
504462 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
505463 activateLocationSpy.target = locationActionGroup.location;
@@ -512,68 +470,81 @@ Item {
512470
513471 tap(findChild(page, "forwardButton"));
514472 tryCompare(AccountsService, "hereEnabled", true);
515− tryCompare(activateLocationSpy, "count", 1)
516− tryCompare(activateGPSSpy, "count", 1)
473+ tryCompare(activateLocationSpy, "count", 1);
474+ tryCompare(activateGPSSpy, "count", 1);
517475 }
518476
519− function test_locationHereTerms() {
520− var page = goToPage("locationPage");
477+ function test_timezonePage() {
478+ var page = goToPage("tzPage");
479+ verify(page);
480+ timezoneSpy.target = page.tdModule;
521481
522− var link = findChild(page, "hereTermsLink");
482+ var tzFilter = findChild(page, "tzFilter");
483+ verify(tzFilter);
484+ tap(tzFilter);
485+ typeString("London");
523486
524− // Test our language lookup code a bit
487+ var tzList = findChild(page, "tzList");
488+ verify(tzList);
525489
526− i18n.language = "fr_FR.UTF-8";
527− link.linkActivated("not-used");
528− page = waitForPage("hereTermsPage");
529− tryCompare(findChild(page, "termsLabel"), "text", "fr_FR\n");
530− tap(findChild(page, "backButton"));
531− waitForPage("locationPage");
490+ // test filtering works and returns some results
491+ tryCompareFunction(function() { return tzList.count > 0; }, true);
532492
533− i18n.language = "fr_CA";
534− link.linkActivated("not-used");
535− page = waitForPage("hereTermsPage");
536− tryCompare(findChild(page, "termsLabel"), "text", "fr_CA\n");
537− tap(findChild(page, "backButton"));
538− waitForPage("locationPage");
493+ // just tap the first one
494+ tap(findChild(page, "tz0"));
539495
540− i18n.language = "fr_US";
541− link.linkActivated("not-used");
542− page = waitForPage("hereTermsPage");
543− tryCompare(findChild(page, "termsLabel"), "text", "fr_FR\n");
544− tap(findChild(page, "backButton"));
545− waitForPage("locationPage");
496+ // go next and verify the (mock) signal got fired
497+ tap(findChild(page, "forwardButton"));
498+ tryCompare(timezoneSpy, "count", 1);
499+ tryCompare(page.tdModule, "timeZone", timezoneSpy.signalArguments[0][0]);
500+ }
546501
547− i18n.language = "fr.utf8";
548− link.linkActivated("not-used");
549− page = waitForPage("hereTermsPage");
550− tryCompare(findChild(page, "termsLabel"), "text", "fr_FR\n");
551− tap(findChild(page, "backButton"));
552− waitForPage("locationPage");
502+ function test_accountPage() {
503+ var page = goToPage("accountPage");
504+ var password1 = findChild(page, "passInput");
505+ var password2 = findChild(page, "pass2Input");
506+ var forwardButton = findChild(page, "forwardButton");
553507
554− i18n.language = "es"; // will not be found
555− link.linkActivated("not-used");
556− page = waitForPage("hereTermsPage");
557− tryCompare(findChild(page, "termsLabel"), "text", "en_US\n");
508+ tap(findChild(page, "nameInput"));
509+ typeString("foobar");
558510
559− // OK, done with languages, back to actual page
511+ verify(forwardButton.enabled, false); // no passwords yet
560512
561− var label = findChild(page, "termsLabel");
562− label.linkActivated(Qt.resolvedUrl("licenses/en_US.html"));
563− tryCompare(label, "visible", false);
513+ tap(password1);
514+ typeString("12345");
564515
565− var webview = findChild(page, "webview");
566− tryCompare(webview, "visible", true);
567− tryCompare(webview, "url", Qt.resolvedUrl("licenses/en_US.html"));
568− tryCompare(webview, "loadProgress", 100);
516+ verify(forwardButton.enabled, false); // password too short
569517
570− tap(findChild(page, "backButton"));
571− waitForPage("hereTermsPage"); // confirm we're on same page
572− tryCompare(webview, "visible", false);
573− tryCompare(label, "visible", true);
518+ tap(password2);
519+ typeString("12345678");
574520
575− tap(findChild(page, "backButton"));
576− waitForPage("locationPage");
521+ verify(forwardButton.enabled, false); // passwords don't match
522+
523+ tap(password1);
524+ password1.selectAll();
525+ typeString("12345678");
526+
527+ verify(forwardButton.enabled, true); // now they match
528+
529+ var pages = findChild(wizard, "wizardPages");
530+ var security = findInvisibleChild(pages, "securityPrivacy");
531+ setSecuritySpy.target = security;
532+
533+ // now finish up
534+ tap(forwardButton);
535+ page = waitForPage("passwdPage");
536+ tap(findChild(page, "passwdDelegate0")); // account option
537+ tap(findChild(page, "forwardButton"));
538+ page = waitForPage("reportingPage");
539+ tap(findChild(page, "forwardButton"));
540+ page = waitForPage("finishedPage");
541+ waitUntilTransitionsEnd(page);
542+ tap(findChild(page, "finishButton"));
543+
544+ tryCompare(setSecuritySpy, "count", 1);
545+ compare(setSecuritySpy.signalArguments[0][0], "");
546+ compare(setSecuritySpy.signalArguments[0][1], "12345678");
547+ compare(setSecuritySpy.signalArguments[0][2], UbuntuSecurityPrivacyPanel.Passphrase);
577548 }
578549 }
579550}