on xenial help sign in
Add some tests
commitf6767c9c820ab9b71ddff500f84282d7269d5fc9 authorMichael Terry <michael.terry@canonical.com> dateMon 30 Jun 2014, 18:26 (12 years ago) parentd4c4cb1
4 files changed+73−36
qml/Shell.qml+7 tests/qmltests/Greeter/tst_Lockscreen.qml+3−3 tests/qmltests/tst_Shell.qml−1 tests/qmltests/tst_ShellWithPin.qml+63−32
qml/Shell.qml+7
@@ -305,6 +305,11 @@ FocusScope {
305305
306306 source: shell.sideStageEnabled ? "Stages/StageWithSideStage.qml" : "Stages/PhoneStage.qml"
307307
308+ Binding {
309+ target: applicationsDisplayLoader.item
310+ property: "objectName"
311+ value: "stage"
312+ }
308313 Binding {
309314 target: applicationsDisplayLoader.item
310315 property: "moving"
@@ -554,6 +559,7 @@ FocusScope {
554559
555560 Panel {
556561 id: panel
562+ objectName: "panel"
557563 anchors.fill: parent //because this draws indicator menus
558564 indicatorsMenuWidth: parent.width > units.gu(60) ? units.gu(40) : parent.width
559565 indicators {
@@ -589,6 +595,7 @@ FocusScope {
589595
590596 Launcher {
591597 id: launcher
598+ objectName: "launcher"
592599
593600 readonly property bool dashSwipe: progress > 0
594601
tests/qmltests/Greeter/tst_Lockscreen.qml+3−3
@@ -57,10 +57,10 @@ Rectangle {
5757 target: LightDM.Greeter
5858
5959 onShowPrompt: {
60− if (text == "PIN") {
61− pinPadCheckBox.checked = true
62− } else {
60+ if (text === "PIN") {
6361 pinPadCheckBox.checked = false
62+ } else {
63+ pinPadCheckBox.checked = true
6464 }
6565 lockscreen.placeholderText = text;
6666 }
tests/qmltests/tst_Shell.qml−1
@@ -99,7 +99,6 @@ Item {
9999 swipeAwayGreeter();
100100
101101 sessionSpy.target = findChild(shell, "greeter")
102− sessionSpy.clear()
103102 }
104103
105104 function cleanup() {
tests/qmltests/tst_ShellWithPin.qml+63−32
@@ -93,10 +93,27 @@ Item {
9393
9494 verify(ok);
9595
96− swipeAwayGreeter();
97−
9896 sessionSpy.target = findChild(shell, "greeter")
99− sessionSpy.clear()
97+ }
98+
99+ function init() {
100+ swipeAwayGreeter()
101+ }
102+
103+ function cleanup() {
104+ LightDM.Greeter.showGreeter()
105+ var greeter = findChild(shell, "greeter")
106+ tryCompare(greeter, "showProgress", 1)
107+
108+ // kill all (fake) running apps
109+ killApps()
110+ }
111+
112+ function killApps() {
113+ while (ApplicationManager.count > 0) {
114+ ApplicationManager.stopApplication(ApplicationManager.get(0).appId)
115+ }
116+ compare(ApplicationManager.count, 0)
100117 }
101118
102119 function swipeAwayGreeter() {
@@ -126,45 +143,59 @@ Item {
126143 }
127144 }
128145
129− function dragLauncherIntoView() {
130− var launcherPanel = findChild(shell, "launcherPanel");
131− verify(launcherPanel.x = - launcherPanel.width);
132−
133− var touchStartX = 2;
134− var touchStartY = shell.height / 2;
135− touchFlick(shell, touchStartX, touchStartY, launcherPanel.width + units.gu(1), touchStartY);
136−
137− tryCompare(launcherPanel, "x", 0);
146+ function test_login() {
147+ tryCompare(sessionSpy, "count", 0)
148+ enterPin("1234")
149+ tryCompare(sessionSpy, "count", 1)
138150 }
139151
140− function tapOnAppIconInLauncher() {
141− var launcherPanel = findChild(shell, "launcherPanel");
152+ function test_emergencyCall() {
153+ var greeter = findChild(shell, "greeter")
154+ var lockscreen = findChild(shell, "lockscreen")
155+ var emergencyButton = findChild(lockscreen, "emergencyCallIcon")
156+ var panel = findChild(shell, "panel")
157+ var indicators = findChild(shell, "indicators")
158+ var launcher = findChild(shell, "launcher")
159+ var stage = findChild(shell, "stage")
142160
143− // pick the first icon, the one at the bottom.
144− var appIcon = findChild(launcherPanel, "launcherDelegate0")
161+ mouseClick(emergencyButton, units.gu(1), units.gu(1))
145162
146− // Swipe upwards over the launcher to ensure that this icon
147− // at the bottom is not folded and faded away.
148− var touchStartX = launcherPanel.width / 2;
149− var touchStartY = launcherPanel.height / 2;
150− touchFlick(launcherPanel, touchStartX, touchStartY, touchStartX, 0);
151− tryCompare(launcherPanel, "moving", false);
163+ tryCompare(lockscreen, "shown", false)
164+ tryCompare(greeter, "fakeActiveForApp", "dialer-app")
165+ tryCompare(panel, "fullscreenMode", true)
166+ tryCompare(indicators, "available", false)
167+ tryCompare(launcher, "available", false)
168+ tryCompare(stage, "spreadEnabled", false)
152169
153− // NB tapping (i.e., using touch events) doesn't activate the icon... go figure...
154− mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2);
155− }
170+ // Cancel emergency mode, and go back to normal
171+ LightDM.Greeter.showGreeter()
156172
157− function test_login() {
158− tryCompare(sessionSpy, "count", 0)
159− enterPin("1234")
160− tryCompare(sessionSpy, "count", 1)
173+ tryCompare(lockscreen, "shown", true)
174+ tryCompare(greeter, "shown", true)
175+ tryCompare(greeter, "fakeActiveForApp", "")
176+ tryCompare(panel, "fullscreenMode", false)
177+ tryCompare(indicators, "available", true)
178+ tryCompare(launcher, "available", true)
179+ tryCompare(stage, "spreadEnabled", true)
161180 }
162181
163− function test_emergencyCall() {
164− dragLauncherIntoView()
165− tapOnAppIconInLauncher()
182+ function test_emergencyCallCrash() {
183+ var lockscreen = findChild(shell, "lockscreen")
184+ var emergencyButton = findChild(lockscreen, "emergencyCallIcon")
185+ mouseClick(emergencyButton, units.gu(1), units.gu(1))
166186
187+ tryCompare(lockscreen, "shown", false)
188+ killApps() // kill dialer-app, as if it crashed
189+ tryCompare(lockscreen, "shown", true)
190+ }
191+
192+ function test_emergencyCallAppLaunch() {
167193 var lockscreen = findChild(shell, "lockscreen")
194+ var emergencyButton = findChild(lockscreen, "emergencyCallIcon")
195+ mouseClick(emergencyButton, units.gu(1), units.gu(1))
196+
197+ tryCompare(lockscreen, "shown", false)
198+ ApplicationManager.startApplication("gallery-app", ApplicationManager.NoFlag)
168199 tryCompare(lockscreen, "shown", true)
169200 }
170201 }