on xenial help sign in
Use signal instead of property for clicked-action test, be more verbose with the model-name, try to reuse the repeater element for the interactive notification
commit973af86281e238dea8b63187156e7cda72123ea7 authorMirco Müller <mirco.mueller@ubuntu.com> dateWed 19 Jun 2013, 17:15 (13 years ago) parent2bfccfb
3 files changed+12−21
Notifications/Notification.qml+1−10 Shell.qml+2−2 tests/qmltests/Notifications/tst_Notifications.qml+9−9
Notifications/Notification.qml+1−10
@@ -37,16 +37,6 @@ UbuntuShape {
3737 MouseArea {
3838 id: interactiveArea
3939
40− Repeater {
41− id: actionRepeater
42−
43− model: notification.actions
44−
45− delegate: Item {
46− property string actionId: model.id
47− }
48− }
49−
5040 anchors.fill: contentColumn
5141 objectName: "interactiveArea"
5242 enabled: notification.type == Notification.Interactive
@@ -148,6 +138,7 @@ UbuntuShape {
148138 }
149139
150140 Repeater {
141+ id: actionRepeater
151142 model: notification.actions
152143
153144 Button {
Shell.qml+2−2
@@ -28,7 +28,7 @@ import "Components/Math.js" as MathLocal
2828import "Bottombar"
2929import "SideStage"
3030import "Notifications"
31−import Unity.Notifications 1.0
31+import Unity.Notifications 1.0 as Notifications
3232
3333FocusScope {
3434 id: shell
@@ -177,7 +177,7 @@ FocusScope {
177177 Notifications {
178178 id: notifications
179179
180− model: Model
180+ model: Notifications.Model
181181 anchors {
182182 fill: parent
183183 leftMargin: units.gu(1)
tests/qmltests/Notifications/tst_Notifications.qml+9−9
@@ -30,7 +30,7 @@ Row {
3030
3131 QtObject {
3232 function invokeAction(actionId) {
33− mockModel.actionId = actionId
33+ mockModel.actionInvoked(actionId)
3434 }
3535 }
3636 }
@@ -38,7 +38,7 @@ Row {
3838 ListModel {
3939 id: mockModel
4040
41− property string actionId
41+ signal actionInvoked(string actionId)
4242
4343 function getRaw(id) {
4444 return mockNotification.createObject(mockModel)
@@ -289,7 +289,9 @@ Row {
289289
290290 SignalSpy {
291291 id: actionSpy
292− signalName: "clicked"
292+
293+ target: mockModel
294+ signalName: "actionInvoked"
293295 }
294296
295297 function cleanup() {
@@ -320,10 +322,9 @@ Row {
320322 compare(interactiveArea.enabled, data.interactiveAreaEnabled, "check for interactive area")
321323
322324 if(data.interactiveAreaEnabled) {
323− actionSpy.target = findChild(notification, "interactiveArea")
324325 mouseClick(notification, notification.width / 2, notification.height / 2)
325326 actionSpy.wait()
326− compare(mockModel.actionId, data.actions[0]["id"], "got wrong id for interactive action")
327+ compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id for interactive action")
327328 compare(clickThroughSpy.count, 0, "click on interactive notification fell through")
328329 } else {
329330 mouseClick(notification, notification.width / 2, notification.height / 2)
@@ -340,16 +341,15 @@ Row {
340341 var buttonAccept = findChild(buttonRow, "button0")
341342
342343 waitForRendering(notification)
343− actionSpy.target = buttonCancel
344344 mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2)
345345 actionSpy.wait()
346− compare(mockModel.actionId, data.actions[1]["id"], "got wrong id for negative action")
346+ compare(actionSpy.signalArguments[0][0], data.actions[1]["id"], "got wrong id for negative action")
347347 actionSpy.clear()
348348
349− actionSpy.target = buttonAccept
350349 mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2)
351350 actionSpy.wait()
352− compare(mockModel.actionId, data.actions[0]["id"], "got wrong id positive action")
351+ compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id positive action")
352+ actionSpy.clear()
353353 }
354354 }
355355 }