Merge lp:~mterry/unity8/unlock-sim-after-wizard into lp:unity8

Proposed by Michael Terry
Status: Superseded
Proposed branch: lp:~mterry/unity8/unlock-sim-after-wizard
Merge into: lp:unity8
Diff against target: 1124 lines (+395/-400)
6 files modified
qml/Greeter/Greeter.qml (+0/-5)
qml/Shell.qml (+11/-0)
qml/Wizard/Wizard.qml (+1/-1)
tests/qmltests/CMakeLists.txt (+0/-1)
tests/qmltests/tst_Shell.qml (+383/-89)
tests/qmltests/tst_TabletShell.qml (+0/-304)
To merge this branch: bzr merge lp:~mterry/unity8/unlock-sim-after-wizard
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Unity Team Pending
Review via email: mp+251005@code.launchpad.net

This proposal has been superseded by a proposal from 2015-03-03.

Commit message

Only call unlockAllModems once the wizard is done. (LP: #1425161)

Description of the change

Only call unlockAllModems once the wizard is done. (LP: #1425161)

This is only a problem in vivid because in RTM, the shell isn't running when the wizard is.

I never noticed this when testing because I'm a silly American.

== Checklist ==

 * Are there any related MPs required for this MP to build/function as expected? Please list.
 No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
 Yes

 * Did you make sure that your branch does not contain spurious tags?
 Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
 NA

 * If you changed the UI, has there been a design review?
 NA

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Would you mind rebasing it on top of lp:~dandrader/unity8/unifyShellTests?

With unifyShellTests, tests functions have to load the shell explicitly using the loadShell(form-factor) helper function, which will be useful for your new test.

Besides, the two conflict anyway, so either of the MPs would have to do that in any case.

1637. By Michael Terry

Merge unifyShellTests

1638. By Michael Terry

Merge from unifyShellTests

1639. By Michael Terry

Add some comments on why we cache the 'active' bool instead of using an alias

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Greeter/Greeter.qml'
2--- qml/Greeter/Greeter.qml 2015-02-23 15:43:41 +0000
3+++ qml/Greeter/Greeter.qml 2015-03-03 14:57:58 +0000
4@@ -19,7 +19,6 @@
5 import LightDM 0.1 as LightDM
6 import Ubuntu.Components 1.1
7 import Ubuntu.SystemImage 0.1
8-import Unity.Connectivity 0.1
9 import Unity.Launcher 0.1
10 import "../Components"
11
12@@ -179,10 +178,6 @@
13 }
14 }
15
16- Component.onCompleted: {
17- Connectivity.unlockAllModems();
18- }
19-
20 Timer {
21 id: forcedDelayTimer
22 interval: 1000 * 60
23
24=== modified file 'qml/Shell.qml'
25--- qml/Shell.qml 2015-02-23 15:43:41 +0000
26+++ qml/Shell.qml 2015-03-03 14:57:58 +0000
27@@ -23,6 +23,7 @@
28 import Ubuntu.Components.Popups 1.0
29 import Ubuntu.Gestures 0.1
30 import Ubuntu.Telephony 0.1 as Telephony
31+import Unity.Connectivity 0.1
32 import Unity.Launcher 0.1
33 import Utils 0.1
34 import LightDM 0.1 as LightDM
35@@ -535,8 +536,18 @@
36
37 Wizard {
38 id: wizard
39+ objectName: "wizard"
40 anchors.fill: parent
41 background: shell.background
42+
43+ function unlockWhenDoneWithWizard() {
44+ if (!active) {
45+ Connectivity.unlockAllModems();
46+ }
47+ }
48+
49+ Component.onCompleted: unlockWhenDoneWithWizard()
50+ onActiveChanged: unlockWhenDoneWithWizard()
51 }
52
53 Rectangle {
54
55=== modified file 'qml/Wizard/Wizard.qml'
56--- qml/Wizard/Wizard.qml 2014-11-24 17:56:44 +0000
57+++ qml/Wizard/Wizard.qml 2015-03-03 14:57:58 +0000
58@@ -25,7 +25,7 @@
59 // The background wallpaper to use
60 property string background
61
62- readonly property alias active: loader.active
63+ readonly property bool active: loader.active
64
65 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
66
67
68=== modified file 'tests/qmltests/CMakeLists.txt'
69--- tests/qmltests/CMakeLists.txt 2015-02-18 13:33:49 +0000
70+++ tests/qmltests/CMakeLists.txt 2015-03-03 14:57:58 +0000
71@@ -20,7 +20,6 @@
72
73 add_qml_test(. Shell)
74 add_qml_test(. ShellWithPin)
75-add_qml_test(. TabletShell)
76 add_qml_test(Components Background)
77 add_qml_test(Components Carousel)
78 add_qml_test(Components Dialogs)
79
80=== modified file 'tests/qmltests/tst_Shell.qml'
81--- tests/qmltests/tst_Shell.qml 2015-02-23 15:43:41 +0000
82+++ tests/qmltests/tst_Shell.qml 2015-03-03 14:57:58 +0000
83@@ -1,5 +1,5 @@
84 /*
85- * Copyright (C) 2013-2014 Canonical, Ltd.
86+ * Copyright (C) 2013-2015 Canonical, Ltd.
87 *
88 * Authors:
89 * Daniel d'Andrada <daniel.dandrada@canonical.com>
90@@ -31,12 +31,14 @@
91 import Unity.Notifications 1.0
92 import Unity.Test 0.1 as UT
93 import Powerd 0.1
94+import Wizard 0.1 as Wizard
95
96 import "../../qml"
97
98-Item {
99+Rectangle {
100 id: root
101- width: units.gu(60)
102+ color: "grey"
103+ width: units.gu(100) + controls.width
104 height: units.gu(71)
105
106 Component.onCompleted: {
107@@ -62,12 +64,37 @@
108 }
109 }
110
111- Row {
112- anchors.fill: parent
113+ Item {
114+ anchors.left: root.left
115+ anchors.right: controls.left
116+ anchors.top: root.top
117+ anchors.bottom: root.bottom
118 Loader {
119 id: shellLoader
120 focus: true
121
122+ anchors.centerIn: parent
123+
124+ state: "phone"
125+ states: [
126+ State {
127+ name: "phone"
128+ PropertyChanges {
129+ target: shellLoader
130+ width: units.gu(40)
131+ height: units.gu(71)
132+ }
133+ },
134+ State {
135+ name: "tablet"
136+ PropertyChanges {
137+ target: shellLoader
138+ width: units.gu(100)
139+ height: units.gu(71)
140+ }
141+ }
142+ ]
143+
144 active: false
145 property bool itemDestroyed: false
146 sourceComponent: Component {
147@@ -80,42 +107,56 @@
148 }
149 }
150 }
151-
152- Rectangle {
153- color: "darkgrey"
154- width: units.gu(30)
155- height: shellLoader.height
156-
157- Column {
158- anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
159- spacing: units.gu(1)
160- Row {
161- anchors { left: parent.left; right: parent.right }
162- Button {
163- text: "Show Greeter"
164- activeFocusOnPress: false
165- onClicked: {
166- if (shellLoader.status !== Loader.Ready)
167- return;
168-
169- var greeter = testCase.findChild(shellLoader.item, "greeter");
170- if (!greeter.shown) {
171- LightDM.Greeter.showGreeter();
172- }
173+ }
174+
175+ Rectangle {
176+ id: controls
177+ color: "darkgrey"
178+ width: units.gu(30)
179+ anchors.top: root.top
180+ anchors.bottom: root.bottom
181+ anchors.right: root.right
182+
183+ Column {
184+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
185+ spacing: units.gu(1)
186+ Row {
187+ anchors { left: parent.left; right: parent.right }
188+ Button {
189+ text: "Show Greeter"
190+ activeFocusOnPress: false
191+ onClicked: {
192+ if (shellLoader.status !== Loader.Ready)
193+ return;
194+
195+ var greeter = testCase.findChild(shellLoader.item, "greeter");
196+ if (!greeter.shown) {
197+ LightDM.Greeter.showGreeter();
198 }
199 }
200 }
201- ListItem.ItemSelector {
202- anchors { left: parent.left; right: parent.right }
203- activeFocusOnPress: false
204- text: "LightDM mock mode"
205- model: ["single", "single-passphrase", "single-pin"]
206- onSelectedIndexChanged: {
207- shellLoader.active = false;
208- LightDM.Greeter.mockMode = model[selectedIndex];
209- LightDM.Users.mockMode = model[selectedIndex];
210- shellLoader.active = true;
211- }
212+ }
213+ ListItem.ItemSelector {
214+ anchors { left: parent.left; right: parent.right }
215+ activeFocusOnPress: false
216+ text: "LightDM mock mode"
217+ model: ["single", "single-passphrase", "single-pin", "full"]
218+ onSelectedIndexChanged: {
219+ shellLoader.active = false;
220+ LightDM.Greeter.mockMode = model[selectedIndex];
221+ LightDM.Users.mockMode = model[selectedIndex];
222+ shellLoader.active = true;
223+ }
224+ }
225+ ListItem.ItemSelector {
226+ anchors { left: parent.left; right: parent.right }
227+ activeFocusOnPress: false
228+ text: "Size"
229+ model: ["phone", "tablet"]
230+ onSelectedIndexChanged: {
231+ shellLoader.active = false;
232+ shellLoader.state = model[selectedIndex];
233+ shellLoader.active = true;
234 }
235 }
236 }
237@@ -186,20 +227,49 @@
238 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
239
240 function init() {
241+ if (shellLoader.active) {
242+ // happens for the very first test function as shell
243+ // is loaded by default
244+ tearDown();
245+ }
246+
247+ }
248+
249+ function cleanup() {
250+ tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
251+ tearDown();
252+ }
253+
254+ function loadShell(formFactor) {
255+ shellLoader.state = formFactor;
256+ shellLoader.active = true;
257+ tryCompare(shellLoader, "status", Loader.Ready);
258+ removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
259 tryCompare(shell, "enabled", true); // enabled by greeter when ready
260- shell.indicatorProfile = "phone";
261-
262- swipeAwayGreeter();
263
264 sessionSpy.target = findChild(shell, "greeter")
265 dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator");
266
267 var launcher = findChild(shell, "launcher");
268 launcherShowDashHomeSpy.target = launcher;
269- }
270-
271- function cleanup() {
272- tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
273+
274+ waitForGreeterToStabilize();
275+ }
276+
277+ function waitForGreeterToStabilize() {
278+ var greeter = findChild(shell, "greeter");
279+ verify(greeter);
280+
281+ var loginList = findChild(greeter, "loginList");
282+ // Only present in WideView
283+ if (loginList) {
284+ var userList = findChild(loginList, "userList");
285+ verify(userList);
286+ tryCompare(userList, "movingInternally", false);
287+ }
288+ }
289+
290+ function tearDown() {
291 launcherShowDashHomeSpy.target = null;
292
293 shellLoader.itemDestroyed = false;
294@@ -216,17 +286,18 @@
295 // Shell instance gets destroyed.
296 tryCompare(shellLoader, "itemDestroyed", true);
297
298+ setLightDMMockMode("single"); // back to the default value
299+
300+ AccountsService.demoEdges = false;
301+ Wizard.System.wizardEnabled = false;
302+
303 // kill all (fake) running apps
304 killApps(ApplicationManager);
305
306 unlockAllModemsSpy.clear()
307 LightDM.Greeter.authenticate(""); // reset greeter
308
309- // reload our test subject to get it in a fresh state once again
310- shellLoader.active = true;
311-
312- tryCompare(shellLoader, "status", Loader.Ready);
313- removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
314+ sessionSpy.clear();
315 }
316
317 function killApps() {
318@@ -238,6 +309,8 @@
319 }
320
321 function test_snapDecisionDismissalReturnsFocus() {
322+ loadShell("phone");
323+ swipeAwayGreeter();
324 var notifications = findChild(shell, "notificationList");
325 var app = ApplicationManager.startApplication("camera-app");
326 var stage = findChild(shell, "stage")
327@@ -296,19 +369,41 @@
328 mockNotificationsModel.append(n)
329 }
330
331- function test_leftEdgeDrag_data() {
332+ function test_phoneLeftEdgeDrag_data() {
333 return [
334- {tag: "without launcher", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
335- {tag: "with launcher", revealLauncher: true, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
336- {tag: "small swipe", revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app", launcherHides: false, greeterShown: false},
337- {tag: "long swipe", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
338- {tag: "small swipe with greeter", revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app", launcherHides: false, greeterShown: true},
339- {tag: "long swipe with greeter", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: true},
340- {tag: "swipe over dash", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "unity8-dash", launcherHides: false, greeterShown: false},
341+ {tag: "without launcher",
342+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
343+ launcherHides: true, greeterShown: false},
344+
345+ {tag: "with launcher",
346+ revealLauncher: true, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
347+ launcherHides: true, greeterShown: false},
348+
349+ {tag: "small swipe",
350+ revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
351+ launcherHides: false, greeterShown: false},
352+
353+ {tag: "long swipe",
354+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
355+ launcherHides: true, greeterShown: false},
356+
357+ {tag: "small swipe with greeter",
358+ revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
359+ launcherHides: false, greeterShown: true},
360+
361+ {tag: "long swipe with greeter",
362+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
363+ launcherHides: true, greeterShown: true},
364+
365+ {tag: "swipe over dash",
366+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "unity8-dash",
367+ launcherHides: false, greeterShown: false},
368 ];
369 }
370
371- function test_leftEdgeDrag(data) {
372+ function test_phoneLeftEdgeDrag(data) {
373+ loadShell("phone");
374+ swipeAwayGreeter();
375 dragLauncherIntoView();
376 tapOnAppIconInLauncher();
377 waitUntilApplicationWindowIsFullyVisible();
378@@ -317,8 +412,7 @@
379
380 var greeter = findChild(shell, "greeter");
381 if (data.greeterShown) {
382- LightDM.Greeter.showGreeter();
383- tryCompare(greeter, "fullyShown", true);
384+ showGreeter();
385 }
386
387 if (data.revealLauncher) {
388@@ -342,7 +436,32 @@
389 compare(animateTimer.nextState, "visible");
390 }
391
392+ function test_tabletLeftEdgeDrag_data() {
393+ return [
394+ {tag: "without password", user: "no-password", loggedIn: true, demo: false},
395+ {tag: "with password", user: "has-password", loggedIn: false, demo: false},
396+ {tag: "with demo", user: "has-password", loggedIn: true, demo: true},
397+ ]
398+ }
399+
400+ function test_tabletLeftEdgeDrag(data) {
401+ setLightDMMockMode("full");
402+ loadShell("tablet");
403+
404+ selectUser(data.user)
405+
406+ AccountsService.demoEdges = data.demo
407+ var tutorial = findChild(shell, "tutorial");
408+ tryCompare(tutorial, "running", data.demo);
409+
410+ swipeFromLeftEdge(shell.width * 0.75)
411+ wait(500) // to give time to handle dash() signal from Launcher
412+ confirmLoggedIn(data.loggedIn)
413+ }
414+
415 function test_suspend() {
416+ loadShell("phone");
417+ swipeAwayGreeter();
418 var greeter = findChild(shell, "greeter");
419
420 // Launch an app from the launcher
421@@ -375,7 +494,15 @@
422 tryCompare(greeter, "fullyShown", true);
423
424 // Swipe away greeter to focus app
425+
426+ // greeter unloads its internal components when hidden
427+ // and reloads them when shown. Thus we have to do this
428+ // again before interacting with it otherwise any
429+ // DirectionalDragAreas in there won't be easily fooled by
430+ // fake swipes.
431+ removeTimeConstraintsFromDirectionalDragAreas(greeter);
432 swipeAwayGreeter();
433+
434 tryCompare(ApplicationManager, "suspended", false);
435 compare(mainApp.state, ApplicationInfoInterface.Running);
436 tryCompare(ApplicationManager, "focusedApplicationId", mainAppId);
437@@ -394,6 +521,60 @@
438 waitForRendering(greeter);
439 }
440
441+ function selectUserAtIndex(i) {
442+ // We could be anywhere in list; find target index to know which direction
443+ var greeter = findChild(shell, "greeter")
444+ var userlist = findChild(greeter, "userList")
445+ if (userlist.currentIndex == i)
446+ keyClick(Qt.Key_Escape) // Reset state if we're not moving
447+ while (userlist.currentIndex != i) {
448+ var next = userlist.currentIndex + 1
449+ if (userlist.currentIndex > i) {
450+ next = userlist.currentIndex - 1
451+ }
452+ tap(findChild(greeter, "username"+next));
453+ tryCompare(userlist, "currentIndex", next)
454+ tryCompare(userlist, "movingInternally", false)
455+ }
456+ }
457+
458+ function selectUser(name) {
459+ // Find index of user with the right name
460+ for (var i = 0; i < LightDM.Users.count; i++) {
461+ if (LightDM.Users.data(i, LightDM.UserRoles.NameRole) == name) {
462+ break
463+ }
464+ }
465+ if (i == LightDM.Users.count) {
466+ fail("Didn't find name")
467+ return -1
468+ }
469+ selectUserAtIndex(i)
470+ return i
471+ }
472+
473+ function clickPasswordInput(isButton) {
474+ var greeter = findChild(shell, "greeter")
475+ tryCompare(greeter, "fullyShown", true);
476+
477+ var passwordMouseArea = findChild(shell, "passwordMouseArea")
478+ tryCompare(passwordMouseArea, "enabled", isButton)
479+
480+ var passwordInput = findChild(shell, "passwordInput")
481+ mouseClick(passwordInput)
482+ }
483+
484+ function confirmLoggedIn(loggedIn) {
485+ var greeter = findChild(shell, "greeter");
486+ tryCompare(greeter, "shown", loggedIn ? false : true);
487+ verify(loggedIn ? sessionSpy.count > 0 : sessionSpy.count === 0);
488+ }
489+
490+ function setLightDMMockMode(mode) {
491+ LightDM.Greeter.mockMode = mode;
492+ LightDM.Users.mockMode = mode;
493+ }
494+
495 /*
496 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
497
498@@ -406,6 +587,8 @@
499 - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
500 */
501 function test_minimizingAppTakesToDashApps() {
502+ loadShell("phone");
503+ swipeAwayGreeter();
504 dragLauncherIntoView();
505
506 // Launch an app from the launcher
507@@ -426,6 +609,8 @@
508 }
509
510 function test_showInputMethod() {
511+ loadShell("phone");
512+ swipeAwayGreeter();
513 var item = findChild(shell, "inputMethod");
514 var surface = SurfaceManager.inputMethodSurface();
515
516@@ -464,6 +649,8 @@
517 }
518
519 function test_surfaceLosesActiveFocusWhilePanelIsOpen() {
520+ loadShell("phone");
521+ swipeAwayGreeter();
522 var app = ApplicationManager.startApplication("dialer-app");
523 waitUntilAppWindowIsFullyLoaded(app);
524
525@@ -494,28 +681,26 @@
526 tryCompare(app.session.surface, "activeFocus", true);
527 }
528
529- function test_launchedAppHasActiveFocus() {
530- var dialerApp = ApplicationManager.startApplication("dialer-app");
531+ function test_launchedAppHasActiveFocus_data() {
532+ return [
533+ {tag:"phone", formFactor:"phone"},
534+ {tag:"tablet", formFactor:"tablet"},
535+ ];
536+ }
537+
538+ function test_launchedAppHasActiveFocus(data) {
539+ loadShell(data.formFactor);
540+ swipeAwayGreeter();
541+
542+ var dialerApp = ApplicationManager.startApplication("webbrowser-app");
543 verify(dialerApp);
544- waitUntilAppSurfaceShowsUp("dialer-app")
545+ waitUntilAppSurfaceShowsUp("webbrowser-app")
546
547 verify(dialerApp.session.surface);
548
549 tryCompare(dialerApp.session.surface, "activeFocus", true);
550 }
551
552- // Wait for the whole UI to settle down
553- function waitForUIToSettle() {
554- var launcher = findChild(shell, "launcherPanel")
555- tryCompareFunction(function() {return launcher.x === 0 || launcher.x === -launcher.width;}, true);
556- if (launcher.x === 0) {
557- mouseClick(shell)
558- }
559- tryCompare(launcher, "x", -launcher.width)
560-
561- waitForRendering(shell)
562- }
563-
564 function waitUntilAppSurfaceShowsUp(appId) {
565 var appWindow = findChild(shell, "appWindow_" + appId);
566 verify(appWindow);
567@@ -593,11 +778,27 @@
568 && itemRectInShell.y + itemRectInShell.height <= shell.height;
569 }
570
571+ function showGreeter() {
572+ var greeter = findChild(shell, "greeter");
573+ LightDM.Greeter.showGreeter();
574+ waitForRendering(greeter);
575+ tryCompare(greeter, "fullyShown", true);
576+
577+ // greeter unloads its internal components when hidden
578+ // and reloads them when shown. Thus we have to do this
579+ // again before interacting with it otherwise any
580+ // DirectionalDragAreas in there won't be easily fooled by
581+ // fake swipes.
582+ removeTimeConstraintsFromDirectionalDragAreas(greeter);
583+ }
584+
585 function test_greeterDoesNotChangeIndicatorProfile() {
586+ loadShell("phone");
587+ swipeAwayGreeter();
588 var panel = findChild(shell, "panel");
589 tryCompare(panel.indicators.indicatorsModel, "profile", shell.indicatorProfile);
590
591- LightDM.Greeter.showGreeter();
592+ showGreeter();
593 tryCompare(panel.indicators.indicatorsModel, "profile", shell.indicatorProfile);
594
595 LightDM.Greeter.hideGreeter();
596@@ -605,6 +806,8 @@
597 }
598
599 function test_shellProfileChangesReachIndicators() {
600+ loadShell("phone");
601+ swipeAwayGreeter();
602 var panel = findChild(shell, "panel");
603
604 shell.indicatorProfile = "test1";
605@@ -621,6 +824,8 @@
606 }
607
608 function test_focusRequestedHidesGreeter() {
609+ loadShell("phone");
610+ swipeAwayGreeter();
611 var greeter = findChild(shell, "greeter");
612
613 var app = ApplicationManager.startApplication("dialer-app");
614@@ -632,8 +837,7 @@
615
616 waitUntilDashIsFocused();
617
618- LightDM.Greeter.showGreeter();
619- tryCompare(greeter, "fullyShown", true);
620+ showGreeter();
621
622 // The main point of this test
623 ApplicationManager.requestFocusApplication("dialer-app");
624@@ -642,6 +846,8 @@
625 }
626
627 function test_focusRequestedHidesIndicators() {
628+ loadShell("phone");
629+ swipeAwayGreeter();
630 var indicators = findChild(shell, "indicators");
631
632 showIndicators();
633@@ -654,6 +860,8 @@
634 }
635
636 function test_showAndHideGreeterDBusCalls() {
637+ loadShell("phone");
638+ swipeAwayGreeter();
639 var greeter = findChild(shell, "greeter")
640 tryCompare(greeter, "shown", false)
641 waitForRendering(greeter);
642@@ -664,18 +872,21 @@
643 tryCompare(greeter, "shown", false)
644 }
645
646- function test_login() {
647- var greeter = findChild(shell, "greeter")
648- waitForRendering(greeter)
649- LightDM.Greeter.showGreeter();
650- tryCompare(greeter, "fullyShown", true)
651+ function test_greeterLoginsAutomaticallyWhenNoPasswordSet() {
652+ loadShell("phone");
653+ swipeAwayGreeter();
654
655 sessionSpy.clear();
656- swipeAwayGreeter()
657- tryCompare(sessionSpy, "count", 1)
658+ verify(sessionSpy.valid);
659+
660+ showGreeter();
661+
662+ tryCompare(sessionSpy, "count", 1);
663 }
664
665 function test_fullscreen() {
666+ loadShell("phone");
667+ swipeAwayGreeter();
668 var panel = findChild(shell, "panel");
669 compare(panel.fullscreenMode, false);
670 ApplicationManager.startApplication("camera-app");
671@@ -689,6 +900,8 @@
672 }
673
674 function test_leftEdgeDragFullscreen() {
675+ loadShell("phone");
676+ swipeAwayGreeter();
677 var panel = findChild(shell, "panel");
678 tryCompare(panel, "fullscreenMode", false)
679
680@@ -710,6 +923,8 @@
681 }
682
683 function test_unlockedProperties() {
684+ loadShell("phone");
685+ swipeAwayGreeter();
686 // Confirm that various properties have the correct values when unlocked
687 var greeter = findChild(shell, "greeter");
688 tryCompare(greeter, "locked", false);
689@@ -722,10 +937,29 @@
690 }
691
692 function test_unlockAllModemsOnBoot() {
693+ loadShell("phone");
694+ swipeAwayGreeter();
695 tryCompare(unlockAllModemsSpy, "count", 1)
696 }
697
698+ function test_unlockAllModemsAfterWizard() {
699+ Wizard.System.wizardEnabled = true;
700+ loadShell("phone");
701+
702+ var wizard = findChild(shell, "wizard");
703+ compare(wizard.active, true);
704+ compare(Wizard.System.wizardEnabled, true);
705+ compare(unlockAllModemsSpy.count, 0);
706+
707+ wizard.hide();
708+ tryCompare(wizard, "active", false);
709+ compare(Wizard.System.wizardEnabled, false);
710+ compare(unlockAllModemsSpy.count, 1);
711+ }
712+
713 function test_tapOnRightEdgeReachesApplicationSurface() {
714+ loadShell("phone");
715+ swipeAwayGreeter();
716 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
717 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
718 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
719@@ -748,6 +982,8 @@
720 by the right-edge drag area)
721 */
722 function test_rightEdgeDragDoesNotReachApplicationSurface() {
723+ loadShell("phone");
724+ swipeAwayGreeter();
725 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
726 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
727 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
728@@ -792,6 +1028,8 @@
729 }
730
731 function test_tapUbuntuIconInLauncherOverAppSpread() {
732+ loadShell("phone");
733+ swipeAwayGreeter();
734
735 waitUntilFocusedApplicationIsShowingItsSurface();
736
737@@ -838,19 +1076,75 @@
738 function test_background_data() {
739 return [
740 {tag: "color", accounts: Qt.resolvedUrl("data:image/svg+xml,<svg><rect width='100%' height='100%' fill='#dd4814'/></svg>"), gsettings: "", output: Qt.resolvedUrl("data:image/svg+xml,<svg><rect width='100%' height='100%' fill='#dd4814'/></svg>")},
741- {tag: "empty", accounts: "", gsettings: "", output: shell.defaultBackground},
742+ {tag: "empty", accounts: "", gsettings: "", output: "defaultBackground"},
743 {tag: "as-specified", accounts: Qt.resolvedUrl("../data/unity/backgrounds/blue.png"), gsettings: "", output: Qt.resolvedUrl("../data/unity/backgrounds/blue.png")},
744 {tag: "gs-specified", accounts: "", gsettings: Qt.resolvedUrl("../data/unity/backgrounds/red.png"), output: Qt.resolvedUrl("../data/unity/backgrounds/red.png")},
745 {tag: "both-specified", accounts: Qt.resolvedUrl("../data/unity/backgrounds/blue.png"), gsettings: Qt.resolvedUrl("../data/unity/backgrounds/red.png"), output: Qt.resolvedUrl("../data/unity/backgrounds/blue.png")},
746 {tag: "invalid-as", accounts: Qt.resolvedUrl("../data/unity/backgrounds/nope.png"), gsettings: Qt.resolvedUrl("../data/unity/backgrounds/red.png"), output: Qt.resolvedUrl("../data/unity/backgrounds/red.png")},
747- {tag: "invalid-both", accounts: Qt.resolvedUrl("../data/unity/backgrounds/nope.png"), gsettings: Qt.resolvedUrl("../data/unity/backgrounds/stillnope.png"), output: shell.defaultBackground},
748+ {tag: "invalid-both", accounts: Qt.resolvedUrl("../data/unity/backgrounds/nope.png"), gsettings: Qt.resolvedUrl("../data/unity/backgrounds/stillnope.png"), output: "defaultBackground"},
749 ]
750 }
751 function test_background(data) {
752+ loadShell("phone");
753+ swipeAwayGreeter();
754 AccountsService.backgroundFile = data.accounts;
755 var backgroundSettings = findInvisibleChild(shell, "backgroundSettings");
756 backgroundSettings.pictureUri = data.gsettings;
757- tryCompare(shell, "background", data.output);
758+
759+ if (data.output === "defaultBackground") {
760+ tryCompare(shell, "background", shell.defaultBackground);
761+ } else {
762+ tryCompare(shell, "background", data.output);
763+ }
764+ }
765+
766+ function test_tabletLogin_data() {
767+ return [
768+ {tag: "auth error", user: "auth-error", loggedIn: false, password: ""},
769+ {tag: "with password", user: "has-password", loggedIn: true, password: "password"},
770+ {tag: "without password", user: "no-password", loggedIn: true, password: ""},
771+ ]
772+ }
773+
774+ function test_tabletLogin(data) {
775+ setLightDMMockMode("full");
776+ loadShell("tablet");
777+
778+ selectUser(data.user);
779+
780+ clickPasswordInput(data.password === "" /* isButton */);
781+
782+ if (data.password !== "") {
783+ typeString(data.password);
784+ keyClick(Qt.Key_Enter);
785+ }
786+
787+ confirmLoggedIn(data.loggedIn);
788+ }
789+
790+ function test_appLaunchDuringGreeter_data() {
791+ return [
792+ {tag: "auth error", user: "auth-error", loggedIn: false, passwordFocus: false},
793+ {tag: "without password", user: "no-password", loggedIn: true, passwordFocus: false},
794+ {tag: "with password", user: "has-password", loggedIn: false, passwordFocus: true},
795+ ]
796+ }
797+
798+ function test_appLaunchDuringGreeter(data) {
799+ setLightDMMockMode("full");
800+ loadShell("tablet");
801+
802+ selectUser(data.user)
803+
804+ var greeter = findChild(shell, "greeter")
805+ var app = ApplicationManager.startApplication("dialer-app")
806+
807+ confirmLoggedIn(data.loggedIn)
808+
809+ if (data.passwordFocus) {
810+ var passwordInput = findChild(greeter, "passwordInput")
811+ tryCompare(passwordInput, "focus", true)
812+ }
813 }
814 }
815 }
816
817=== removed file 'tests/qmltests/tst_TabletShell.qml'
818--- tests/qmltests/tst_TabletShell.qml 2015-02-09 15:24:48 +0000
819+++ tests/qmltests/tst_TabletShell.qml 1970-01-01 00:00:00 +0000
820@@ -1,304 +0,0 @@
821-/*
822- * Copyright (C) 2013,2014 Canonical, Ltd.
823- *
824- * This program is free software; you can redistribute it and/or modify
825- * it under the terms of the GNU General Public License as published by
826- * the Free Software Foundation; version 3.
827- *
828- * This program is distributed in the hope that it will be useful,
829- * but WITHOUT ANY WARRANTY; without even the implied warranty of
830- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
831- * GNU General Public License for more details.
832- *
833- * You should have received a copy of the GNU General Public License
834- * along with this program. If not, see <http://www.gnu.org/licenses/>.
835- */
836-
837-import QtQuick 2.0
838-import QtTest 1.0
839-import AccountsService 0.1
840-import GSettings 1.0
841-import LightDM 0.1 as LightDM
842-import Ubuntu.Components 1.1
843-import Ubuntu.Telephony 0.1 as Telephony
844-import Unity.Application 0.1
845-import Unity.Connectivity 0.1
846-import Unity.Test 0.1 as UT
847-import Powerd 0.1
848-
849-import "../../qml"
850-
851-Item {
852- id: root
853- width: units.gu(120)
854- height: units.gu(80)
855-
856- Component.onCompleted: {
857- // must set the mock mode before loading the Shell
858- LightDM.Greeter.mockMode = "full";
859- LightDM.Users.mockMode = "full";
860- shellLoader.active = true;
861- }
862-
863- QtObject {
864- id: applicationArguments
865-
866- function hasGeometry() {
867- return false
868- }
869-
870- function width() {
871- return 0
872- }
873-
874- function height() {
875- return 0
876- }
877- }
878-
879- Row {
880- anchors.fill: parent
881- Loader {
882- id: shellLoader
883-
884- active: false
885- width: units.gu(100)
886- height: parent.height
887-
888- property bool itemDestroyed: false
889- sourceComponent: Component {
890- Shell {
891- property string indicatorProfile: "phone"
892-
893- Component.onDestruction: {
894- shellLoader.itemDestroyed = true
895- }
896- }
897- }
898- }
899-
900- Rectangle {
901- color: "white"
902- width: units.gu(20)
903- height: parent.height
904-
905- Column {
906- anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
907- spacing: units.gu(1)
908- Button {
909- text: "Show Greeter"
910- onClicked: {
911- if (shellLoader.status !== Loader.Ready)
912- return
913-
914- var greeter = testCase.findChild(shellLoader.item, "greeter")
915- if (!greeter.shown) {
916- greeter.show()
917- }
918- }
919- }
920- Button {
921- text: "Demo edges"
922- onClicked: {
923- AccountsService.demoEdges = true;
924- }
925- }
926- }
927- }
928- }
929-
930- SignalSpy {
931- id: sessionSpy
932- signalName: "sessionStarted"
933- }
934-
935- SignalSpy {
936- id: dashCommunicatorSpy
937- signalName: "setCurrentScopeCalled"
938- }
939-
940- SignalSpy {
941- id: unlockAllModemsSpy
942- target: Connectivity
943- signalName: "unlockingAllModems"
944- }
945-
946- Telephony.CallEntry {
947- id: phoneCall
948- phoneNumber: "+447812221111"
949- }
950-
951- UT.UnityTestCase {
952- id: testCase
953- name: "TabletShell"
954- when: windowShown
955-
956- property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
957-
958- function init() {
959- tryCompare(shell, "enabled", true); // will be enabled when greeter is all ready
960- var userList = findChild(shell, "userList");
961- tryCompare(userList, "movingInternally", false);
962- sessionSpy.clear()
963- sessionSpy.target = findChild(shell, "greeter")
964- dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator")
965- }
966-
967- function cleanup() {
968- tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
969-
970- shellLoader.itemDestroyed = false
971-
972- shellLoader.active = false
973-
974- tryCompare(shellLoader, "status", Loader.Null)
975- tryCompare(shellLoader, "item", null)
976- // Loader.status might be Loader.Null and Loader.item might be null but the Loader
977- // item might still be alive. So if we set Loader.active back to true
978- // again right now we will get the very same Shell instance back. So no reload
979- // actually took place. Likely because Loader waits until the next event loop
980- // iteration to do its work. So to ensure the reload, we will wait until the
981- // Shell instance gets destroyed.
982- tryCompare(shellLoader, "itemDestroyed", true)
983-
984- // kill all (fake) running apps
985- killApps()
986-
987- unlockAllModemsSpy.clear()
988- AccountsService.demoEdges = false
989- LightDM.Greeter.authenticate(""); // reset greeter
990-
991- // reload our test subject to get it in a fresh state once again
992- shellLoader.active = true
993-
994- tryCompare(shellLoader, "status", Loader.Ready)
995- removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item)
996- }
997-
998- function killApps() {
999- while (ApplicationManager.count > 1) {
1000- var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
1001- ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId)
1002- }
1003- compare(ApplicationManager.count, 1)
1004- }
1005-
1006- function selectIndex(i) {
1007- // We could be anywhere in list; find target index to know which direction
1008- var greeter = findChild(shell, "greeter")
1009- var userlist = findChild(greeter, "userList")
1010- if (userlist.currentIndex == i)
1011- keyClick(Qt.Key_Escape) // Reset state if we're not moving
1012- while (userlist.currentIndex != i) {
1013- var next = userlist.currentIndex + 1
1014- if (userlist.currentIndex > i) {
1015- next = userlist.currentIndex - 1
1016- }
1017- tap(findChild(greeter, "username"+next));
1018- tryCompare(userlist, "currentIndex", next)
1019- tryCompare(userlist, "movingInternally", false)
1020- }
1021- }
1022-
1023- function selectUser(name) {
1024- // Find index of user with the right name
1025- for (var i = 0; i < LightDM.Users.count; i++) {
1026- if (LightDM.Users.data(i, LightDM.UserRoles.NameRole) == name) {
1027- break
1028- }
1029- }
1030- if (i == LightDM.Users.count) {
1031- fail("Didn't find name")
1032- return -1
1033- }
1034- selectIndex(i)
1035- return i
1036- }
1037-
1038- function clickPasswordInput(isButton) {
1039- var greeter = findChild(shell, "greeter")
1040- tryCompare(greeter, "fullyShown", true);
1041-
1042- var passwordMouseArea = findChild(shell, "passwordMouseArea")
1043- tryCompare(passwordMouseArea, "enabled", isButton)
1044-
1045- var passwordInput = findChild(shell, "passwordInput")
1046- mouseClick(passwordInput)
1047- }
1048-
1049- function confirmLoggedIn(loggedIn) {
1050- var greeter = findChild(shell, "greeter");
1051- tryCompare(greeter, "shown", loggedIn ? false : true);
1052- verify(loggedIn ? sessionSpy.count > 0 : sessionSpy.count === 0);
1053- }
1054-
1055- function swipeFromLeftEdge(swipeLength) {
1056- var touchStartX = 2
1057- var touchStartY = shell.height / 2
1058- touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY)
1059- }
1060-
1061- function test_login_data() {
1062- return [
1063- {tag: "auth error", user: "auth-error", loggedIn: false, password: ""},
1064- {tag: "with password", user: "has-password", loggedIn: true, password: "password"},
1065- {tag: "without password", user: "no-password", loggedIn: true, password: ""},
1066- ]
1067- }
1068-
1069- function test_login(data) {
1070- selectUser(data.user)
1071-
1072- clickPasswordInput(data.password === "")
1073-
1074- if (data.password !== "") {
1075- typeString(data.password)
1076- keyClick(Qt.Key_Enter)
1077- }
1078-
1079- confirmLoggedIn(data.loggedIn)
1080- }
1081-
1082- function test_appLaunchDuringGreeter_data() {
1083- return [
1084- {tag: "auth error", user: "auth-error", loggedIn: false, passwordFocus: false},
1085- {tag: "without password", user: "no-password", loggedIn: true, passwordFocus: false},
1086- {tag: "with password", user: "has-password", loggedIn: false, passwordFocus: true},
1087- ]
1088- }
1089-
1090- function test_appLaunchDuringGreeter(data) {
1091- selectUser(data.user)
1092-
1093- var greeter = findChild(shell, "greeter")
1094- var app = ApplicationManager.startApplication("dialer-app")
1095-
1096- confirmLoggedIn(data.loggedIn)
1097-
1098- if (data.passwordFocus) {
1099- var passwordInput = findChild(greeter, "passwordInput")
1100- tryCompare(passwordInput, "focus", true)
1101- }
1102- }
1103-
1104- function test_leftEdgeDrag_data() {
1105- return [
1106- {tag: "without password", user: "no-password", loggedIn: true, demo: false},
1107- {tag: "with password", user: "has-password", loggedIn: false, demo: false},
1108- {tag: "with demo", user: "has-password", loggedIn: true, demo: true},
1109- ]
1110- }
1111-
1112- function test_leftEdgeDrag(data) {
1113- selectUser(data.user)
1114-
1115- AccountsService.demoEdges = data.demo
1116- var tutorial = findChild(shell, "tutorial");
1117- tryCompare(tutorial, "running", data.demo);
1118-
1119- swipeFromLeftEdge(shell.width * 0.75)
1120- wait(500) // to give time to handle dash() signal from Launcher
1121- confirmLoggedIn(data.loggedIn)
1122- }
1123- }
1124-}

Subscribers

People subscribed via source and target branches