summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-01-14 18:23:04 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-01-14 18:23:04 +0100
commitc631c520e260a8455dcdc501a19f4513bada13cb (patch)
tree91047f388fcb0db3b091d32953be99cd2b6544ad
parentfd9703a6f990d965d1c7fba21fee36b2beef644e (diff)
downloadsink-c631c520e260a8455dcdc501a19f4513bada13cb.tar.gz
sink-c631c520e260a8455dcdc501a19f4513bada13cb.zip
Ported a first test to the new API
This also requires a new KAsync version
-rw-r--r--tests/maildirresourcetest.cpp51
1 files 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:
120 120
121 void testListMailsOfFolder() 121 void testListMailsOfFolder()
122 { 122 {
123 { 123 using namespace Akonadi2;
124 Akonadi2::Query query; 124 using namespace Akonadi2::ApplicationDomain;
125 query.resources << "org.kde.maildir.instance1"; 125 //Ensure all local data is processed
126 query.syncOnDemand = true; 126 auto query = Query::ResourceFilter("org.kde.maildir.instance1");
127 query.processAll = true; 127 query.processAll = true;
128 128 query.syncOnDemand = true;
129 //Ensure all local data is processed 129 Store::synchronize(query).exec().waitForFinished();
130 Akonadi2::Store::synchronize(query).exec().waitForFinished(); 130 // Store::flushMessageQueues(Query::ResourceFilter("org.kde.maildir.instance1")).exec().waitForFinished();
131 } 131 auto result = Store::fetchOne<Folder>(
132 QByteArray folderIdentifier; 132 Query::ResourceFilter("org.kde.maildir.instance1") + Query::RequestedProperties(QByteArrayList() << "name")
133 { 133 )
134 Akonadi2::Query query; 134 .then<QList<Mail::Ptr>, Folder>([](const Folder &folder) {
135 query.resources << "org.kde.maildir.instance1"; 135 Trace() << "Found a folder" << folder.identifier();
136 query.requestedProperties << "folder" << "name"; 136 return Store::fetchAll<Mail>(
137 137 Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject")
138 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); 138 );
139 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 139 })
140 QVERIFY(model->rowCount(QModelIndex()) > 1); 140 .then<void, QList<Mail::Ptr> >([](const QList<Mail::Ptr> &mails) {
141 folderIdentifier = model->index(1, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>()->identifier(); 141 QVERIFY(mails.size() >= 1);
142 } 142 })
143 143 .exec();
144 Akonadi2::Query query; 144 result.waitForFinished();
145 query.resources << "org.kde.maildir.instance1"; 145 QVERIFY(!result.errorCode());
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 } 146 }
152 147
153 void testMailContent() 148 void testMailContent()