on xenial help sign in
Merge unifyShellTests
commita14798e2e4a4f898d1407226bec265655a214e68 authorMichael Terry <michael.terry@canonical.com> dateTue 3 Mar 2015, 09:57 (12 years ago) parent60faf714bdf94b
3 files changed+373−410
tests/qmltests/CMakeLists.txt−1 tests/qmltests/tst_Shell.qml+373−105 tests/qmltests/tst_TabletShell.qml−304
tests/qmltests/CMakeLists.txt−1
@@ -20,7 +20,6 @@ set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/
2020
2121add_qml_test(. Shell)
2222add_qml_test(. ShellWithPin)
23−add_qml_test(. TabletShell)
2423add_qml_test(Components Background)
2524add_qml_test(Components Carousel)
2625add_qml_test(Components Dialogs)
tests/qmltests/tst_Shell.qml+373−105
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013-2014 Canonical, Ltd.
2+ * Copyright (C) 2013-2015 Canonical, Ltd.
33 *
44 * Authors:
55 * Daniel d'Andrada <daniel.dandrada@canonical.com>
@@ -35,9 +35,10 @@ import Wizard 0.1 as Wizard
3535
3636import "../../qml"
3737
38−Item {
38+Rectangle {
3939 id: root
40− width: units.gu(60)
40+ color: "grey"
41+ width: units.gu(100) + controls.width
4142 height: units.gu(71)
4243
4344 Component.onCompleted: {
@@ -63,12 +64,37 @@ Item {
6364 }
6465 }
6566
66− Row {
67− anchors.fill: parent
67+ Item {
68+ anchors.left: root.left
69+ anchors.right: controls.left
70+ anchors.top: root.top
71+ anchors.bottom: root.bottom
6872 Loader {
6973 id: shellLoader
7074 focus: true
7175
76+ anchors.centerIn: parent
77+
78+ state: "phone"
79+ states: [
80+ State {
81+ name: "phone"
82+ PropertyChanges {
83+ target: shellLoader
84+ width: units.gu(40)
85+ height: units.gu(71)
86+ }
87+ },
88+ State {
89+ name: "tablet"
90+ PropertyChanges {
91+ target: shellLoader
92+ width: units.gu(100)
93+ height: units.gu(71)
94+ }
95+ }
96+ ]
97+
7298 active: false
7399 property bool itemDestroyed: false
74100 sourceComponent: Component {
@@ -81,42 +107,56 @@ Item {
81107 }
82108 }
83109 }
110+ }
111+
112+ Rectangle {
113+ id: controls
114+ color: "darkgrey"
115+ width: units.gu(30)
116+ anchors.top: root.top
117+ anchors.bottom: root.bottom
118+ anchors.right: root.right
119+
120+ Column {
121+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
122+ spacing: units.gu(1)
123+ Row {
124+ anchors { left: parent.left; right: parent.right }
125+ Button {
126+ text: "Show Greeter"
127+ activeFocusOnPress: false
128+ onClicked: {
129+ if (shellLoader.status !== Loader.Ready)
130+ return;
84131
85− Rectangle {
86− color: "darkgrey"
87− width: units.gu(30)
88− height: shellLoader.height
89−
90− Column {
91− anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
92− spacing: units.gu(1)
93− Row {
94− anchors { left: parent.left; right: parent.right }
95− Button {
96− text: "Show Greeter"
97− activeFocusOnPress: false
98− onClicked: {
99− if (shellLoader.status !== Loader.Ready)
100− return;
101−
102− var greeter = testCase.findChild(shellLoader.item, "greeter");
103− if (!greeter.shown) {
104− LightDM.Greeter.showGreeter();
105− }
132+ var greeter = testCase.findChild(shellLoader.item, "greeter");
133+ if (!greeter.shown) {
134+ LightDM.Greeter.showGreeter();
106135 }
107136 }
108137 }
109− ListItem.ItemSelector {
110− anchors { left: parent.left; right: parent.right }
111− activeFocusOnPress: false
112− text: "LightDM mock mode"
113− model: ["single", "single-passphrase", "single-pin"]
114− onSelectedIndexChanged: {
115− shellLoader.active = false;
116− LightDM.Greeter.mockMode = model[selectedIndex];
117− LightDM.Users.mockMode = model[selectedIndex];
118− shellLoader.active = true;
119− }
138+ }
139+ ListItem.ItemSelector {
140+ anchors { left: parent.left; right: parent.right }
141+ activeFocusOnPress: false
142+ text: "LightDM mock mode"
143+ model: ["single", "single-passphrase", "single-pin", "full"]
144+ onSelectedIndexChanged: {
145+ shellLoader.active = false;
146+ LightDM.Greeter.mockMode = model[selectedIndex];
147+ LightDM.Users.mockMode = model[selectedIndex];
148+ shellLoader.active = true;
149+ }
150+ }
151+ ListItem.ItemSelector {
152+ anchors { left: parent.left; right: parent.right }
153+ activeFocusOnPress: false
154+ text: "Size"
155+ model: ["phone", "tablet"]
156+ onSelectedIndexChanged: {
157+ shellLoader.active = false;
158+ shellLoader.state = model[selectedIndex];
159+ shellLoader.active = true;
120160 }
121161 }
122162 }
@@ -187,38 +227,55 @@ Item {
187227 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
188228
189229 function init() {
190− tryCompare(shell, "enabled", true); // enabled by greeter when ready
191− shell.indicatorProfile = "phone";
192−
193− swipeAwayGreeter();
194−
195− sessionSpy.target = findChild(shell, "greeter")
196− dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator");
230+ if (shellLoader.active) {
231+ // happens for the very first test function as shell
232+ // is loaded by default
233+ tearDown();
234+ }
197235
198− var launcher = findChild(shell, "launcher");
199− launcherShowDashHomeSpy.target = launcher;
200236 }
201237
202238 function cleanup() {
203239 tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
204− launcherShowDashHomeSpy.target = null;
240+ tearDown();
241+ }
205242
206− stopShell();
243+ function loadShell(formFactor) {
244+ shellLoader.state = formFactor;
245+ shellLoader.active = true;
246+ tryCompare(shellLoader, "status", Loader.Ready);
247+ removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
248+ tryCompare(shell, "enabled", true); // enabled by greeter when ready
207249
208− // kill all (fake) running apps
209− killApps(ApplicationManager);
250+ sessionSpy.target = findChild(shell, "greeter")
251+ dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator");
210252
211− unlockAllModemsSpy.clear()
212− LightDM.Greeter.authenticate(""); // reset greeter
213− Wizard.System.wizardEnabled = false;
253+ var launcher = findChild(shell, "launcher");
254+ launcherShowDashHomeSpy.target = launcher;
214255
215− // reload our test subject to get it in a fresh state once again
216− startShell();
256+ waitForGreeterToStabilize();
217257 }
218258
219− function stopShell() {
259+ function waitForGreeterToStabilize() {
260+ var greeter = findChild(shell, "greeter");
261+ verify(greeter);
262+
263+ var loginList = findChild(greeter, "loginList");
264+ // Only present in WideView
265+ if (loginList) {
266+ var userList = findChild(loginList, "userList");
267+ verify(userList);
268+ tryCompare(userList, "movingInternally", false);
269+ }
270+ }
271+
272+ function tearDown() {
273+ launcherShowDashHomeSpy.target = null;
274+
220275 shellLoader.itemDestroyed = false;
276+
221277 shellLoader.active = false;
278+
222279 tryCompare(shellLoader, "status", Loader.Null);
223280 tryCompare(shellLoader, "item", null);
224281 // Loader.status might be Loader.Null and Loader.item might be null but the Loader
@@ -228,12 +285,19 @@ Item {
228285 // iteration to do its work. So to ensure the reload, we will wait until the
229286 // Shell instance gets destroyed.
230287 tryCompare(shellLoader, "itemDestroyed", true);
231− }
232288
233− function startShell() {
234− shellLoader.active = true;
235− tryCompare(shellLoader, "status", Loader.Ready);
236− removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
289+ setLightDMMockMode("single"); // back to the default value
290+
291+ AccountsService.demoEdges = false;
292+ Wizard.System.wizardEnabled = false;
293+
294+ // kill all (fake) running apps
295+ killApps(ApplicationManager);
296+
297+ unlockAllModemsSpy.clear()
298+ LightDM.Greeter.authenticate(""); // reset greeter
299+
300+ sessionSpy.clear();
237301 }
238302
239303 function killApps() {
@@ -245,6 +309,8 @@ Item {
245309 }
246310
247311 function test_snapDecisionDismissalReturnsFocus() {
312+ loadShell("phone");
313+ swipeAwayGreeter();
248314 var notifications = findChild(shell, "notificationList");
249315 var app = ApplicationManager.startApplication("camera-app");
250316 var stage = findChild(shell, "stage")
@@ -303,19 +369,41 @@ Item {
303369 mockNotificationsModel.append(n)
304370 }
305371
306− function test_leftEdgeDrag_data() {
372+ function test_phoneLeftEdgeDrag_data() {
307373 return [
308− {tag: "without launcher", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
309− {tag: "with launcher", revealLauncher: true, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
310− {tag: "small swipe", revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app", launcherHides: false, greeterShown: false},
311− {tag: "long swipe", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
312− {tag: "small swipe with greeter", revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app", launcherHides: false, greeterShown: true},
313− {tag: "long swipe with greeter", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: true},
314− {tag: "swipe over dash", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "unity8-dash", launcherHides: false, greeterShown: false},
374+ {tag: "without launcher",
375+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
376+ launcherHides: true, greeterShown: false},
377+
378+ {tag: "with launcher",
379+ revealLauncher: true, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
380+ launcherHides: true, greeterShown: false},
381+
382+ {tag: "small swipe",
383+ revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
384+ launcherHides: false, greeterShown: false},
385+
386+ {tag: "long swipe",
387+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
388+ launcherHides: true, greeterShown: false},
389+
390+ {tag: "small swipe with greeter",
391+ revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
392+ launcherHides: false, greeterShown: true},
393+
394+ {tag: "long swipe with greeter",
395+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
396+ launcherHides: true, greeterShown: true},
397+
398+ {tag: "swipe over dash",
399+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "unity8-dash",
400+ launcherHides: false, greeterShown: false},
315401 ];
316402 }
317403
318− function test_leftEdgeDrag(data) {
404+ function test_phoneLeftEdgeDrag(data) {
405+ loadShell("phone");
406+ swipeAwayGreeter();
319407 dragLauncherIntoView();
320408 tapOnAppIconInLauncher();
321409 waitUntilApplicationWindowIsFullyVisible();
@@ -324,8 +412,7 @@ Item {
324412
325413 var greeter = findChild(shell, "greeter");
326414 if (data.greeterShown) {
327− LightDM.Greeter.showGreeter();
328− tryCompare(greeter, "fullyShown", true);
415+ showGreeter();
329416 }
330417
331418 if (data.revealLauncher) {
@@ -349,7 +436,32 @@ Item {
349436 compare(animateTimer.nextState, "visible");
350437 }
351438
439+ function test_tabletLeftEdgeDrag_data() {
440+ return [
441+ {tag: "without password", user: "no-password", loggedIn: true, demo: false},
442+ {tag: "with password", user: "has-password", loggedIn: false, demo: false},
443+ {tag: "with demo", user: "has-password", loggedIn: true, demo: true},
444+ ]
445+ }
446+
447+ function test_tabletLeftEdgeDrag(data) {
448+ setLightDMMockMode("full");
449+ loadShell("tablet");
450+
451+ selectUser(data.user)
452+
453+ AccountsService.demoEdges = data.demo
454+ var tutorial = findChild(shell, "tutorial");
455+ tryCompare(tutorial, "running", data.demo);
456+
457+ swipeFromLeftEdge(shell.width * 0.75)
458+ wait(500) // to give time to handle dash() signal from Launcher
459+ confirmLoggedIn(data.loggedIn)
460+ }
461+
352462 function test_suspend() {
463+ loadShell("phone");
464+ swipeAwayGreeter();
353465 var greeter = findChild(shell, "greeter");
354466
355467 // Launch an app from the launcher
@@ -382,7 +494,15 @@ Item {
382494 tryCompare(greeter, "fullyShown", true);
383495
384496 // Swipe away greeter to focus app
497+
498+ // greeter unloads its internal components when hidden
499+ // and reloads them when shown. Thus we have to do this
500+ // again before interacting with it otherwise any
501+ // DirectionalDragAreas in there won't be easily fooled by
502+ // fake swipes.
503+ removeTimeConstraintsFromDirectionalDragAreas(greeter);
385504 swipeAwayGreeter();
505+
386506 tryCompare(ApplicationManager, "suspended", false);
387507 compare(mainApp.state, ApplicationInfoInterface.Running);
388508 tryCompare(ApplicationManager, "focusedApplicationId", mainAppId);
@@ -401,6 +521,60 @@ Item {
401521 waitForRendering(greeter);
402522 }
403523
524+ function selectUserAtIndex(i) {
525+ // We could be anywhere in list; find target index to know which direction
526+ var greeter = findChild(shell, "greeter")
527+ var userlist = findChild(greeter, "userList")
528+ if (userlist.currentIndex == i)
529+ keyClick(Qt.Key_Escape) // Reset state if we're not moving
530+ while (userlist.currentIndex != i) {
531+ var next = userlist.currentIndex + 1
532+ if (userlist.currentIndex > i) {
533+ next = userlist.currentIndex - 1
534+ }
535+ tap(findChild(greeter, "username"+next));
536+ tryCompare(userlist, "currentIndex", next)
537+ tryCompare(userlist, "movingInternally", false)
538+ }
539+ }
540+
541+ function selectUser(name) {
542+ // Find index of user with the right name
543+ for (var i = 0; i < LightDM.Users.count; i++) {
544+ if (LightDM.Users.data(i, LightDM.UserRoles.NameRole) == name) {
545+ break
546+ }
547+ }
548+ if (i == LightDM.Users.count) {
549+ fail("Didn't find name")
550+ return -1
551+ }
552+ selectUserAtIndex(i)
553+ return i
554+ }
555+
556+ function clickPasswordInput(isButton) {
557+ var greeter = findChild(shell, "greeter")
558+ tryCompare(greeter, "fullyShown", true);
559+
560+ var passwordMouseArea = findChild(shell, "passwordMouseArea")
561+ tryCompare(passwordMouseArea, "enabled", isButton)
562+
563+ var passwordInput = findChild(shell, "passwordInput")
564+ mouseClick(passwordInput)
565+ }
566+
567+ function confirmLoggedIn(loggedIn) {
568+ var greeter = findChild(shell, "greeter");
569+ tryCompare(greeter, "shown", loggedIn ? false : true);
570+ verify(loggedIn ? sessionSpy.count > 0 : sessionSpy.count === 0);
571+ }
572+
573+ function setLightDMMockMode(mode) {
574+ LightDM.Greeter.mockMode = mode;
575+ LightDM.Users.mockMode = mode;
576+ }
577+
404578 /*
405579 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
406580
@@ -413,6 +587,8 @@ Item {
413587 - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
414588 */
415589 function test_minimizingAppTakesToDashApps() {
590+ loadShell("phone");
591+ swipeAwayGreeter();
416592 dragLauncherIntoView();
417593
418594 // Launch an app from the launcher
@@ -433,6 +609,8 @@ Item {
433609 }
434610
435611 function test_showInputMethod() {
612+ loadShell("phone");
613+ swipeAwayGreeter();
436614 var item = findChild(shell, "inputMethod");
437615 var surface = SurfaceManager.inputMethodSurface();
438616
@@ -471,6 +649,8 @@ Item {
471649 }
472650
473651 function test_surfaceLosesActiveFocusWhilePanelIsOpen() {
652+ loadShell("phone");
653+ swipeAwayGreeter();
474654 var app = ApplicationManager.startApplication("dialer-app");
475655 waitUntilAppWindowIsFullyLoaded(app);
476656
@@ -501,28 +681,26 @@ Item {
501681 tryCompare(app.session.surface, "activeFocus", true);
502682 }
503683
504− function test_launchedAppHasActiveFocus() {
505− var dialerApp = ApplicationManager.startApplication("dialer-app");
684+ function test_launchedAppHasActiveFocus_data() {
685+ return [
686+ {tag:"phone", formFactor:"phone"},
687+ {tag:"tablet", formFactor:"tablet"},
688+ ];
689+ }
690+
691+ function test_launchedAppHasActiveFocus(data) {
692+ loadShell(data.formFactor);
693+ swipeAwayGreeter();
694+
695+ var dialerApp = ApplicationManager.startApplication("webbrowser-app");
506696 verify(dialerApp);
507− waitUntilAppSurfaceShowsUp("dialer-app")
697+ waitUntilAppSurfaceShowsUp("webbrowser-app")
508698
509699 verify(dialerApp.session.surface);
510700
511701 tryCompare(dialerApp.session.surface, "activeFocus", true);
512702 }
513703
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−
526704 function waitUntilAppSurfaceShowsUp(appId) {
527705 var appWindow = findChild(shell, "appWindow_" + appId);
528706 verify(appWindow);
@@ -600,11 +778,27 @@ Item {
600778 && itemRectInShell.y + itemRectInShell.height <= shell.height;
601779 }
602780
781+ function showGreeter() {
782+ var greeter = findChild(shell, "greeter");
783+ LightDM.Greeter.showGreeter();
784+ waitForRendering(greeter);
785+ tryCompare(greeter, "fullyShown", true);
786+
787+ // greeter unloads its internal components when hidden
788+ // and reloads them when shown. Thus we have to do this
789+ // again before interacting with it otherwise any
790+ // DirectionalDragAreas in there won't be easily fooled by
791+ // fake swipes.
792+ removeTimeConstraintsFromDirectionalDragAreas(greeter);
793+ }
794+
603795 function test_greeterDoesNotChangeIndicatorProfile() {
796+ loadShell("phone");
797+ swipeAwayGreeter();
604798 var panel = findChild(shell, "panel");
605799 tryCompare(panel.indicators.indicatorsModel, "profile", shell.indicatorProfile);
606800
607− LightDM.Greeter.showGreeter();
801+ showGreeter();
608802 tryCompare(panel.indicators.indicatorsModel, "profile", shell.indicatorProfile);
609803
610804 LightDM.Greeter.hideGreeter();
@@ -612,6 +806,8 @@ Item {
612806 }
613807
614808 function test_shellProfileChangesReachIndicators() {
809+ loadShell("phone");
810+ swipeAwayGreeter();
615811 var panel = findChild(shell, "panel");
616812
617813 shell.indicatorProfile = "test1";
@@ -628,6 +824,8 @@ Item {
628824 }
629825
630826 function test_focusRequestedHidesGreeter() {
827+ loadShell("phone");
828+ swipeAwayGreeter();
631829 var greeter = findChild(shell, "greeter");
632830
633831 var app = ApplicationManager.startApplication("dialer-app");
@@ -639,8 +837,7 @@ Item {
639837
640838 waitUntilDashIsFocused();
641839
642− LightDM.Greeter.showGreeter();
643− tryCompare(greeter, "fullyShown", true);
840+ showGreeter();
644841
645842 // The main point of this test
646843 ApplicationManager.requestFocusApplication("dialer-app");
@@ -649,6 +846,8 @@ Item {
649846 }
650847
651848 function test_focusRequestedHidesIndicators() {
849+ loadShell("phone");
850+ swipeAwayGreeter();
652851 var indicators = findChild(shell, "indicators");
653852
654853 showIndicators();
@@ -661,6 +860,8 @@ Item {
661860 }
662861
663862 function test_showAndHideGreeterDBusCalls() {
863+ loadShell("phone");
864+ swipeAwayGreeter();
664865 var greeter = findChild(shell, "greeter")
665866 tryCompare(greeter, "shown", false)
666867 waitForRendering(greeter);
@@ -671,18 +872,21 @@ Item {
671872 tryCompare(greeter, "shown", false)
672873 }
673874
674− function test_login() {
675− var greeter = findChild(shell, "greeter")
676− waitForRendering(greeter)
677− LightDM.Greeter.showGreeter();
678− tryCompare(greeter, "fullyShown", true)
875+ function test_greeterLoginsAutomaticallyWhenNoPasswordSet() {
876+ loadShell("phone");
877+ swipeAwayGreeter();
679878
680879 sessionSpy.clear();
681− swipeAwayGreeter()
682− tryCompare(sessionSpy, "count", 1)
880+ verify(sessionSpy.valid);
881+
882+ showGreeter();
883+
884+ tryCompare(sessionSpy, "count", 1);
683885 }
684886
685887 function test_fullscreen() {
888+ loadShell("phone");
889+ swipeAwayGreeter();
686890 var panel = findChild(shell, "panel");
687891 compare(panel.fullscreenMode, false);
688892 ApplicationManager.startApplication("camera-app");
@@ -696,6 +900,8 @@ Item {
696900 }
697901
698902 function test_leftEdgeDragFullscreen() {
903+ loadShell("phone");
904+ swipeAwayGreeter();
699905 var panel = findChild(shell, "panel");
700906 tryCompare(panel, "fullscreenMode", false)
701907
@@ -717,6 +923,8 @@ Item {
717923 }
718924
719925 function test_unlockedProperties() {
926+ loadShell("phone");
927+ swipeAwayGreeter();
720928 // Confirm that various properties have the correct values when unlocked
721929 var greeter = findChild(shell, "greeter");
722930 tryCompare(greeter, "locked", false);
@@ -729,16 +937,14 @@ Item {
729937 }
730938
731939 function test_unlockAllModemsOnBoot() {
940+ loadShell("phone");
941+ swipeAwayGreeter();
732942 tryCompare(unlockAllModemsSpy, "count", 1)
733943 }
734944
735945 function test_unlockAllModemsAfterWizard() {
736− // Stop and start shell to simulate wizard being enabled during
737− // boot, instead of just being enabled after the fact.
738− stopShell();
739946 Wizard.System.wizardEnabled = true;
740− unlockAllModemsSpy.clear();
741− startShell();
947+ loadShell("phone");
742948
743949 var wizard = findChild(shell, "wizard");
744950 compare(wizard.active, true);
@@ -752,6 +958,8 @@ Item {
752958 }
753959
754960 function test_tapOnRightEdgeReachesApplicationSurface() {
961+ loadShell("phone");
962+ swipeAwayGreeter();
755963 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
756964 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
757965 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
@@ -774,6 +982,8 @@ Item {
774982 by the right-edge drag area)
775983 */
776984 function test_rightEdgeDragDoesNotReachApplicationSurface() {
985+ loadShell("phone");
986+ swipeAwayGreeter();
777987 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
778988 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
779989 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
@@ -818,6 +1028,8 @@ Item {
8181028 }
8191029
8201030 function test_tapUbuntuIconInLauncherOverAppSpread() {
1031+ loadShell("phone");
1032+ swipeAwayGreeter();
8211033
8221034 waitUntilFocusedApplicationIsShowingItsSurface();
8231035
@@ -864,19 +1076,75 @@ Item {
8641076 function test_background_data() {
8651077 return [
8661078 {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>")},
867− {tag: "empty", accounts: "", gsettings: "", output: shell.defaultBackground},
1079+ {tag: "empty", accounts: "", gsettings: "", output: "defaultBackground"},
8681080 {tag: "as-specified", accounts: Qt.resolvedUrl("../data/unity/backgrounds/blue.png"), gsettings: "", output: Qt.resolvedUrl("../data/unity/backgrounds/blue.png")},
8691081 {tag: "gs-specified", accounts: "", gsettings: Qt.resolvedUrl("../data/unity/backgrounds/red.png"), output: Qt.resolvedUrl("../data/unity/backgrounds/red.png")},
8701082 {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")},
8711083 {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")},
872− {tag: "invalid-both", accounts: Qt.resolvedUrl("../data/unity/backgrounds/nope.png"), gsettings: Qt.resolvedUrl("../data/unity/backgrounds/stillnope.png"), output: shell.defaultBackground},
1084+ {tag: "invalid-both", accounts: Qt.resolvedUrl("../data/unity/backgrounds/nope.png"), gsettings: Qt.resolvedUrl("../data/unity/backgrounds/stillnope.png"), output: "defaultBackground"},
8731085 ]
8741086 }
8751087 function test_background(data) {
1088+ loadShell("phone");
1089+ swipeAwayGreeter();
8761090 AccountsService.backgroundFile = data.accounts;
8771091 var backgroundSettings = findInvisibleChild(shell, "backgroundSettings");
8781092 backgroundSettings.pictureUri = data.gsettings;
879− tryCompare(shell, "background", data.output);
1093+
1094+ if (data.output === "defaultBackground") {
1095+ tryCompare(shell, "background", shell.defaultBackground);
1096+ } else {
1097+ tryCompare(shell, "background", data.output);
1098+ }
1099+ }
1100+
1101+ function test_tabletLogin_data() {
1102+ return [
1103+ {tag: "auth error", user: "auth-error", loggedIn: false, password: ""},
1104+ {tag: "with password", user: "has-password", loggedIn: true, password: "password"},
1105+ {tag: "without password", user: "no-password", loggedIn: true, password: ""},
1106+ ]
1107+ }
1108+
1109+ function test_tabletLogin(data) {
1110+ setLightDMMockMode("full");
1111+ loadShell("tablet");
1112+
1113+ selectUser(data.user);
1114+
1115+ clickPasswordInput(data.password === "" /* isButton */);
1116+
1117+ if (data.password !== "") {
1118+ typeString(data.password);
1119+ keyClick(Qt.Key_Enter);
1120+ }
1121+
1122+ confirmLoggedIn(data.loggedIn);
1123+ }
1124+
1125+ function test_appLaunchDuringGreeter_data() {
1126+ return [
1127+ {tag: "auth error", user: "auth-error", loggedIn: false, passwordFocus: false},
1128+ {tag: "without password", user: "no-password", loggedIn: true, passwordFocus: false},
1129+ {tag: "with password", user: "has-password", loggedIn: false, passwordFocus: true},
1130+ ]
1131+ }
1132+
1133+ function test_appLaunchDuringGreeter(data) {
1134+ setLightDMMockMode("full");
1135+ loadShell("tablet");
1136+
1137+ selectUser(data.user)
1138+
1139+ var greeter = findChild(shell, "greeter")
1140+ var app = ApplicationManager.startApplication("dialer-app")
1141+
1142+ confirmLoggedIn(data.loggedIn)
1143+
1144+ if (data.passwordFocus) {
1145+ var passwordInput = findChild(greeter, "passwordInput")
1146+ tryCompare(passwordInput, "focus", true)
1147+ }
8801148 }
8811149 }
8821150}
tests/qmltests/tst_TabletShell.qmldeleted−304
@@ -1,304 +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− }
202−
203− function selectUser(name) {
204− // Find index of user with the right name
205− for (var i = 0; i < LightDM.Users.count; i++) {
206− if (LightDM.Users.data(i, LightDM.UserRoles.NameRole) == name) {
207− break
208− }
209− }
210− if (i == LightDM.Users.count) {
211− fail("Didn't find name")
212− return -1
213− }
214− selectIndex(i)
215− return i
216− }
217−
218− function clickPasswordInput(isButton) {
219− var greeter = findChild(shell, "greeter")
220− tryCompare(greeter, "fullyShown", true);
221−
222− var passwordMouseArea = findChild(shell, "passwordMouseArea")
223− tryCompare(passwordMouseArea, "enabled", isButton)
224−
225− var passwordInput = findChild(shell, "passwordInput")
226− mouseClick(passwordInput)
227− }
228−
229− function confirmLoggedIn(loggedIn) {
230− var greeter = findChild(shell, "greeter");
231− tryCompare(greeter, "shown", loggedIn ? false : true);
232− verify(loggedIn ? sessionSpy.count > 0 : sessionSpy.count === 0);
233− }
234−
235− function swipeFromLeftEdge(swipeLength) {
236− var touchStartX = 2
237− var touchStartY = shell.height / 2
238− touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY)
239− }
240−
241− function test_login_data() {
242− return [
243− {tag: "auth error", user: "auth-error", loggedIn: false, password: ""},
244− {tag: "with password", user: "has-password", loggedIn: true, password: "password"},
245− {tag: "without password", user: "no-password", loggedIn: true, password: ""},
246− ]
247− }
248−
249− function test_login(data) {
250− selectUser(data.user)
251−
252− clickPasswordInput(data.password === "")
253−
254− if (data.password !== "") {
255− typeString(data.password)
256− keyClick(Qt.Key_Enter)
257− }
258−
259− confirmLoggedIn(data.loggedIn)
260− }
261−
262− function test_appLaunchDuringGreeter_data() {
263− return [
264− {tag: "auth error", user: "auth-error", loggedIn: false, passwordFocus: false},
265− {tag: "without password", user: "no-password", loggedIn: true, passwordFocus: false},
266− {tag: "with password", user: "has-password", loggedIn: false, passwordFocus: true},
267− ]
268− }
269−
270− function test_appLaunchDuringGreeter(data) {
271− selectUser(data.user)
272−
273− var greeter = findChild(shell, "greeter")
274− var app = ApplicationManager.startApplication("dialer-app")
275−
276− confirmLoggedIn(data.loggedIn)
277−
278− if (data.passwordFocus) {
279− var passwordInput = findChild(greeter, "passwordInput")
280− tryCompare(passwordInput, "focus", true)
281− }
282− }
283−
284− function test_leftEdgeDrag_data() {
285− return [
286− {tag: "without password", user: "no-password", loggedIn: true, demo: false},
287− {tag: "with password", user: "has-password", loggedIn: false, demo: false},
288− {tag: "with demo", user: "has-password", loggedIn: true, demo: true},
289− ]
290− }
291−
292− function test_leftEdgeDrag(data) {
293− selectUser(data.user)
294−
295− AccountsService.demoEdges = data.demo
296− var tutorial = findChild(shell, "tutorial");
297− tryCompare(tutorial, "running", data.demo);
298−
299− swipeFromLeftEdge(shell.width * 0.75)
300− wait(500) // to give time to handle dash() signal from Launcher
301− confirmLoggedIn(data.loggedIn)
302− }
303− }
304−}