on xenial help sign in
Phew... now it works.
a5a32d1Mirco Müller
tests/mocks/Unity/Notifications/MockNotification.cpp+5−3
@@ -22,7 +22,7 @@
22#include <QDebug>
22#include <QDebug>
23
23
24struct MockNotificationPrivate {
24struct MockNotificationPrivate {
25− unsigned int id;
25+ int id;
26 QString summary;
26 QString summary;
27 QString body;
27 QString body;
28 int value;
28 int value;
@@ -65,12 +65,14 @@ void MockNotification::setBody(const QString &body) {
65 }
65 }
66}
66}
67
67
68−unsigned int MockNotification::getID() const {
68+int MockNotification::getID() const {
69 return p->id;
69 return p->id;
70}
70}
71
71
72−void MockNotification::setID(const unsigned int id) {
72+void MockNotification::setID(const int id) {
73+ qDebug() << "id: " << id;
73 p->id = id;
74 p->id = id;
75+ qDebug() << "id: " << p->id;
74}
76}
75
77
76int MockNotification::getValue() const {
78int MockNotification::getValue() const {
tests/mocks/Unity/Notifications/MockNotification.h+6−6
@@ -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 getID WRITE setID NOTIFY idChanged)
36+ Q_PROPERTY(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 idChanged(const unsigned int id);
55+ void idChanged(const 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);
@@ -60,8 +60,8 @@ Q_SIGNALS:
60 void actionsChanged(const QStringList &actions);
60 void actionsChanged(const QStringList &actions);
61 void hintsChanged(const QVariantMap& hints);
61 void hintsChanged(const QVariantMap& hints);
62
62
63− void dataChanged(unsigned int nid);
63+ void dataChanged(int nid);
64− void completed(unsigned int nid);
64+ void completed(int nid);
65
65
66public:
66public:
67 MockNotification(QObject *parent=nullptr);
67 MockNotification(QObject *parent=nullptr);
@@ -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 getID() const;
74+ int getID() const;
75− void setID(const unsigned int id);
75+ void setID(const 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/mocks/Unity/Notifications/MockNotificationModel.cpp+7−7
@@ -94,7 +94,7 @@ void MockNotificationModel::append(MockNotification* n) {
94 endInsertRows();
94 endInsertRows();
95}
95}
96
96
97−MockNotification* MockNotificationModel::getNotification(unsigned int id) const {
97+MockNotification* MockNotificationModel::getNotification(int id) const {
98 for(int i=0; i < m_queue.size(); i++) {
98 for(int i=0; i < m_queue.size(); i++) {
99 if(m_queue[i]->getID() == id) {
99 if(m_queue[i]->getID() == id) {
100 return m_queue[i];
100 return m_queue[i];
@@ -114,11 +114,11 @@ MockNotification* MockNotificationModel::getNotification(const QString &summary)
114 return nullptr;
114 return nullptr;
115}
115}
116
116
117−bool MockNotificationModel::hasNotification(unsigned int id) const {
117+bool MockNotificationModel::hasNotification(int id) const {
118 return !(getNotification(id) != nullptr);
118 return !(getNotification(id) != nullptr);
119}
119}
120
120
121−void MockNotificationModel::remove(const unsigned int id) {
121+void MockNotificationModel::remove(const int id) {
122 qDebug() << "remove(" << id << ")";
122 qDebug() << "remove(" << id << ")";
123 for(int i = 0; i < m_queue.size(); i++) {
123 for(int i = 0; i < m_queue.size(); i++) {
124 if(m_queue[i]->getID() == id) {
124 if(m_queue[i]->getID() == id) {
@@ -143,7 +143,7 @@ void MockNotificationModel::deleteFromVisible(int loc) {
143 endRemoveRows();
143 endRemoveRows();
144}
144}
145
145
146−MockNotification* MockNotificationModel::getRaw(const unsigned int notificationId) const {
146+MockNotification* MockNotificationModel::getRaw(const int notificationId) const {
147 for(int i = 0; i < m_queue.size(); i++) {
147 for(int i = 0; i < m_queue.size(); i++) {
148 if(m_queue[i]->getID() == notificationId) {
148 if(m_queue[i]->getID() == notificationId) {
149 MockNotification* n = m_queue[i];
149 MockNotification* n = m_queue[i];
@@ -163,7 +163,7 @@ QHash<int, QByteArray> MockNotificationModel::roleNames() const {
163
163
164 roles.insert(ModelInterface::RoleType, "type");
164 roles.insert(ModelInterface::RoleType, "type");
165 roles.insert(ModelInterface::RoleUrgency, "urgency");
165 roles.insert(ModelInterface::RoleUrgency, "urgency");
166− roles.insert(ModelInterface::RoleId, "nid");
166+ roles.insert(ModelInterface::RoleId, "id");
167 roles.insert(ModelInterface::RoleSummary, "summary");
167 roles.insert(ModelInterface::RoleSummary, "summary");
168 roles.insert(ModelInterface::RoleBody, "body");
168 roles.insert(ModelInterface::RoleBody, "body");
169 roles.insert(ModelInterface::RoleValue, "value");
169 roles.insert(ModelInterface::RoleValue, "value");
@@ -176,12 +176,12 @@ QHash<int, QByteArray> MockNotificationModel::roleNames() const {
176 return roles;
176 return roles;
177}
177}
178
178
179−void MockNotificationModel::onCompleted(unsigned int id) {
179+void MockNotificationModel::onCompleted(int id) {
180 qDebug() << "onCompleted(" << id << ")";
180 qDebug() << "onCompleted(" << id << ")";
181 remove(id);
181 remove(id);
182}
182}
183
183
184−void MockNotificationModel::onDataChanged(unsigned int id) {
184+void MockNotificationModel::onDataChanged(int id) {
185 for(int i = 0; i < m_queue.size(); i++) {
185 for(int i = 0; i < m_queue.size(); i++) {
186 if(m_queue[i]->getID() == id) {
186 if(m_queue[i]->getID() == id) {
187 Q_EMIT dataChanged(index(i, 0), index(i, 0));
187 Q_EMIT dataChanged(index(i, 0), index(i, 0));
tests/mocks/Unity/Notifications/MockNotificationModel.h+6−6
@@ -40,24 +40,24 @@ public:
40 virtual QHash<int, QByteArray> roleNames() const;
40 virtual QHash<int, QByteArray> roleNames() const;
41
41
42 Q_INVOKABLE void append(MockNotification* n);
42 Q_INVOKABLE void append(MockNotification* n);
43− MockNotification* getNotification(unsigned int id) const;
43+ MockNotification* getNotification(int id) const;
44 MockNotification* getNotification(const QString &summary) const;
44 MockNotification* getNotification(const QString &summary) const;
45− bool hasNotification(unsigned int id) const;
45+ bool hasNotification(int id) const;
46
46
47 // getRaw() is only meant to be used from QML, since QML cannot handle
47 // getRaw() is only meant to be used from QML, since QML cannot handle
48 // QSharedPointers... on C++-side only use getNotification()
48 // QSharedPointers... on C++-side only use getNotification()
49− Q_INVOKABLE MockNotification* getRaw(const unsigned int notificationId) const;
49+ Q_INVOKABLE MockNotification* getRaw(const int notificationId) const;
50
50
51 Q_INVOKABLE int queued() const;
51 Q_INVOKABLE int queued() const;
52− Q_INVOKABLE void remove(const unsigned int id);
52+ Q_INVOKABLE void remove(const int id);
53
53
54 int getCount() const;
54 int getCount() const;
55
55
56public Q_SLOTS:
56public Q_SLOTS:
57− void onCompleted(unsigned int id);
57+ void onCompleted(int id);
58
58
59private Q_SLOTS:
59private Q_SLOTS:
60− void onDataChanged(unsigned int id);
60+ void onDataChanged(int id);
61
61
62Q_SIGNALS:
62Q_SIGNALS:
63 void queueSizeChanged(int newSize);
63 void queueSizeChanged(int newSize);
tests/qmltests/Notifications/tst_Notifications.qml+1−1
@@ -113,7 +113,7 @@ Item {
113 secondaryIcon: ""
113 secondaryIcon: ""
114 rawActions: ["reply_id", "Dummy"]
114 rawActions: ["reply_id", "Dummy"]
115 Component.onCompleted: {
115 Component.onCompleted: {
116− n5.completed.connect(mockModel.remove)
116+ n5.completed.connect(mockModel.onCompleted)
117 }
117 }
118 },
118 },
119 Notification {
119 Notification {