on xenial help sign in
Expose size of mocked notification-model as count for the qmltest.
commit25c5617dfb48c52effa7c1ea642a6eb59e474ca6 authorMirco Müller <mirco.mueller@ubuntu.com> dateFri 16 Jan 2015, 16:31 (12 years ago) parent2286975
3 files changed+12−8
tests/mocks/Unity/Notifications/MockNotificationModel.cpp+5−4 tests/mocks/Unity/Notifications/MockNotificationModel.h+4−1 tests/qmltests/Notifications/tst_Notifications.qml+3−3
tests/mocks/Unity/Notifications/MockNotificationModel.cpp+5−4
@@ -42,8 +42,11 @@ int MockNotificationModel::rowCount(const QModelIndex &parent) const {
4242 return m_queue.size();
4343}
4444
45+int MockNotificationModel::getCount() const {
46+ return m_queue.size();
47+}
48+
4549QVariant MockNotificationModel::data(const QModelIndex &index, int role) const {
46− qDebug() << "::data()";
4750 if (!index.isValid())
4851 return QVariant();
4952
@@ -89,7 +92,6 @@ void MockNotificationModel::append(MockNotification* n) {
8992 beginInsertRows(insertionPoint, location, location);
9093 m_queue.insert(location, n);
9194 endInsertRows();
92− qDebug() << "queue-size:" << m_queue.size();
9395}
9496
9597MockNotification* MockNotificationModel::getNotification(unsigned int id) const {
@@ -116,7 +118,7 @@ bool MockNotificationModel::hasNotification(unsigned int id) const {
116118 return !(getNotification(id) != nullptr);
117119}
118120
119−void MockNotificationModel::removeNotification(const unsigned int id) {
121+void MockNotificationModel::remove(const unsigned int id) {
120122 for(int i = 0; i < m_queue.size(); i++) {
121123 if(m_queue[i]->getID() == id) {
122124 deleteFromVisible(i);
@@ -140,7 +142,6 @@ void MockNotificationModel::deleteFromVisible(int loc) {
140142}
141143
142144MockNotification* MockNotificationModel::getRaw(const unsigned int notificationId) const {
143− qDebug() << "::getRaw()";
144145 for(int i = 0; i < m_queue.size(); i++) {
145146 if(m_queue[i]->getID() == notificationId) {
146147 MockNotification* n = m_queue[i];
tests/mocks/Unity/Notifications/MockNotificationModel.h+4−1
@@ -29,6 +29,7 @@ class MockNotification;
2929
3030class MockNotificationModel : public QAbstractListModel {
3131 Q_OBJECT
32+ Q_PROPERTY(int count READ getCount)
3233
3334public:
3435 MockNotificationModel(QObject *parent=nullptr);
@@ -48,7 +49,9 @@ public:
4849 Q_INVOKABLE MockNotification* getRaw(const unsigned int notificationId) const;
4950
5051 Q_INVOKABLE int queued() const;
51− Q_INVOKABLE void removeNotification(const unsigned int id);
52+ Q_INVOKABLE void remove(const unsigned int id);
53+
54+ int getCount() const;
5255
5356private Q_SLOTS:
5457 void onDataChanged(unsigned int id);
tests/qmltests/Notifications/tst_Notifications.qml+3−3
@@ -125,7 +125,7 @@ Item {
125125
126126 // add the default/PlaceHolder notification to the model
127127 Component.onCompleted: {
128− //append(mockList[0])
128+ append(mockList[0])
129129 }
130130 }
131131
@@ -164,8 +164,9 @@ Item {
164164 }
165165
166166 function remove1stNotification() {
167− if (mockModel.count > 1)
167+ if (mockModel.count > 1) {
168168 mockModel.remove(1)
169+ }
169170 }
170171
171172 Rectangle {
@@ -187,7 +188,6 @@ Item {
187188
188189 anchors.fill: parent
189190 model: mockModel
190− //model: mockList
191191 }
192192 }
193193