diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-30 18:49:04 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-30 18:49:04 +0100 |
commit | 412563b7ff18684f9786f4e40b1a4d538f2d5233 (patch) | |
tree | 3190a317306cfb71b0d5d9bc4c0f06b260a92ce6 /tests/dummyresourcetest.cpp | |
parent | 790991aa1007d3271d80bc7e77f5b4f86c9bcef0 (diff) | |
parent | 6ad307dd846d07f1b55a1679a8d2eb47525af57d (diff) | |
download | sink-412563b7ff18684f9786f4e40b1a4d538f2d5233.tar.gz sink-412563b7ff18684f9786f4e40b1a4d538f2d5233.zip |
Merge branch 'feature/modelresult' into develop
Diffstat (limited to 'tests/dummyresourcetest.cpp')
-rw-r--r-- | tests/dummyresourcetest.cpp | 105 |
1 files changed, 65 insertions, 40 deletions
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index d027266..20c725f 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp | |||
@@ -4,10 +4,10 @@ | |||
4 | 4 | ||
5 | #include "dummyresource/resourcefactory.h" | 5 | #include "dummyresource/resourcefactory.h" |
6 | #include "clientapi.h" | 6 | #include "clientapi.h" |
7 | #include "synclistresult.h" | ||
8 | #include "commands.h" | 7 | #include "commands.h" |
9 | #include "entitybuffer.h" | 8 | #include "entitybuffer.h" |
10 | #include "resourceconfig.h" | 9 | #include "resourceconfig.h" |
10 | #include "modelresult.h" | ||
11 | #include "pipeline.h" | 11 | #include "pipeline.h" |
12 | #include "log.h" | 12 | #include "log.h" |
13 | 13 | ||
@@ -64,11 +64,13 @@ private Q_SLOTS: | |||
64 | query.syncOnDemand = false; | 64 | query.syncOnDemand = false; |
65 | query.processAll = true; | 65 | query.processAll = true; |
66 | 66 | ||
67 | //Ensure all local data is processed | ||
68 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
69 | |||
67 | query.propertyFilter.insert("uid", "testuid"); | 70 | query.propertyFilter.insert("uid", "testuid"); |
68 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 71 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); |
69 | result.exec(); | 72 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
70 | QCOMPARE(result.size(), 1); | 73 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); |
71 | auto value = result.first(); | ||
72 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 74 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
73 | } | 75 | } |
74 | 76 | ||
@@ -88,11 +90,15 @@ private Q_SLOTS: | |||
88 | query.syncOnDemand = false; | 90 | query.syncOnDemand = false; |
89 | query.processAll = true; | 91 | query.processAll = true; |
90 | 92 | ||
93 | //Ensure all local data is processed | ||
94 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
95 | |||
91 | query.propertyFilter.insert("uid", "testuid"); | 96 | query.propertyFilter.insert("uid", "testuid"); |
92 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 97 | |
93 | result.exec(); | 98 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); |
94 | QCOMPARE(result.size(), 1); | 99 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
95 | auto value = result.first(); | 100 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); |
101 | |||
96 | qDebug() << value->getProperty("uid").toByteArray(); | 102 | qDebug() << value->getProperty("uid").toByteArray(); |
97 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 103 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
98 | } | 104 | } |
@@ -114,11 +120,15 @@ private Q_SLOTS: | |||
114 | query.syncOnDemand = false; | 120 | query.syncOnDemand = false; |
115 | query.processAll = true; | 121 | query.processAll = true; |
116 | 122 | ||
123 | //Ensure all local data is processed | ||
124 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
125 | |||
117 | query.propertyFilter.insert("summary", "summaryValue2"); | 126 | query.propertyFilter.insert("summary", "summaryValue2"); |
118 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 127 | |
119 | result.exec(); | 128 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); |
120 | QCOMPARE(result.size(), 1); | 129 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
121 | auto value = result.first(); | 130 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); |
131 | |||
122 | qDebug() << value->getProperty("uid").toByteArray(); | 132 | qDebug() << value->getProperty("uid").toByteArray(); |
123 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid2")); | 133 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid2")); |
124 | } | 134 | } |
@@ -145,10 +155,13 @@ private Q_SLOTS: | |||
145 | query.syncOnDemand = true; | 155 | query.syncOnDemand = true; |
146 | query.processAll = true; | 156 | query.processAll = true; |
147 | 157 | ||
148 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 158 | //Ensure all local data is processed |
149 | result.exec(); | 159 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
150 | QVERIFY(!result.isEmpty()); | 160 | |
151 | auto value = result.first(); | 161 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); |
162 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); | ||
163 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); | ||
164 | |||
152 | QVERIFY(!value->getProperty("summary").toString().isEmpty()); | 165 | QVERIFY(!value->getProperty("summary").toString().isEmpty()); |
153 | qDebug() << value->getProperty("summary").toString(); | 166 | qDebug() << value->getProperty("summary").toString(); |
154 | } | 167 | } |
@@ -160,10 +173,13 @@ private Q_SLOTS: | |||
160 | query.syncOnDemand = true; | 173 | query.syncOnDemand = true; |
161 | query.processAll = true; | 174 | query.processAll = true; |
162 | 175 | ||
163 | async::SyncListResult<Akonadi2::ApplicationDomain::Mail::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Mail>(query)); | 176 | //Ensure all local data is processed |
164 | result.exec(); | 177 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
165 | QVERIFY(!result.isEmpty()); | 178 | |
166 | auto value = result.first(); | 179 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); |
180 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); | ||
181 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>(); | ||
182 | |||
167 | QVERIFY(!value->getProperty("subject").toString().isEmpty()); | 183 | QVERIFY(!value->getProperty("subject").toString().isEmpty()); |
168 | qDebug() << value->getProperty("subject").toString(); | 184 | qDebug() << value->getProperty("subject").toString(); |
169 | } | 185 | } |
@@ -182,13 +198,16 @@ private Q_SLOTS: | |||
182 | query.processAll = true; | 198 | query.processAll = true; |
183 | query.propertyFilter.insert("uid", "testuid"); | 199 | query.propertyFilter.insert("uid", "testuid"); |
184 | 200 | ||
201 | //Ensure all local data is processed | ||
202 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
203 | |||
185 | //Test create | 204 | //Test create |
186 | Akonadi2::ApplicationDomain::Event event2; | 205 | Akonadi2::ApplicationDomain::Event event2; |
187 | { | 206 | { |
188 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 207 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); |
189 | result.exec(); | 208 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
190 | QCOMPARE(result.size(), 1); | 209 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); |
191 | auto value = result.first(); | 210 | |
192 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 211 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
193 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue")); | 212 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue")); |
194 | event2 = *value; | 213 | event2 = *value; |
@@ -198,23 +217,29 @@ private Q_SLOTS: | |||
198 | event2.setProperty("summary", "summaryValue2"); | 217 | event2.setProperty("summary", "summaryValue2"); |
199 | Akonadi2::Store::modify<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); | 218 | Akonadi2::Store::modify<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); |
200 | 219 | ||
220 | //Ensure all local data is processed | ||
221 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
222 | |||
201 | //Test modify | 223 | //Test modify |
202 | { | 224 | { |
203 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 225 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); |
204 | result.exec(); | 226 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
205 | QCOMPARE(result.size(), 1); | 227 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); |
206 | auto value = result.first(); | 228 | |
207 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 229 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
208 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue2")); | 230 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue2")); |
209 | } | 231 | } |
210 | 232 | ||
211 | Akonadi2::Store::remove<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); | 233 | Akonadi2::Store::remove<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); |
212 | 234 | ||
235 | //Ensure all local data is processed | ||
236 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
237 | |||
213 | //Test remove | 238 | //Test remove |
214 | { | 239 | { |
215 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 240 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); |
216 | result.exec(); | 241 | //TODO ensure the initial query is done |
217 | QTRY_COMPARE(result.size(), 0); | 242 | QTRY_COMPARE(model->rowCount(QModelIndex()), 0); |
218 | } | 243 | } |
219 | } | 244 | } |
220 | 245 | ||
@@ -228,9 +253,8 @@ private Q_SLOTS: | |||
228 | query.liveQuery = true; | 253 | query.liveQuery = true; |
229 | query.propertyFilter.insert("uid", "testuid"); | 254 | query.propertyFilter.insert("uid", "testuid"); |
230 | 255 | ||
231 | 256 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | |
232 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Event>(query)); | 257 | //TODO ensure the initial query is done |
233 | result.exec(); | ||
234 | 258 | ||
235 | Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1"); | 259 | Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1"); |
236 | event.setProperty("uid", "testuid"); | 260 | event.setProperty("uid", "testuid"); |
@@ -241,8 +265,8 @@ private Q_SLOTS: | |||
241 | //Test create | 265 | //Test create |
242 | Akonadi2::ApplicationDomain::Event event2; | 266 | Akonadi2::ApplicationDomain::Event event2; |
243 | { | 267 | { |
244 | QTRY_COMPARE(result.size(), 1); | 268 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
245 | auto value = result.first(); | 269 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); |
246 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 270 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
247 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue")); | 271 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue")); |
248 | event2 = *value; | 272 | event2 = *value; |
@@ -254,8 +278,9 @@ private Q_SLOTS: | |||
254 | 278 | ||
255 | //Test modify | 279 | //Test modify |
256 | { | 280 | { |
257 | QTRY_COMPARE(result.size(), 1); | 281 | //TODO wait for a change signal |
258 | auto value = result.first(); | 282 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
283 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); | ||
259 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 284 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
260 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue2")); | 285 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue2")); |
261 | } | 286 | } |
@@ -264,7 +289,7 @@ private Q_SLOTS: | |||
264 | 289 | ||
265 | //Test remove | 290 | //Test remove |
266 | { | 291 | { |
267 | QTRY_COMPARE(result.size(), 0); | 292 | QTRY_COMPARE(model->rowCount(QModelIndex()), 0); |
268 | } | 293 | } |
269 | } | 294 | } |
270 | 295 | ||