@@ -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": {
@@ -96,7 +102,6 @@ Item {
96102 }
97103
98104 Component.onCompleted: {
99− theme.name = "Ubuntu.Components.Themes.SuruDark";
100105 setup();
101106 }
102107
@@ -180,11 +185,6 @@ Item {
180185 tap(findChild(page, "forwardButton"));
181186 }
182187
183− page = waitForPage("passwdPage");
184− if (name === page.objectName) return page;
185− tap(findChild(page, "passwdDelegate0"));
186− tap(findChild(page, "forwardButton"));
187−
188188 page = waitForPage("wifiPage");
189189 if (name === page.objectName) return page;
190190 tap(findChild(page, "forwardButton"));
@@ -195,6 +195,24 @@ Item {
195195 tap(findChild(page, "forwardButton"));
196196 }
197197
198+ page = waitForPage("tzPage");
199+ if (name === page.objectName) return page;
200+ var tzList = findChild(page, "tzList");
201+ verify(tzList);
202+ waitForRendering(tzList);
203+ page.selectedTimeZone = "Pacific/Honolulu";
204+ tap(findChild(page, "forwardButton"));
205+
206+ page = waitForPage("accountPage");
207+ if (name === page.objectName) return page;
208+ tap(findChild(page, "nameInput"));
209+ typeString("foobar");
210+ tap(findChild(page, "forwardButton"));
211+
212+ page = waitForPage("passwdPage");
213+ if (name === page.objectName) return page;
214+ tap(findChild(page, "forwardButton"));
215+
198216 if (!skipReporting) {
199217 page = waitForPage("reportingPage");
200218 if (name === page.objectName) return page;
@@ -203,7 +221,8 @@ Item {
203221
204222 page = waitForPage("finishedPage");
205223 if (name === page.objectName) return page;
206− tap(findChild(page, "forwardButton"));
224+ waitUntilTransitionsEnd(page);
225+ tap(findChild(page, "finishButton"));
207226
208227 tryCompare(wizard, "shown", false);
209228 compare(name, null);
@@ -212,100 +231,43 @@ Item {
212231
213232 function test_languageChange() {
214233 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");
234+ tap(findChild(page, "languageDelegate1")); // should invoke "fr" lang
235+
236+ tryCompare(i18n, "language", "fr_FR");
230237 tap(findChild(page, "forwardButton"));
231238 tryCompare(updateSessionLanguageSpy, "count", 1);
232− compare(updateSessionLanguageSpy.signalArguments[0][0], "fr");
239+ compare(updateSessionLanguageSpy.signalArguments[0][0], "fr_FR");
233240 }
234241
235242 function test_languageNoChange() {
236− goToPage("simPage"); // one past language page
243+ var page = goToPage("languagePage");
244+ tap(findChild(page, "forwardButton"));
237245 compare(updateSessionLanguageSpy.count, 0);
238246 }
239247
240248 function test_simUnavailableSkip() {
241249 MockQOfono.available = false;
242− goToPage("passwdPage", true);
250+ goToPage("wifiPage", true);
243251 }
244252
245253 function test_simNoModemsSkip() {
246254 MockQOfono.setModems([], [], []);
247− goToPage("passwdPage", true);
255+ goToPage("wifiPage", true);
248256 }
249257
250258 function test_simFirstSkip() {
251259 MockQOfono.setModems(["a", "b"], [true, false], []);
252− goToPage("passwdPage", true);
260+ goToPage("wifiPage", true);
253261 }
254262
255263 function test_simSecondSkip() {
256264 MockQOfono.setModems(["a", "b"], [false, true], []);
257− goToPage("passwdPage", true);
265+ goToPage("wifiPage", true);
258266 }
259267
260268 function test_simBothSkip() {
261269 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);
270+ goToPage("wifiPage", true);
309271 }
310272
311273 function enterPasscode(passcode) {
@@ -330,35 +292,44 @@ Item {
330292 waitForPage("wifiPage"); // thus skipping passwdPage
331293 }
332294
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);
300+ }
301+
333302 function test_passwdPasscode() {
334303 var page = goToPage("passwdPage");
335−
304+ tap(findChild(page, "passwdDelegate1")); // passcode option
336305 tap(findChild(page, "forwardButton"));
337− page = waitForPage("passwdSetPage");
306+ page = waitForPage("passcodeSetPage");
307+ verifyAnimationsNotRunning(page);
338308
339309 enterPasscode("1111");
340− page = waitForPage("passwdConfirmPage");
310+ page = waitForPage("passcodeConfirmPage");
311+ verifyAnimationsNotRunning(page);
341312
342− // make sure we go back to 'set' page not 'type' page
343313 tap(findChild(page, "backButton"));
344− page = waitForPage("passwdSetPage");
314+ page = waitForPage("passcodeSetPage");
315+ verifyAnimationsNotRunning(page);
345316
346317 enterPasscode("1111");
347− page = waitForPage("passwdConfirmPage");
318+ page = waitForPage("passcodeConfirmPage");
319+ verifyAnimationsNotRunning(page);
348320
349321 enterPasscode("1112");
350322 var error = findChild(page, "wrongNoticeLabel");
351323 tryCompareFunction(function() { return error.text !== ""; }, true);
352324
353325 enterPasscode("1111");
354− page = waitForPage("wifiPage");
355326
356327 // now finish up
357− tap(findChild(page, "forwardButton"));
358− page = waitForPage("locationPage");
328+ page = waitForPage("reportingPage");
359329 tap(findChild(page, "forwardButton"));
360330 page = waitForPage("finishedPage");
361− tap(findChild(page, "forwardButton"));
331+ waitUntilTransitionsEnd(page);
332+ tap(findChild(page, "finishButton"));
362333
363334 tryCompare(setSecuritySpy, "count", 1);
364335 compare(setSecuritySpy.signalArguments[0][0], "");
@@ -368,96 +339,64 @@ Item {
368339
369340 function test_passwdPassphrase() {
370341 var page = goToPage("passwdPage");
371− tap(findChild(page, "passwdDelegate2"));
372−
342+ tap(findChild(page, "passwdDelegate0")); // password option
373343 tap(findChild(page, "forwardButton"));
374344 page = waitForPage("passwdSetPage");
375345
346+ var passwdField = findChild(page, "passwordField");
347+ verify(passwdField);
348+ tap(passwdField);
349+ verifyAnimationsNotRunning(page);
376350 typeString("aaa");
377351 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);
382−
383− typeString("aaaa");
352+ tryCompare(page, "passwordsMatching", false);
353+
354+ tap(passwdField);
355+ verifyAnimationsNotRunning(page);
356+ passwdField.selectAll(); // overwrite the text
357+ typeString("12345678");
358+ tryCompare(page, "passwordsMatching", false);
359+
360+ var passwd2Field = findChild(page, "password2Field");
361+ tap(passwd2Field);
362+ verifyAnimationsNotRunning(page);
363+ typeString("12345678");
364+ tryCompare(continueButton, "enabled", true);
384365 tap(continueButton);
385− page = waitForPage("passwdConfirmPage");
386−
387− // make sure we go back to 'set' page not 'type' page
388− var back = findChild(page, "backButton");
389− tap(back);
390− page = waitForPage("passwdSetPage");
391−
392− typeString("aaaa");
393− keyClick(Qt.Key_Enter);
394− page = waitForPage("passwdConfirmPage");
395−
396− continueButton = findChild(page, "forwardButton");
397− typeString("aaab");
398− tryCompare(continueButton.item, "enabled", false);
399− keyClick(Qt.Key_Enter);
400− var error = findChild(page, "wrongNoticeLabel");
401− tryCompareFunction(function() { return error.text !== ""; }, true);
402−
403− typeString("aaaa");
404− tap(continueButton);
405− page = waitForPage("wifiPage");
406366
407367 // now finish up
408− tap(findChild(page, "forwardButton"));
409− page = waitForPage("locationPage");
368+ page = waitForPage("reportingPage");
410369 tap(findChild(page, "forwardButton"));
411370 page = waitForPage("finishedPage");
412− tap(findChild(page, "forwardButton"));
371+ waitUntilTransitionsEnd(page);
372+ tap(findChild(page, "finishButton"));
413373
414374 tryCompare(setSecuritySpy, "count", 1);
415375 compare(setSecuritySpy.signalArguments[0][0], "");
416− compare(setSecuritySpy.signalArguments[0][1], "aaaa");
376+ compare(setSecuritySpy.signalArguments[0][1], "12345678");
417377 compare(setSecuritySpy.signalArguments[0][2], UbuntuSecurityPrivacyPanel.Passphrase);
418378 }
419379
420380 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");
381+ var page = goToPage("passwdPage");
382+ tap(findChild(page, "passwdDelegate2")); // swipe option
443383
444− var pages = findChild(wizard, "wizardPages");
445− var stack = findChild(pages, "pageStack");
384+ // now finish up
446385 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);
386+ page = waitForPage("reportingPage");
387+ tap(findChild(page, "forwardButton"));
388+ page = waitForPage("finishedPage");
389+ waitUntilTransitionsEnd(page);
390+ tap(findChild(page, "finishButton"));
451391
452− AccountsService.hereLicensePath = "";
453− waitForPage("finishedPage", false, false, true);
392+ tryCompare(setSecuritySpy, "count", 0); // not called for swipe method
454393 }
455394
456395 function test_locationGpsOnly() {
457396 var page = goToPage("locationPage");
458− var gpsCheck = findChild(page, "gpsCheck");
459− var hereCheck = findChild(page, "hereCheck");
460− var nopeCheck = findChild(page, "nopeCheck");
397+ var gpsCheck = findChild(page, "gpsCheckLabel");
398+ var hereCheck = findChild(page, "hereCheckLabel");
399+ var nopeCheck = findChild(page, "nopeCheckLabel");
461400
462401 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
463402 activateLocationSpy.target = locationActionGroup.location;
@@ -476,9 +415,9 @@ Item {
476415
477416 function test_locationNope() {
478417 var page = goToPage("locationPage");
479− var gpsCheck = findChild(page, "gpsCheck");
480− var hereCheck = findChild(page, "hereCheck");
481− var nopeCheck = findChild(page, "nopeCheck");
418+ var gpsCheck = findChild(page, "gpsCheckLabel");
419+ var hereCheck = findChild(page, "hereCheckLabel");
420+ var nopeCheck = findChild(page, "nopeCheckLabel");
482421
483422 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
484423 activateLocationSpy.target = locationActionGroup.location;
@@ -491,15 +430,15 @@ Item {
491430
492431 tap(findChild(page, "forwardButton"));
493432 tryCompare(AccountsService, "hereEnabled", false);
494− tryCompare(activateLocationSpy, "count", 0)
495− tryCompare(activateGPSSpy, "count", 0)
433+ tryCompare(activateLocationSpy, "count", 0);
434+ tryCompare(activateGPSSpy, "count", 0);
496435 }
497436
498437 function test_locationHere() {
499438 var page = goToPage("locationPage");
500− var gpsCheck = findChild(page, "gpsCheck");
501− var hereCheck = findChild(page, "hereCheck");
502− var nopeCheck = findChild(page, "nopeCheck");
439+ var gpsCheck = findChild(page, "gpsCheckLabel");
440+ var hereCheck = findChild(page, "hereCheckLabel");
441+ var nopeCheck = findChild(page, "nopeCheckLabel");
503442
504443 var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
505444 activateLocationSpy.target = locationActionGroup.location;
@@ -512,68 +451,41 @@ Item {
512451
513452 tap(findChild(page, "forwardButton"));
514453 tryCompare(AccountsService, "hereEnabled", true);
515− tryCompare(activateLocationSpy, "count", 1)
516− tryCompare(activateGPSSpy, "count", 1)
454+ tryCompare(activateLocationSpy, "count", 1);
455+ tryCompare(activateGPSSpy, "count", 1);
517456 }
518457
519− function test_locationHereTerms() {
520− var page = goToPage("locationPage");
521−
522− var link = findChild(page, "hereTermsLink");
458+ function test_timezonePage() {
459+ var page = goToPage("tzPage");
460+ verify(page);
461+ timezoneSpy.target = page.tdModule;
523462
524− // Test our language lookup code a bit
463+ var tzFilter = findChild(page, "tzFilter");
464+ verify(tzFilter);
465+ tap(tzFilter);
466+ typeString("London");
525467
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");
532−
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");
539−
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");
546−
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");
553−
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");
468+ var tzList = findChild(page, "tzList");
469+ verify(tzList);
558470
559− // OK, done with languages, back to actual page
471+ // test filtering works and returns some results
472+ tryCompareFunction(function() { return tzList.count > 0; }, true);
560473
561− var label = findChild(page, "termsLabel");
562− label.linkActivated(Qt.resolvedUrl("licenses/en_US.html"));
563− tryCompare(label, "visible", false);
474+ // just tap the first one
475+ tap(findChild(page, "tz0"));
564476
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);
477+ // go next and verify the (mock) signal got fired
478+ tap(findChild(page, "forwardButton"));
479+ tryCompare(timezoneSpy, "count", 1);
480+ tryCompare(page.tdModule, "timeZone", timezoneSpy.signalArguments[0][0]);
481+ }
569482
570− tap(findChild(page, "backButton"));
571− waitForPage("hereTermsPage"); // confirm we're on same page
572− tryCompare(webview, "visible", false);
573− tryCompare(label, "visible", true);
483+ function test_accountPage() {
484+ var page = goToPage("accountPage");
485+ var forwardButton = findChild(page, "forwardButton");
574486
575− tap(findChild(page, "backButton"));
576− waitForPage("locationPage");
487+ tap(findChild(page, "nameInput"));
488+ typeString("foobar");
577489 }
578490 }
579491}