diff options
Diffstat (limited to 'tests/maildirresourcetest.cpp')
-rw-r--r-- | tests/maildirresourcetest.cpp | 178 |
1 files changed, 101 insertions, 77 deletions
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index 6e7818a..ec4f6a4 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -87,11 +87,10 @@ private Q_SLOTS: | |||
87 | { | 87 | { |
88 | Akonadi2::Query query; | 88 | Akonadi2::Query query; |
89 | query.resources << "org.kde.maildir.instance1"; | 89 | query.resources << "org.kde.maildir.instance1"; |
90 | query.syncOnDemand = true; | ||
91 | query.processAll = true; | ||
92 | 90 | ||
93 | //Ensure all local data is processed | 91 | //Ensure all local data is processed |
94 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 92 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
93 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
95 | 94 | ||
96 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 95 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); |
97 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 96 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -102,12 +101,11 @@ private Q_SLOTS: | |||
102 | { | 101 | { |
103 | Akonadi2::Query query; | 102 | Akonadi2::Query query; |
104 | query.resources << "org.kde.maildir.instance1"; | 103 | query.resources << "org.kde.maildir.instance1"; |
105 | query.syncOnDemand = true; | ||
106 | query.processAll = true; | ||
107 | query.parentProperty = "parent"; | 104 | query.parentProperty = "parent"; |
108 | 105 | ||
109 | //Ensure all local data is processed | 106 | //Ensure all local data is processed |
110 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 107 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
108 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
111 | 109 | ||
112 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 110 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); |
113 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 111 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -120,34 +118,27 @@ private Q_SLOTS: | |||
120 | 118 | ||
121 | void testListMailsOfFolder() | 119 | void testListMailsOfFolder() |
122 | { | 120 | { |
123 | { | 121 | using namespace Akonadi2; |
124 | Akonadi2::Query query; | 122 | using namespace Akonadi2::ApplicationDomain; |
125 | query.resources << "org.kde.maildir.instance1"; | 123 | //Ensure all local data is processed |
126 | query.syncOnDemand = true; | 124 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
127 | query.processAll = true; | 125 | Store::synchronize(query).exec().waitForFinished(); |
128 | 126 | Store::flushMessageQueue(query.resources).exec().waitForFinished(); | |
129 | //Ensure all local data is processed | 127 | auto result = Store::fetchOne<Folder>( |
130 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 128 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::RequestedProperties(QByteArrayList() << "name") |
131 | } | 129 | ) |
132 | QByteArray folderIdentifier; | 130 | .then<QList<Mail::Ptr>, Folder>([](const Folder &folder) { |
133 | { | 131 | Trace() << "Found a folder" << folder.identifier(); |
134 | Akonadi2::Query query; | 132 | return Store::fetchAll<Mail>( |
135 | query.resources << "org.kde.maildir.instance1"; | 133 | Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject") |
136 | query.requestedProperties << "folder" << "name"; | 134 | ); |
137 | 135 | }) | |
138 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 136 | .then<void, QList<Mail::Ptr> >([](const QList<Mail::Ptr> &mails) { |
139 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 137 | QVERIFY(mails.size() >= 1); |
140 | QVERIFY(model->rowCount(QModelIndex()) > 1); | 138 | }) |
141 | folderIdentifier = model->index(1, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>()->identifier(); | 139 | .exec(); |
142 | } | 140 | result.waitForFinished(); |
143 | 141 | QVERIFY(!result.errorCode()); | |
144 | Akonadi2::Query query; | ||
145 | query.resources << "org.kde.maildir.instance1"; | ||
146 | query.requestedProperties << "folder" << "subject"; | ||
147 | query.propertyFilter.insert("folder", folderIdentifier); | ||
148 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | ||
149 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
150 | QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); | ||
151 | } | 142 | } |
152 | 143 | ||
153 | void testMailContent() | 144 | void testMailContent() |
@@ -155,11 +146,10 @@ private Q_SLOTS: | |||
155 | Akonadi2::Query query; | 146 | Akonadi2::Query query; |
156 | query.resources << "org.kde.maildir.instance1"; | 147 | query.resources << "org.kde.maildir.instance1"; |
157 | query.requestedProperties << "folder" << "subject" << "mimeMessage" << "date"; | 148 | query.requestedProperties << "folder" << "subject" << "mimeMessage" << "date"; |
158 | query.syncOnDemand = true; | ||
159 | query.processAll = true; | ||
160 | 149 | ||
161 | //Ensure all local data is processed | 150 | //Ensure all local data is processed |
162 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 151 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
152 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
163 | 153 | ||
164 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 154 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); |
165 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 155 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -175,12 +165,11 @@ private Q_SLOTS: | |||
175 | { | 165 | { |
176 | Akonadi2::Query query; | 166 | Akonadi2::Query query; |
177 | query.resources << "org.kde.maildir.instance1"; | 167 | query.resources << "org.kde.maildir.instance1"; |
178 | query.syncOnDemand = true; | ||
179 | query.processAll = true; | ||
180 | query.requestedProperties << "name"; | 168 | query.requestedProperties << "name"; |
181 | 169 | ||
182 | //Ensure all local data is processed | 170 | //Ensure all local data is processed |
183 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 171 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
172 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
184 | 173 | ||
185 | auto targetPath = tempDir.path() + "/maildir1/"; | 174 | auto targetPath = tempDir.path() + "/maildir1/"; |
186 | QDir dir(targetPath); | 175 | QDir dir(targetPath); |
@@ -188,6 +177,7 @@ private Q_SLOTS: | |||
188 | 177 | ||
189 | //Ensure all local data is processed | 178 | //Ensure all local data is processed |
190 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 179 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
180 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
191 | 181 | ||
192 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 182 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); |
193 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 183 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -199,15 +189,15 @@ private Q_SLOTS: | |||
199 | { | 189 | { |
200 | Akonadi2::Query query; | 190 | Akonadi2::Query query; |
201 | query.resources << "org.kde.maildir.instance1"; | 191 | query.resources << "org.kde.maildir.instance1"; |
202 | query.syncOnDemand = true; | ||
203 | query.processAll = true; | ||
204 | query.requestedProperties << "folder" << "subject"; | 192 | query.requestedProperties << "folder" << "subject"; |
205 | 193 | ||
206 | //Ensure all local data is processed | 194 | //Ensure all local data is processed |
207 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 195 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
196 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
208 | 197 | ||
209 | //Ensure all local data is processed | 198 | //Ensure all local data is processed |
210 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 199 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
200 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
211 | 201 | ||
212 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 202 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); |
213 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 203 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -218,12 +208,11 @@ private Q_SLOTS: | |||
218 | { | 208 | { |
219 | Akonadi2::Query query; | 209 | Akonadi2::Query query; |
220 | query.resources << "org.kde.maildir.instance1"; | 210 | query.resources << "org.kde.maildir.instance1"; |
221 | query.syncOnDemand = true; | ||
222 | query.processAll = true; | ||
223 | query.requestedProperties << "folder" << "subject"; | 211 | query.requestedProperties << "folder" << "subject"; |
224 | 212 | ||
225 | //Ensure all local data is processed | 213 | //Ensure all local data is processed |
226 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 214 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
215 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
227 | 216 | ||
228 | auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; | 217 | auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; |
229 | QFile file(targetPath); | 218 | QFile file(targetPath); |
@@ -231,6 +220,7 @@ private Q_SLOTS: | |||
231 | 220 | ||
232 | //Ensure all local data is processed | 221 | //Ensure all local data is processed |
233 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 222 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
223 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
234 | 224 | ||
235 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 225 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); |
236 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 226 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -241,11 +231,9 @@ private Q_SLOTS: | |||
241 | { | 231 | { |
242 | Akonadi2::Query query; | 232 | Akonadi2::Query query; |
243 | query.resources << "org.kde.maildir.instance1"; | 233 | query.resources << "org.kde.maildir.instance1"; |
244 | query.syncOnDemand = false; | ||
245 | query.processAll = true; | ||
246 | 234 | ||
247 | //Ensure all local data is processed | 235 | //Ensure all local data is processed |
248 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 236 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
249 | 237 | ||
250 | Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); | 238 | Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); |
251 | folder.setProperty("name", "testCreateFolder"); | 239 | folder.setProperty("name", "testCreateFolder"); |
@@ -253,7 +241,7 @@ private Q_SLOTS: | |||
253 | Akonadi2::Store::create(folder).exec().waitForFinished(); | 241 | Akonadi2::Store::create(folder).exec().waitForFinished(); |
254 | 242 | ||
255 | //Ensure all local data is processed | 243 | //Ensure all local data is processed |
256 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 244 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
257 | 245 | ||
258 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; | 246 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; |
259 | QFileInfo file(targetPath); | 247 | QFileInfo file(targetPath); |
@@ -265,15 +253,13 @@ private Q_SLOTS: | |||
265 | { | 253 | { |
266 | Akonadi2::Query query; | 254 | Akonadi2::Query query; |
267 | query.resources << "org.kde.maildir.instance1"; | 255 | query.resources << "org.kde.maildir.instance1"; |
268 | query.syncOnDemand = false; | ||
269 | query.processAll = true; | ||
270 | 256 | ||
271 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; | 257 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; |
272 | 258 | ||
273 | Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); | 259 | Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); |
274 | folder.setProperty("name", "testCreateFolder"); | 260 | folder.setProperty("name", "testCreateFolder"); |
275 | Akonadi2::Store::create(folder).exec().waitForFinished(); | 261 | Akonadi2::Store::create(folder).exec().waitForFinished(); |
276 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 262 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
277 | QTRY_VERIFY(QFileInfo(targetPath).exists()); | 263 | QTRY_VERIFY(QFileInfo(targetPath).exists()); |
278 | 264 | ||
279 | Akonadi2::Query folderQuery; | 265 | Akonadi2::Query folderQuery; |
@@ -285,7 +271,7 @@ private Q_SLOTS: | |||
285 | auto createdFolder = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | 271 | auto createdFolder = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); |
286 | 272 | ||
287 | Akonadi2::Store::remove(*createdFolder).exec().waitForFinished(); | 273 | Akonadi2::Store::remove(*createdFolder).exec().waitForFinished(); |
288 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 274 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
289 | QTRY_VERIFY(!QFileInfo(targetPath).exists()); | 275 | QTRY_VERIFY(!QFileInfo(targetPath).exists()); |
290 | } | 276 | } |
291 | 277 | ||
@@ -293,11 +279,9 @@ private Q_SLOTS: | |||
293 | { | 279 | { |
294 | Akonadi2::Query query; | 280 | Akonadi2::Query query; |
295 | query.resources << "org.kde.maildir.instance1"; | 281 | query.resources << "org.kde.maildir.instance1"; |
296 | query.syncOnDemand = false; | ||
297 | query.processAll = true; | ||
298 | 282 | ||
299 | //Ensure all local data is processed | 283 | //Ensure all local data is processed |
300 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 284 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
301 | 285 | ||
302 | Akonadi2::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); | 286 | Akonadi2::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); |
303 | mail.setProperty("name", "testCreateMail"); | 287 | mail.setProperty("name", "testCreateMail"); |
@@ -305,7 +289,7 @@ private Q_SLOTS: | |||
305 | Akonadi2::Store::create(mail).exec().waitForFinished(); | 289 | Akonadi2::Store::create(mail).exec().waitForFinished(); |
306 | 290 | ||
307 | //Ensure all local data is processed | 291 | //Ensure all local data is processed |
308 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 292 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
309 | 293 | ||
310 | auto targetPath = tempDir.path() + "/maildir1/new"; | 294 | auto targetPath = tempDir.path() + "/maildir1/new"; |
311 | QDir dir(targetPath); | 295 | QDir dir(targetPath); |
@@ -315,32 +299,72 @@ private Q_SLOTS: | |||
315 | 299 | ||
316 | void testRemoveMail() | 300 | void testRemoveMail() |
317 | { | 301 | { |
318 | Akonadi2::Query query; | 302 | using namespace Akonadi2; |
319 | query.resources << "org.kde.maildir.instance1"; | 303 | using namespace Akonadi2::ApplicationDomain; |
320 | query.syncOnDemand = true; | 304 | |
321 | query.processAll = true; | 305 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
322 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 306 | Store::synchronize(query).exec().waitForFinished(); |
323 | 307 | Store::flushMessageQueue(query.resources).exec().waitForFinished(); | |
324 | Akonadi2::Query folderQuery; | 308 | |
325 | folderQuery.resources << "org.kde.maildir.instance1"; | 309 | auto result = Store::fetchOne<Folder>( |
326 | folderQuery.propertyFilter.insert("name", "maildir1"); | 310 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("name", "maildir1") + Query::RequestedProperties(QByteArrayList() << "name") |
327 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(folderQuery); | 311 | ) |
328 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 312 | .then<void, KAsync::Job<void>, Folder>([query](const Folder &folder) { |
329 | QCOMPARE(model->rowCount(QModelIndex()), 1); | 313 | return Store::fetchAll<Mail>( |
330 | auto folder = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | 314 | Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject") |
331 | 315 | ) | |
332 | Akonadi2::Query mailQuery; | 316 | .then<void, KAsync::Job<void>, QList<Mail::Ptr> >([query](const QList<Mail::Ptr> &mails) { |
333 | mailQuery.resources << "org.kde.maildir.instance1"; | 317 | //Can't use QCOMPARE because it tries to return FIXME Implement ASYNCCOMPARE |
334 | mailQuery.propertyFilter.insert("folder", folder->identifier()); | 318 | if (mails.size() != 1) { |
335 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(mailQuery); | 319 | return KAsync::error<void>(1, "Wrong number of mails."); |
336 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 320 | } |
337 | QCOMPARE(mailModel->rowCount(QModelIndex()), 1); | 321 | auto mail = mails.first(); |
338 | auto mail = mailModel->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>(); | 322 | |
339 | 323 | return Store::remove(*mail) | |
340 | Akonadi2::Store::remove(*mail).exec().waitForFinished(); | 324 | .then(Store::flushReplayQueue(query.resources)) //The change needs to be replayed already |
341 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 325 | .then(Resources::inspect<Mail>(Resources::Inspection::ExistenceInspection(*mail, false))); |
326 | }) | ||
327 | .then<void>([](){}); | ||
328 | }) | ||
329 | .exec(); | ||
330 | result.waitForFinished(); | ||
331 | QVERIFY(!result.errorCode()); | ||
332 | } | ||
342 | 333 | ||
343 | QTRY_COMPARE(QDir(tempDir.path() + "/maildir1/cur", QString(), QDir::NoSort, QDir::Files).count(), static_cast<unsigned int>(0)); | 334 | void testMarkMailAsRead() |
335 | { | ||
336 | using namespace Akonadi2; | ||
337 | using namespace Akonadi2::ApplicationDomain; | ||
338 | |||
339 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); | ||
340 | Store::synchronize(query).exec().waitForFinished(); | ||
341 | Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
342 | |||
343 | auto result = Store::fetchOne<Folder>( | ||
344 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("name", "maildir1") + Query::RequestedProperties(QByteArrayList() << "name") | ||
345 | ) | ||
346 | .then<void, KAsync::Job<void>, Folder>([query](const Folder &folder) { | ||
347 | Trace() << "Found a folder" << folder.identifier(); | ||
348 | return Store::fetchAll<Mail>( | ||
349 | Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject") | ||
350 | ) | ||
351 | .then<void, KAsync::Job<void>, QList<Mail::Ptr> >([query](const QList<Mail::Ptr> &mails) { | ||
352 | //Can't use QCOMPARE because it tries to return FIXME Implement ASYNCCOMPARE | ||
353 | if (mails.size() != 1) { | ||
354 | return KAsync::error<void>(1, "Wrong number of mails."); | ||
355 | } | ||
356 | auto mail = mails.first(); | ||
357 | mail->setProperty("unread", true); | ||
358 | auto inspectionCommand = Resources::Inspection::PropertyInspection(*mail, "unread", true); | ||
359 | return Store::modify(*mail) | ||
360 | .then<void>(Store::flushReplayQueue(query.resources)) //The change needs to be replayed already | ||
361 | .then(Resources::inspect<Mail>(inspectionCommand)); | ||
362 | }) | ||
363 | .then<void>([](){}); | ||
364 | }) | ||
365 | .exec(); | ||
366 | result.waitForFinished(); | ||
367 | QVERIFY(!result.errorCode()); | ||
344 | } | 368 | } |
345 | 369 | ||
346 | }; | 370 | }; |