@@ -20,7 +20,9 @@ import AccountsService 0.1
2020import MeeGo.QOfono 0.2
2121import QMenuModel 0.1
2222import Ubuntu.Components 1.3
23+import Ubuntu.Connectivity 1.0
2324import Ubuntu.SystemSettings.SecurityPrivacy 1.0
25+import Ubuntu.SystemSettings.Update 1.0
2426import Ubuntu.SystemSettings.TimeDate 1.1
2527import Unity.Test 0.1 as UT
2628import Wizard 0.1
@@ -86,34 +88,22 @@ Item {
8688 signalName: "keymapsChanged"
8789 }
8890
89− function setup() {
90− i18n.language = "en";
91− MockQOfono.setModems(["sim1"], [false], []);
92− MockQOfono.available = true;
93− MockQOfono.ready = true;
94− System.wizardEnabled = true;
95−
96− updateSessionLanguageSpy.clear();
97− setSecuritySpy.clear();
98− activateLocationSpy.clear();
99− activateGPSSpy.clear();
100− timezoneSpy.clear();
101− kbdLayoutSpy.clear();
102−
103− ActionData.data = {
104− "location-detection-enabled": {
105− 'valid': true,
106− 'state': false
107− },
108− "gps-detection-enabled": {
109− 'valid': true,
110− 'state': false
111− }
112− };
91+ SignalSpy {
92+ id: updateDownloadedSpy
93+ target: SystemImage
94+ signalName: "updateDownloaded"
11395 }
11496
115− Component.onCompleted: {
116− setup();
97+ SignalSpy {
98+ id: applyUpdateSpy
99+ target: SystemImage
100+ signalName: "applyUpdate"
101+ }
102+
103+ SignalSpy {
104+ id: skipUntilFinishedSpy
105+ target: System
106+ signalName: "wouldHaveSetSkipUntilFinish"
117107 }
118108
119109 UT.UnityTestCase {
@@ -123,6 +113,52 @@ Item {
123113
124114 property Item wizard: wizardLoader.status === Loader.Ready ? wizardLoader.item : null
125115
116+ function init() {
117+ i18n.language = "en";
118+ MockQOfono.setModems(["sim1"], [false], []);
119+ MockQOfono.available = true;
120+ MockQOfono.ready = true;
121+
122+ System.wizardEnabled = true;
123+ System.isUpdate = false;
124+
125+ SystemImage.updateAvailable = false;
126+ SystemImage.checkingForUpdates = false;
127+
128+ NetworkingStatus.status = NetworkingStatus.Offline;
129+
130+ updateSessionLanguageSpy.clear();
131+ setSecuritySpy.clear();
132+ activateLocationSpy.clear();
133+ activateGPSSpy.clear();
134+ timezoneSpy.clear();
135+ kbdLayoutSpy.clear();
136+ updateDownloadedSpy.clear();
137+ applyUpdateSpy.clear();
138+ skipUntilFinishedSpy.clear();
139+
140+ // reload our test subject to get it in a fresh state once again
141+ wizardLoader.active = true;
142+
143+ tryCompare(wizardLoader, "status", Loader.Ready);
144+
145+ var pages = findChild(wizard, "wizardPages")
146+ var security = findInvisibleChild(pages, "securityPrivacy");
147+ security.setSecurity("", "", UbuntuSecurityPrivacyPanel.Swipe);
148+ setSecuritySpy.target = security;
149+
150+ ActionData.data = {
151+ "location-detection-enabled": {
152+ 'valid': true,
153+ 'state': false
154+ },
155+ "gps-detection-enabled": {
156+ 'valid': true,
157+ 'state': false
158+ }
159+ };
160+ }
161+
126162 function cleanup() {
127163 wizardLoader.itemDestroyed = false;
128164
@@ -137,18 +173,6 @@ Item {
137173 // iteration to do its work. So to ensure the reload, we will wait until the
138174 // Shell instance gets destroyed.
139175 tryCompare(wizardLoader, "itemDestroyed", true);
140−
141− // reload our test subject to get it in a fresh state once again
142− wizardLoader.active = true;
143−
144− tryCompare(wizardLoader, "status", Loader.Ready);
145−
146− var pages = findChild(wizard, "wizardPages");
147− var security = findInvisibleChild(pages, "securityPrivacy");
148− security.setSecurity("", "", UbuntuSecurityPrivacyPanel.Swipe);
149− setSecuritySpy.target = security;
150−
151− setup();
152176 }
153177
154178 function waitForPage(name) {
@@ -166,13 +190,10 @@ Item {
166190 return stack.currentPage;
167191 }
168192
169− function goToPage(name, skipSim, skipLocation) {
193+ function goToPage(name, skipSim) {
170194 if (skipSim === undefined) {
171195 skipSim = false;
172196 }
173− if (skipLocation === undefined) {
174− skipLocation = false;
175− }
176197
177198 var page = waitForPage("languagePage");
178199 if (name === page.objectName) return page;
@@ -192,12 +213,6 @@ Item {
192213 if (name === page.objectName) return page;
193214 tap(findChild(page, "forwardButton"));
194215
195− if (!skipLocation) {
196− page = waitForPage("locationPage");
197− if (name === page.objectName) return page;
198− tap(findChild(page, "forwardButton"));
199− }
200−
201216 page = waitForPage("tzPage");
202217 if (name === page.objectName) return page;
203218 waitUntilTransitionsEnd(page);
@@ -211,10 +226,23 @@ Item {
211226 if (name === page.objectName) return page;
212227 tap(findChild(page, "nameInput"));
213228 typeString("foobar");
214− tap(findChild(page, "forwardButton"));
215229
216− page = waitForPage("passwdPage");
230+ if (name != "passwdPage") {
231+ // Skip the password prompt
232+ var pages = findChild(wizard, "wizardPages");
233+ var security = findInvisibleChild(pages, "securityPrivacy");
234+ security.setSecurity("", "", UbuntuSecurityPrivacyPanel.Passphrase);
235+ tap(findChild(page, "forwardButton"));
236+ } else {
237+ tap(findChild(page, "forwardButton"));
238+ page = waitForPage("passwdPage");
239+ if (name === page.objectName) return page;
240+ tap(findChild(page, "forwardButton"));
241+ }
242+
243+ page = waitForPage("systemUpdatePage");
217244 if (name === page.objectName) return page;
245+ waitUntilTransitionsEnd(page);
218246 tap(findChild(page, "forwardButton"));
219247
220248 page = waitForPage("finishedPage");
@@ -323,8 +351,6 @@ Item {
323351 enterPasscode("1111");
324352
325353 // now finish up
326− page = waitForPage("systemUpdatePage");
327− tap(findChild(page, "forwardButton"));
328354 page = waitForPage("finishedPage");
329355 waitUntilTransitionsEnd(page);
330356 tap(findChild(page, "finishButton"));
@@ -363,8 +389,6 @@ Item {
363389 tap(continueButton);
364390
365391 // now finish up
366− page = waitForPage("systemUpdatePage");
367− tap(findChild(page, "forwardButton"));
368392 page = waitForPage("finishedPage");
369393 waitUntilTransitionsEnd(page);
370394 tap(findChild(page, "finishButton"));
@@ -381,8 +405,6 @@ Item {
381405
382406 // now finish up
383407 tap(findChild(page, "forwardButton"));
384− page = waitForPage("systemUpdatePage");
385− tap(findChild(page, "forwardButton"));
386408 page = waitForPage("finishedPage");
387409 waitUntilTransitionsEnd(page);
388410 tap(findChild(page, "finishButton"));
@@ -390,42 +412,6 @@ Item {
390412 tryCompare(setSecuritySpy, "count", 0); // not called for swipe method
391413 }
392414
393− function test_locationGpsOnly() {
394− var page = goToPage("locationPage");
395− var gpsCheck = findChild(page, "gpsCheckLabel");
396− var nopeCheck = findChild(page, "nopeCheckLabel");
397−
398− var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
399− activateLocationSpy.target = locationActionGroup.location;
400− activateGPSSpy.target = locationActionGroup.gps;
401−
402− tap(gpsCheck);
403− tryCompare(gpsCheck, "checked", true);
404− tryCompare(nopeCheck, "checked", false);
405−
406− tap(findChild(page, "forwardButton"));
407− tryCompare(activateLocationSpy, "count", 1)
408− tryCompare(activateGPSSpy, "count", 1)
409− }
410−
411− function test_locationNope() {
412− var page = goToPage("locationPage");
413− var gpsCheck = findChild(page, "gpsCheckLabel");
414− var nopeCheck = findChild(page, "nopeCheckLabel");
415−
416− var locationActionGroup = findInvisibleChild(page, "locationActionGroup");
417− activateLocationSpy.target = locationActionGroup.location;
418− activateGPSSpy.target = locationActionGroup.gps;
419−
420− tap(nopeCheck);
421− tryCompare(gpsCheck, "checked", false);
422− tryCompare(nopeCheck, "checked", true);
423−
424− tap(findChild(page, "forwardButton"));
425− tryCompare(activateLocationSpy, "count", 0);
426− tryCompare(activateGPSSpy, "count", 0);
427− }
428−
429415 function test_timezonePage() {
430416 var page = goToPage("tzPage");
431417 verify(page);
@@ -452,6 +438,24 @@ Item {
452438 compare(timezoneSpy.signalArguments[0][1], "Belfast");
453439 }
454440
441+ function test_systemUpdatePage() {
442+
443+ compare(updateDownloadedSpy.count, 0);
444+ SystemImage.updateAvailable = true;
445+ SystemImage.targetBuildNumber = 42;
446+ SystemImage.updateDownloaded();
447+ compare(updateDownloadedSpy.count, 1);
448+
449+ var page = goToPage("systemUpdatePage");
450+ var updateButton = findChild(page, "installButton");
451+
452+ compare(skipUntilFinishedSpy.count, 0);
453+ compare(applyUpdateSpy.count, 0);
454+ tap(updateButton);
455+ compare(skipUntilFinishedSpy.count, 1);
456+ compare(applyUpdateSpy.count, 1);
457+ }
458+
455459 function test_accountPage() {
456460 var page = goToPage("accountPage");
457461 var forwardButton = findChild(page, "forwardButton");