on xenial help sign in
Merge unifyShellTests
7ebe874Michael Terry
tests/qmltests/CMakeLists.txt−1
@@ -21,7 +21,6 @@ set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/
21
21
22add_qml_test(. Shell)
22add_qml_test(. Shell)
23add_qml_test(. ShellWithPin)
23add_qml_test(. ShellWithPin)
24−add_qml_test(. TabletShell)
25add_qml_test(Components Background)
24add_qml_test(Components Background)
26add_qml_test(Components Carousel)
25add_qml_test(Components Carousel)
27add_qml_test(Components Dialogs)
26add_qml_test(Components Dialogs)
tests/qmltests/tst_Shell.qml+334−74
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013-2014 Canonical, Ltd.
2+ * Copyright (C) 2013-2015 Canonical, Ltd.
3 *
3 *
4 * Authors:
4 * Authors:
5 * Daniel d'Andrada <daniel.dandrada@canonical.com>
5 * Daniel d'Andrada <daniel.dandrada@canonical.com>
@@ -34,9 +34,10 @@ import Powerd 0.1
34
34
35import "../../qml"
35import "../../qml"
36
36
37−Item {
37+Rectangle {
38 id: root
38 id: root
39+ color: "grey"
39− width: units.gu(60)
40+ width: units.gu(100) + controls.width
40 height: units.gu(71)
41 height: units.gu(71)
41
42
42 Component.onCompleted: {
43 Component.onCompleted: {
@@ -62,12 +63,37 @@ Item {
62 }
63 }
63 }
64 }
64
65
65− Row {
66+ Item {
66− anchors.fill: parent
67+ anchors.left: root.left
68+ anchors.right: controls.left
69+ anchors.top: root.top
70+ anchors.bottom: root.bottom
67 Loader {
71 Loader {
68 id: shellLoader
72 id: shellLoader
69 focus: true
73 focus: true
70
74
75+ anchors.centerIn: parent
76+
77+ state: "phone"
78+ states: [
79+ State {
80+ name: "phone"
81+ PropertyChanges {
82+ target: shellLoader
83+ width: units.gu(40)
84+ height: units.gu(71)
85+ }
86+ },
87+ State {
88+ name: "tablet"
89+ PropertyChanges {
90+ target: shellLoader
91+ width: units.gu(100)
92+ height: units.gu(71)
93+ }
94+ }
95+ ]
96+
71 active: false
97 active: false
72 property bool itemDestroyed: false
98 property bool itemDestroyed: false
73 sourceComponent: Component {
99 sourceComponent: Component {
@@ -80,42 +106,56 @@ Item {
80 }
106 }
81 }
107 }
82 }
108 }
109+ }
110+
111+ Rectangle {
112+ id: controls
113+ color: "darkgrey"
114+ width: units.gu(30)
115+ anchors.top: root.top
116+ anchors.bottom: root.bottom
117+ anchors.right: root.right
118+
119+ Column {
120+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
121+ spacing: units.gu(1)
122+ Row {
123+ anchors { left: parent.left; right: parent.right }
124+ Button {
125+ text: "Show Greeter"
126+ activeFocusOnPress: false
127+ onClicked: {
128+ if (shellLoader.status !== Loader.Ready)
129+ return;
83
130
84− Rectangle {
85− color: "darkgrey"
86− width: units.gu(30)
87− height: shellLoader.height
88−
89− Column {
90− anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
91− spacing: units.gu(1)
92− Row {
93− anchors { left: parent.left; right: parent.right }
94− Button {
95− text: "Show Greeter"
96− activeFocusOnPress: false
97− onClicked: {
98− if (shellLoader.status !== Loader.Ready)
99− return;
100−
101− var greeter = testCase.findChild(shellLoader.item, "greeter");
131+ var greeter = testCase.findChild(shellLoader.item, "greeter");
102− if (!greeter.shown) {
132+ if (!greeter.shown) {
103− LightDM.Greeter.showGreeter();
133+ LightDM.Greeter.showGreeter();
104− }
105 }
134 }
106 }
135 }
107 }
136 }
137+ }
108− ListItem.ItemSelector {
138+ ListItem.ItemSelector {
109− anchors { left: parent.left; right: parent.right }
139+ anchors { left: parent.left; right: parent.right }
110− activeFocusOnPress: false
140+ activeFocusOnPress: false
111− text: "LightDM mock mode"
141+ text: "LightDM mock mode"
112− model: ["single", "single-passphrase", "single-pin"]
142+ model: ["single", "single-passphrase", "single-pin", "full"]
113− onSelectedIndexChanged: {
143+ onSelectedIndexChanged: {
114− shellLoader.active = false;
144+ shellLoader.active = false;
115− LightDM.Greeter.mockMode = model[selectedIndex];
145+ LightDM.Greeter.mockMode = model[selectedIndex];
116− LightDM.Users.mockMode = model[selectedIndex];
146+ LightDM.Users.mockMode = model[selectedIndex];
117− shellLoader.active = true;
147+ shellLoader.active = true;
118− }
148+ }
149+ }
150+ ListItem.ItemSelector {
151+ anchors { left: parent.left; right: parent.right }
152+ activeFocusOnPress: false
153+ text: "Size"
154+ model: ["phone", "tablet"]
155+ onSelectedIndexChanged: {
156+ shellLoader.active = false;
157+ shellLoader.state = model[selectedIndex];
158+ shellLoader.active = true;
119 }
159 }
120 }
160 }
121 }
161 }
@@ -186,20 +226,49 @@ Item {
186 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
226 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
187
227
188 function init() {
228 function init() {
189− tryCompare(shell, "enabled", true); // enabled by greeter when ready
229+ if (shellLoader.active) {
190− shell.indicatorProfile = "phone";
230+ // happens for the very first test function as shell
231+ // is loaded by default
232+ tearDown();
233+ }
191
234
192− swipeAwayGreeter();
235+ }
236+
237+ function cleanup() {
238+ tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
239+ tearDown();
240+ }
241+
242+ function loadShell(formFactor) {
243+ shellLoader.state = formFactor;
244+ shellLoader.active = true;
245+ tryCompare(shellLoader, "status", Loader.Ready);
246+ removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
247+ tryCompare(shell, "enabled", true); // enabled by greeter when ready
193
248
194 sessionSpy.target = findChild(shell, "greeter")
249 sessionSpy.target = findChild(shell, "greeter")
195 dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator");
250 dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator");
196
251
197 var launcher = findChild(shell, "launcher");
252 var launcher = findChild(shell, "launcher");
198 launcherShowDashHomeSpy.target = launcher;
253 launcherShowDashHomeSpy.target = launcher;
254+
255+ waitForGreeterToStabilize();
199 }
256 }
200
257
201− function cleanup() {
258+ function waitForGreeterToStabilize() {
202− tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
259+ var greeter = findChild(shell, "greeter");
260+ verify(greeter);
261+
262+ var loginList = findChild(greeter, "loginList");
263+ // Only present in WideView
264+ if (loginList) {
265+ var userList = findChild(loginList, "userList");
266+ verify(userList);
267+ tryCompare(userList, "movingInternally", false);
268+ }
269+ }
270+
271+ function tearDown() {
203 launcherShowDashHomeSpy.target = null;
272 launcherShowDashHomeSpy.target = null;
204
273
205 shellLoader.itemDestroyed = false;
274 shellLoader.itemDestroyed = false;
@@ -216,17 +285,17 @@ Item {
216 // Shell instance gets destroyed.
285 // Shell instance gets destroyed.
217 tryCompare(shellLoader, "itemDestroyed", true);
286 tryCompare(shellLoader, "itemDestroyed", true);
218
287
288+ setLightDMMockMode("single"); // back to the default value
289+
290+ AccountsService.demoEdges = false;
291+
219 // kill all (fake) running apps
292 // kill all (fake) running apps
220 killApps(ApplicationManager);
293 killApps(ApplicationManager);
221
294
222 unlockAllModemsSpy.clear()
295 unlockAllModemsSpy.clear()
223 LightDM.Greeter.authenticate(""); // reset greeter
296 LightDM.Greeter.authenticate(""); // reset greeter
224
297
225− // reload our test subject to get it in a fresh state once again
298+ sessionSpy.clear();
226− shellLoader.active = true;
227−
228− tryCompare(shellLoader, "status", Loader.Ready);
229− removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
230 }
299 }
231
300
232 function killApps() {
301 function killApps() {
@@ -238,6 +307,8 @@ Item {
238 }
307 }
239
308
240 function test_snapDecisionDismissalReturnsFocus() {
309 function test_snapDecisionDismissalReturnsFocus() {
310+ loadShell("phone");
311+ swipeAwayGreeter();
241 var notifications = findChild(shell, "notificationList");
312 var notifications = findChild(shell, "notificationList");
242 var app = ApplicationManager.startApplication("camera-app");
313 var app = ApplicationManager.startApplication("camera-app");
243 var stage = findChild(shell, "stage")
314 var stage = findChild(shell, "stage")
@@ -296,19 +367,41 @@ Item {
296 mockNotificationsModel.append(n)
367 mockNotificationsModel.append(n)
297 }
368 }
298
369
299− function test_leftEdgeDrag_data() {
370+ function test_phoneLeftEdgeDrag_data() {
300 return [
371 return [
372+ {tag: "without launcher",
301− {tag: "without launcher", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
373+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
374+ launcherHides: true, greeterShown: false},
375+
376+ {tag: "with launcher",
302− {tag: "with launcher", revealLauncher: true, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
377+ revealLauncher: true, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
378+ launcherHides: true, greeterShown: false},
379+
380+ {tag: "small swipe",
303− {tag: "small swipe", revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app", launcherHides: false, greeterShown: false},
381+ revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
382+ launcherHides: false, greeterShown: false},
383+
384+ {tag: "long swipe",
304− {tag: "long swipe", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
385+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
386+ launcherHides: true, greeterShown: false},
387+
388+ {tag: "small swipe with greeter",
305− {tag: "small swipe with greeter", revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app", launcherHides: false, greeterShown: true},
389+ revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
390+ launcherHides: false, greeterShown: true},
391+
392+ {tag: "long swipe with greeter",
306− {tag: "long swipe with greeter", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: true},
393+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
394+ launcherHides: true, greeterShown: true},
395+
396+ {tag: "swipe over dash",
307− {tag: "swipe over dash", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "unity8-dash", launcherHides: false, greeterShown: false},
397+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "unity8-dash",
398+ launcherHides: false, greeterShown: false},
308 ];
399 ];
309 }
400 }
310
401
311− function test_leftEdgeDrag(data) {
402+ function test_phoneLeftEdgeDrag(data) {
403+ loadShell("phone");
404+ swipeAwayGreeter();
312 dragLauncherIntoView();
405 dragLauncherIntoView();
313 tapOnAppIconInLauncher();
406 tapOnAppIconInLauncher();
314 waitUntilApplicationWindowIsFullyVisible();
407 waitUntilApplicationWindowIsFullyVisible();
@@ -341,7 +434,32 @@ Item {
341 compare(animateTimer.nextState, "visible");
434 compare(animateTimer.nextState, "visible");
342 }
435 }
343
436
437+ function test_tabletLeftEdgeDrag_data() {
438+ return [
439+ {tag: "without password", user: "no-password", loggedIn: true, demo: false},
440+ {tag: "with password", user: "has-password", loggedIn: false, demo: false},
441+ {tag: "with demo", user: "has-password", loggedIn: true, demo: true},
442+ ]
443+ }
444+
445+ function test_tabletLeftEdgeDrag(data) {
446+ setLightDMMockMode("full");
447+ loadShell("tablet");
448+
449+ selectUser(data.user)
450+
451+ AccountsService.demoEdges = data.demo
452+ var tutorial = findChild(shell, "tutorial");
453+ tryCompare(tutorial, "running", data.demo);
454+
455+ swipeFromLeftEdge(shell.width * 0.75)
456+ wait(500) // to give time to handle dash() signal from Launcher
457+ confirmLoggedIn(data.loggedIn)
458+ }
459+
344 function test_suspend() {
460 function test_suspend() {
461+ loadShell("phone");
462+ swipeAwayGreeter();
345 var greeter = findChild(shell, "greeter");
463 var greeter = findChild(shell, "greeter");
346
464
347 // Launch an app from the launcher
465 // Launch an app from the launcher
@@ -401,6 +519,61 @@ Item {
401 waitForRendering(greeter);
519 waitForRendering(greeter);
402 }
520 }
403
521
522+ function selectUserAtIndex(i) {
523+ // We could be anywhere in list; find target index to know which direction
524+ var greeter = findChild(shell, "greeter")
525+ var userlist = findChild(greeter, "userList")
526+ if (userlist.currentIndex == i)
527+ keyClick(Qt.Key_Escape) // Reset state if we're not moving
528+ while (userlist.currentIndex != i) {
529+ var next = userlist.currentIndex + 1
530+ if (userlist.currentIndex > i) {
531+ next = userlist.currentIndex - 1
532+ }
533+ tap(findChild(greeter, "username"+next));
534+ tryCompare(userlist, "currentIndex", next)
535+ tryCompare(userlist, "movingInternally", false)
536+ }
537+ tryCompare(shell, "enabled", true); // wait for PAM to settle
538+ }
539+
540+ function selectUser(name) {
541+ // Find index of user with the right name
542+ for (var i = 0; i < LightDM.Users.count; i++) {
543+ if (LightDM.Users.data(i, LightDM.UserRoles.NameRole) == name) {
544+ break
545+ }
546+ }
547+ if (i == LightDM.Users.count) {
548+ fail("Didn't find name")
549+ return -1
550+ }
551+ selectUserAtIndex(i)
552+ return i
553+ }
554+
555+ function clickPasswordInput(isButton) {
556+ var greeter = findChild(shell, "greeter")
557+ tryCompare(greeter, "fullyShown", true);
558+
559+ var passwordMouseArea = findChild(shell, "passwordMouseArea")
560+ tryCompare(passwordMouseArea, "enabled", isButton)
561+
562+ var passwordInput = findChild(shell, "passwordInput")
563+ mouseClick(passwordInput)
564+ }
565+
566+ function confirmLoggedIn(loggedIn) {
567+ var greeter = findChild(shell, "greeter");
568+ tryCompare(greeter, "shown", loggedIn ? false : true);
569+ verify(loggedIn ? sessionSpy.count > 0 : sessionSpy.count === 0);
570+ }
571+
572+ function setLightDMMockMode(mode) {
573+ LightDM.Greeter.mockMode = mode;
574+ LightDM.Users.mockMode = mode;
575+ }
576+
404 /*
577 /*
405 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
578 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
406
579
@@ -413,6 +586,8 @@ Item {
413 - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
586 - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
414 */
587 */
415 function test_minimizingAppTakesToDashApps() {
588 function test_minimizingAppTakesToDashApps() {
589+ loadShell("phone");
590+ swipeAwayGreeter();
416 dragLauncherIntoView();
591 dragLauncherIntoView();
417
592
418 // Launch an app from the launcher
593 // Launch an app from the launcher
@@ -433,6 +608,8 @@ Item {
433 }
608 }
434
609
435 function test_showInputMethod() {
610 function test_showInputMethod() {
611+ loadShell("phone");
612+ swipeAwayGreeter();
436 var item = findChild(shell, "inputMethod");
613 var item = findChild(shell, "inputMethod");
437 var surface = SurfaceManager.inputMethodSurface();
614 var surface = SurfaceManager.inputMethodSurface();
438
615
@@ -471,6 +648,8 @@ Item {
471 }
648 }
472
649
473 function test_surfaceLosesActiveFocusWhilePanelIsOpen() {
650 function test_surfaceLosesActiveFocusWhilePanelIsOpen() {
651+ loadShell("phone");
652+ swipeAwayGreeter();
474 var app = ApplicationManager.startApplication("dialer-app");
653 var app = ApplicationManager.startApplication("dialer-app");
475 waitUntilAppWindowIsFullyLoaded(app);
654 waitUntilAppWindowIsFullyLoaded(app);
476
655
@@ -501,28 +680,26 @@ Item {
501 tryCompare(app.session.surface, "activeFocus", true);
680 tryCompare(app.session.surface, "activeFocus", true);
502 }
681 }
503
682
683+ function test_launchedAppHasActiveFocus_data() {
684+ return [
685+ {tag:"phone", formFactor:"phone"},
686+ {tag:"tablet", formFactor:"tablet"},
687+ ];
688+ }
689+
504− function test_launchedAppHasActiveFocus() {
690+ function test_launchedAppHasActiveFocus(data) {
691+ loadShell(data.formFactor);
692+ swipeAwayGreeter();
693+
505− var dialerApp = ApplicationManager.startApplication("dialer-app");
694+ var dialerApp = ApplicationManager.startApplication("webbrowser-app");
506 verify(dialerApp);
695 verify(dialerApp);
507− waitUntilAppSurfaceShowsUp("dialer-app")
696+ waitUntilAppSurfaceShowsUp("webbrowser-app")
508
697
509 verify(dialerApp.session.surface);
698 verify(dialerApp.session.surface);
510
699
511 tryCompare(dialerApp.session.surface, "activeFocus", true);
700 tryCompare(dialerApp.session.surface, "activeFocus", true);
512 }
701 }
513
702
514− // Wait for the whole UI to settle down
515− function waitForUIToSettle() {
516− var launcher = findChild(shell, "launcherPanel")
517− tryCompareFunction(function() {return launcher.x === 0 || launcher.x === -launcher.width;}, true);
518− if (launcher.x === 0) {
519− mouseClick(shell)
520− }
521− tryCompare(launcher, "x", -launcher.width)
522−
523− waitForRendering(shell)
524− }
525−
526 function waitUntilAppSurfaceShowsUp(appId) {
703 function waitUntilAppSurfaceShowsUp(appId) {
527 var appWindow = findChild(shell, "appWindow_" + appId);
704 var appWindow = findChild(shell, "appWindow_" + appId);
528 verify(appWindow);
705 verify(appWindow);
@@ -615,6 +792,8 @@ Item {
615 }
792 }
616
793
617 function test_greeterDoesNotChangeIndicatorProfile() {
794 function test_greeterDoesNotChangeIndicatorProfile() {
795+ loadShell("phone");
796+ swipeAwayGreeter();
618 var panel = findChild(shell, "panel");
797 var panel = findChild(shell, "panel");
619 tryCompare(panel.indicators.indicatorsModel, "profile", shell.indicatorProfile);
798 tryCompare(panel.indicators.indicatorsModel, "profile", shell.indicatorProfile);
620
799
@@ -626,6 +805,8 @@ Item {
626 }
805 }
627
806
628 function test_shellProfileChangesReachIndicators() {
807 function test_shellProfileChangesReachIndicators() {
808+ loadShell("phone");
809+ swipeAwayGreeter();
629 var panel = findChild(shell, "panel");
810 var panel = findChild(shell, "panel");
630
811
631 shell.indicatorProfile = "test1";
812 shell.indicatorProfile = "test1";
@@ -642,6 +823,8 @@ Item {
642 }
823 }
643
824
644 function test_focusRequestedHidesGreeter() {
825 function test_focusRequestedHidesGreeter() {
826+ loadShell("phone");
827+ swipeAwayGreeter();
645 var greeter = findChild(shell, "greeter");
828 var greeter = findChild(shell, "greeter");
646
829
647 var app = ApplicationManager.startApplication("dialer-app");
830 var app = ApplicationManager.startApplication("dialer-app");
@@ -662,6 +845,8 @@ Item {
662 }
845 }
663
846
664 function test_focusRequestedHidesIndicators() {
847 function test_focusRequestedHidesIndicators() {
848+ loadShell("phone");
849+ swipeAwayGreeter();
665 var indicators = findChild(shell, "indicators");
850 var indicators = findChild(shell, "indicators");
666
851
667 showIndicators();
852 showIndicators();
@@ -674,6 +859,8 @@ Item {
674 }
859 }
675
860
676 function test_showAndHideGreeterDBusCalls() {
861 function test_showAndHideGreeterDBusCalls() {
862+ loadShell("phone");
863+ swipeAwayGreeter();
677 var greeter = findChild(shell, "greeter")
864 var greeter = findChild(shell, "greeter")
678 tryCompare(greeter, "shown", false)
865 tryCompare(greeter, "shown", false)
679 waitForRendering(greeter);
866 waitForRendering(greeter);
@@ -685,6 +872,9 @@ Item {
685 }
872 }
686
873
687 function test_greeterLoginsAutomaticallyWhenNoPasswordSet() {
874 function test_greeterLoginsAutomaticallyWhenNoPasswordSet() {
875+ loadShell("phone");
876+ swipeAwayGreeter();
877+
688 sessionSpy.clear();
878 sessionSpy.clear();
689 verify(sessionSpy.valid);
879 verify(sessionSpy.valid);
690
880
@@ -694,6 +884,8 @@ Item {
694 }
884 }
695
885
696 function test_fullscreen() {
886 function test_fullscreen() {
887+ loadShell("phone");
888+ swipeAwayGreeter();
697 var panel = findChild(shell, "panel");
889 var panel = findChild(shell, "panel");
698 compare(panel.fullscreenMode, false);
890 compare(panel.fullscreenMode, false);
699 ApplicationManager.startApplication("camera-app");
891 ApplicationManager.startApplication("camera-app");
@@ -707,6 +899,8 @@ Item {
707 }
899 }
708
900
709 function test_leftEdgeDragFullscreen() {
901 function test_leftEdgeDragFullscreen() {
902+ loadShell("phone");
903+ swipeAwayGreeter();
710 var panel = findChild(shell, "panel");
904 var panel = findChild(shell, "panel");
711 tryCompare(panel, "fullscreenMode", false)
905 tryCompare(panel, "fullscreenMode", false)
712
906
@@ -728,6 +922,8 @@ Item {
728 }
922 }
729
923
730 function test_unlockedProperties() {
924 function test_unlockedProperties() {
925+ loadShell("phone");
926+ swipeAwayGreeter();
731 // Confirm that various properties have the correct values when unlocked
927 // Confirm that various properties have the correct values when unlocked
732 var greeter = findChild(shell, "greeter");
928 var greeter = findChild(shell, "greeter");
733 tryCompare(greeter, "locked", false);
929 tryCompare(greeter, "locked", false);
@@ -740,10 +936,14 @@ Item {
740 }
936 }
741
937
742 function test_unlockAllModemsOnBoot() {
938 function test_unlockAllModemsOnBoot() {
939+ loadShell("phone");
940+ swipeAwayGreeter();
743 tryCompare(unlockAllModemsSpy, "count", 1)
941 tryCompare(unlockAllModemsSpy, "count", 1)
744 }
942 }
745
943
746 function test_tapOnRightEdgeReachesApplicationSurface() {
944 function test_tapOnRightEdgeReachesApplicationSurface() {
945+ loadShell("phone");
946+ swipeAwayGreeter();
747 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
947 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
748 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
948 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
749 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
949 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
@@ -766,6 +966,8 @@ Item {
766 by the right-edge drag area)
966 by the right-edge drag area)
767 */
967 */
768 function test_rightEdgeDragDoesNotReachApplicationSurface() {
968 function test_rightEdgeDragDoesNotReachApplicationSurface() {
969+ loadShell("phone");
970+ swipeAwayGreeter();
769 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
971 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
770 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
972 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
771 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
973 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
@@ -810,6 +1012,8 @@ Item {
810 }
1012 }
811
1013
812 function test_tapUbuntuIconInLauncherOverAppSpread() {
1014 function test_tapUbuntuIconInLauncherOverAppSpread() {
1015+ loadShell("phone");
1016+ swipeAwayGreeter();
813
1017
814 waitUntilFocusedApplicationIsShowingItsSurface();
1018 waitUntilFocusedApplicationIsShowingItsSurface();
815
1019
@@ -856,19 +1060,75 @@ Item {
856 function test_background_data() {
1060 function test_background_data() {
857 return [
1061 return [
858 {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>")},
1062 {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>")},
859− {tag: "empty", accounts: "", gsettings: "", output: shell.defaultBackground},
1063+ {tag: "empty", accounts: "", gsettings: "", output: "defaultBackground"},
860 {tag: "as-specified", accounts: Qt.resolvedUrl("../data/unity/backgrounds/blue.png"), gsettings: "", output: Qt.resolvedUrl("../data/unity/backgrounds/blue.png")},
1064 {tag: "as-specified", accounts: Qt.resolvedUrl("../data/unity/backgrounds/blue.png"), gsettings: "", output: Qt.resolvedUrl("../data/unity/backgrounds/blue.png")},
861 {tag: "gs-specified", accounts: "", gsettings: Qt.resolvedUrl("../data/unity/backgrounds/red.png"), output: Qt.resolvedUrl("../data/unity/backgrounds/red.png")},
1065 {tag: "gs-specified", accounts: "", gsettings: Qt.resolvedUrl("../data/unity/backgrounds/red.png"), output: Qt.resolvedUrl("../data/unity/backgrounds/red.png")},
862 {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")},
1066 {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")},
863 {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")},
1067 {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")},
864− {tag: "invalid-both", accounts: Qt.resolvedUrl("../data/unity/backgrounds/nope.png"), gsettings: Qt.resolvedUrl("../data/unity/backgrounds/stillnope.png"), output: shell.defaultBackground},
1068+ {tag: "invalid-both", accounts: Qt.resolvedUrl("../data/unity/backgrounds/nope.png"), gsettings: Qt.resolvedUrl("../data/unity/backgrounds/stillnope.png"), output: "defaultBackground"},
865 ]
1069 ]
866 }
1070 }
867 function test_background(data) {
1071 function test_background(data) {
1072+ loadShell("phone");
1073+ swipeAwayGreeter();
868 AccountsService.backgroundFile = data.accounts;
1074 AccountsService.backgroundFile = data.accounts;
869 var backgroundSettings = findInvisibleChild(shell, "backgroundSettings");
1075 var backgroundSettings = findInvisibleChild(shell, "backgroundSettings");
870 backgroundSettings.pictureUri = data.gsettings;
1076 backgroundSettings.pictureUri = data.gsettings;
1077+
1078+ if (data.output === "defaultBackground") {
1079+ tryCompare(shell, "background", shell.defaultBackground);
1080+ } else {
871− tryCompare(shell, "background", data.output);
1081+ tryCompare(shell, "background", data.output);
1082+ }
1083+ }
1084+
1085+ function test_tabletLogin_data() {
1086+ return [
1087+ {tag: "auth error", user: "auth-error", loggedIn: false, password: ""},
1088+ {tag: "with password", user: "has-password", loggedIn: true, password: "password"},
1089+ {tag: "without password", user: "no-password", loggedIn: true, password: ""},
1090+ ]
1091+ }
1092+
1093+ function test_tabletLogin(data) {
1094+ setLightDMMockMode("full");
1095+ loadShell("tablet");
1096+
1097+ selectUser(data.user);
1098+
1099+ clickPasswordInput(data.password === "" /* isButton */);
1100+
1101+ if (data.password !== "") {
1102+ typeString(data.password);
1103+ keyClick(Qt.Key_Enter);
1104+ }
1105+
1106+ confirmLoggedIn(data.loggedIn);
1107+ }
1108+
1109+ function test_appLaunchDuringGreeter_data() {
1110+ return [
1111+ {tag: "auth error", user: "auth-error", loggedIn: false, passwordFocus: false},
1112+ {tag: "without password", user: "no-password", loggedIn: true, passwordFocus: false},
1113+ {tag: "with password", user: "has-password", loggedIn: false, passwordFocus: true},
1114+ ]
1115+ }
1116+
1117+ function test_appLaunchDuringGreeter(data) {
1118+ setLightDMMockMode("full");
1119+ loadShell("tablet");
1120+
1121+ selectUser(data.user)
1122+
1123+ var greeter = findChild(shell, "greeter")
1124+ var app = ApplicationManager.startApplication("dialer-app")
1125+
1126+ confirmLoggedIn(data.loggedIn)
1127+
1128+ if (data.passwordFocus) {
1129+ var passwordInput = findChild(greeter, "passwordInput")
1130+ tryCompare(passwordInput, "focus", true)
1131+ }
872 }
1132 }
873 }
1133 }
874}
1134}
tests/qmltests/tst_TabletShell.qmldeleted−305
@@ -1,305 +0,0 @@
1−/*
2− * Copyright (C) 2013,2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−import QtTest 1.0
19−import AccountsService 0.1
20−import GSettings 1.0
21−import LightDM 0.1 as LightDM
22−import Ubuntu.Components 1.1
23−import Ubuntu.Telephony 0.1 as Telephony
24−import Unity.Application 0.1
25−import Unity.Connectivity 0.1
26−import Unity.Test 0.1 as UT
27−import Powerd 0.1
28−
29−import "../../qml"
30−
31−Item {
32− id: root
33− width: units.gu(120)
34− height: units.gu(80)
35−
36− Component.onCompleted: {
37− // must set the mock mode before loading the Shell
38− LightDM.Greeter.mockMode = "full";
39− LightDM.Users.mockMode = "full";
40− shellLoader.active = true;
41− }
42−
43− QtObject {
44− id: applicationArguments
45−
46− function hasGeometry() {
47− return false
48− }
49−
50− function width() {
51− return 0
52− }
53−
54− function height() {
55− return 0
56− }
57− }
58−
59− Row {
60− anchors.fill: parent
61− Loader {
62− id: shellLoader
63−
64− active: false
65− width: units.gu(100)
66− height: parent.height
67−
68− property bool itemDestroyed: false
69− sourceComponent: Component {
70− Shell {
71− property string indicatorProfile: "phone"
72−
73− Component.onDestruction: {
74− shellLoader.itemDestroyed = true
75− }
76− }
77− }
78− }
79−
80− Rectangle {
81− color: "white"
82− width: units.gu(20)
83− height: parent.height
84−
85− Column {
86− anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
87− spacing: units.gu(1)
88− Button {
89− text: "Show Greeter"
90− onClicked: {
91− if (shellLoader.status !== Loader.Ready)
92− return
93−
94− var greeter = testCase.findChild(shellLoader.item, "greeter")
95− if (!greeter.shown) {
96− greeter.show()
97− }
98− }
99− }
100− Button {
101− text: "Demo edges"
102− onClicked: {
103− AccountsService.demoEdges = true;
104− }
105− }
106− }
107− }
108− }
109−
110− SignalSpy {
111− id: sessionSpy
112− signalName: "sessionStarted"
113− }
114−
115− SignalSpy {
116− id: dashCommunicatorSpy
117− signalName: "setCurrentScopeCalled"
118− }
119−
120− SignalSpy {
121− id: unlockAllModemsSpy
122− target: Connectivity
123− signalName: "unlockingAllModems"
124− }
125−
126− Telephony.CallEntry {
127− id: phoneCall
128− phoneNumber: "+447812221111"
129− }
130−
131− UT.UnityTestCase {
132− id: testCase
133− name: "TabletShell"
134− when: windowShown
135−
136− property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
137−
138− function init() {
139− tryCompare(shell, "enabled", true); // will be enabled when greeter is all ready
140− var userList = findChild(shell, "userList");
141− tryCompare(userList, "movingInternally", false);
142− sessionSpy.clear()
143− sessionSpy.target = findChild(shell, "greeter")
144− dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator")
145− }
146−
147− function cleanup() {
148− tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
149−
150− shellLoader.itemDestroyed = false
151−
152− shellLoader.active = false
153−
154− tryCompare(shellLoader, "status", Loader.Null)
155− tryCompare(shellLoader, "item", null)
156− // Loader.status might be Loader.Null and Loader.item might be null but the Loader
157− // item might still be alive. So if we set Loader.active back to true
158− // again right now we will get the very same Shell instance back. So no reload
159− // actually took place. Likely because Loader waits until the next event loop
160− // iteration to do its work. So to ensure the reload, we will wait until the
161− // Shell instance gets destroyed.
162− tryCompare(shellLoader, "itemDestroyed", true)
163−
164− // kill all (fake) running apps
165− killApps()
166−
167− unlockAllModemsSpy.clear()
168− AccountsService.demoEdges = false
169− LightDM.Greeter.authenticate(""); // reset greeter
170−
171− // reload our test subject to get it in a fresh state once again
172− shellLoader.active = true
173−
174− tryCompare(shellLoader, "status", Loader.Ready)
175− removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item)
176− }
177−
178− function killApps() {
179− while (ApplicationManager.count > 1) {
180− var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
181− ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId)
182− }
183− compare(ApplicationManager.count, 1)
184− }
185−
186− function selectIndex(i) {
187− // We could be anywhere in list; find target index to know which direction
188− var greeter = findChild(shell, "greeter")
189− var userlist = findChild(greeter, "userList")
190− if (userlist.currentIndex == i)
191− keyClick(Qt.Key_Escape) // Reset state if we're not moving
192− while (userlist.currentIndex != i) {
193− var next = userlist.currentIndex + 1
194− if (userlist.currentIndex > i) {
195− next = userlist.currentIndex - 1
196− }
197− tap(findChild(greeter, "username"+next));
198− tryCompare(userlist, "currentIndex", next)
199− tryCompare(userlist, "movingInternally", false)
200− }
201− tryCompare(shell, "enabled", true); // wait for PAM to settle
202− }
203−
204− function selectUser(name) {
205− // Find index of user with the right name
206− for (var i = 0; i < LightDM.Users.count; i++) {
207− if (LightDM.Users.data(i, LightDM.UserRoles.NameRole) == name) {
208− break
209− }
210− }
211− if (i == LightDM.Users.count) {
212− fail("Didn't find name")
213− return -1
214− }
215− selectIndex(i)
216− return i
217− }
218−
219− function clickPasswordInput(isButton) {
220− var greeter = findChild(shell, "greeter")
221− tryCompare(greeter, "fullyShown", true);
222−
223− var passwordMouseArea = findChild(shell, "passwordMouseArea")
224− tryCompare(passwordMouseArea, "enabled", isButton)
225−
226− var passwordInput = findChild(shell, "passwordInput")
227− mouseClick(passwordInput)
228− }
229−
230− function confirmLoggedIn(loggedIn) {
231− var greeter = findChild(shell, "greeter");
232− tryCompare(greeter, "shown", loggedIn ? false : true);
233− verify(loggedIn ? sessionSpy.count > 0 : sessionSpy.count === 0);
234− }
235−
236− function swipeFromLeftEdge(swipeLength) {
237− var touchStartX = 2
238− var touchStartY = shell.height / 2
239− touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY)
240− }
241−
242− function test_login_data() {
243− return [
244− {tag: "auth error", user: "auth-error", loggedIn: false, password: ""},
245− {tag: "with password", user: "has-password", loggedIn: true, password: "password"},
246− {tag: "without password", user: "no-password", loggedIn: true, password: ""},
247− ]
248− }
249−
250− function test_login(data) {
251− selectUser(data.user)
252−
253− clickPasswordInput(data.password === "")
254−
255− if (data.password !== "") {
256− typeString(data.password)
257− keyClick(Qt.Key_Enter)
258− }
259−
260− confirmLoggedIn(data.loggedIn)
261− }
262−
263− function test_appLaunchDuringGreeter_data() {
264− return [
265− {tag: "auth error", user: "auth-error", loggedIn: false, passwordFocus: false},
266− {tag: "without password", user: "no-password", loggedIn: true, passwordFocus: false},
267− {tag: "with password", user: "has-password", loggedIn: false, passwordFocus: true},
268− ]
269− }
270−
271− function test_appLaunchDuringGreeter(data) {
272− selectUser(data.user)
273−
274− var greeter = findChild(shell, "greeter")
275− var app = ApplicationManager.startApplication("dialer-app")
276−
277− confirmLoggedIn(data.loggedIn)
278−
279− if (data.passwordFocus) {
280− var passwordInput = findChild(greeter, "passwordInput")
281− tryCompare(passwordInput, "focus", true)
282− }
283− }
284−
285− function test_leftEdgeDrag_data() {
286− return [
287− {tag: "without password", user: "no-password", loggedIn: true, demo: false},
288− {tag: "with password", user: "has-password", loggedIn: false, demo: false},
289− {tag: "with demo", user: "has-password", loggedIn: true, demo: true},
290− ]
291− }
292−
293− function test_leftEdgeDrag(data) {
294− selectUser(data.user)
295−
296− AccountsService.demoEdges = data.demo
297− var tutorial = findChild(shell, "tutorial");
298− tryCompare(tutorial, "running", data.demo);
299−
300− swipeFromLeftEdge(shell.width * 0.75)
301− wait(500) // to give time to handle dash() signal from Launcher
302− confirmLoggedIn(data.loggedIn)
303− }
304− }
305−}