on xenial help sign in
Started to add SwipeToAct-checks to notification's qml-tests.
commit20ff88a6a9786973e368dfb1c9ce8f3d625d2f19 authorMirco Müller <mirco.mueller@canonical.com> dateTue 21 Oct 2014, 15:21 (12 years ago) parent0c162fc
1 file changed+501−436
tests/qmltests/Notifications/tst_Notifications.qml+501−436
tests/qmltests/Notifications/tst_Notifications.qml+501−436
@@ -23,505 +23,570 @@ import Unity.Test 0.1
2323import Unity.Notifications 1.0
2424import QtMultimedia 5.0
2525
26−Row {
27− id: rootRow
26+Item {
27+ width: notificationsRect.width + interactiveControls.width
28+ height: notificationsRect.height
2829
29− Component {
30− id: mockNotification
30+ Row {
31+ id: rootRow
3132
32− QtObject {
33− function invokeAction(actionId) {
34− mockModel.actionInvoked(actionId)
33+ Component {
34+ id: mockNotification
35+
36+ QtObject {
37+ function invokeAction(actionId) {
38+ mockModel.actionInvoked(actionId)
39+ }
3540 }
3641 }
37− }
3842
39− ListModel {
40− id: mockModel
43+ ListModel {
44+ id: mockModel
4145
42− signal actionInvoked(string actionId)
46+ signal actionInvoked(string actionId)
4347
44− function getRaw(id) {
45− return mockNotification.createObject(mockModel)
46− }
47−
48− // add the default/PlaceHolder notification to the model
49− Component.onCompleted: {
50− var n = {
51− type: Notification.PlaceHolder,
52− hints: {},
53− summary: "",
54− body: "",
55− icon: "",
56− secondaryIcon: "",
57− actions: []
48+ function getRaw(id) {
49+ return mockNotification.createObject(mockModel)
5850 }
5951
60− append(n)
61− }
62− }
52+ // add the default/PlaceHolder notification to the model
53+ Component.onCompleted: {
54+ var n = {
55+ type: Notification.PlaceHolder,
56+ hints: {},
57+ summary: "",
58+ body: "",
59+ icon: "",
60+ secondaryIcon: "",
61+ actions: []
62+ }
6363
64− function addSnapDecisionNotification() {
65− var n = {
66− type: Notification.SnapDecision,
67− hints: {"x-canonical-private-affirmative-tint": "true"},
68− summary: "Tom Ato",
69− body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
70− icon: "../graphics/avatars/funky.png",
71− secondaryIcon: "../graphics/applicationIcons/facebook.png",
72− actions: [{ id: "ok_id", label: "Ok"},
73− { id: "cancel_id", label: "Cancel"},
74− { id: "notreally_id", label: "Not really"},
75− { id: "noway_id", label: "messages:No way"},
76− { id: "nada_id", label: "messages:Nada"}]
64+ append(n)
65+ }
7766 }
7867
79− mockModel.append(n)
80− }
68+ function addSnapDecisionNotification() {
69+ var n = {
70+ type: Notification.SnapDecision,
71+ hints: {"x-canonical-private-affirmative-tint": "true"},
72+ summary: "Tom Ato",
73+ body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
74+ icon: "../graphics/avatars/funky.png",
75+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
76+ actions: [{ id: "ok_id", label: "Ok"},
77+ { id: "cancel_id", label: "Cancel"},
78+ { id: "notreally_id", label: "Not really"},
79+ { id: "noway_id", label: "messages:No way"},
80+ { id: "nada_id", label: "messages:Nada"}]
81+ }
8182
82− function add2over1SnapDecisionNotification() {
83− var n = {
84− type: Notification.SnapDecision,
85− hints: {"x-canonical-private-affirmative-tint": "true",},
86− summary: "Theatre at Ferria Stadium",
87− body: "at Ferria Stadium in Bilbao, Spain\n07578545317",
88− icon: "",
89− secondaryIcon: "",
90− actions: [{ id: "ok_id", label: "Ok"},
91− { id: "snooze_id", label: "Snooze"},
92− { id: "view_id", label: "View"}]
83+ mockModel.append(n)
9384 }
9485
95− mockModel.append(n)
96− }
86+ function addSwipeToActNotification() {
87+ var n = {
88+ type: Notification.SnapDecision,
89+ hints: {"x-canonical-snap-decisions-swipe": "true"},
90+ summary: "Incoming call",
91+ body: "Frank Zappa\n+44 (0)7736 027340",
92+ icon: "../graphics/avatars/amanda.png",
93+ secondaryIcon: "incoming-call",
94+ actions: [{ id: "ok_id", label: "Ok"},
95+ { id: "cancel_id", label: "Cancel"}]
96+ }
9797
98− function addEphemeralNotification() {
99− var n = {
100− type: Notification.Ephemeral,
101− summary: "Cole Raby",
102− body: "I did not expect it to be that late.",
103− icon: "../graphics/avatars/amanda.png",
104− secondaryIcon: "../graphics/applicationIcons/facebook.png",
105− actions: []
98+ mockModel.append(n)
10699 }
107100
108− mockModel.append(n)
109− }
101+ function add2over1SnapDecisionNotification() {
102+ var n = {
103+ type: Notification.SnapDecision,
104+ hints: {"x-canonical-private-affirmative-tint": "true"},
105+ summary: "Theatre at Ferria Stadium",
106+ body: "at Ferria Stadium in Bilbao, Spain\n07578545317",
107+ icon: "",
108+ secondaryIcon: "",
109+ actions: [{ id: "ok_id", label: "Ok"},
110+ { id: "snooze_id", label: "Snooze"},
111+ { id: "view_id", label: "View"}]
112+ }
110113
111− function addEphemeralNonShapedIconNotification() {
112− var n = {
113− type: Notification.Ephemeral,
114− hints: {"x-canonical-non-shaped-icon": "true"},
115− summary: "Contacts",
116− body: "Synchronised contacts-database with cloud-storage.",
117− icon: "../graphics/applicationIcons/contacts-app.png",
118− secondaryIcon: "",
119− actions: []
114+ mockModel.append(n)
120115 }
121116
122− mockModel.append(n)
123− }
117+ function addEphemeralNotification() {
118+ var n = {
119+ type: Notification.Ephemeral,
120+ summary: "Cole Raby",
121+ body: "I did not expect it to be that late.",
122+ icon: "../graphics/avatars/amanda.png",
123+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
124+ actions: []
125+ }
124126
125− function addEphemeralIconSummaryNotification() {
126− var n = {
127− type: Notification.Ephemeral,
128− summary: "Photo upload completed",
129− body: "",
130− icon: "",
131− secondaryIcon: "../graphics/applicationIcons/facebook.png",
132− actions: []
127+ mockModel.append(n)
133128 }
134129
135− mockModel.append(n)
136− }
130+ function addEphemeralNonShapedIconNotification() {
131+ var n = {
132+ type: Notification.Ephemeral,
133+ hints: {"x-canonical-non-shaped-icon": "true"},
134+ summary: "Contacts",
135+ body: "Synchronised contacts-database with cloud-storage.",
136+ icon: "../graphics/applicationIcons/contacts-app.png",
137+ secondaryIcon: "",
138+ actions: []
139+ }
137140
138− function addInteractiveNotification() {
139− var n = {
140− type: Notification.Interactive,
141− summary: "Interactive notification",
142− body: "This is a notification that can be clicked",
143− icon: "../graphics/avatars/anna_olsson.png",
144− secondaryIcon: "",
145− actions: [{ id: "reply_id", label: "Dummy"}],
141+ mockModel.append(n)
146142 }
147143
148− mockModel.append(n)
149− }
150−
151− function clearNotifications() {
152− mockModel.clear()
153− }
154−
155− function remove1stNotification() {
156− if (mockModel.count > 0)
157− mockModel.remove(0)
158− }
159−
160− Rectangle {
161− id: notificationsRect
144+ function addEphemeralIconSummaryNotification() {
145+ var n = {
146+ type: Notification.Ephemeral,
147+ summary: "Photo upload completed",
148+ body: "",
149+ icon: "",
150+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
151+ actions: []
152+ }
162153
163− width: units.gu(40)
164− height: units.gu(71)
154+ mockModel.append(n)
155+ }
165156
166− MouseArea{
167− id: clickThroughCatcher
157+ function addInteractiveNotification() {
158+ var n = {
159+ type: Notification.Interactive,
160+ summary: "Interactive notification",
161+ body: "This is a notification that can be clicked",
162+ icon: "../graphics/avatars/anna_olsson.png",
163+ secondaryIcon: "",
164+ actions: [{ id: "reply_id", label: "Dummy"}],
165+ }
168166
169− anchors.fill: parent
167+ mockModel.append(n)
170168 }
171169
172− Notifications {
173− id: notifications
174−
175− margin: units.gu(1)
170+ function clearNotifications() {
171+ mockModel.clear()
172+ }
176173
177− anchors.fill: parent
178− model: mockModel
174+ function remove1stNotification() {
175+ if (mockModel.count > 0)
176+ mockModel.remove(0)
179177 }
180− }
181178
182− Rectangle {
183− id: interactiveControls
179+ Rectangle {
180+ id: notificationsRect
184181
185− width: units.gu(30)
186− height: units.gu(81)
187− color: "grey"
182+ width: units.gu(40)
183+ height: units.gu(71)
188184
189− Column {
190− spacing: units.gu(1)
191− anchors.fill: parent
192− anchors.margins: units.gu(1)
185+ MouseArea{
186+ id: clickThroughCatcher
193187
194− Button {
195− width: parent.width
196− text: "add a snap-decision"
197− onClicked: addSnapDecisionNotification()
188+ anchors.fill: parent
198189 }
199190
200− Button {
201− width: parent.width
202− text: "add a 2over1 snap-decision"
203− onClicked: add2over1SnapDecisionNotification()
204− }
191+ Notifications {
192+ id: notifications
205193
206− Button {
207− width: parent.width
208− text: "add an ephemeral"
209− onClicked: addEphemeralNotification()
210− }
194+ margin: units.gu(1)
211195
212− Button {
213− width: parent.width
214− text: "add an non-shaped-icon-summary-body"
215− onClicked: addEphemeralNonShapedIconNotification()
196+ anchors.fill: parent
197+ model: mockModel
216198 }
199+ }
217200
218− Button {
219− width: parent.width
220− text: "add an icon-summary"
221− onClicked: addEphemeralIconSummaryNotification()
222− }
201+ Rectangle {
202+ id: interactiveControls
223203
224− Button {
225− width: parent.width
226− text: "add an interactive"
227− onClicked: addInteractiveNotification()
228− }
204+ width: units.gu(30)
205+ height: units.gu(81)
206+ color: "grey"
229207
230− Button {
231− width: parent.width
232− text: "remove 1st notification"
233− onClicked: remove1stNotification()
234− }
208+ Column {
209+ spacing: units.gu(1)
210+ anchors.fill: parent
211+ anchors.margins: units.gu(1)
235212
236− Button {
237− width: parent.width
238− text: "clear model"
239− onClicked: clearNotifications()
240− }
241− }
242− }
213+ Button {
214+ width: parent.width
215+ text: "add a snap-decision"
216+ onClicked: rootRow.addSnapDecisionNotification()
217+ }
243218
244− UnityTestCase {
245− id: root
246− name: "NotificationRendererTest"
247− when: windowShown
219+ Button {
220+ width: parent.width
221+ text: "add a SwipeToAct snap-decision"
222+ onClicked: rootRow.addSwipeToActNotification()
223+ }
248224
249− function test_NotificationRenderer_data() {
250− return [
251− {
252− tag: "Snap Decision with secondary icon and button-tint",
253− type: Notification.SnapDecision,
254− hints: {"x-canonical-private-affirmative-tint": "true"},
255− summary: "Tom Ato",
256− body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
257− icon: "../graphics/avatars/funky.png",
258− secondaryIcon: "../graphics/applicationIcons/facebook.png",
259− actions: [{ id: "ok_id", label: "Ok"},
260− { id: "cancel_id", label: "Cancel"},
261− { id: "notreally_id", label: "Not really"},
262− { id: "noway_id", label: "messages:No way"},
263− { id: "nada_id", label: "messages:Nada"}],
264− summaryVisible: true,
265− bodyVisible: true,
266− iconVisible: true,
267− shapedIcon: true,
268− nonShapedIcon: false,
269− secondaryIconVisible: true,
270− buttonRowVisible: true,
271− buttonTinted: true,
272− hasSound: false
273− },
274− {
275− tag: "2-over-1 Snap Decision with button-tint",
276− type: Notification.SnapDecision,
277− hints: {"x-canonical-private-affirmative-tint": "true"},
278− summary: "Theatre at Ferria Stadium",
279− body: "at Ferria Stadium in Bilbao, Spain\n07578545317",
280− icon: "",
281− secondaryIcon: "",
282− actions: [{ id: "ok_id", label: "Ok"},
283− { id: "snooze_id", label: "Snooze"},
284− { id: "view_id", label: "View"}],
285− summaryVisible: true,
286− bodyVisible: true,
287− iconVisible: false,
288− shapedIcon: false,
289− nonShapedIcon: false,
290− secondaryIconVisible: false,
291− buttonRowVisible: false,
292− buttonTinted: true,
293− hasSound: false
294− },
295− {
296− tag: "Ephemeral notification - icon-summary layout",
297− type: Notification.Ephemeral,
298− hints: {"x-canonical-private-affirmative-tint": "false"},
299− summary: "Photo upload completed",
300− body: "",
301− icon: "",
302− secondaryIcon: "../graphics/applicationIcons/facebook.png",
303− actions: [],
304− summaryVisible: true,
305− bodyVisible: false,
306− iconVisible: false,
307− shapedIcon: false,
308− nonShapedIcon: false,
309− secondaryIconVisible: true,
310− buttonRowVisible: false,
311− buttonTinted: false,
312− hasSound: false
313− },
314− {
315− tag: "Ephemeral notification - check suppression of secondary icon for icon-summary layout",
316− type: Notification.Ephemeral,
317− hints: {"x-canonical-private-affirmative-tint": "false",
318− "sound-file": "dummy.ogg",
319− "suppress-sound": "true"},
320− summary: "New comment successfully published",
321− body: "",
322− icon: "",
323− secondaryIcon: "../graphics/applicationIcons/facebook.png",
324− actions: [],
325− summaryVisible: true,
326− bodyVisible: false,
327− interactiveAreaEnabled: false,
328− iconVisible: false,
329− shapedIcon: false,
330− nonShapedIcon: false,
331− secondaryIconVisible: true,
332− buttonRowVisible: false,
333− buttonTinted: false,
334− hasSound: false
335− },
336− {
337− tag: "Interactive notification",
338− type: Notification.Interactive,
339− hints: {"x-canonical-private-affirmative-tint": "false",
340− "sound-file": "dummy.ogg"},
341− summary: "Interactive notification",
342− body: "This is a notification that can be clicked",
343− icon: "../graphics/avatars/amanda.png",
344− secondaryIcon: "",
345− actions: [{ id: "reply_id", label: "Dummy"}],
346− summaryVisible: true,
347− bodyVisible: true,
348− iconVisible: true,
349− shapedIcon: true,
350− nonShapedIcon: false,
351− secondaryIconVisible: false,
352− buttonRowVisible: false,
353− buttonTinted: false,
354− hasSound: true
355− },
356− {
357− tag: "Snap Decision without secondary icon and no button-tint",
358− type: Notification.SnapDecision,
359− hints: {"x-canonical-private-affirmative-tint": "false",
360− "sound-file": "dummy.ogg"},
361− summary: "Bro Coly",
362− body: "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.",
363− icon: "../graphics/avatars/anna_olsson.png",
364− secondaryIcon: "",
365− actions: [{ id: "accept_id", label: "Accept"},
366− { id: "reject_id", label: "Reject"}],
367− summaryVisible: true,
368− bodyVisible: true,
369− iconVisible: true,
370− shapedIcon: true,
371− nonShapedIcon: false,
372− secondaryIconVisible: false,
373− buttonRowVisible: true,
374− buttonTinted: false,
375− hasSound: true
376− },
377− {
378− tag: "Ephemeral notification",
379− type: Notification.Ephemeral,
380− hints: {"x-canonical-private-affirmative-tint": "false",
381− "sound-file": "dummy.ogg"},
382− summary: "Cole Raby",
383− body: "I did not expect it to be that late.",
384− icon: "../graphics/avatars/funky.png",
385− secondaryIcon: "../graphics/applicationIcons/facebook.png",
386− actions: [],
387− summaryVisible: true,
388− bodyVisible: true,
389− iconVisible: true,
390− shapedIcon: true,
391− nonShapedIcon: false,
392− secondaryIconVisible: true,
393− buttonRowVisible: false,
394− buttonTinted: false,
395− hasSound: true
396− },
397− {
398− tag: "Ephemeral notification with non-shaped icon",
399− type: Notification.Ephemeral,
400− hints: {"x-canonical-private-affirmative-tint": "false",
401− "x-canonical-non-shaped-icon": "true"},
402− summary: "Contacts",
403− body: "Synchronised contacts-database with cloud-storage.",
404− icon: "../graphics/applicationIcons/contacts-app.png",
405− secondaryIcon: "",
406− actions: [],
407− summaryVisible: true,
408− bodyVisible: true,
409− iconVisible: true,
410− shapedIcon: false,
411− nonShapedIcon: true,
412− secondaryIconVisible: false,
413− buttonRowVisible: false,
414− buttonTinted: false,
415− hasSound: false
416− }
417− ]
418− }
225+ Button {
226+ width: parent.width
227+ text: "add a 2over1 snap-decision"
228+ onClicked: rootRow.add2over1SnapDecisionNotification()
229+ }
419230
420− SignalSpy {
421− id: clickThroughSpy
231+ Button {
232+ width: parent.width
233+ text: "add an ephemeral"
234+ onClicked: rootRow.addEphemeralNotification()
235+ }
422236
423− target: clickThroughCatcher
424− signalName: "clicked"
425− }
237+ Button {
238+ width: parent.width
239+ text: "add an non-shaped-icon-summary-body"
240+ onClicked: rootRow.addEphemeralNonShapedIconNotification()
241+ }
426242
427− SignalSpy {
428− id: actionSpy
243+ Button {
244+ width: parent.width
245+ text: "add an icon-summary"
246+ onClicked: rootRow.addEphemeralIconSummaryNotification()
247+ }
429248
430− target: mockModel
431− signalName: "actionInvoked"
432− }
249+ Button {
250+ width: parent.width
251+ text: "add an interactive"
252+ onClicked: rootRow.addInteractiveNotification()
253+ }
433254
434− function cleanup() {
435− clickThroughSpy.clear()
436− actionSpy.clear()
437− }
255+ Button {
256+ width: parent.width
257+ text: "remove 1st notification"
258+ onClicked: rootRow.remove1stNotification()
259+ }
438260
439− function test_NotificationRenderer(data) {
440− // populate model with some mock notifications
441− mockModel.append(data)
442−
443− // make sure the view is properly updated before going on
444− notifications.forceLayout();
445− waitForRendering(notifications);
446−
447− var notification = findChild(notifications, "notification" + (mockModel.count - 1))
448− verify(notification !== undefined, "notification wasn't found");
449−
450− waitForRendering(notification);
451−
452− var icon = findChild(notification, "icon")
453− var shapedIcon = findChild(notification, "shapedIcon")
454− var nonShapedIcon = findChild(notification, "nonShapedIcon")
455− var interactiveArea = findChild(notification, "interactiveArea")
456− var secondaryIcon = findChild(notification, "secondaryIcon")
457− var summaryLabel = findChild(notification, "summaryLabel")
458− var bodyLabel = findChild(notification, "bodyLabel")
459− var buttonRow = findChild(notification, "buttonRow")
460−
461− compare(icon.visible, data.iconVisible, "avatar-icon visibility is incorrect")
462− compare(shapedIcon.visible, data.shapedIcon, "shaped-icon visibility is incorrect")
463− compare(nonShapedIcon.visible, data.nonShapedIcon, "non-shaped-icon visibility is incorrect")
464−
465− // test input does not fall through
466− mouseClick(notification, notification.width / 2, notification.height / 2)
467− if(data.type == Notification.Interactive) {
468− actionSpy.wait()
469− compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id for interactive action")
261+ Button {
262+ width: parent.width
263+ text: "clear model"
264+ onClicked: rootRow.clearNotifications()
265+ }
470266 }
471− compare(clickThroughSpy.count, 0, "click on notification fell through")
267+ }
472268
473− compare(secondaryIcon.visible, data.secondaryIconVisible, "secondary-icon visibility is incorrect")
474− compare(summaryLabel.visible, data.summaryVisible, "summary-text visibility is incorrect")
475− compare(bodyLabel.visible, data.bodyVisible, "body-text visibility is incorrect")
476− compare(buttonRow.visible, data.buttonRowVisible, "button visibility is incorrect")
269+ UnityTestCase {
270+ id: root
271+ name: "NotificationRendererTest"
272+ when: windowShown
273+
274+ function test_NotificationRenderer_data() {
275+ return [
276+ {
277+ tag: "Snap Decision with secondary icon and button-tint",
278+ type: Notification.SnapDecision,
279+ hints: {"x-canonical-private-affirmative-tint": "true"},
280+ summary: "Tom Ato",
281+ body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
282+ icon: "../graphics/avatars/funky.png",
283+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
284+ actions: [{ id: "ok_id", label: "Ok"},
285+ { id: "cancel_id", label: "Cancel"},
286+ { id: "notreally_id", label: "Not really"},
287+ { id: "noway_id", label: "messages:No way"},
288+ { id: "nada_id", label: "messages:Nada"}],
289+ summaryVisible: true,
290+ bodyVisible: true,
291+ iconVisible: true,
292+ shapedIcon: true,
293+ nonShapedIcon: false,
294+ secondaryIconVisible: true,
295+ buttonRowVisible: true,
296+ buttonTinted: true,
297+ hasSound: false,
298+ hasSwipeToAct: false
299+ },
300+ {
301+ tag: "Snap Decision with SwipeToAct-widget",
302+ type: Notification.SnapDecision,
303+ hints: {"x-canonical-snap-decisions-swipe": "true"},
304+ summary: "Incoming call",
305+ body: "Frank Zappa\n+44 (0)7736 027340",
306+ icon: "../graphics/avatars/amanda.png",
307+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
308+ actions: [{ id: "ok_id", label: "Ok"},
309+ { id: "cancel_id", label: "Cancel"}],
310+ summaryVisible: true,
311+ bodyVisible: true,
312+ iconVisible: true,
313+ shapedIcon: true,
314+ nonShapedIcon: false,
315+ secondaryIconVisible: true,
316+ buttonRowVisible: true,
317+ buttonTinted: false,
318+ hasSound: false,
319+ hasSwipeToAct: true
320+ },
321+ {
322+ tag: "2-over-1 Snap Decision with button-tint",
323+ type: Notification.SnapDecision,
324+ hints: {"x-canonical-private-affirmative-tint": "true"},
325+ summary: "Theatre at Ferria Stadium",
326+ body: "at Ferria Stadium in Bilbao, Spain\n07578545317",
327+ icon: "",
328+ secondaryIcon: "",
329+ actions: [{ id: "ok_id", label: "Ok"},
330+ { id: "snooze_id", label: "Snooze"},
331+ { id: "view_id", label: "View"}],
332+ summaryVisible: true,
333+ bodyVisible: true,
334+ iconVisible: false,
335+ shapedIcon: false,
336+ nonShapedIcon: false,
337+ secondaryIconVisible: false,
338+ buttonRowVisible: false,
339+ buttonTinted: true,
340+ hasSound: false,
341+ hasSwipeToAct: false
342+ },
343+ {
344+ tag: "Ephemeral notification - icon-summary layout",
345+ type: Notification.Ephemeral,
346+ hints: {"x-canonical-private-affirmative-tint": "false"},
347+ summary: "Photo upload completed",
348+ body: "",
349+ icon: "",
350+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
351+ actions: [],
352+ summaryVisible: true,
353+ bodyVisible: false,
354+ iconVisible: false,
355+ shapedIcon: false,
356+ nonShapedIcon: false,
357+ secondaryIconVisible: true,
358+ buttonRowVisible: false,
359+ buttonTinted: false,
360+ hasSound: false,
361+ hasSwipeToAct: false
362+ },
363+ {
364+ tag: "Ephemeral notification - check suppression of secondary icon for icon-summary layout",
365+ type: Notification.Ephemeral,
366+ hints: {"x-canonical-private-affirmative-tint": "false",
367+ "sound-file": "dummy.ogg",
368+ "suppress-sound": "true"},
369+ summary: "New comment successfully published",
370+ body: "",
371+ icon: "",
372+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
373+ actions: [],
374+ summaryVisible: true,
375+ bodyVisible: false,
376+ interactiveAreaEnabled: false,
377+ iconVisible: false,
378+ shapedIcon: false,
379+ nonShapedIcon: false,
380+ secondaryIconVisible: true,
381+ buttonRowVisible: false,
382+ buttonTinted: false,
383+ hasSound: false,
384+ hasSwipeToAct: false
385+ },
386+ {
387+ tag: "Interactive notification",
388+ type: Notification.Interactive,
389+ hints: {"x-canonical-private-affirmative-tint": "false",
390+ "sound-file": "dummy.ogg"},
391+ summary: "Interactive notification",
392+ body: "This is a notification that can be clicked",
393+ icon: "../graphics/avatars/amanda.png",
394+ secondaryIcon: "",
395+ actions: [{ id: "reply_id", label: "Dummy"}],
396+ summaryVisible: true,
397+ bodyVisible: true,
398+ iconVisible: true,
399+ shapedIcon: true,
400+ nonShapedIcon: false,
401+ secondaryIconVisible: false,
402+ buttonRowVisible: false,
403+ buttonTinted: false,
404+ hasSound: true,
405+ hasSwipeToAct: false
406+ },
407+ {
408+ tag: "Snap Decision without secondary icon and no button-tint",
409+ type: Notification.SnapDecision,
410+ hints: {"x-canonical-private-affirmative-tint": "false",
411+ "sound-file": "dummy.ogg"},
412+ summary: "Bro Coly",
413+ body: "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.",
414+ icon: "../graphics/avatars/anna_olsson.png",
415+ secondaryIcon: "",
416+ actions: [{ id: "accept_id", label: "Accept"},
417+ { id: "reject_id", label: "Reject"}],
418+ summaryVisible: true,
419+ bodyVisible: true,
420+ iconVisible: true,
421+ shapedIcon: true,
422+ nonShapedIcon: false,
423+ secondaryIconVisible: false,
424+ buttonRowVisible: true,
425+ buttonTinted: false,
426+ hasSound: true,
427+ hasSwipeToAct: false
428+ },
429+ {
430+ tag: "Ephemeral notification",
431+ type: Notification.Ephemeral,
432+ hints: {"x-canonical-private-affirmative-tint": "false",
433+ "sound-file": "dummy.ogg"},
434+ summary: "Cole Raby",
435+ body: "I did not expect it to be that late.",
436+ icon: "../graphics/avatars/funky.png",
437+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
438+ actions: [],
439+ summaryVisible: true,
440+ bodyVisible: true,
441+ iconVisible: true,
442+ shapedIcon: true,
443+ nonShapedIcon: false,
444+ secondaryIconVisible: true,
445+ buttonRowVisible: false,
446+ buttonTinted: false,
447+ hasSound: true,
448+ hasSwipeToAct: false
449+ },
450+ {
451+ tag: "Ephemeral notification with non-shaped icon",
452+ type: Notification.Ephemeral,
453+ hints: {"x-canonical-private-affirmative-tint": "false",
454+ "x-canonical-non-shaped-icon": "true"},
455+ summary: "Contacts",
456+ body: "Synchronised contacts-database with cloud-storage.",
457+ icon: "../graphics/applicationIcons/contacts-app.png",
458+ secondaryIcon: "",
459+ actions: [],
460+ summaryVisible: true,
461+ bodyVisible: true,
462+ iconVisible: true,
463+ shapedIcon: false,
464+ nonShapedIcon: true,
465+ secondaryIconVisible: false,
466+ buttonRowVisible: false,
467+ buttonTinted: false,
468+ hasSound: false,
469+ hasSwipeToAct: false
470+ }
471+ ]
472+ }
477473
478− var audioItem = findInvisibleChild(notification, "sound")
479− compare(audioItem.playbackState, data.hasSound ? Audio.PlayingState : Audio.StoppedState, "Audio has wrong state")
474+ SignalSpy {
475+ id: clickThroughSpy
480476
481− if(data.buttonRowVisible) {
482− var buttonCancel = findChild(buttonRow, "notify_button1")
483− var buttonAccept = findChild(buttonRow, "notify_button0")
477+ target: clickThroughCatcher
478+ signalName: "clicked"
479+ }
484480
485− // only test the left/cancel-button if two actions have been passed in
486− if (data.actions.length == 2) {
487− tryCompareFunction(function() { mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2); return actionSpy.signalArguments.length > 0; }, true);
488− compare(actionSpy.signalArguments[0][0], data.actions[1]["id"], "got wrong id for negative action")
489− actionSpy.clear()
490− }
481+ SignalSpy {
482+ id: actionSpy
491483
492− // check the tinting of the positive/right button
493− verify(buttonAccept.color === data.buttonTinted ? "#3fb24f" : "#dddddd", "button has the wrong color-tint")
484+ target: mockModel
485+ signalName: "actionInvoked"
486+ }
494487
495− // click the positive/right button
496− tryCompareFunction(function() { mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2); return actionSpy.signalArguments.length > 0; }, true);
497− compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id positive action")
488+ function cleanup() {
489+ clickThroughSpy.clear()
498490 actionSpy.clear()
499− waitForRendering(notification)
500−
501− // check if there's a ComboButton created due to more actions being passed
502− if (data.actions.length > 2) {
503− var comboButton = findChild(notification, "notify_button2")
504− tryCompareFunction(function() { return comboButton.expanded == false; }, true);
505−
506− // click to expand
507− tryCompareFunction(function() { mouseClick(comboButton, comboButton.width - comboButton.__styleInstance.dropDownWidth / 2, comboButton.height / 2); return comboButton.expanded == true; }, true);
508−
509− // try clicking on choices in expanded comboList
510− var choiceButton1 = findChild(notification, "notify_button3")
511− tryCompareFunction(function() { mouseClick(choiceButton1, choiceButton1.width / 2, choiceButton1.height / 2); return actionSpy.signalArguments.length > 0; }, true);
512− compare(actionSpy.signalArguments[0][0], data.actions[3]["id"], "got wrong id choice action 1")
513− actionSpy.clear()
514−
515− var choiceButton2 = findChild(notification, "notify_button4")
516− tryCompareFunction(function() { mouseClick(choiceButton2, choiceButton2.width / 2, choiceButton2.height / 2); return actionSpy.signalArguments.length > 0; }, true);
517− compare(actionSpy.signalArguments[0][0], data.actions[4]["id"], "got wrong id choice action 2")
518− actionSpy.clear()
519−
520− // click to collapse
521− //tryCompareFunction(function() { mouseClick(comboButton, comboButton.width - comboButton.__styleInstance.dropDownWidth / 2, comboButton.height / 2); return comboButton.expanded == false; }, true);
522− } else {
523− mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2)
524− compare(actionSpy.signalArguments[0][0], data.actions[1]["id"], "got wrong id for negative action")
491+ }
492+
493+ function test_NotificationRenderer(data) {
494+ // populate model with some mock notifications
495+ mockModel.append(data)
496+
497+ // make sure the view is properly updated before going on
498+ notifications.forceLayout();
499+ waitForRendering(notifications);
500+
501+ var notification = findChild(notifications, "notification" + (mockModel.count - 1))
502+ verify(notification !== undefined, "notification wasn't found");
503+
504+ waitForRendering(notification);
505+
506+ var icon = findChild(notification, "icon")
507+ var shapedIcon = findChild(notification, "shapedIcon")
508+ var nonShapedIcon = findChild(notification, "nonShapedIcon")
509+ var interactiveArea = findChild(notification, "interactiveArea")
510+ var secondaryIcon = findChild(notification, "secondaryIcon")
511+ var summaryLabel = findChild(notification, "summaryLabel")
512+ var bodyLabel = findChild(notification, "bodyLabel")
513+ var buttonRow = findChild(notification, "buttonRow")
514+
515+ compare(icon.visible, data.iconVisible, "avatar-icon visibility is incorrect")
516+ compare(shapedIcon.visible, data.shapedIcon, "shaped-icon visibility is incorrect")
517+ compare(nonShapedIcon.visible, data.nonShapedIcon, "non-shaped-icon visibility is incorrect")
518+
519+ // test input does not fall through
520+ mouseClick(notification, notification.width / 2, notification.height / 2)
521+ if(data.type == Notification.Interactive) {
522+ actionSpy.wait()
523+ compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id for interactive action")
524+ }
525+ compare(clickThroughSpy.count, 0, "click on notification fell through")
526+
527+ compare(secondaryIcon.visible, data.secondaryIconVisible, "secondary-icon visibility is incorrect")
528+ compare(summaryLabel.visible, data.summaryVisible, "summary-text visibility is incorrect")
529+ compare(bodyLabel.visible, data.bodyVisible, "body-text visibility is incorrect")
530+ compare(buttonRow.visible, data.buttonRowVisible, "button visibility is incorrect")
531+
532+ var audioItem = findInvisibleChild(notification, "sound")
533+ compare(audioItem.playbackState, data.hasSound ? Audio.PlayingState : Audio.StoppedState, "Audio has wrong state")
534+
535+ if(data.buttonRowVisible) {
536+ if(data.hasSwipeToAct) {
537+ var swipeButton = findChild(buttonRow, "notify_swipe_button")
538+ var slider = findChild(swipeButton, "slider")
539+ var x = slider.x + slider.width / 2
540+ var y = slider.y + slider.height / 2
541+ mousePress(slider, x, y)
542+ mouseMove(slider, x + units.gu(15), y)
543+ mouseRelease(slider)
544+ } else {
545+ var buttonCancel = findChild(buttonRow, "notify_button1")
546+ var buttonAccept = findChild(buttonRow, "notify_button0")
547+
548+ // only test the left/cancel-button if two actions have been passed in
549+ if (data.actions.length == 2) {
550+ tryCompareFunction(function() { mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2); return actionSpy.signalArguments.length > 0; }, true);
551+ compare(actionSpy.signalArguments[0][0], data.actions[1]["id"], "got wrong id for negative action")
552+ actionSpy.clear()
553+ }
554+
555+ // check the tinting of the positive/right button
556+ verify(buttonAccept.color === data.buttonTinted ? "#3fb24f" : "#dddddd", "button has the wrong color-tint")
557+
558+ // click the positive/right button
559+ tryCompareFunction(function() { mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2); return actionSpy.signalArguments.length > 0; }, true);
560+ compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id positive action")
561+ actionSpy.clear()
562+ (notification)
563+
564+ // check if there's a ComboButton created due to more actions being passed
565+ if (data.actions.length > 2) {
566+ var comboButton = findChild(notification, "notify_button2")
567+ tryCompareFunction(function() { return comboButton.expanded == false; }, true);
568+
569+ // click to expand
570+ tryCompareFunction(function() { mouseClick(comboButton, comboButton.width - comboButton.__styleInstance.dropDownWidth / 2, comboButton.height / 2); return comboButton.expanded == true; }, true);
571+
572+ // try clicking on choices in expanded comboList
573+ var choiceButton1 = findChild(notification, "notify_button3")
574+ tryCompareFunction(function() { mouseClick(choiceButton1, choiceButton1.width / 2, choiceButton1.height / 2); return actionSpy.signalArguments.length > 0; }, true);
575+ compare(actionSpy.signalArguments[0][0], data.actions[3]["id"], "got wrong id choice action 1")
576+ actionSpy.clear()
577+
578+ var choiceButton2 = findChild(notification, "notify_button4")
579+ tryCompareFunction(function() { mouseClick(choiceButton2, choiceButton2.width / 2, choiceButton2.height / 2); return actionSpy.signalArguments.length > 0; }, true);
580+ compare(actionSpy.signalArguments[0][0], data.actions[4]["id"], "got wrong id choice action 2")
581+ actionSpy.clear()
582+
583+ // click to collapse
584+ //tryCompareFunction(function() { mouseClick(comboButton, comboButton.width - comboButton.__styleInstance.dropDownWidth / 2, comboButton.height / 2); return comboButton.expanded == false; }, true);
585+ } else {
586+ mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2)
587+ compare(actionSpy.signalArguments[0][0], data.actions[1]["id"], "got wrong id for negative action")
588+ }
589+ }
525590 }
526591 }
527592 }