From c631c520e260a8455dcdc501a19f4513bada13cb Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 14 Jan 2016 18:23:04 +0100 Subject: Ported a first test to the new API This also requires a new KAsync version --- tests/maildirresourcetest.cpp | 51 +++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index 6e7818a..b61190d 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp @@ -120,34 +120,29 @@ private Q_SLOTS: void testListMailsOfFolder() { - { - Akonadi2::Query query; - query.resources << "org.kde.maildir.instance1"; - query.syncOnDemand = true; - query.processAll = true; - - //Ensure all local data is processed - Akonadi2::Store::synchronize(query).exec().waitForFinished(); - } - QByteArray folderIdentifier; - { - Akonadi2::Query query; - query.resources << "org.kde.maildir.instance1"; - query.requestedProperties << "folder" << "name"; - - auto model = Akonadi2::Store::loadModel(query); - QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); - QVERIFY(model->rowCount(QModelIndex()) > 1); - folderIdentifier = model->index(1, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value()->identifier(); - } - - Akonadi2::Query query; - query.resources << "org.kde.maildir.instance1"; - query.requestedProperties << "folder" << "subject"; - query.propertyFilter.insert("folder", folderIdentifier); - auto mailModel = Akonadi2::Store::loadModel(query); - QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); - QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); + using namespace Akonadi2; + using namespace Akonadi2::ApplicationDomain; + //Ensure all local data is processed + auto query = Query::ResourceFilter("org.kde.maildir.instance1"); + query.processAll = true; + query.syncOnDemand = true; + Store::synchronize(query).exec().waitForFinished(); + // Store::flushMessageQueues(Query::ResourceFilter("org.kde.maildir.instance1")).exec().waitForFinished(); + auto result = Store::fetchOne( + Query::ResourceFilter("org.kde.maildir.instance1") + Query::RequestedProperties(QByteArrayList() << "name") + ) + .then, Folder>([](const Folder &folder) { + Trace() << "Found a folder" << folder.identifier(); + return Store::fetchAll( + Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject") + ); + }) + .then >([](const QList &mails) { + QVERIFY(mails.size() >= 1); + }) + .exec(); + result.waitForFinished(); + QVERIFY(!result.errorCode()); } void testMailContent() -- cgit v1.2.3