on xenial help sign in
Still trying to get the mocked Notification to work with the tst_Notifications qmltest.
2e39a7cMirco Müller
qml/Notifications/Notification.qml+3−3
@@ -41,7 +41,7 @@ Item {
41 property int maxHeight
41 property int maxHeight
42 property int margins
42 property int margins
43 readonly property bool draggable: (type === Notification.SnapDecision && state === "contracted") || type === Notification.Interactive || type === Notification.Ephemeral
43 readonly property bool draggable: (type === Notification.SnapDecision && state === "contracted") || type === Notification.Interactive || type === Notification.Ephemeral
44− readonly property bool darkOnBright: panel.indicators.shown || type === Notification.SnapDecision
44+ readonly property bool darkOnBright: true //panel.indicators.shown || type === Notification.SnapDecision
45 readonly property color red: "#fc4949"
45 readonly property color red: "#fc4949"
46 readonly property color green: "#3fb24f"
46 readonly property color green: "#3fb24f"
47 readonly property color sdLightGrey: "#eaeaea"
47 readonly property color sdLightGrey: "#eaeaea"
@@ -80,7 +80,7 @@ Item {
80 Audio {
80 Audio {
81 id: sound
81 id: sound
82 objectName: "sound"
82 objectName: "sound"
83− audioRole: MediaPlayer.alert
83+ //audioRole: MediaPlayer.alert
84 source: hints["suppress-sound"] !== "true" && hints["sound-file"] !== undefined ? hints["sound-file"] : ""
84 source: hints["suppress-sound"] !== "true" && hints["sound-file"] !== undefined ? hints["sound-file"] : ""
85 }
85 }
86
86
@@ -186,7 +186,7 @@ Item {
186 actions: paths.actions
186 actions: paths.actions
187 menuObjectPath: paths.menuObjectPath
187 menuObjectPath: paths.menuObjectPath
188 onNameOwnerChanged: {
188 onNameOwnerChanged: {
189− if (lastNameOwner != "" && nameOwner == "" && notification.notification != undefined) {
189+ if (lastNameOwner !== "" && nameOwner === "" && notification.notification !== undefined) {
190 notification.notification.close()
190 notification.notification.close()
191 }
191 }
192 lastNameOwner = nameOwner
192 lastNameOwner = nameOwner
qml/Notifications/Notifications.qml+1−1
@@ -54,7 +54,7 @@ ListView {
54 body: model.body
54 body: model.body
55 value: model.value
55 value: model.value
56 actions: model.actions
56 actions: model.actions
57− notificationId: model.id
57+ notificationId: model.nid
58 notification: notificationList.model.getRaw(notificationId)
58 notification: notificationList.model.getRaw(notificationId)
59 maxHeight: notificationList.height
59 maxHeight: notificationList.height
60 margins: notificationList.margin
60 margins: notificationList.margin
tests/mocks/Unity/Notifications/MockNotificationTypes.cpp+15−12
@@ -18,9 +18,10 @@
18 */
18 */
19
19
20#include "MockNotificationTypes.h"
20#include "MockNotificationTypes.h"
21+#include <QDebug>
21
22
22struct MockNotificationPrivate {
23struct MockNotificationPrivate {
23− unsigned int nid;
24+ unsigned int id;
24 QString summary;
25 QString summary;
25 QString body;
26 QString body;
26 int value;
27 int value;
@@ -47,7 +48,7 @@ void MockNotification::setSummary(const QString &summary) {
47 if(p->summary != summary) {
48 if(p->summary != summary) {
48 p->summary= summary;
49 p->summary= summary;
49 Q_EMIT summaryChanged(p->summary);
50 Q_EMIT summaryChanged(p->summary);
50− Q_EMIT dataChanged(p->nid);
51+ Q_EMIT dataChanged(p->id);
51 }
52 }
52}
53}
53
54
@@ -59,16 +60,16 @@ void MockNotification::setBody(const QString &body) {
59 if(p->body != body) {
60 if(p->body != body) {
60 p->body = body;
61 p->body = body;
61 Q_EMIT bodyChanged(p->body);
62 Q_EMIT bodyChanged(p->body);
62− Q_EMIT dataChanged(p->nid);
63+ Q_EMIT dataChanged(p->id);
63 }
64 }
64}
65}
65
66
66−unsigned int MockNotification::getNID() const {
67+unsigned int MockNotification::getID() const {
67− return p->nid;
68+ return p->id;
68}
69}
69
70
70−void MockNotification::setNID(const unsigned int nid) {
71+void MockNotification::setID(const unsigned int id) {
71− p->nid = nid;
72+ p->id = id;
72}
73}
73
74
74int MockNotification::getValue() const {
75int MockNotification::getValue() const {
@@ -79,7 +80,7 @@ void MockNotification::setValue(int value) {
79 if(p->value != value) {
80 if(p->value != value) {
80 p->value = value;
81 p->value = value;
81 Q_EMIT valueChanged(p->value);
82 Q_EMIT valueChanged(p->value);
82− Q_EMIT dataChanged(p->nid);
83+ Q_EMIT dataChanged(p->id);
83 }
84 }
84}
85}
85
86
@@ -100,7 +101,7 @@ void MockNotification::setIcon(const QString &icon) {
100 }
101 }
101
102
102 Q_EMIT iconChanged(p->icon);
103 Q_EMIT iconChanged(p->icon);
103− Q_EMIT dataChanged(p->nid);
104+ Q_EMIT dataChanged(p->id);
104}
105}
105
106
106QString MockNotification::getSecondaryIcon() const {
107QString MockNotification::getSecondaryIcon() const {
@@ -120,7 +121,7 @@ void MockNotification::setSecondaryIcon(const QString &secondaryIcon) {
120 }
121 }
121
122
122 Q_EMIT secondaryIconChanged(p->secondaryIcon);
123 Q_EMIT secondaryIconChanged(p->secondaryIcon);
123− Q_EMIT dataChanged(p->nid);
124+ Q_EMIT dataChanged(p->id);
124}
125}
125
126
126MockNotification::Type MockNotification::getType() const {
127MockNotification::Type MockNotification::getType() const {
@@ -163,7 +164,8 @@ void MockNotification::setHints(const QVariantMap& hints) {
163void MockNotification::invokeAction(const QString &action) {
164void MockNotification::invokeAction(const QString &action) {
164 for(int i=0; i<p->actions.size(); i++) {
165 for(int i=0; i<p->actions.size(); i++) {
165 if(p->actions[i] == action) {
166 if(p->actions[i] == action) {
167+ qDebug() << "MockNotification::invokeAction("<< action << ") called";
166− Q_EMIT completed(p->nid);
168+ Q_EMIT completed(p->id);
167 return;
169 return;
168 }
170 }
169 }
171 }
@@ -171,5 +173,6 @@ void MockNotification::invokeAction(const QString &action) {
171}
173}
172
174
173void MockNotification::close() {
175void MockNotification::close() {
176+ qDebug() << "MockNotification::close() called";
174− Q_EMIT completed(p->nid);
177+ Q_EMIT completed(p->id);
175}
178}
tests/mocks/Unity/Notifications/MockNotificationTypes.h+4−4
@@ -33,7 +33,7 @@ class MockNotification : public QObject {
33 Q_ENUMS(Type)
33 Q_ENUMS(Type)
34 Q_PROPERTY(QString summary READ getSummary WRITE setSummary NOTIFY summaryChanged)
34 Q_PROPERTY(QString summary READ getSummary WRITE setSummary NOTIFY summaryChanged)
35 Q_PROPERTY(QString body READ getBody WRITE setBody NOTIFY bodyChanged)
35 Q_PROPERTY(QString body READ getBody WRITE setBody NOTIFY bodyChanged)
36− Q_PROPERTY(unsigned int nid READ getNID WRITE setNID NOTIFY nidChanged)
36+ Q_PROPERTY(unsigned int nid READ getID WRITE setID NOTIFY idChanged)
37 Q_PROPERTY(int value READ getValue WRITE setValue NOTIFY valueChanged)
37 Q_PROPERTY(int value READ getValue WRITE setValue NOTIFY valueChanged)
38 Q_PROPERTY(QString icon READ getIcon WRITE setIcon NOTIFY iconChanged)
38 Q_PROPERTY(QString icon READ getIcon WRITE setIcon NOTIFY iconChanged)
39 Q_PROPERTY(QString secondaryIcon READ getSecondaryIcon WRITE setSecondaryIcon NOTIFY secondaryIconChanged)
39 Q_PROPERTY(QString secondaryIcon READ getSecondaryIcon WRITE setSecondaryIcon NOTIFY secondaryIconChanged)
@@ -52,7 +52,7 @@ public:
52Q_SIGNALS:
52Q_SIGNALS:
53 void summaryChanged(const QString &summary);
53 void summaryChanged(const QString &summary);
54 void bodyChanged(const QString &body);
54 void bodyChanged(const QString &body);
55− void nidChanged(const unsigned int nid);
55+ void idChanged(const unsigned int id);
56 void valueChanged(int value);
56 void valueChanged(int value);
57 void iconChanged(const QString &icon);
57 void iconChanged(const QString &icon);
58 void secondaryIconChanged(const QString &secondaryIcon);
58 void secondaryIconChanged(const QString &secondaryIcon);
@@ -71,8 +71,8 @@ public:
71 void setSummary(const QString &summary);
71 void setSummary(const QString &summary);
72 QString getBody() const;
72 QString getBody() const;
73 void setBody(const QString &body);
73 void setBody(const QString &body);
74− unsigned int getNID() const;
74+ unsigned int getID() const;
75− void setNID(const unsigned int nid);
75+ void setID(const unsigned int id);
76 int getValue() const;
76 int getValue() const;
77 void setValue(int value);
77 void setValue(int value);
78 QString getIcon() const;
78 QString getIcon() const;
tests/qmltests/Notifications/tst_Notifications.qml+28−28
@@ -33,8 +33,7 @@ Item {
33 Notification {
33 Notification {
34 id: mockNotificationDefault
34 id: mockNotificationDefault
35 type: Notification.PlaceHolder
35 type: Notification.PlaceHolder
36− nid: 1 //mockModel.getNextId()
36+ nid: 1
37− //hints: {}
38 summary: ""
37 summary: ""
39 body: ""
38 body: ""
40 icon: ""
39 icon: ""
@@ -47,18 +46,11 @@ Item {
47 dynamicRoles: true
46 dynamicRoles: true
48
47
49 signal actionInvoked(string actionId)
48 signal actionInvoked(string actionId)
50− property var internalId: 0
51
49
52− function getNextId() {
50+ function getRaw(id) {
53− return internalId++
54− }
55−
56− function getRaw(nid) {
57− print ("Looking for:", nid)
58 for (var i = 0; i < mockModel.count; i++) {
51 for (var i = 0; i < mockModel.count; i++) {
59− if (nid === mockModel.get(i).nid) {
52+ if (id === mockModel.get(i).nid) {
60− print ("Found something...", i)
61− return mockModel.get(i).notification
53+ return mockModel.get(i)
62 }
54 }
63 }
55 }
64 }
56 }
@@ -72,7 +64,7 @@ Item {
72 Notification {
64 Notification {
73 id: mock2over1SnapDecisionNotification
65 id: mock2over1SnapDecisionNotification
74 type: Notification.SnapDecision
66 type: Notification.SnapDecision
75− nid: 2 //mockModel.getNextId()
67+ nid: 2
76 hints: {"x-canonical-private-affirmative-tint": "true"}
68 hints: {"x-canonical-private-affirmative-tint": "true"}
77 summary: "Theatre at Ferria Stadium"
69 summary: "Theatre at Ferria Stadium"
78 body: "at Ferria Stadium in Bilbao, Spain\n07578545317"
70 body: "at Ferria Stadium in Bilbao, Spain\n07578545317"
@@ -85,12 +77,20 @@ Item {
85
77
86 function add2over1SnapDecisionNotification() {
78 function add2over1SnapDecisionNotification() {
87 mockModel.append(mock2over1SnapDecisionNotification)
79 mockModel.append(mock2over1SnapDecisionNotification)
80+
81+ // trying out/debugging stuff
82+ mockModel.getRaw(2).close()
83+ print("summary:", mock2over1SnapDecisionNotification.summary)
84+ print("summary:", mockModel.getRaw(2).summary)
85+ print("summary:", mockModel.get(1).summary)
86+ mock2over1SnapDecisionNotification.close()
87+ mock2over1SnapDecisionNotification.invokeAction("ok_id")
88 }
88 }
89
89
90 Notification {
90 Notification {
91 id: mockEphemeralNotification
91 id: mockEphemeralNotification
92 type: Notification.Ephemeral
92 type: Notification.Ephemeral
93− nid: 3 //mockModel.getNextId()
93+ nid: 3
94 summary: "Cole Raby"
94 summary: "Cole Raby"
95 body: "I did not expect it to be that late."
95 body: "I did not expect it to be that late."
96 icon: "../graphics/avatars/amanda.png"
96 icon: "../graphics/avatars/amanda.png"
@@ -105,7 +105,7 @@ Item {
105 Notification {
105 Notification {
106 id: mockEphemeralNonShapedIconNotification
106 id: mockEphemeralNonShapedIconNotification
107 type: Notification.Ephemeral
107 type: Notification.Ephemeral
108− nid: 4 //mockModel.getNextId()
108+ nid: 4
109 hints: {"x-canonical-non-shaped-icon": "true"}
109 hints: {"x-canonical-non-shaped-icon": "true"}
110 summary: "Contacts"
110 summary: "Contacts"
111 body: "Synchronised contacts-database with cloud-storage."
111 body: "Synchronised contacts-database with cloud-storage."
@@ -121,7 +121,7 @@ Item {
121 Notification {
121 Notification {
122 id: mockEphemeralIconSummaryNotification
122 id: mockEphemeralIconSummaryNotification
123 type: Notification.Ephemeral
123 type: Notification.Ephemeral
124− nid: 5 //mockModel.getNextId()
124+ nid: 5
125 hints: {"x-canonical-non-shaped-icon": "false"}
125 hints: {"x-canonical-non-shaped-icon": "false"}
126 summary: "Photo upload completed"
126 summary: "Photo upload completed"
127 body: ""
127 body: ""
@@ -137,7 +137,7 @@ Item {
137 Notification {
137 Notification {
138 id: mockInteractiveNotification
138 id: mockInteractiveNotification
139 type: Notification.Interactive
139 type: Notification.Interactive
140− nid: 6 //mockModel.getNextId()
140+ nid: 6
141 summary: "Interactive notification"
141 summary: "Interactive notification"
142 body: "This is a notification that can be clicked"
142 body: "This is a notification that can be clicked"
143 icon: "../graphics/avatars/anna_olsson.png"
143 icon: "../graphics/avatars/anna_olsson.png"
@@ -152,7 +152,7 @@ Item {
152 Notification {
152 Notification {
153 id: mockConfirmationNotification
153 id: mockConfirmationNotification
154 type: Notification.Confirmation
154 type: Notification.Confirmation
155− nid: 7 //mockModel.getNextId()
155+ nid: 7
156 hints: {"x-canonical-non-shaped-icon": "true"}
156 hints: {"x-canonical-non-shaped-icon": "true"}
157 summary: "Confirmation notification"
157 summary: "Confirmation notification"
158 body: ""
158 body: ""
@@ -169,7 +169,7 @@ Item {
169 Notification {
169 Notification {
170 id: mock2ndConfirmationNotification
170 id: mock2ndConfirmationNotification
171 type: Notification.Confirmation
171 type: Notification.Confirmation
172− nid: 8 //mockModel.getNextId()
172+ nid: 8
173 hints: {"x-canonical-non-shaped-icon": "true",
173 hints: {"x-canonical-non-shaped-icon": "true",
174 "x-canonical-value-bar-tint": "true"}
174 "x-canonical-value-bar-tint": "true"}
175 summary: "Confirmation notification"
175 summary: "Confirmation notification"
@@ -295,7 +295,7 @@ Item {
295 {
295 {
296 tag: "2-over-1 Snap Decision with button-tint",
296 tag: "2-over-1 Snap Decision with button-tint",
297 type: Notification.SnapDecision,
297 type: Notification.SnapDecision,
298− //nid: mockModel.getNextId(),
298+ nid: 2,
299 hints: {"x-canonical-private-affirmative-tint": "true"},
299 hints: {"x-canonical-private-affirmative-tint": "true"},
300 summary: "Theatre at Ferria Stadium",
300 summary: "Theatre at Ferria Stadium",
301 body: "at Ferria Stadium in Bilbao, Spain\n07578545317",
301 body: "at Ferria Stadium in Bilbao, Spain\n07578545317",
@@ -321,7 +321,7 @@ Item {
321 {
321 {
322 tag: "Ephemeral notification - icon-summary layout",
322 tag: "Ephemeral notification - icon-summary layout",
323 type: Notification.Ephemeral,
323 type: Notification.Ephemeral,
324− //nid: mockModel.getNextId(),
324+ nid: 3,
325 hints: {},
325 hints: {},
326 summary: "Photo upload completed",
326 summary: "Photo upload completed",
327 body: "",
327 body: "",
@@ -345,7 +345,7 @@ Item {
345 {
345 {
346 tag: "Ephemeral notification - check suppression of secondary icon for icon-summary layout",
346 tag: "Ephemeral notification - check suppression of secondary icon for icon-summary layout",
347 type: Notification.Ephemeral,
347 type: Notification.Ephemeral,
348− //nid: mockModel.getNextId(),
348+ nid: 4,
349 hints: {"x-canonical-private-affirmative-tint": "false",
349 hints: {"x-canonical-private-affirmative-tint": "false",
350 "sound-file": "dummy.ogg",
350 "sound-file": "dummy.ogg",
351 "suppress-sound": "true"},
351 "suppress-sound": "true"},
@@ -372,7 +372,7 @@ Item {
372 {
372 {
373 tag: "Interactive notification",
373 tag: "Interactive notification",
374 type: Notification.Interactive,
374 type: Notification.Interactive,
375− //nid: mockModel.getNextId(),
375+ nid: 5,
376 hints: {"x-canonical-private-affirmative-tint": "false",
376 hints: {"x-canonical-private-affirmative-tint": "false",
377 "sound-file": "dummy.ogg"},
377 "sound-file": "dummy.ogg"},
378 summary: "Interactive notification",
378 summary: "Interactive notification",
@@ -397,7 +397,7 @@ Item {
397 {
397 {
398 tag: "Snap Decision without secondary icon and no button-tint",
398 tag: "Snap Decision without secondary icon and no button-tint",
399 type: Notification.SnapDecision,
399 type: Notification.SnapDecision,
400− //nid: mockModel.getNextId(),
400+ nid: 6,
401 hints: {"x-canonical-private-affirmative-tint": "false",
401 hints: {"x-canonical-private-affirmative-tint": "false",
402 "sound-file": "dummy.ogg"},
402 "sound-file": "dummy.ogg"},
403 summary: "Bro Coly",
403 summary: "Bro Coly",
@@ -423,7 +423,7 @@ Item {
423 {
423 {
424 tag: "Ephemeral notification",
424 tag: "Ephemeral notification",
425 type: Notification.Ephemeral,
425 type: Notification.Ephemeral,
426− //nid: mockModel.getNextId(),
426+ nid: 7,
427 hints: {"x-canonical-private-affirmative-tint": "false",
427 hints: {"x-canonical-private-affirmative-tint": "false",
428 "sound-file": "dummy.ogg"},
428 "sound-file": "dummy.ogg"},
429 summary: "Cole Raby",
429 summary: "Cole Raby",
@@ -448,7 +448,7 @@ Item {
448 {
448 {
449 tag: "Ephemeral notification with non-shaped icon",
449 tag: "Ephemeral notification with non-shaped icon",
450 type: Notification.Ephemeral,
450 type: Notification.Ephemeral,
451− //nid: mockModel.getNextId(),
451+ nid: 8,
452 hints: {"x-canonical-private-affirmative-tint": "false",
452 hints: {"x-canonical-private-affirmative-tint": "false",
453 "x-canonical-non-shaped-icon": "true"},
453 "x-canonical-non-shaped-icon": "true"},
454 summary: "Contacts",
454 summary: "Contacts",
@@ -473,7 +473,7 @@ Item {
473 {
473 {
474 tag: "Confirmation notification with value",
474 tag: "Confirmation notification with value",
475 type: Notification.Confirmation,
475 type: Notification.Confirmation,
476− //nid: mockModel.getNextId(),
476+ nid: 9,
477 hints: {"x-canonical-non-shaped-icon": "true"},
477 hints: {"x-canonical-non-shaped-icon": "true"},
478 summary: "",
478 summary: "",
479 body: "",
479 body: "",
@@ -497,7 +497,7 @@ Item {
497 {
497 {
498 tag: "Confirmation notification with value, label and tint",
498 tag: "Confirmation notification with value, label and tint",
499 type: Notification.Confirmation,
499 type: Notification.Confirmation,
500− //nid: mockModel.getNextId(),
500+ nid: 10,
501 hints: {"x-canonical-non-shaped-icon": "true",
501 hints: {"x-canonical-non-shaped-icon": "true",
502 "x-canonical-value-bar-tint" : "true"},
502 "x-canonical-value-bar-tint" : "true"},
503 summary: "",
503 summary: "",