on xenial help sign in
Make tst_Shell absorb tst_TabletShell
commita2eea123436e0c5a6bbafd0820cff56780785dc4 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 25 Feb 2015, 17:17 (12 years ago) parentc3b9000
3 files changed+317−367
tests/qmltests/CMakeLists.txt−1 tests/qmltests/tst_Shell.qml+317−62 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+317−62
@@ -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>
@@ -34,9 +34,10 @@ import Powerd 0.1
3434
3535import "../../qml"
3636
37−Item {
37+Rectangle {
3838 id: root
39− width: units.gu(60)
39+ color: "grey"
40+ width: units.gu(100) + controls.width
4041 height: units.gu(71)
4142
4243 Component.onCompleted: {
@@ -62,12 +63,37 @@ Item {
6263 }
6364 }
6465
65− Row {
66− anchors.fill: parent
66+ Item {
67+ anchors.left: root.left
68+ anchors.right: controls.left
69+ anchors.top: root.top
70+ anchors.bottom: root.bottom
6771 Loader {
6872 id: shellLoader
6973 focus: true
7074
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+
7197 active: false
7298 property bool itemDestroyed: false
7399 sourceComponent: Component {
@@ -80,42 +106,56 @@ Item {
80106 }
81107 }
82108 }
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;
83130
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");
102− if (!greeter.shown) {
103− LightDM.Greeter.showGreeter();
104− }
131+ var greeter = testCase.findChild(shellLoader.item, "greeter");
132+ if (!greeter.shown) {
133+ LightDM.Greeter.showGreeter();
105134 }
106135 }
107136 }
108− ListItem.ItemSelector {
109− anchors { left: parent.left; right: parent.right }
110− activeFocusOnPress: false
111− text: "LightDM mock mode"
112− model: ["single", "single-passphrase", "single-pin"]
113− onSelectedIndexChanged: {
114− shellLoader.active = false;
115− LightDM.Greeter.mockMode = model[selectedIndex];
116− LightDM.Users.mockMode = model[selectedIndex];
117− shellLoader.active = true;
118− }
137+ }
138+ ListItem.ItemSelector {
139+ anchors { left: parent.left; right: parent.right }
140+ activeFocusOnPress: false
141+ text: "LightDM mock mode"
142+ model: ["single", "single-passphrase", "single-pin", "full"]
143+ onSelectedIndexChanged: {
144+ shellLoader.active = false;
145+ LightDM.Greeter.mockMode = model[selectedIndex];
146+ LightDM.Users.mockMode = model[selectedIndex];
147+ shellLoader.active = true;
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;
119159 }
120160 }
121161 }
@@ -186,10 +226,25 @@ Item {
186226 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
187227
188228 function init() {
189− tryCompare(shell, "enabled", true); // enabled by greeter when ready
190− shell.indicatorProfile = "phone";
229+ if (shellLoader.active) {
230+ // happens for the very first test function as shell
231+ // is loaded by default
232+ tearDown();
233+ }
191234
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
193248
194249 sessionSpy.target = findChild(shell, "greeter")
195250 dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator");
@@ -198,8 +253,7 @@ Item {
198253 launcherShowDashHomeSpy.target = launcher;
199254 }
200255
201− function cleanup() {
202− tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
256+ function tearDown() {
203257 launcherShowDashHomeSpy.target = null;
204258
205259 shellLoader.itemDestroyed = false;
@@ -216,17 +270,17 @@ Item {
216270 // Shell instance gets destroyed.
217271 tryCompare(shellLoader, "itemDestroyed", true);
218272
273+ setLightDMMockMode("single"); // back to the default value
274+
275+ AccountsService.demoEdges = false;
276+
219277 // kill all (fake) running apps
220278 killApps(ApplicationManager);
221279
222280 unlockAllModemsSpy.clear()
223281 LightDM.Greeter.authenticate(""); // reset greeter
224282
225− // reload our test subject to get it in a fresh state once again
226− shellLoader.active = true;
227−
228− tryCompare(shellLoader, "status", Loader.Ready);
229− removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item);
283+ sessionSpy.clear();
230284 }
231285
232286 function killApps() {
@@ -238,6 +292,8 @@ Item {
238292 }
239293
240294 function test_snapDecisionDismissalReturnsFocus() {
295+ loadShell("phone");
296+ swipeAwayGreeter();
241297 var notifications = findChild(shell, "notificationList");
242298 var app = ApplicationManager.startApplication("camera-app");
243299 var stage = findChild(shell, "stage")
@@ -296,19 +352,41 @@ Item {
296352 mockNotificationsModel.append(n)
297353 }
298354
299− function test_leftEdgeDrag_data() {
355+ function test_phoneLeftEdgeDrag_data() {
300356 return [
301− {tag: "without launcher", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
302− {tag: "with launcher", revealLauncher: true, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
303− {tag: "small swipe", revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app", launcherHides: false, greeterShown: false},
304− {tag: "long swipe", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: false},
305− {tag: "small swipe with greeter", revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app", launcherHides: false, greeterShown: true},
306− {tag: "long swipe with greeter", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true, greeterShown: true},
307− {tag: "swipe over dash", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "unity8-dash", launcherHides: false, greeterShown: false},
357+ {tag: "without launcher",
358+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
359+ launcherHides: true, greeterShown: false},
360+
361+ {tag: "with launcher",
362+ revealLauncher: true, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
363+ launcherHides: true, greeterShown: false},
364+
365+ {tag: "small swipe",
366+ revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
367+ launcherHides: false, greeterShown: false},
368+
369+ {tag: "long swipe",
370+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
371+ launcherHides: true, greeterShown: false},
372+
373+ {tag: "small swipe with greeter",
374+ revealLauncher: false, swipeLength: units.gu(25), appHides: false, focusedApp: "dialer-app",
375+ launcherHides: false, greeterShown: true},
376+
377+ {tag: "long swipe with greeter",
378+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app",
379+ launcherHides: true, greeterShown: true},
380+
381+ {tag: "swipe over dash",
382+ revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "unity8-dash",
383+ launcherHides: false, greeterShown: false},
308384 ];
309385 }
310386
311− function test_leftEdgeDrag(data) {
387+ function test_phoneLeftEdgeDrag(data) {
388+ loadShell("phone");
389+ swipeAwayGreeter();
312390 dragLauncherIntoView();
313391 tapOnAppIconInLauncher();
314392 waitUntilApplicationWindowIsFullyVisible();
@@ -341,7 +419,32 @@ Item {
341419 compare(animateTimer.nextState, "visible");
342420 }
343421
422+ function test_tabletLeftEdgeDrag_data() {
423+ return [
424+ {tag: "without password", user: "no-password", loggedIn: true, demo: false},
425+ {tag: "with password", user: "has-password", loggedIn: false, demo: false},
426+ {tag: "with demo", user: "has-password", loggedIn: true, demo: true},
427+ ]
428+ }
429+
430+ function test_tabletLeftEdgeDrag(data) {
431+ setLightDMMockMode("full");
432+ loadShell("tablet");
433+
434+ selectUser(data.user)
435+
436+ AccountsService.demoEdges = data.demo
437+ var tutorial = findChild(shell, "tutorial");
438+ tryCompare(tutorial, "running", data.demo);
439+
440+ swipeFromLeftEdge(shell.width * 0.75)
441+ wait(500) // to give time to handle dash() signal from Launcher
442+ confirmLoggedIn(data.loggedIn)
443+ }
444+
344445 function test_suspend() {
446+ loadShell("phone");
447+ swipeAwayGreeter();
345448 var greeter = findChild(shell, "greeter");
346449
347450 // Launch an app from the launcher
@@ -401,6 +504,60 @@ Item {
401504 waitForRendering(greeter);
402505 }
403506
507+ function selectUserAtIndex(i) {
508+ // We could be anywhere in list; find target index to know which direction
509+ var greeter = findChild(shell, "greeter")
510+ var userlist = findChild(greeter, "userList")
511+ if (userlist.currentIndex == i)
512+ keyClick(Qt.Key_Escape) // Reset state if we're not moving
513+ while (userlist.currentIndex != i) {
514+ var next = userlist.currentIndex + 1
515+ if (userlist.currentIndex > i) {
516+ next = userlist.currentIndex - 1
517+ }
518+ tap(findChild(greeter, "username"+next));
519+ tryCompare(userlist, "currentIndex", next)
520+ tryCompare(userlist, "movingInternally", false)
521+ }
522+ }
523+
524+ function selectUser(name) {
525+ // Find index of user with the right name
526+ for (var i = 0; i < LightDM.Users.count; i++) {
527+ if (LightDM.Users.data(i, LightDM.UserRoles.NameRole) == name) {
528+ break
529+ }
530+ }
531+ if (i == LightDM.Users.count) {
532+ fail("Didn't find name")
533+ return -1
534+ }
535+ selectUserAtIndex(i)
536+ return i
537+ }
538+
539+ function clickPasswordInput(isButton) {
540+ var greeter = findChild(shell, "greeter")
541+ tryCompare(greeter, "fullyShown", true);
542+
543+ var passwordMouseArea = findChild(shell, "passwordMouseArea")
544+ tryCompare(passwordMouseArea, "enabled", isButton)
545+
546+ var passwordInput = findChild(shell, "passwordInput")
547+ mouseClick(passwordInput)
548+ }
549+
550+ function confirmLoggedIn(loggedIn) {
551+ var greeter = findChild(shell, "greeter");
552+ tryCompare(greeter, "shown", loggedIn ? false : true);
553+ verify(loggedIn ? sessionSpy.count > 0 : sessionSpy.count === 0);
554+ }
555+
556+ function setLightDMMockMode(mode) {
557+ LightDM.Greeter.mockMode = mode;
558+ LightDM.Users.mockMode = mode;
559+ }
560+
404561 /*
405562 Regression test for bug https://bugs.launchpad.net/touch-preview-images/+bug/1193419
406563
@@ -413,6 +570,8 @@ Item {
413570 - verify the setCurrentScope() D-Bus call to the dash has been called for the correct scope id.
414571 */
415572 function test_minimizingAppTakesToDashApps() {
573+ loadShell("phone");
574+ swipeAwayGreeter();
416575 dragLauncherIntoView();
417576
418577 // Launch an app from the launcher
@@ -433,6 +592,8 @@ Item {
433592 }
434593
435594 function test_showInputMethod() {
595+ loadShell("phone");
596+ swipeAwayGreeter();
436597 var item = findChild(shell, "inputMethod");
437598 var surface = SurfaceManager.inputMethodSurface();
438599
@@ -471,6 +632,8 @@ Item {
471632 }
472633
473634 function test_surfaceLosesActiveFocusWhilePanelIsOpen() {
635+ loadShell("phone");
636+ swipeAwayGreeter();
474637 var app = ApplicationManager.startApplication("dialer-app");
475638 waitUntilAppWindowIsFullyLoaded(app);
476639
@@ -501,10 +664,19 @@ Item {
501664 tryCompare(app.session.surface, "activeFocus", true);
502665 }
503666
504− function test_launchedAppHasActiveFocus() {
505− var dialerApp = ApplicationManager.startApplication("dialer-app");
667+ function test_launchedAppHasActiveFocus_data() {
668+ return [
669+ {tag:"phone", formFactor:"phone"},
670+ {tag:"tablet", formFactor:"tablet"},
671+ ];
672+ }
673+
674+ function test_launchedAppHasActiveFocus(data) {
675+ loadShell(data.formFactor);
676+ swipeAwayGreeter();
677+ var dialerApp = ApplicationManager.startApplication("webbrowser-app");
506678 verify(dialerApp);
507− waitUntilAppSurfaceShowsUp("dialer-app")
679+ waitUntilAppSurfaceShowsUp("webbrowser-app")
508680
509681 verify(dialerApp.session.surface);
510682
@@ -615,6 +787,8 @@ Item {
615787 }
616788
617789 function test_greeterDoesNotChangeIndicatorProfile() {
790+ loadShell("phone");
791+ swipeAwayGreeter();
618792 var panel = findChild(shell, "panel");
619793 tryCompare(panel.indicators.indicatorsModel, "profile", shell.indicatorProfile);
620794
@@ -626,6 +800,8 @@ Item {
626800 }
627801
628802 function test_shellProfileChangesReachIndicators() {
803+ loadShell("phone");
804+ swipeAwayGreeter();
629805 var panel = findChild(shell, "panel");
630806
631807 shell.indicatorProfile = "test1";
@@ -642,6 +818,8 @@ Item {
642818 }
643819
644820 function test_focusRequestedHidesGreeter() {
821+ loadShell("phone");
822+ swipeAwayGreeter();
645823 var greeter = findChild(shell, "greeter");
646824
647825 var app = ApplicationManager.startApplication("dialer-app");
@@ -662,6 +840,8 @@ Item {
662840 }
663841
664842 function test_focusRequestedHidesIndicators() {
843+ loadShell("phone");
844+ swipeAwayGreeter();
665845 var indicators = findChild(shell, "indicators");
666846
667847 showIndicators();
@@ -674,6 +854,8 @@ Item {
674854 }
675855
676856 function test_showAndHideGreeterDBusCalls() {
857+ loadShell("phone");
858+ swipeAwayGreeter();
677859 var greeter = findChild(shell, "greeter")
678860 tryCompare(greeter, "shown", false)
679861 waitForRendering(greeter);
@@ -685,6 +867,9 @@ Item {
685867 }
686868
687869 function test_greeterLoginsAutomaticallyWhenNoPasswordSet() {
870+ loadShell("phone");
871+ swipeAwayGreeter();
872+
688873 sessionSpy.clear();
689874 verify(sessionSpy.valid);
690875
@@ -694,6 +879,8 @@ Item {
694879 }
695880
696881 function test_fullscreen() {
882+ loadShell("phone");
883+ swipeAwayGreeter();
697884 var panel = findChild(shell, "panel");
698885 compare(panel.fullscreenMode, false);
699886 ApplicationManager.startApplication("camera-app");
@@ -707,6 +894,8 @@ Item {
707894 }
708895
709896 function test_leftEdgeDragFullscreen() {
897+ loadShell("phone");
898+ swipeAwayGreeter();
710899 var panel = findChild(shell, "panel");
711900 tryCompare(panel, "fullscreenMode", false)
712901
@@ -728,6 +917,8 @@ Item {
728917 }
729918
730919 function test_unlockedProperties() {
920+ loadShell("phone");
921+ swipeAwayGreeter();
731922 // Confirm that various properties have the correct values when unlocked
732923 var greeter = findChild(shell, "greeter");
733924 tryCompare(greeter, "locked", false);
@@ -740,10 +931,14 @@ Item {
740931 }
741932
742933 function test_unlockAllModemsOnBoot() {
934+ loadShell("phone");
935+ swipeAwayGreeter();
743936 tryCompare(unlockAllModemsSpy, "count", 1)
744937 }
745938
746939 function test_tapOnRightEdgeReachesApplicationSurface() {
940+ loadShell("phone");
941+ swipeAwayGreeter();
747942 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
748943 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
749944 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
@@ -766,6 +961,8 @@ Item {
766961 by the right-edge drag area)
767962 */
768963 function test_rightEdgeDragDoesNotReachApplicationSurface() {
964+ loadShell("phone");
965+ swipeAwayGreeter();
769966 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
770967 var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
771968 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
@@ -810,6 +1007,8 @@ Item {
8101007 }
8111008
8121009 function test_tapUbuntuIconInLauncherOverAppSpread() {
1010+ loadShell("phone");
1011+ swipeAwayGreeter();
8131012
8141013 waitUntilFocusedApplicationIsShowingItsSurface();
8151014
@@ -856,19 +1055,75 @@ Item {
8561055 function test_background_data() {
8571056 return [
8581057 {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},
1058+ {tag: "empty", accounts: "", gsettings: "", output: "defaultBackground"},
8601059 {tag: "as-specified", accounts: Qt.resolvedUrl("../data/unity/backgrounds/blue.png"), gsettings: "", output: Qt.resolvedUrl("../data/unity/backgrounds/blue.png")},
8611060 {tag: "gs-specified", accounts: "", gsettings: Qt.resolvedUrl("../data/unity/backgrounds/red.png"), output: Qt.resolvedUrl("../data/unity/backgrounds/red.png")},
8621061 {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")},
8631062 {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},
1063+ {tag: "invalid-both", accounts: Qt.resolvedUrl("../data/unity/backgrounds/nope.png"), gsettings: Qt.resolvedUrl("../data/unity/backgrounds/stillnope.png"), output: "defaultBackground"},
8651064 ]
8661065 }
8671066 function test_background(data) {
1067+ loadShell("phone");
1068+ swipeAwayGreeter();
8681069 AccountsService.backgroundFile = data.accounts;
8691070 var backgroundSettings = findInvisibleChild(shell, "backgroundSettings");
8701071 backgroundSettings.pictureUri = data.gsettings;
871− tryCompare(shell, "background", data.output);
1072+
1073+ if (data.output === "defaultBackground") {
1074+ tryCompare(shell, "background", shell.defaultBackground);
1075+ } else {
1076+ tryCompare(shell, "background", data.output);
1077+ }
1078+ }
1079+
1080+ function test_tabletLogin_data() {
1081+ return [
1082+ {tag: "auth error", user: "auth-error", loggedIn: false, password: ""},
1083+ {tag: "with password", user: "has-password", loggedIn: true, password: "password"},
1084+ {tag: "without password", user: "no-password", loggedIn: true, password: ""},
1085+ ]
1086+ }
1087+
1088+ function test_tabletLogin(data) {
1089+ setLightDMMockMode("full");
1090+ loadShell("tablet");
1091+
1092+ selectUser(data.user);
1093+
1094+ clickPasswordInput(data.password === "" /* isButton */);
1095+
1096+ if (data.password !== "") {
1097+ typeString(data.password);
1098+ keyClick(Qt.Key_Enter);
1099+ }
1100+
1101+ confirmLoggedIn(data.loggedIn);
1102+ }
1103+
1104+ function test_appLaunchDuringGreeter_data() {
1105+ return [
1106+ {tag: "auth error", user: "auth-error", loggedIn: false, passwordFocus: false},
1107+ {tag: "without password", user: "no-password", loggedIn: true, passwordFocus: false},
1108+ {tag: "with password", user: "has-password", loggedIn: false, passwordFocus: true},
1109+ ]
1110+ }
1111+
1112+ function test_appLaunchDuringGreeter(data) {
1113+ setLightDMMockMode("full");
1114+ loadShell("tablet");
1115+
1116+ selectUser(data.user)
1117+
1118+ var greeter = findChild(shell, "greeter")
1119+ var app = ApplicationManager.startApplication("dialer-app")
1120+
1121+ confirmLoggedIn(data.loggedIn)
1122+
1123+ if (data.passwordFocus) {
1124+ var passwordInput = findChild(greeter, "passwordInput")
1125+ tryCompare(passwordInput, "focus", true)
1126+ }
8721127 }
8731128 }
8741129}
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−}