on xenial help sign in
Trying to connect MockNotification::close() to MockNotificationModel::remove()
commitd19090f91032a8f11095d3357b0d29ac410c674b authorMirco Müller <mirco.mueller@ubuntu.com> dateTue 20 Jan 2015, 15:32 (12 years ago) parent44dae67
4 files changed+48−2
tests/mocks/Unity/Notifications/MockNotification.cpp+3 tests/mocks/Unity/Notifications/MockNotificationModel.cpp+6 tests/mocks/Unity/Notifications/MockNotificationModel.h+3 tests/qmltests/Notifications/tst_Notifications.qml+36−2
tests/mocks/Unity/Notifications/MockNotification.cpp+3
@@ -19,6 +19,8 @@
1919
2020#include "MockNotification.h"
2121
22+#include <QDebug>
23+
2224struct MockNotificationPrivate {
2325 unsigned int id;
2426 QString summary;
@@ -171,5 +173,6 @@ void MockNotification::invokeAction(const QString &action) {
171173}
172174
173175void MockNotification::close() {
176+ qDebug() << "close() called";
174177 Q_EMIT completed(p->id);
175178}
tests/mocks/Unity/Notifications/MockNotificationModel.cpp+6
@@ -28,6 +28,7 @@
2828#include <QMap>
2929#include <QStringListModel>
3030#include <QQmlEngine>
31+#include <QDebug>
3132
3233using namespace unity::shell::notifications;
3334
@@ -173,6 +174,11 @@ QHash<int, QByteArray> MockNotificationModel::roleNames() const {
173174 return roles;
174175}
175176
177+void MockNotificationModel::onCompleted(unsigned int id) {
178+ qDebug() << "onCompleted(" << id << ")";
179+ remove(id);
180+}
181+
176182void MockNotificationModel::onDataChanged(unsigned int id) {
177183 for(int i = 0; i < m_queue.size(); i++) {
178184 if(m_queue[i]->getID() == id) {
tests/mocks/Unity/Notifications/MockNotificationModel.h+3
@@ -53,6 +53,9 @@ public:
5353
5454 int getCount() const;
5555
56+public Q_SLOTS:
57+ void onCompleted(unsigned int id);
58+
5659private Q_SLOTS:
5760 void onDataChanged(unsigned int id);
5861
tests/qmltests/Notifications/tst_Notifications.qml+36−2
@@ -27,11 +27,14 @@ import Unity.Notifications 1.0
2727import QtMultimedia 5.0
2828
2929Item {
30+ id: foobar
31+
3032 width: notificationsRect.width + interactiveControls.width
3133 height: notificationsRect.height
3234
3335 property list<Notification> mockList: [
3436 Notification {
37+ id: n0
3538 nid: 0
3639 type: Notification.PlaceHolder
3740 summary: ""
@@ -39,8 +42,12 @@ Item {
3942 icon: ""
4043 secondaryIcon: ""
4144 rawActions: ["reply_id", "Dummy"]
45+ Component.onCompleted: {
46+ n0.completed.connect(mockModel.remove)
47+ }
4248 },
4349 Notification {
50+ id: n1
4451 nid: 1
4552 type: Notification.SnapDecision
4653 hints: {"x-canonical-private-affirmative-tint": "true"}
@@ -51,8 +58,12 @@ Item {
5158 rawActions: ["ok_id", "Ok",
5259 "snooze_id", "Snooze",
5360 "view_id", "View"]
61+ Component.onCompleted: {
62+ n1.completed.connect(mockModel.remove)
63+ }
5464 },
5565 Notification {
66+ id: n2
5667 nid: 2
5768 type: Notification.Ephemeral
5869 summary: "Cole Raby"
@@ -60,8 +71,12 @@ Item {
6071 icon: "../graphics/avatars/amanda.png"
6172 secondaryIcon: "../graphics/applicationIcons/facebook.png"
6273 rawActions: ["reply_id", "Dummy"]
74+ Component.onCompleted: {
75+ n2.completed.connect(mockModel.remove)
76+ }
6377 },
6478 Notification {
79+ id: n3
6580 nid: 3
6681 type: Notification.Ephemeral
6782 hints: {"x-canonical-non-shaped-icon": "true"}
@@ -70,8 +85,12 @@ Item {
7085 icon: "../graphics/applicationIcons/contacts-app.png"
7186 secondaryIcon: ""
7287 rawActions: ["reply_id", "Dummy"]
88+ Component.onCompleted: {
89+ n3.completed.connect(mockModel.remove)
90+ }
7391 },
7492 Notification {
93+ id: n4
7594 nid: 4
7695 type: Notification.Ephemeral
7796 hints: {"x-canonical-non-shaped-icon": "false"}
@@ -80,8 +99,12 @@ Item {
8099 icon: "../graphics/applicationIcons/facebook.png"
81100 secondaryIcon: ""
82101 rawActions: ["reply_id", "Dummy"]
102+ Component.onCompleted: {
103+ n4.completed.connect(mockModel.remove)
104+ }
83105 },
84106 Notification {
107+ id: n5
85108 nid: 5
86109 type: Notification.Interactive
87110 summary: "Interactive notification"
@@ -89,8 +112,12 @@ Item {
89112 icon: "../graphics/avatars/anna_olsson.png"
90113 secondaryIcon: ""
91114 rawActions: ["reply_id", "Dummy"]
115+ Component.onCompleted: {
116+ n5.completed.connect(mockModel.remove)
117+ }
92118 },
93119 Notification {
120+ id: n6
94121 nid: 6
95122 type: Notification.Confirmation
96123 hints: {"x-canonical-non-shaped-icon": "true"}
@@ -100,8 +127,12 @@ Item {
100127 secondaryIcon: ""
101128 value: 50
102129 rawActions: ["reply_id", "Dummy"]
130+ Component.onCompleted: {
131+ n6.completed.connect(mockModel.remove)
132+ }
103133 },
104134 Notification {
135+ id: n7
105136 nid: 7
106137 type: Notification.Confirmation
107138 hints: {"x-canonical-non-shaped-icon": "true",
@@ -112,6 +143,9 @@ Item {
112143 secondaryIcon: ""
113144 value: 85
114145 rawActions: ["reply_id", "Dummy"]
146+ Component.onCompleted: {
147+ n7.completed.connect(mockModel.remove)
148+ }
115149 }
116150 ]
117151
@@ -159,13 +193,13 @@ Item {
159193
160194 function clearNotifications() {
161195 while(mockModel.count > 1) {
162− remove1stNotification()
196+ //remove1stNotification()
163197 }
164198 }
165199
166200 function remove1stNotification() {
167201 if (mockModel.count > 1) {
168− mockModel.remove(1)
202+ //mockModel.remove(1)
169203 }
170204 }
171205