Merge lp:~dandrader/unity8/unifyShellTests into lp:unity8

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Michael Terry
Approved revision: 1638
Merged at revision: 1665
Proposed branch: lp:~dandrader/unity8/unifyShellTests
Merge into: lp:unity8
Prerequisite: lp:~dandrader/unity8/stabilizeShellTest
Diff against target: 971 lines (+336/-382)
3 files modified
tests/qmltests/CMakeLists.txt (+0/-1)
tests/qmltests/tst_Shell.qml (+336/-77)
tests/qmltests/tst_TabletShell.qml (+0/-304)
To merge this branch: bzr merge lp:~dandrader/unity8/unifyShellTests
Reviewer Review Type Date Requested Status
Michael Terry Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+250986@code.launchpad.net

Commit message

Make tst_Shell absorb tst_TabletShell

Benefits:
  - less code duplication (the code beyond the test functions themselves, such as qml code and helper functions)
  - Enables one to try out and test all possible combinations involving shell, like tablet vs phone vs single user vs multi user. test_launchedAppHasActiveFocus being the first example. The same test is run against both phone and tablet shell configurations.
  - Sticks to the convention that all qml tests for a given component are run by "make testComponentName". For Shell they were spread around between tst_Shell, tst_TabletShell and tst_ShellWithPin (that last one remains for now).

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.
No, but it builds upon lp:~dandrader/unity8/stabilizeShellTest

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

* 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?
Not applicable.

* If you changed the UI, has there been a design review?
Not applicable.

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
Albert Astals Cid (aacid) wrote :

Seems the new tests actually didn't pass

lp:~dandrader/unity8/unifyShellTests updated
1638. By Daniel d'Andrada

Wait for greeter to stabilize before running test and remove unused function

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 :

On 26/02/15 05:20, Albert Astals Cid wrote:
> Seems the new tests actually didn't pass
Fixed.

Revision history for this message
Michael Terry (mterry) wrote :

You dropped the following code during cleanup:
shell.indicatorProfile = "phone";

(It is property defined outside of Shell.qml, so reloading Shell.qml doesn't reset it. And it is modified by some tests, so we should clean it to a known-good value.)

review: Needs Fixing
Revision history for this message
Michael Terry (mterry) wrote :

Nope, I'm wrong. That property is defined in the sourceComponent. It's fine as is.

Revision history for this message
Michael Terry (mterry) wrote :

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

 * Did CI run pass? If not, please explain why.
 Yesish, autopilot is it's own problem.

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

review: Approve
lp:~dandrader/unity8/unifyShellTests updated
1639. By Daniel d'Andrada

Merge trunk

[ Albert Astals ]
* Don't precache items that are outisde the 1.5*height buffering area
  (LP: #1410131)
[ Albert Astals Cid ]
* Don't precache items that are outisde the 1.5*height buffering area
  (LP: #1410131)
[ Chris Townsend ]
* Add a wrapper for handling the
  /org/gnome/SessionManager/EndSessionDialog DBus object used by
  indicator-session. This allows indicator-session to properly talk to
  the Unity 8 session management functions. (LP: #1392187)
* Allow for proper logout session management. This uses the
  EndSession() Upstart DBus method on the current session bus. (LP:
  #1360316)
* Make the Unity 8 session dialogs behave in the same fashion as Unity
  7. From indicator-session: Clicking "Log Out" will now present a
  dialog to "Lock", "Log Out", or "Cancel". Clicking "Shut Down" will
  now present a dialog to "Reboot", "Shut Down", or "Cancel". (LP:
  #1416074)
[ Daniel d'Andrada ]
* Add NO_TESTS cmake option to skip tests and therefore speed up
  builds
* Remove enums and properties that doesn't exist in the real
  ApplicationManager
* Stabilize some Shell qml tests
[ Josh Arenson ]
* Create a PhysicalKeyMapper to handle all physical/hardware keys (LP:
  #1390393)
[ Michael Terry ]
* Make the draggable part of the right edge (during the tutorial) a
  constant size, instead of having it grow and shrink as the spread
  peeks out from the side.
[ MichaƂ Sawicz ]
* Create a PhysicalKeyMapper to handle all physical/hardware keys (LP:
  #1390393)
[ Robert Bruce Park ]
* Launchpad automatic translations update.
[ CI Train Bot ]
* New rebuild forced.
[ Pete Woods ]
* Only set scopes active when the screen is on (LP: #1422879)

Preview Diff

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

Subscribers

People subscribed via source and target branches