on xenial help sign in
Stripped down MockNotificationModel further. Checks of the Audio-state still fail... no idea why.
1b7c3aeMirco Müller
tests/mocks/Unity/Notifications/MockNotificationModel.cpp+3−18
@@ -103,37 +103,22 @@ MockNotification* MockNotificationModel::getNotification(int id) const {
103 return nullptr;
103 return nullptr;
104}
104}
105
105
106−MockNotification* MockNotificationModel::getNotification(const QString &summary) const {
107− for(int i=0; i < m_queue.size(); i++) {
108− if(m_queue[i]->getSummary() == summary) {
109− return m_queue[i];
110− }
111− }
112−
113− return nullptr;
114−}
115−
116−bool MockNotificationModel::hasNotification(int id) const {
117− return !(getNotification(id) != nullptr);
118−}
119−
120void MockNotificationModel::remove(const int id) {
106void MockNotificationModel::remove(const int id) {
121 for(int i = 0; i < m_queue.size(); i++) {
107 for(int i = 0; i < m_queue.size(); i++) {
122 if(m_queue[i]->getID() == id) {
108 if(m_queue[i]->getID() == id) {
123− deleteFromVisible(i);
109+ removeInternal(i);
124 return;
110 return;
125 }
111 }
126 }
112 }
127− // The ID was not found in any queue. Should it be an error case or not?
128}
113}
129
114
130void MockNotificationModel::removeSecond() {
115void MockNotificationModel::removeSecond() {
131 if(m_queue.size() < 2)
116 if(m_queue.size() < 2)
132 return;
117 return;
133− deleteFromVisible(1);
118+ removeInternal(1);
134}
119}
135
120
136−void MockNotificationModel::deleteFromVisible(int loc) {
121+void MockNotificationModel::removeInternal(int loc) {
137 QModelIndex deletePoint = QModelIndex();
122 QModelIndex deletePoint = QModelIndex();
138 beginRemoveRows(deletePoint, loc, loc);
123 beginRemoveRows(deletePoint, loc, loc);
139 m_queue.erase(m_queue.begin() + loc);
124 m_queue.erase(m_queue.begin() + loc);
tests/mocks/Unity/Notifications/MockNotificationModel.h+1−3
@@ -41,8 +41,6 @@ public:
41
41
42 Q_INVOKABLE void append(MockNotification* n);
42 Q_INVOKABLE void append(MockNotification* n);
43 MockNotification* getNotification(int id) const;
43 MockNotification* getNotification(int id) const;
44− MockNotification* getNotification(const QString &summary) const;
45− bool hasNotification(int id) const;
46
44
47 // getRaw() is only meant to be used from QML, since QML cannot handle
45 // getRaw() is only meant to be used from QML, since QML cannot handle
48 // QSharedPointers... on C++-side only use getNotification()
46 // QSharedPointers... on C++-side only use getNotification()
@@ -68,7 +66,7 @@ Q_SIGNALS:
68
66
69private:
67private:
70 QList<MockNotification*> m_queue;
68 QList<MockNotification*> m_queue;
71− void deleteFromVisible(int loc);
69+ void removeInternal(int loc);
72};
70};
73
71
74#endif
72#endif
tests/qmltests/Notifications/Notification.qml−8
@@ -17,17 +17,9 @@
17 * Mirco Mueller <mirco.mueller@canonical.com>
17 * Mirco Mueller <mirco.mueller@canonical.com>
18 */
18 */
19
19
20−import QtQuick 2.0
21−import QtTest 1.0
22−import ".."
23−import "../../../qml/Notifications"
24−import Ubuntu.Components 0.1
25−import Unity.Test 0.1
26import Unity.Notifications 1.0
20import Unity.Notifications 1.0
27−import QtMultimedia 5.0
28
21
29Notification {
22Notification {
30− id: bla
31 nid: 0
23 nid: 0
32 type: Notification.PlaceHolder
24 type: Notification.PlaceHolder
33 summary: ""
25 summary: ""
tests/qmltests/Notifications/tst_Notifications.qml+1−1
@@ -603,7 +603,7 @@ Item {
603 compare(buttonRow.visible, data.buttonRowVisible, "button visibility is incorrect")
603 compare(buttonRow.visible, data.buttonRowVisible, "button visibility is incorrect")
604
604
605 var audioItem = findInvisibleChild(notification, "sound")
605 var audioItem = findInvisibleChild(notification, "sound")
606− //compare(audioItem.playbackState, data.hasSound ? Audio.PlayingState : Audio.StoppedState, "Audio has wrong state")
606+ compare(audioItem.playbackState, data.hasSound ? Audio.PlayingState : Audio.StoppedState, "Audio has wrong state")
607
607
608 if(data.buttonRowVisible) {
608 if(data.buttonRowVisible) {
609 var buttonCancel = findChild(buttonRow, "notify_button1")
609 var buttonCancel = findChild(buttonRow, "notify_button1")