on xenial help sign in
Use a different way to test clicks on buttons and interactive-areas
b7b5af8Mirco Müller
tests/qmltests/Notifications/tst_Notifications.qml+9−4
@@ -29,13 +29,18 @@ Row {
29 id: mockNotification
29 id: mockNotification
30
30
31 QtObject {
31 QtObject {
32− function invokeAction(actionId) { }
32+ function invokeAction(actionId) {
33+ mockModel.actionId = actionId
34+ print ("action-id: ", actionId)
35+ }
33 }
36 }
34 }
37 }
35
38
36 ListModel {
39 ListModel {
37 id: mockModel
40 id: mockModel
38
41
42+ property string actionId
43+
39 function getRaw(id) {
44 function getRaw(id) {
40 return mockNotification.createObject(mockModel)
45 return mockNotification.createObject(mockModel)
41 }
46 }
@@ -319,7 +324,7 @@ Row {
319 actionSpy.target = findChild(notification, "interactiveArea")
324 actionSpy.target = findChild(notification, "interactiveArea")
320 mouseClick(notification, notification.width / 2, notification.height / 2)
325 mouseClick(notification, notification.width / 2, notification.height / 2)
321 actionSpy.wait()
326 actionSpy.wait()
322− compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id for interactive action")
327+ compare(mockModel.actionId, data.actions[0]["id"], "got wrong id for interactive action")
323 compare(clickThroughSpy.count, 0, "click on interactive notification fell through")
328 compare(clickThroughSpy.count, 0, "click on interactive notification fell through")
324 } else {
329 } else {
325 mouseClick(notification, notification.width / 2, notification.height / 2)
330 mouseClick(notification, notification.width / 2, notification.height / 2)
@@ -339,13 +344,13 @@ Row {
339 actionSpy.target = buttonCancel
344 actionSpy.target = buttonCancel
340 mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2)
345 mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2)
341 actionSpy.wait()
346 actionSpy.wait()
342− compare(actionSpy.signalArguments[0][0], data.actions[1]["id"], "got wrong id for negative action")
347+ compare(mockModel.actionId, data.actions[1]["id"], "got wrong id for negative action")
343 actionSpy.clear()
348 actionSpy.clear()
344
349
345 actionSpy.target = buttonAccept
350 actionSpy.target = buttonAccept
346 mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2)
351 mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2)
347 actionSpy.wait()
352 actionSpy.wait()
348− compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id positive action")
353+ compare(mockModel.actionId, data.actions[0]["id"], "got wrong id positive action")
349 }
354 }
350 }
355 }
351 }
356 }