@@ -0,0 +1,285 @@
2+ * Copyright (C) 2013,2014 Canonical, Ltd.
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.
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.
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/>.
20+import LightDM 0.1 as LightDM
21+import Ubuntu.Components 1.1
22+import Ubuntu.Telephony 0.1 as Telephony
23+import Unity.Application 0.1
24+import Unity.Connectivity 0.1
25+import Unity.Test 0.1 as UT
35+ id: applicationArguments
37+ function hasGeometry() {
56+ property bool itemDestroyed: false
57+ sourceComponent: Component {
59+ Component.onDestruction: {
60+ shellLoader.itemDestroyed = true
69+ height: shellLoader.height
72+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
75+ anchors { left: parent.left; right: parent.right }
79+ if (shellLoader.status !== Loader.Ready)
82+ var greeter = testCase.findChild(shellLoader.item, "greeter")
83+ if (!greeter.shown) {
94+ signalName: "sessionStarted"
98+ id: dashCommunicatorSpy
99+ signalName: "setCurrentScopeCalled"
103+ id: unlockAllModemsSpy
104+ target: Connectivity
105+ signalName: "unlockingAllModems"
108+ Telephony.CallEntry {
110+ phoneNumber: "+447812221111"
118+ property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
122+ sessionSpy.target = findChild(shell, "greeter")
123+ dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator")
126+ function cleanup() {
127+ shellLoader.itemDestroyed = false
129+ shellLoader.active = false
131+ tryCompare(shellLoader, "status", Loader.Null)
132+ tryCompare(shellLoader, "item", null)
133+ // Loader.status might be Loader.Null and Loader.item might be null but the Loader
134+ // item might still be alive. So if we set Loader.active back to true
135+ // again right now we will get the very same Shell instance back. So no reload
136+ // actually took place. Likely because Loader waits until the next event loop
137+ // iteration to do its work. So to ensure the reload, we will wait until the
138+ // Shell instance gets destroyed.
139+ tryCompare(shellLoader, "itemDestroyed", true)
141+ // kill all (fake) running apps
142+ killApps(ApplicationManager)
144+ unlockAllModemsSpy.clear()
146+ // reload our test subject to get it in a fresh state once again
147+ shellLoader.active = true
149+ tryCompare(shellLoader, "status", Loader.Ready)
150+ removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item)
153+ function killApps() {
154+ while (ApplicationManager.count > 1) {
155+ var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
156+ ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId)
158+ compare(ApplicationManager.count, 1)
161+ function selectIndex(i) {
162+ // We could be anywhere in list; find target index to know which direction
163+ var greeter = findChild(shell, "greeter")
164+ var userlist = findChild(greeter, "userList")
165+ if (userlist.currentIndex == i)
166+ keyClick(Qt.Key_Escape) // Reset state if we're not moving
167+ while (userlist.currentIndex != i) {
168+ var next = userlist.currentIndex + 1
169+ if (userlist.currentIndex > i) {
170+ next = userlist.currentIndex - 1
172+ var account = findChild(greeter, "username"+next)
173+ mouseClick(account, 1, 1)
174+ tryCompare(userlist, "currentIndex", next)
175+ tryCompare(userlist, "movingInternally", false)
179+ function selectUser(name) {
180+ // Find index of user with the right name
181+ var greeter = findChild(shell, "greeter")
182+ for (var i = 0; i < greeter.model.count; i++) {
183+ if (greeter.model.data(i, LightDM.UserRoles.NameRole) == name) {
187+ if (i == greeter.model.count) {
188+ fail("Didn't find name")
195+ function clickPasswordInput() {
196+ var greeter = findChild(shell, "greeter")
197+ tryCompare(greeter, "showProgress", 1)
199+ var passwordInput = findChild(shell, "passwordInput")
200+ mouseClick(passwordInput, passwordInput.width / 2, passwordInput.height / 2)
203+ function confirmLoggedIn(loggedIn) {
204+ var greeter = findChild(shell, "greeter")
205+ tryCompare(greeter, "showProgress", loggedIn ? 0 : 1)
206+ tryCompare(sessionSpy, "count", loggedIn ? 1 : 0)
209+ function swipeFromLeftEdge(swipeLength) {
211+ var touchStartY = shell.height / 2
212+ touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY)
215+ function test_noLockscreen() {
216+ selectUser("has-password")
217+ var lockscreen = findChild(shell, "lockscreen")
218+ tryCompare(lockscreen, "shown", false)
221+ function test_showAndHideGreeterDBusCalls() {
222+ var greeter = findChild(shell, "greeter")
223+ LightDM.Greeter.hideGreeter()
224+ tryCompare(greeter, "showProgress", 0)
225+ LightDM.Greeter.showGreeter()
226+ tryCompare(greeter, "showProgress", 1)
229+ function test_login_data() {
231+ //{tag: "auth error", user: "auth-error", loggedIn: false, password: ""},
232+ //{tag: "without password", user: "no-password", loggedIn: true, password: ""},
233+ {tag: "with password", user: "has-password", loggedIn: true, password: "password"},
237+ function test_login(data) {
238+ selectUser(data.user)
240+ clickPasswordInput()
242+ if (data.password !== "") {
243+ typeString(data.password)
244+ keyClick(Qt.Key_Enter)
247+ confirmLoggedIn(data.loggedIn)
250+ function test_appLaunchDuringGreeter_data() {
252+ {tag: "auth error", user: "auth-error", loggedIn: false, passwordFocus: false},
253+ {tag: "without password", user: "no-password", loggedIn: true, passwordFocus: false},
254+ {tag: "with password", user: "has-password", loggedIn: false, passwordFocus: true},
258+ function test_appLaunchDuringGreeter(data) {
259+ selectUser(data.user)
261+ var greeter = findChild(shell, "greeter")
262+ var app = ApplicationManager.startApplication("dialer-app")
264+ confirmLoggedIn(data.loggedIn)
266+ if (data.passwordFocus) {
267+ var passwordInput = findChild(greeter, "passwordInput")
268+ tryCompare(passwordInput, "focus", true)
272+ function test_leftEdgeDrag_data() {
274+ {tag: "without password", user: "no-password", loggedIn: true},
275+ {tag: "with password", user: "has-password", loggedIn: false},
279+ function test_leftEdgeDrag(data) {
280+ selectUser(data.user)
281+ swipeFromLeftEdge(shell.width * 0.75)
282+ confirmLoggedIn(data.loggedIn)