diff options
Diffstat (limited to 'tests/maildirresourcetest.cpp')
-rw-r--r-- | tests/maildirresourcetest.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index 741706c..6e7818a 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -313,6 +313,36 @@ private Q_SLOTS: | |||
313 | QTRY_COMPARE(dir.count(), static_cast<unsigned int>(1)); | 313 | QTRY_COMPARE(dir.count(), static_cast<unsigned int>(1)); |
314 | } | 314 | } |
315 | 315 | ||
316 | void testRemoveMail() | ||
317 | { | ||
318 | Akonadi2::Query query; | ||
319 | query.resources << "org.kde.maildir.instance1"; | ||
320 | query.syncOnDemand = true; | ||
321 | query.processAll = true; | ||
322 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
323 | |||
324 | Akonadi2::Query folderQuery; | ||
325 | folderQuery.resources << "org.kde.maildir.instance1"; | ||
326 | folderQuery.propertyFilter.insert("name", "maildir1"); | ||
327 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(folderQuery); | ||
328 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
329 | QCOMPARE(model->rowCount(QModelIndex()), 1); | ||
330 | auto folder = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | ||
331 | |||
332 | Akonadi2::Query mailQuery; | ||
333 | mailQuery.resources << "org.kde.maildir.instance1"; | ||
334 | mailQuery.propertyFilter.insert("folder", folder->identifier()); | ||
335 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(mailQuery); | ||
336 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
337 | QCOMPARE(mailModel->rowCount(QModelIndex()), 1); | ||
338 | auto mail = mailModel->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>(); | ||
339 | |||
340 | Akonadi2::Store::remove(*mail).exec().waitForFinished(); | ||
341 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
342 | |||
343 | QTRY_COMPARE(QDir(tempDir.path() + "/maildir1/cur", QString(), QDir::NoSort, QDir::Files).count(), static_cast<unsigned int>(0)); | ||
344 | } | ||
345 | |||
316 | }; | 346 | }; |
317 | 347 | ||
318 | QTEST_MAIN(MaildirResourceTest) | 348 | QTEST_MAIN(MaildirResourceTest) |