on xenial help sign in
Fix the ShellWithPin test and some functionality.
a326304Michał Sawicz
tests/qmltests/tst_ShellWithPin.qml+39−35
@@ -28,9 +28,10 @@ import Powerd 0.1
28
28
29import "../../qml"
29import "../../qml"
30
30
31−Row {
31+Item {
32 id: root
32 id: root
33− spacing: 0
33+ width: contentRow.width
34+ height: contentRow.height
34
35
35 QtObject {
36 QtObject {
36 id: applicationArguments
37 id: applicationArguments
@@ -48,34 +49,36 @@ Row {
48 }
49 }
49 }
50 }
50
51
51− Loader {
52+ Row {
52− id: shellLoader
53+ id: contentRow
53
54
54− width: units.gu(40)
55+ Loader {
55− height: units.gu(71)
56+ id: shellLoader
56
57
58+ width: units.gu(40)
59+ height: units.gu(71)
60+
57− property bool itemDestroyed: false
61+ property bool itemDestroyed: false
58− sourceComponent: Component {
62+ sourceComponent: Component {
59− Shell {
63+ Shell {
60− Component.onDestruction: {
64+ Component.onDestruction: {
61− shellLoader.itemDestroyed = true
65+ shellLoader.itemDestroyed = true
66+ }
67+ maxFailedLogins: maxRetriesTextField.text
62 }
68 }
63− maxFailedLogins: maxRetriesTextField.text
64 }
69 }
65 }
70 }
66− }
67
71
68− Rectangle {
72+ Rectangle {
69− color: "white"
73+ color: "white"
70− width: units.gu(30)
74+ width: units.gu(30)
71− height: shellLoader.height
75+ height: shellLoader.height
72
76
73− Column {
77+ Column {
74− anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
78+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
75− spacing: units.gu(1)
79+ spacing: units.gu(1)
76− Row {
77− anchors { left: parent.left; right: parent.right }
78 Button {
80 Button {
81+ anchors { left: parent.left; right: parent.right }
79 text: "Show Greeter"
82 text: "Show Greeter"
80 onClicked: {
83 onClicked: {
81 if (shellLoader.status !== Loader.Ready)
84 if (shellLoader.status !== Loader.Ready)
@@ -87,15 +90,15 @@ Row {
87 }
90 }
88 }
91 }
89 }
92 }
90− }
91
93
92− Label {
94+ Label {
93− text: "Max retries:"
95+ text: "Max retries:"
94− color: "black"
96+ color: "black"
95− }
97+ }
96− TextField {
98+ TextField {
97− id: maxRetriesTextField
99+ id: maxRetriesTextField
98− text: "-1"
100+ text: "-1"
101+ }
99 }
102 }
100 }
103 }
101 }
104 }
@@ -117,6 +120,7 @@ Row {
117 }
120 }
118
121
119 UT.UnityTestCase {
122 UT.UnityTestCase {
123+ id: testCase
120 name: "ShellWithPin"
124 name: "ShellWithPin"
121 when: windowShown
125 when: windowShown
122
126
@@ -192,7 +196,7 @@ Row {
192 for (var i = 0; i < pin.length; ++i) {
196 for (var i = 0; i < pin.length; ++i) {
193 var character = pin.charAt(i)
197 var character = pin.charAt(i)
194 var button = findChild(shell, "pinPadButton" + character)
198 var button = findChild(shell, "pinPadButton" + character)
195− mouseClick(button, units.gu(1), units.gu(1))
199+ tap(button)
196 }
200 }
197 }
201 }
198
202
@@ -253,7 +257,7 @@ Row {
253 var launcher = findChild(shell, "launcher")
257 var launcher = findChild(shell, "launcher")
254 var stage = findChild(shell, "stage")
258 var stage = findChild(shell, "stage")
255
259
256− mouseClick(emergencyButton, units.gu(1), units.gu(1))
260+ tap(emergencyButton)
257
261
258 tryCompare(greeter, "lockedApp", "dialer-app")
262 tryCompare(greeter, "lockedApp", "dialer-app")
259 tryCompare(greeter, "hasLockedApp", true)
263 tryCompare(greeter, "hasLockedApp", true)
@@ -280,7 +284,7 @@ Row {
280 function test_emergencyCallCrash() {
284 function test_emergencyCallCrash() {
281 var lockscreen = findChild(shell, "lockscreen")
285 var lockscreen = findChild(shell, "lockscreen")
282 var emergencyButton = findChild(lockscreen, "emergencyCallLabel")
286 var emergencyButton = findChild(lockscreen, "emergencyCallLabel")
283− mouseClick(emergencyButton, units.gu(1), units.gu(1))
287+ tap(emergencyButton)
284
288
285 tryCompare(lockscreen, "shown", false)
289 tryCompare(lockscreen, "shown", false)
286 killApps() // kill dialer-app, as if it crashed
290 killApps() // kill dialer-app, as if it crashed
@@ -290,7 +294,7 @@ Row {
290 function test_emergencyCallAppLaunch() {
294 function test_emergencyCallAppLaunch() {
291 var lockscreen = findChild(shell, "lockscreen")
295 var lockscreen = findChild(shell, "lockscreen")
292 var emergencyButton = findChild(lockscreen, "emergencyCallLabel")
296 var emergencyButton = findChild(lockscreen, "emergencyCallLabel")
293− mouseClick(emergencyButton, units.gu(1), units.gu(1))
297+ tap(emergencyButton)
294
298
295 tryCompare(lockscreen, "shown", false)
299 tryCompare(lockscreen, "shown", false)
296 ApplicationManager.startApplication("gallery-app", ApplicationManager.NoFlag)
300 ApplicationManager.startApplication("gallery-app", ApplicationManager.NoFlag)
@@ -335,7 +339,7 @@ Row {
335
339
336 var dialog = findChild(root, "infoPopup")
340 var dialog = findChild(root, "infoPopup")
337 var button = findChild(dialog, "infoPopupOkButton")
341 var button = findChild(dialog, "infoPopupOkButton")
338− mouseClick(button, units.gu(1), units.gu(1))
342+ tap(button)
339 tryCompareFunction(function() {return findChild(root, "infoPopup")}, null)
343 tryCompareFunction(function() {return findChild(root, "infoPopup")}, null)
340
344
341 tryCompare(resetSpy, "count", 0)
345 tryCompare(resetSpy, "count", 0)
tests/utils/modules/Unity/Test/UnityTestCase.qml+9
@@ -321,7 +321,16 @@ TestCase {
321 event.commit()
321 event.commit()
322 }
322 }
323
323
324+ /*! \brief Tap the item with a touch event.
325+
326+ \param item The item to be tapped
327+ \param x The x coordinate of the tap, defaults to horizontal center
328+ \param y The y coordinate of the tap, defaults to vertical center
329+ */
324 function tap(item, x, y) {
330 function tap(item, x, y) {
331+ if (typeof x !== "number") x = item.width / 2;
332+ if (typeof y !== "number") y = item.height / 2;
333+
325 var root = fetchRootItem(item)
334 var root = fetchRootItem(item)
326 var rootPoint = item.mapToItem(root, x, y)
335 var rootPoint = item.mapToItem(root, x, y)
327
336