diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/maildirresourcetest.cpp | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index 046c920..8952ff2 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -299,32 +299,37 @@ private Q_SLOTS: | |||
299 | 299 | ||
300 | void testRemoveMail() | 300 | void testRemoveMail() |
301 | { | 301 | { |
302 | Akonadi2::Query query; | 302 | using namespace Akonadi2; |
303 | query.resources << "org.kde.maildir.instance1"; | 303 | using namespace Akonadi2::ApplicationDomain; |
304 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
305 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
306 | |||
307 | Akonadi2::Query folderQuery; | ||
308 | folderQuery.resources << "org.kde.maildir.instance1"; | ||
309 | folderQuery.propertyFilter.insert("name", "maildir1"); | ||
310 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(folderQuery); | ||
311 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
312 | QCOMPARE(model->rowCount(QModelIndex()), 1); | ||
313 | auto folder = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | ||
314 | 304 | ||
315 | Akonadi2::Query mailQuery; | 305 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
316 | mailQuery.resources << "org.kde.maildir.instance1"; | 306 | Store::synchronize(query).exec().waitForFinished(); |
317 | mailQuery.propertyFilter.insert("folder", folder->identifier()); | 307 | Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
318 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(mailQuery); | ||
319 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
320 | QCOMPARE(mailModel->rowCount(QModelIndex()), 1); | ||
321 | auto mail = mailModel->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>(); | ||
322 | 308 | ||
323 | Akonadi2::Store::remove(*mail).exec().waitForFinished(); | 309 | auto result = Store::fetchOne<Folder>( |
324 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 310 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("name", "maildir1") + Query::RequestedProperties(QByteArrayList() << "name") |
325 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 311 | ) |
312 | .then<void, KAsync::Job<void>, Folder>([query](const Folder &folder) { | ||
313 | return Store::fetchAll<Mail>( | ||
314 | Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject") | ||
315 | ) | ||
316 | .then<void, KAsync::Job<void>, QList<Mail::Ptr> >([query](const QList<Mail::Ptr> &mails) { | ||
317 | //Can't use QCOMPARE because it tries to return FIXME Implement ASYNCCOMPARE | ||
318 | if (mails.size() != 1) { | ||
319 | return KAsync::error<void>(1, "Wrong number of mails."); | ||
320 | } | ||
321 | auto mail = mails.first(); | ||
326 | 322 | ||
327 | QTRY_COMPARE(QDir(tempDir.path() + "/maildir1/cur", QString(), QDir::NoSort, QDir::Files).count(), static_cast<unsigned int>(0)); | 323 | auto inspectionCommand = Akonadi2::Resources::Inspection::ExistenceInspection(*mail, true); |
324 | return Store::remove(*mail) | ||
325 | .then(Store::flushMessageQueue(query.resources)) //The change needs to be replayed already | ||
326 | .then(Resources::inspect<Mail>(inspectionCommand)); | ||
327 | }) | ||
328 | .then<void>([](){}); | ||
329 | }) | ||
330 | .exec(); | ||
331 | result.waitForFinished(); | ||
332 | QVERIFY(!result.errorCode()); | ||
328 | } | 333 | } |
329 | 334 | ||
330 | void testMarkMailAsRead() | 335 | void testMarkMailAsRead() |