on xenial help sign in
Trying to connect MockNotification::close() to MockNotificationModel::remove()
d19090fMirco Müller
tests/mocks/Unity/Notifications/MockNotification.cpp+3
@@ -19,6 +19,8 @@
19
19
20#include "MockNotification.h"
20#include "MockNotification.h"
21
21
22+#include <QDebug>
23+
22struct MockNotificationPrivate {
24struct MockNotificationPrivate {
23 unsigned int id;
25 unsigned int id;
24 QString summary;
26 QString summary;
@@ -171,5 +173,6 @@ void MockNotification::invokeAction(const QString &action) {
171}
173}
172
174
173void MockNotification::close() {
175void MockNotification::close() {
176+ qDebug() << "close() called";
174 Q_EMIT completed(p->id);
177 Q_EMIT completed(p->id);
175}
178}
tests/mocks/Unity/Notifications/MockNotificationModel.cpp+6
@@ -28,6 +28,7 @@
28#include <QMap>
28#include <QMap>
29#include <QStringListModel>
29#include <QStringListModel>
30#include <QQmlEngine>
30#include <QQmlEngine>
31+#include <QDebug>
31
32
32using namespace unity::shell::notifications;
33using namespace unity::shell::notifications;
33
34
@@ -173,6 +174,11 @@ QHash<int, QByteArray> MockNotificationModel::roleNames() const {
173 return roles;
174 return roles;
174}
175}
175
176
177+void MockNotificationModel::onCompleted(unsigned int id) {
178+ qDebug() << "onCompleted(" << id << ")";
179+ remove(id);
180+}
181+
176void MockNotificationModel::onDataChanged(unsigned int id) {
182void MockNotificationModel::onDataChanged(unsigned int id) {
177 for(int i = 0; i < m_queue.size(); i++) {
183 for(int i = 0; i < m_queue.size(); i++) {
178 if(m_queue[i]->getID() == id) {
184 if(m_queue[i]->getID() == id) {
tests/mocks/Unity/Notifications/MockNotificationModel.h+3
@@ -53,6 +53,9 @@ public:
53
53
54 int getCount() const;
54 int getCount() const;
55
55
56+public Q_SLOTS:
57+ void onCompleted(unsigned int id);
58+
56private Q_SLOTS:
59private Q_SLOTS:
57 void onDataChanged(unsigned int id);
60 void onDataChanged(unsigned int id);
58
61
tests/qmltests/Notifications/tst_Notifications.qml+36−2
@@ -27,11 +27,14 @@ import Unity.Notifications 1.0
27import QtMultimedia 5.0
27import QtMultimedia 5.0
28
28
29Item {
29Item {
30+ id: foobar
31+
30 width: notificationsRect.width + interactiveControls.width
32 width: notificationsRect.width + interactiveControls.width
31 height: notificationsRect.height
33 height: notificationsRect.height
32
34
33 property list<Notification> mockList: [
35 property list<Notification> mockList: [
34 Notification {
36 Notification {
37+ id: n0
35 nid: 0
38 nid: 0
36 type: Notification.PlaceHolder
39 type: Notification.PlaceHolder
37 summary: ""
40 summary: ""
@@ -39,8 +42,12 @@ Item {
39 icon: ""
42 icon: ""
40 secondaryIcon: ""
43 secondaryIcon: ""
41 rawActions: ["reply_id", "Dummy"]
44 rawActions: ["reply_id", "Dummy"]
45+ Component.onCompleted: {
46+ n0.completed.connect(mockModel.remove)
47+ }
42 },
48 },
43 Notification {
49 Notification {
50+ id: n1
44 nid: 1
51 nid: 1
45 type: Notification.SnapDecision
52 type: Notification.SnapDecision
46 hints: {"x-canonical-private-affirmative-tint": "true"}
53 hints: {"x-canonical-private-affirmative-tint": "true"}
@@ -51,8 +58,12 @@ Item {
51 rawActions: ["ok_id", "Ok",
58 rawActions: ["ok_id", "Ok",
52 "snooze_id", "Snooze",
59 "snooze_id", "Snooze",
53 "view_id", "View"]
60 "view_id", "View"]
61+ Component.onCompleted: {
62+ n1.completed.connect(mockModel.remove)
63+ }
54 },
64 },
55 Notification {
65 Notification {
66+ id: n2
56 nid: 2
67 nid: 2
57 type: Notification.Ephemeral
68 type: Notification.Ephemeral
58 summary: "Cole Raby"
69 summary: "Cole Raby"
@@ -60,8 +71,12 @@ Item {
60 icon: "../graphics/avatars/amanda.png"
71 icon: "../graphics/avatars/amanda.png"
61 secondaryIcon: "../graphics/applicationIcons/facebook.png"
72 secondaryIcon: "../graphics/applicationIcons/facebook.png"
62 rawActions: ["reply_id", "Dummy"]
73 rawActions: ["reply_id", "Dummy"]
74+ Component.onCompleted: {
75+ n2.completed.connect(mockModel.remove)
76+ }
63 },
77 },
64 Notification {
78 Notification {
79+ id: n3
65 nid: 3
80 nid: 3
66 type: Notification.Ephemeral
81 type: Notification.Ephemeral
67 hints: {"x-canonical-non-shaped-icon": "true"}
82 hints: {"x-canonical-non-shaped-icon": "true"}
@@ -70,8 +85,12 @@ Item {
70 icon: "../graphics/applicationIcons/contacts-app.png"
85 icon: "../graphics/applicationIcons/contacts-app.png"
71 secondaryIcon: ""
86 secondaryIcon: ""
72 rawActions: ["reply_id", "Dummy"]
87 rawActions: ["reply_id", "Dummy"]
88+ Component.onCompleted: {
89+ n3.completed.connect(mockModel.remove)
90+ }
73 },
91 },
74 Notification {
92 Notification {
93+ id: n4
75 nid: 4
94 nid: 4
76 type: Notification.Ephemeral
95 type: Notification.Ephemeral
77 hints: {"x-canonical-non-shaped-icon": "false"}
96 hints: {"x-canonical-non-shaped-icon": "false"}
@@ -80,8 +99,12 @@ Item {
80 icon: "../graphics/applicationIcons/facebook.png"
99 icon: "../graphics/applicationIcons/facebook.png"
81 secondaryIcon: ""
100 secondaryIcon: ""
82 rawActions: ["reply_id", "Dummy"]
101 rawActions: ["reply_id", "Dummy"]
102+ Component.onCompleted: {
103+ n4.completed.connect(mockModel.remove)
104+ }
83 },
105 },
84 Notification {
106 Notification {
107+ id: n5
85 nid: 5
108 nid: 5
86 type: Notification.Interactive
109 type: Notification.Interactive
87 summary: "Interactive notification"
110 summary: "Interactive notification"
@@ -89,8 +112,12 @@ Item {
89 icon: "../graphics/avatars/anna_olsson.png"
112 icon: "../graphics/avatars/anna_olsson.png"
90 secondaryIcon: ""
113 secondaryIcon: ""
91 rawActions: ["reply_id", "Dummy"]
114 rawActions: ["reply_id", "Dummy"]
115+ Component.onCompleted: {
116+ n5.completed.connect(mockModel.remove)
117+ }
92 },
118 },
93 Notification {
119 Notification {
120+ id: n6
94 nid: 6
121 nid: 6
95 type: Notification.Confirmation
122 type: Notification.Confirmation
96 hints: {"x-canonical-non-shaped-icon": "true"}
123 hints: {"x-canonical-non-shaped-icon": "true"}
@@ -100,8 +127,12 @@ Item {
100 secondaryIcon: ""
127 secondaryIcon: ""
101 value: 50
128 value: 50
102 rawActions: ["reply_id", "Dummy"]
129 rawActions: ["reply_id", "Dummy"]
130+ Component.onCompleted: {
131+ n6.completed.connect(mockModel.remove)
132+ }
103 },
133 },
104 Notification {
134 Notification {
135+ id: n7
105 nid: 7
136 nid: 7
106 type: Notification.Confirmation
137 type: Notification.Confirmation
107 hints: {"x-canonical-non-shaped-icon": "true",
138 hints: {"x-canonical-non-shaped-icon": "true",
@@ -112,6 +143,9 @@ Item {
112 secondaryIcon: ""
143 secondaryIcon: ""
113 value: 85
144 value: 85
114 rawActions: ["reply_id", "Dummy"]
145 rawActions: ["reply_id", "Dummy"]
146+ Component.onCompleted: {
147+ n7.completed.connect(mockModel.remove)
148+ }
115 }
149 }
116 ]
150 ]
117
151
@@ -159,13 +193,13 @@ Item {
159
193
160 function clearNotifications() {
194 function clearNotifications() {
161 while(mockModel.count > 1) {
195 while(mockModel.count > 1) {
162− remove1stNotification()
196+ //remove1stNotification()
163 }
197 }
164 }
198 }
165
199
166 function remove1stNotification() {
200 function remove1stNotification() {
167 if (mockModel.count > 1) {
201 if (mockModel.count > 1) {
168− mockModel.remove(1)
202+ //mockModel.remove(1)
169 }
203 }
170 }
204 }
171
205