24
27
import QtMultimedia 5.0
27
32
width: notificationsRect.width + interactiveControls.width
28
33
height: notificationsRect.height
37
function invokeAction(actionId) {
38
mockModel.actionInvoked(actionId)
47
signal actionInvoked(string actionId)
50
return mockNotification.createObject(mockModel)
53
42
// add the default/PlaceHolder notification to the model
54
43
Component.onCompleted: {
56
type: Notification.PlaceHolder,
44
var component = Qt.createComponent("Notification.qml")
45
var n = component.createObject("notification", {"nid": index++,
46
"type": Notification.PlaceHolder,
53
n.completed.connect(mockModel.onCompleted)
69
58
function add2over1SnapDecisionNotification() {
71
type: Notification.SnapDecision,
72
hints: {"x-canonical-private-affirmative-tint": "true"},
73
summary: "Theatre at Ferria Stadium",
74
body: "at Ferria Stadium in Bilbao, Spain\n07578545317",
77
actions: [{ id: "ok_id", label: "Ok"},
78
{ id: "snooze_id", label: "Snooze"},
79
{ id: "view_id", label: "View"}]
59
var component = Qt.createComponent("Notification.qml")
60
var n = component.createObject("notification", {"nid": index++,
61
"type": Notification.SnapDecision,
62
"hints": {"x-canonical-private-affirmative-tint": "true"},
63
"summary": "Theatre at Ferria Stadium",
64
"body": "at Ferria Stadium in Bilbao, Spain\n07578545317",
67
"rawActions": ["ok_id", "Ok",
68
"snooze_id", "Snooze",
70
n.completed.connect(mockModel.onCompleted)
82
71
mockModel.append(n)
85
74
function addEphemeralNotification() {
87
type: Notification.Ephemeral,
89
body: "I did not expect it to be that late.",
90
icon: "../graphics/avatars/amanda.png",
91
secondaryIcon: "../graphics/applicationIcons/facebook.png",
75
var component = Qt.createComponent("Notification.qml")
76
var n = component.createObject("notification", {"nid": index++,
77
"type": Notification.Ephemeral,
79
"summary": "Cole Raby",
80
"body": "I did not expect it to be that late.",
81
"icon": "../graphics/avatars/amanda.png",
82
"secondaryIcon": "../graphics/applicationIcons/facebook.png",
83
"rawActions": ["reply_id", "Dummy"]})
84
n.completed.connect(mockModel.onCompleted)
95
85
mockModel.append(n)
98
88
function addEphemeralNonShapedIconNotification() {
100
type: Notification.Ephemeral,
101
hints: {"x-canonical-non-shaped-icon": "true"},
103
body: "Synchronised contacts-database with cloud-storage.",
104
icon: "../graphics/applicationIcons/contacts-app.png",
89
var component = Qt.createComponent("Notification.qml")
90
var n = component.createObject("notification", {"nid": index++,
91
"type": Notification.Ephemeral,
92
"hints": {"x-canonical-non-shaped-icon": "true"},
93
"summary": "Contacts",
94
"body": "Synchronised contacts-database with cloud-storage.",
95
"icon": "../graphics/applicationIcons/contacts-app.png",
97
"rawActions": ["reply_id", "Dummy"]})
98
n.completed.connect(mockModel.onCompleted)
109
99
mockModel.append(n)
112
102
function addEphemeralIconSummaryNotification() {
114
type: Notification.Ephemeral,
115
hints: {"x-canonical-non-shaped-icon": "false"},
116
summary: "Photo upload completed",
118
icon: "../graphics/applicationIcons/facebook.png",
103
var component = Qt.createComponent("Notification.qml")
104
var n = component.createObject("notification", {"nid": index++,
105
"type": Notification.Ephemeral,
106
"hints": {"x-canonical-non-shaped-icon": "false"},
107
"summary": "Photo upload completed",
109
"icon": "../graphics/applicationIcons/facebook.png",
111
"rawActions": ["reply_id", "Dummy"]})
112
n.completed.connect(mockModel.onCompleted)
123
113
mockModel.append(n)
126
116
function addInteractiveNotification() {
128
type: Notification.Interactive,
129
summary: "Interactive notification",
130
body: "This is a notification that can be clicked",
131
icon: "../graphics/avatars/anna_olsson.png",
133
actions: [{ id: "reply_id", label: "Dummy"}],
117
var component = Qt.createComponent("Notification.qml")
118
var n = component.createObject("notification", {"nid": index++,
119
"type": Notification.Interactive,
121
"summary": "Interactive notification",
122
"body": "This is a notification that can be clicked",
123
"icon": "../graphics/avatars/anna_olsson.png",
125
"rawActions": ["reply_id", "Dummy"]})
126
n.completed.connect(mockModel.onCompleted)
136
127
mockModel.append(n)
139
130
function addConfirmationNotification() {
141
type: Notification.Confirmation,
142
hints: {"x-canonical-non-shaped-icon": "true"},
143
summary: "Confirmation notification",
145
icon: "image://theme/audio-volume-medium",
131
var component = Qt.createComponent("Notification.qml")
132
var n = component.createObject("notification", {"nid": index++,
133
"type": Notification.Confirmation,
134
"hints": {"x-canonical-non-shaped-icon": "true"},
135
"summary": "Confirmation notification",
137
"icon": "image://theme/audio-volume-medium",
140
"rawActions": ["reply_id", "Dummy"]})
141
n.completed.connect(mockModel.onCompleted)
151
142
mockModel.append(n)
154
145
function add2ndConfirmationNotification() {
156
type: Notification.Confirmation,
157
hints: {"x-canonical-non-shaped-icon": "true",
158
"x-canonical-value-bar-tint": "true"},
159
summary: "Confirmation notification",
161
icon: "image://theme/audio-volume-high",
146
var component = Qt.createComponent("Notification.qml")
147
var n = component.createObject("notification", {"nid": index++,
148
"type": Notification.Confirmation,
149
"hints": {"x-canonical-non-shaped-icon": "true",
150
"x-canonical-value-bar-tint": "true"},
151
"summary": "Confirmation notification",
152
"body": "High Volume",
153
"icon": "image://theme/audio-volume-high",
156
"rawActions": ["reply_id", "Dummy"]})
157
n.completed.connect(mockModel.onCompleted)
167
158
mockModel.append(n)
273
265
name: "NotificationRendererTest"
274
266
when: windowShown
268
property list<Notification> nlist: [
271
type: Notification.Ephemeral
272
summary: "Photo upload completed"
274
icon: "../graphics/applicationIcons/facebook.png"
281
type: Notification.Ephemeral
282
hints: {"x-canonical-private-affirmative-tint": "false",
283
"sound-file": "dummy.ogg",
284
"suppress-sound": "true"}
285
summary: "New comment successfully published"
288
secondaryIcon: "../graphics/applicationIcons/facebook.png"
294
type: Notification.Interactive
295
hints: {"x-canonical-private-affirmative-tint": "false",
296
"sound-file": "dummy.ogg"}
297
summary: "Interactive notification"
298
body: "This is a notification that can be clicked"
299
icon: "../graphics/avatars/amanda.png"
302
rawActions: ["reply_id", "Dummy"]
306
type: Notification.SnapDecision
307
hints: {"x-canonical-private-affirmative-tint": "false",
308
"sound-file": "dummy.ogg"}
310
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."
311
icon: "../graphics/avatars/anna_olsson.png"
314
rawActions: ["accept_id", "Accept",
315
"reject_id", "Reject"]
319
type: Notification.Ephemeral
320
hints: {"x-canonical-private-affirmative-tint": "false",
321
"sound-file": "dummy.ogg"}
323
body: "I did not expect it to be that late."
324
icon: "../graphics/avatars/funky.png"
325
secondaryIcon: "../graphics/applicationIcons/facebook.png"
331
type: Notification.Ephemeral
332
hints: {"x-canonical-private-affirmative-tint": "false",
333
"x-canonical-non-shaped-icon": "true"}
335
body: "Synchronised contacts-database with cloud-storage."
336
icon: "image://theme/contacts-app"
343
type: Notification.Confirmation
344
hints: {"x-canonical-non-shaped-icon": "true"}
347
icon: "image://theme/audio-volume-medium"
354
type: Notification.Confirmation
355
hints: {"x-canonical-non-shaped-icon": "true",
356
"x-canonical-value-bar-tint" : "true"}
359
icon: "image://theme/audio-volume-high"
366
type: Notification.SnapDecision
367
hints: {"x-canonical-private-affirmative-tint": "true"}
368
summary: "Theatre at Ferria Stadium"
369
body: "at Ferria Stadium in Bilbao, Spain\n07578545317"
373
rawActions: ["ok_id", "Ok",
374
"snooze_id", "Snooze",
276
379
function test_NotificationRenderer_data() {
279
tag: "2-over-1 Snap Decision with button-tint",
280
type: Notification.SnapDecision,
281
hints: {"x-canonical-private-affirmative-tint": "true"},
282
summary: "Theatre at Ferria Stadium",
283
body: "at Ferria Stadium in Bilbao, Spain\n07578545317",
286
actions: [{ id: "ok_id", label: "Ok"},
287
{ id: "snooze_id", label: "Snooze"},
288
{ id: "view_id", label: "View"}],
289
summaryVisible: true,
292
centeredIconVisible: false,
294
secondaryIconVisible: false,
295
buttonRowVisible: false,
299
valueLabelVisible: false,
303
382
tag: "Ephemeral notification - icon-summary layout",
304
type: Notification.Ephemeral,
306
summary: "Photo upload completed",
308
icon: "../graphics/applicationIcons/facebook.png",
311
384
summaryVisible: true,
312
385
bodyVisible: false,
313
386
iconVisible: true,
579
624
// click the positive/right button
580
625
tryCompareFunction(function() { mouseClick(buttonAccept); return actionSpy.signalArguments.length > 0; }, true);
581
compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id positive action")
626
compare(actionSpy.signalArguments[0][0], data.n.actions.data(0, ActionModel.RoleActionId), "got wrong id positive action")
582
627
actionSpy.clear()
583
waitForRendering (notification)
585
629
// check if there's a ComboButton created due to more actions being passed
586
if (data.actions.length > 2) {
630
if (data.n.actions.count > 3) {
587
631
var comboButton = findChild(notification, "notify_button2")
588
tryCompareFunction(function() { return comboButton.expanded == false; }, true);
632
tryCompareFunction(function() { return comboButton.expanded === false; }, true);
590
634
// click to expand
591
tryCompareFunction(function() { mouseClick(comboButton, comboButton.width - comboButton.__styleInstance.dropDownWidth / 2, comboButton.height / 2); return comboButton.expanded == true; }, true);
635
tryCompareFunction(function() { mouseClick(comboButton, comboButton.width / 2, comboButton.height / 2); return comboButton.expanded === true; }, true);
593
637
// try clicking on choices in expanded comboList
594
638
var choiceButton1 = findChild(notification, "notify_button3")
595
639
tryCompareFunction(function() { mouseClick(choiceButton1); return actionSpy.signalArguments.length > 0; }, true);
596
compare(actionSpy.signalArguments[0][0], data.actions[3]["id"], "got wrong id choice action 1")
640
compare(actionSpy.signalArguments[0][0], data.n.actions.data(3, ActionModel.RoleActionId), "got wrong id choice action 1")
597
641
actionSpy.clear()
599
643
var choiceButton2 = findChild(notification, "notify_button4")
600
644
tryCompareFunction(function() { mouseClick(choiceButton2); return actionSpy.signalArguments.length > 0; }, true);
601
compare(actionSpy.signalArguments[0][0], data.actions[4]["id"], "got wrong id choice action 2")
645
compare(actionSpy.signalArguments[0][0], data.n.actions.data(4, ActionModel.RoleActionId), "got wrong id choice action 2")
602
646
actionSpy.clear()
604
648
// click to collapse
605
//tryCompareFunction(function() { mouseClick(comboButton, comboButton.width - comboButton.__styleInstance.dropDownWidth / 2, comboButton.height / 2); return comboButton.expanded == false; }, true);
649
tryCompareFunction(function() { mouseClick(comboButton, comboButton.width / 2, comboButton.height / 2); return comboButton.expanded == false; }, true);
607
651
mouseClick(buttonCancel)
608
compare(actionSpy.signalArguments[0][0], data.actions[1]["id"], "got wrong id for negative action")
652
compare(actionSpy.signalArguments[0][0], data.n.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action")
656
// swipe-to-dismiss check
657
waitForRendering(notification)
658
var before = mockModel.count
659
var dragStart = notification.width * 0.25;
660
var dragEnd = notification.width;
661
var dragY = notification.height / 2;
662
touchFlick(notification, dragStart, dragY, dragEnd, dragY)
663
waitForRendering(notification)
664
if ((data.n.type === Notification.SnapDecision && notification.state === "expanded") || data.n.type === Notification.Confirmation) {
665
tryCompare(mockModel, "count", before)
667
tryCompare(mockModel, "count", before - 1)