@@ -21,15 +21,17 @@ import AccountsService 0.1
2121import GSettings 1.0
2222import LightDM 0.1 as LightDM
2323import Ubuntu.SystemImage 0.1
24+import Ubuntu.Telephony 0.1 as Telephony
2425import Unity.Application 0.1
2526import Unity.Test 0.1 as UT
2627import Powerd 0.1
2728
2829import "../../qml"
2930
30−Row {
31+Item {
3132 id: root
32− spacing: 0
33+ width: contentRow.width
34+ height: contentRow.height
3335
3436 QtObject {
3537 id: applicationArguments
@@ -47,34 +49,36 @@ Row {
4749 }
4850 }
4951
50− Loader {
51− id: shellLoader
52+ Row {
53+ id: contentRow
5254
53− width: units.gu(40)
54− height: units.gu(71)
55+ Loader {
56+ id: shellLoader
5557
56− property bool itemDestroyed: false
57− sourceComponent: Component {
58− Shell {
59− Component.onDestruction: {
60− shellLoader.itemDestroyed = true
58+ width: units.gu(40)
59+ height: units.gu(71)
60+
61+ property bool itemDestroyed: false
62+ sourceComponent: Component {
63+ Shell {
64+ Component.onDestruction: {
65+ shellLoader.itemDestroyed = true
66+ }
67+ maxFailedLogins: maxRetriesTextField.text
6168 }
62− maxFailedLogins: maxRetriesTextField.text
6369 }
6470 }
65− }
6671
67− Rectangle {
68− color: "white"
69− width: units.gu(30)
70− height: shellLoader.height
72+ Rectangle {
73+ color: "white"
74+ width: units.gu(30)
75+ height: shellLoader.height
7176
72− Column {
73− anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
74− spacing: units.gu(1)
75− Row {
76− anchors { left: parent.left; right: parent.right }
77+ Column {
78+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
79+ spacing: units.gu(1)
7780 Button {
81+ anchors { left: parent.left; right: parent.right }
7882 text: "Show Greeter"
7983 onClicked: {
8084 if (shellLoader.status !== Loader.Ready)
@@ -86,15 +90,15 @@ Row {
8690 }
8791 }
8892 }
89− }
9093
91− Label {
92− text: "Max retries:"
93− color: "black"
94− }
95− TextField {
96− id: maxRetriesTextField
97− text: "-1"
94+ Label {
95+ text: "Max retries:"
96+ color: "black"
97+ }
98+ TextField {
99+ id: maxRetriesTextField
100+ text: "-1"
101+ }
98102 }
99103 }
100104 }
@@ -110,7 +114,13 @@ Row {
110114 signalName: "resettingDevice"
111115 }
112116
117+ Telephony.CallEntry {
118+ id: phoneCall
119+ phoneNumber: "+447812221111"
120+ }
121+
113122 UT.UnityTestCase {
123+ id: testCase
114124 name: "ShellWithPin"
115125 when: windowShown
116126
@@ -119,10 +129,9 @@ Row {
119129 function init() {
120130 sessionSpy.target = findChild(shell, "greeter")
121131 swipeAwayGreeter()
132+ waitForLockscreen()
122133 shell.failedLoginsDelayAttempts = -1
123134 maxRetriesTextField.text = "-1"
124− AccountsService.enableLauncherWhileLocked = true
125− AccountsService.enableIndicatorsWhileLocked = true
126135 }
127136
128137 function cleanup() {
@@ -143,6 +152,10 @@ Row {
143152 // kill all (fake) running apps
144153 killApps()
145154
155+ AccountsService.enableLauncherWhileLocked = true
156+ AccountsService.enableIndicatorsWhileLocked = true
157+ AccountsService.demoEdges = false
158+
146159 // reload our test subject to get it in a fresh state once again
147160 shellLoader.active = true
148161
@@ -169,8 +182,9 @@ Row {
169182
170183 // wait until the animation has finished
171184 tryCompare(greeter, "showProgress", 0);
185+ }
172186
173− // and for pin to be ready
187+ function waitForLockscreen() {
174188 var lockscreen = findChild(shell, "lockscreen");
175189 var pinPadLoader = findChild(lockscreen, "pinPadLoader");
176190 tryCompare(pinPadLoader, "status", Loader.Ready)
@@ -182,10 +196,20 @@ Row {
182196 for (var i = 0; i < pin.length; ++i) {
183197 var character = pin.charAt(i)
184198 var button = findChild(shell, "pinPadButton" + character)
185− mouseClick(button, units.gu(1), units.gu(1))
199+ tap(button)
186200 }
187201 }
188202
203+ function confirmLockedApp(app) {
204+ var greeter = findChild(shell, "greeter")
205+ var lockscreen = findChild(shell, "lockscreen")
206+ tryCompare(greeter, "shown", false)
207+ tryCompare(lockscreen, "shown", false)
208+ tryCompare(greeter, "hasLockedApp", true)
209+ tryCompare(greeter, "lockedApp", app)
210+ tryCompare(ApplicationManager, "focusedApplicationId", app)
211+ }
212+
189213 function test_login() {
190214 sessionSpy.clear()
191215 tryCompare(sessionSpy, "count", 0)
@@ -193,6 +217,25 @@ Row {
193217 tryCompare(sessionSpy, "count", 1)
194218 }
195219
220+ function test_edgeDemoHidesLockscreen() {
221+ LightDM.Greeter.showGreeter()
222+ sessionSpy.clear()
223+ var lockscreen = findChild(shell, "lockscreen")
224+
225+ tryCompare(lockscreen, "shown", true)
226+ AccountsService.demoEdges = true
227+ tryCompare(lockscreen, "shown", false)
228+
229+ swipeAwayGreeter()
230+ tryCompare(sessionSpy, "count", 1)
231+
232+ // Lockscreen is only hidden by the edge demo, so if we turn that
233+ // off and show greeter again, lockscreen should appear
234+ AccountsService.demoEdges = false
235+ LightDM.Greeter.showGreeter()
236+ tryCompare(lockscreen, "shown", true)
237+ }
238+
196239 function test_disabledEdges() {
197240 var launcher = findChild(shell, "launcher")
198241 tryCompare(launcher, "available", true)
@@ -214,7 +257,7 @@ Row {
214257 var launcher = findChild(shell, "launcher")
215258 var stage = findChild(shell, "stage")
216259
217− mouseClick(emergencyButton, units.gu(1), units.gu(1))
260+ tap(emergencyButton)
218261
219262 tryCompare(greeter, "lockedApp", "dialer-app")
220263 tryCompare(greeter, "hasLockedApp", true)
@@ -241,7 +284,7 @@ Row {
241284 function test_emergencyCallCrash() {
242285 var lockscreen = findChild(shell, "lockscreen")
243286 var emergencyButton = findChild(lockscreen, "emergencyCallLabel")
244− mouseClick(emergencyButton, units.gu(1), units.gu(1))
287+ tap(emergencyButton)
245288
246289 tryCompare(lockscreen, "shown", false)
247290 killApps() // kill dialer-app, as if it crashed
@@ -251,7 +294,7 @@ Row {
251294 function test_emergencyCallAppLaunch() {
252295 var lockscreen = findChild(shell, "lockscreen")
253296 var emergencyButton = findChild(lockscreen, "emergencyCallLabel")
254− mouseClick(emergencyButton, units.gu(1), units.gu(1))
297+ tap(emergencyButton)
255298
256299 tryCompare(lockscreen, "shown", false)
257300 ApplicationManager.startApplication("gallery-app", ApplicationManager.NoFlag)
@@ -296,7 +339,7 @@ Row {
296339
297340 var dialog = findChild(root, "infoPopup")
298341 var button = findChild(dialog, "infoPopupOkButton")
299− mouseClick(button, units.gu(1), units.gu(1))
342+ tap(button)
300343 tryCompareFunction(function() {return findChild(root, "infoPopup")}, null)
301344
302345 tryCompare(resetSpy, "count", 0)
@@ -317,11 +360,9 @@ Row {
317360 tryCompare(shell, "sideStageEnabled", false)
318361 tryCompare(applicationsDisplayLoader, "tabletMode", false)
319362
320− var app = ApplicationManager.startApplication("dialer-app")
321−
322− var greeter = findChild(shell, "greeter")
323− tryCompare(greeter, "showProgress", 0)
324− tryCompare(greeter, "hasLockedApp", true)
363+ var lockscreen = findChild(shell, "lockscreen")
364+ lockscreen.emergencyCall()
365+ confirmLockedApp("dialer-app")
325366
326367 // OK, we're in. Now try (but fail) to switch to tablet mode
327368 shell.tablet = true
@@ -330,9 +371,15 @@ Row {
330371
331372 // And when we kill the app, we go back to locked tablet mode
332373 killApps()
374+ var greeter = findChild(shell, "greeter")
333375 tryCompare(greeter, "showProgress", 1)
334376 tryCompare(shell, "sideStageEnabled", true)
335377 tryCompare(applicationsDisplayLoader, "tabletMode", true)
336378 }
379+
380+ function test_emergencyDialerIncoming() {
381+ callManager.foregroundCall = phoneCall
382+ confirmLockedApp("dialer-app")
383+ }
337384 }
338385}