summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/accountstest.cpp8
-rw-r--r--tests/clientapitest.cpp4
-rw-r--r--tests/dummyresourcebenchmark.cpp30
-rw-r--r--tests/mailsynctest.cpp22
-rw-r--r--tests/mailtest.cpp22
-rw-r--r--tests/resourcecommunicationtest.cpp28
6 files changed, 43 insertions, 71 deletions
diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp
index 4be8bd6..e0a99c2 100644
--- a/tests/accountstest.cpp
+++ b/tests/accountstest.cpp
@@ -39,7 +39,7 @@ private slots:
39 account.setProperty("icon", accountIcon); 39 account.setProperty("icon", accountIcon);
40 Store::create(account).exec().waitForFinished(); 40 Store::create(account).exec().waitForFinished();
41 41
42 Store::fetchAll<SinkAccount>(Query()).then<void, QList<SinkAccount::Ptr>>([&](const QList<SinkAccount::Ptr> &accounts) { 42 Store::fetchAll<SinkAccount>(Query()).syncThen<void, QList<SinkAccount::Ptr>>([&](const QList<SinkAccount::Ptr> &accounts) {
43 QCOMPARE(accounts.size(), 1); 43 QCOMPARE(accounts.size(), 1);
44 auto account = accounts.first(); 44 auto account = accounts.first();
45 QCOMPARE(account->getProperty("type").toString(), QString("maildir")); 45 QCOMPARE(account->getProperty("type").toString(), QString("maildir"));
@@ -60,7 +60,7 @@ private slots:
60 Store::create(resource).exec().waitForFinished(); 60 Store::create(resource).exec().waitForFinished();
61 61
62 62
63 Store::fetchAll<SinkResource>(Query()).then<void, QList<SinkResource::Ptr>>([&](const QList<SinkResource::Ptr> &resources) { 63 Store::fetchAll<SinkResource>(Query()).syncThen<void, QList<SinkResource::Ptr>>([&](const QList<SinkResource::Ptr> &resources) {
64 QCOMPARE(resources.size(), 1); 64 QCOMPARE(resources.size(), 1);
65 auto resource = resources.first(); 65 auto resource = resources.first();
66 QCOMPARE(resource->getProperty("type").toString(), QString("sink.mailtransport")); 66 QCOMPARE(resource->getProperty("type").toString(), QString("sink.mailtransport"));
@@ -74,7 +74,7 @@ private slots:
74 identity.setProperty("account", account.identifier()); 74 identity.setProperty("account", account.identifier());
75 Store::create(identity).exec().waitForFinished(); 75 Store::create(identity).exec().waitForFinished();
76 76
77 Store::fetchAll<Identity>(Query()).then<void, QList<Identity::Ptr>>([&](const QList<Identity::Ptr> &identities) { 77 Store::fetchAll<Identity>(Query()).syncThen<void, QList<Identity::Ptr>>([&](const QList<Identity::Ptr> &identities) {
78 QCOMPARE(identities.size(), 1); 78 QCOMPARE(identities.size(), 1);
79 }) 79 })
80 .exec().waitForFinished(); 80 .exec().waitForFinished();
@@ -82,7 +82,7 @@ private slots:
82 82
83 Store::remove(resource).exec().waitForFinished(); 83 Store::remove(resource).exec().waitForFinished();
84 84
85 Store::fetchAll<SinkResource>(Query()).then<void, QList<SinkResource::Ptr>>([](const QList<SinkResource::Ptr> &resources) { 85 Store::fetchAll<SinkResource>(Query()).syncThen<void, QList<SinkResource::Ptr>>([](const QList<SinkResource::Ptr> &resources) {
86 QCOMPARE(resources.size(), 0); 86 QCOMPARE(resources.size(), 0);
87 }) 87 })
88 .exec().waitForFinished(); 88 .exec().waitForFinished();
diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp
index b1e49c4..b5405cf 100644
--- a/tests/clientapitest.cpp
+++ b/tests/clientapitest.cpp
@@ -70,7 +70,7 @@ public:
70 } 70 }
71 resultProvider->initialResultSetComplete(parent); 71 resultProvider->initialResultSetComplete(parent);
72 }); 72 });
73 auto job = KAsync::start<void>([query, resultProvider]() {}); 73 auto job = KAsync::syncStart<void>([query, resultProvider]() {});
74 mResultProvider = resultProvider; 74 mResultProvider = resultProvider;
75 return qMakePair(job, emitter); 75 return qMakePair(job, emitter);
76 } 76 }
@@ -273,7 +273,7 @@ private slots:
273 273
274 bool gotValue = false; 274 bool gotValue = false;
275 auto result = Sink::Store::fetchOne<Sink::ApplicationDomain::Event>(query) 275 auto result = Sink::Store::fetchOne<Sink::ApplicationDomain::Event>(query)
276 .then<void, Sink::ApplicationDomain::Event>([&gotValue](const Sink::ApplicationDomain::Event &event) { gotValue = true; }) 276 .syncThen<void, Sink::ApplicationDomain::Event>([&gotValue](const Sink::ApplicationDomain::Event &event) { gotValue = true; })
277 .exec(); 277 .exec();
278 result.waitForFinished(); 278 result.waitForFinished();
279 QVERIFY(!result.errorCode()); 279 QVERIFY(!result.errorCode());
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp
index 72562c3..8636bf6 100644
--- a/tests/dummyresourcebenchmark.cpp
+++ b/tests/dummyresourcebenchmark.cpp
@@ -44,34 +44,6 @@ private slots:
44 { 44 {
45 } 45 }
46 46
47 static KAsync::Job<void> waitForCompletion(QList<KAsync::Future<void>> &futures)
48 {
49 auto context = new QObject;
50 return KAsync::start<void>([futures, context](KAsync::Future<void> &future) {
51 const auto total = futures.size();
52 auto count = QSharedPointer<int>::create();
53 int i = 0;
54 for (KAsync::Future<void> subFuture : futures) {
55 i++;
56 if (subFuture.isFinished()) {
57 *count += 1;
58 continue;
59 }
60 // FIXME bind lifetime all watcher to future (repectively the main job
61 auto watcher = QSharedPointer<KAsync::FutureWatcher<void>>::create();
62 QObject::connect(watcher.data(), &KAsync::FutureWatcher<void>::futureReady, [count, total, &future]() {
63 *count += 1;
64 if (*count == total) {
65 future.setFinished();
66 }
67 });
68 watcher->setFuture(subFuture);
69 context->setProperty(QString("future%1").arg(i).toLatin1().data(), QVariant::fromValue(watcher));
70 }
71 })
72 .then<void>([context]() { delete context; });
73 }
74
75 // Ensure we can process a command in less than 0.1s 47 // Ensure we can process a command in less than 0.1s
76 void testCommandResponsiveness() 48 void testCommandResponsiveness()
77 { 49 {
@@ -120,7 +92,7 @@ private slots:
120 event.setProperty("summary", "summaryValue"); 92 event.setProperty("summary", "summaryValue");
121 waitCondition << Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec(); 93 waitCondition << Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec();
122 } 94 }
123 waitForCompletion(waitCondition).exec().waitForFinished(); 95 KAsync::waitForCompletion(waitCondition).exec().waitForFinished();
124 auto appendTime = time.elapsed(); 96 auto appendTime = time.elapsed();
125 97
126 // Ensure everything is processed 98 // Ensure everything is processed
diff --git a/tests/mailsynctest.cpp b/tests/mailsynctest.cpp
index 4b797c8..9c57f0a 100644
--- a/tests/mailsynctest.cpp
+++ b/tests/mailsynctest.cpp
@@ -69,7 +69,7 @@ void MailSyncTest::testListFolders()
69 //First figure out how many folders we have by default 69 //First figure out how many folders we have by default
70 { 70 {
71 auto job = Store::fetchAll<Folder>(Query()) 71 auto job = Store::fetchAll<Folder>(Query())
72 .then<void, QList<Folder::Ptr>>([&](const QList<Folder::Ptr> &folders) { 72 .syncThen<void, QList<Folder::Ptr>>([&](const QList<Folder::Ptr> &folders) {
73 QStringList names; 73 QStringList names;
74 for (const auto &folder : folders) { 74 for (const auto &folder : folders) {
75 names << folder->getName(); 75 names << folder->getName();
@@ -88,7 +88,7 @@ void MailSyncTest::testListFolders()
88 VERIFYEXEC(Store::synchronize(query)); 88 VERIFYEXEC(Store::synchronize(query));
89 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 89 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
90 90
91 auto job = Store::fetchAll<Folder>(query).then<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) { 91 auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) {
92 QStringList names; 92 QStringList names;
93 QHash<QByteArray, QByteArray> specialPurposeFolders; 93 QHash<QByteArray, QByteArray> specialPurposeFolders;
94 for (const auto &folder : folders) { 94 for (const auto &folder : folders) {
@@ -130,7 +130,7 @@ void MailSyncTest::testListNewFolder()
130 VERIFYEXEC(Store::synchronize(query)); 130 VERIFYEXEC(Store::synchronize(query));
131 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 131 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
132 132
133 auto job = Store::fetchAll<Folder>(query).then<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { 133 auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) {
134 QStringList names; 134 QStringList names;
135 for (const auto &folder : folders) { 135 for (const auto &folder : folders) {
136 names << folder->getName(); 136 names << folder->getName();
@@ -155,7 +155,7 @@ void MailSyncTest::testListRemovedFolder()
155 VERIFYEXEC(Store::synchronize(query)); 155 VERIFYEXEC(Store::synchronize(query));
156 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 156 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
157 157
158 auto job = Store::fetchAll<Folder>(query).then<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { 158 auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) {
159 QStringList names; 159 QStringList names;
160 for (const auto &folder : folders) { 160 for (const auto &folder : folders) {
161 names << folder->getName(); 161 names << folder->getName();
@@ -180,7 +180,7 @@ void MailSyncTest::testListFolderHierarchy()
180 VERIFYEXEC(Store::synchronize(query)); 180 VERIFYEXEC(Store::synchronize(query));
181 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 181 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
182 182
183 auto job = Store::fetchAll<Folder>(query).then<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) { 183 auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) {
184 QHash<QString, Folder::Ptr> map; 184 QHash<QString, Folder::Ptr> map;
185 for (const auto &folder : folders) { 185 for (const auto &folder : folders) {
186 map.insert(folder->getName(), folder); 186 map.insert(folder->getName(), folder);
@@ -223,7 +223,7 @@ void MailSyncTest::testListNewSubFolder()
223 VERIFYEXEC(Store::synchronize(query)); 223 VERIFYEXEC(Store::synchronize(query));
224 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 224 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
225 225
226 auto job = Store::fetchAll<Folder>(query).then<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { 226 auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) {
227 QStringList names; 227 QStringList names;
228 for (const auto &folder : folders) { 228 for (const auto &folder : folders) {
229 names << folder->getName(); 229 names << folder->getName();
@@ -251,7 +251,7 @@ void MailSyncTest::testListRemovedSubFolder()
251 VERIFYEXEC(Store::synchronize(query)); 251 VERIFYEXEC(Store::synchronize(query));
252 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 252 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
253 253
254 auto job = Store::fetchAll<Folder>(query).then<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) { 254 auto job = Store::fetchAll<Folder>(query).syncThen<void, QList<Folder::Ptr>>([](const QList<Folder::Ptr> &folders) {
255 QStringList names; 255 QStringList names;
256 for (const auto &folder : folders) { 256 for (const auto &folder : folders) {
257 names << folder->getName(); 257 names << folder->getName();
@@ -271,7 +271,7 @@ void MailSyncTest::testListMails()
271 VERIFYEXEC(Store::synchronize(query)); 271 VERIFYEXEC(Store::synchronize(query));
272 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 272 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
273 273
274 auto job = Store::fetchAll<Mail>(query).then<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { 274 auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) {
275 QCOMPARE(mails.size(), 1); 275 QCOMPARE(mails.size(), 1);
276 QVERIFY(mails.first()->getSubject().startsWith(QString("[Nepomuk] Jenkins build is still unstable"))); 276 QVERIFY(mails.first()->getSubject().startsWith(QString("[Nepomuk] Jenkins build is still unstable")));
277 const auto data = mails.first()->getMimeMessage(); 277 const auto data = mails.first()->getMimeMessage();
@@ -300,7 +300,7 @@ void MailSyncTest::testResyncMails()
300 VERIFYEXEC(Store::synchronize(query)); 300 VERIFYEXEC(Store::synchronize(query));
301 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 301 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
302 302
303 auto job = Store::fetchAll<Mail>(query).then<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { 303 auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) {
304 QCOMPARE(mails.size(), 1); 304 QCOMPARE(mails.size(), 1);
305 }); 305 });
306 VERIFYEXEC(job); 306 VERIFYEXEC(job);
@@ -325,7 +325,7 @@ void MailSyncTest::testFetchNewRemovedMessages()
325 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 325 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
326 326
327 { 327 {
328 auto job = Store::fetchAll<Mail>(query).then<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { 328 auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) {
329 QCOMPARE(mails.size(), 2); 329 QCOMPARE(mails.size(), 2);
330 }); 330 });
331 VERIFYEXEC(job); 331 VERIFYEXEC(job);
@@ -337,7 +337,7 @@ void MailSyncTest::testFetchNewRemovedMessages()
337 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 337 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
338 338
339 { 339 {
340 auto job = Store::fetchAll<Mail>(query).then<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { 340 auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) {
341 QCOMPARE(mails.size(), 1); 341 QCOMPARE(mails.size(), 1);
342 }); 342 });
343 VERIFYEXEC(job); 343 VERIFYEXEC(job);
diff --git a/tests/mailtest.cpp b/tests/mailtest.cpp
index 908fb84..925fb70 100644
--- a/tests/mailtest.cpp
+++ b/tests/mailtest.cpp
@@ -66,7 +66,7 @@ void MailTest::testCreateModifyDeleteFolder()
66 //First figure out how many folders we have by default 66 //First figure out how many folders we have by default
67 { 67 {
68 auto job = Store::fetchAll<Folder>(Query()) 68 auto job = Store::fetchAll<Folder>(Query())
69 .then<void, QList<Folder::Ptr>>([&](const QList<Folder::Ptr> &folders) { 69 .syncThen<void, QList<Folder::Ptr>>([&](const QList<Folder::Ptr> &folders) {
70 baseCount = folders.size(); 70 baseCount = folders.size();
71 }); 71 });
72 VERIFYEXEC(job); 72 VERIFYEXEC(job);
@@ -83,7 +83,7 @@ void MailTest::testCreateModifyDeleteFolder()
83 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); 83 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier));
84 { 84 {
85 auto job = Store::fetchAll<Folder>(Query::RequestedProperties(QByteArrayList() << Folder::Name::name << Folder::Icon::name)) 85 auto job = Store::fetchAll<Folder>(Query::RequestedProperties(QByteArrayList() << Folder::Name::name << Folder::Icon::name))
86 .then<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) { 86 .syncThen<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) {
87 QCOMPARE(folders.size(), baseCount + 1); 87 QCOMPARE(folders.size(), baseCount + 1);
88 QHash<QString, Folder::Ptr> foldersByName; 88 QHash<QString, Folder::Ptr> foldersByName;
89 for (const auto &folder : folders) { 89 for (const auto &folder : folders) {
@@ -109,7 +109,7 @@ void MailTest::testCreateModifyDeleteFolder()
109 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); 109 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier));
110 { 110 {
111 auto job = Store::fetchAll<Folder>(Query::RequestedProperties(QByteArrayList() << Folder::Name::name << Folder::Icon::name)) 111 auto job = Store::fetchAll<Folder>(Query::RequestedProperties(QByteArrayList() << Folder::Name::name << Folder::Icon::name))
112 .then<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) { 112 .syncThen<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) {
113 QCOMPARE(folders.size(), baseCount + 1); 113 QCOMPARE(folders.size(), baseCount + 1);
114 QHash<QString, Folder::Ptr> foldersByName; 114 QHash<QString, Folder::Ptr> foldersByName;
115 for (const auto &folder : folders) { 115 for (const auto &folder : folders) {
@@ -130,7 +130,7 @@ void MailTest::testCreateModifyDeleteFolder()
130 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); 130 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier));
131 { 131 {
132 auto job = Store::fetchAll<Folder>(Query::RequestedProperties(QByteArrayList() << Folder::Name::name << Folder::Icon::name)) 132 auto job = Store::fetchAll<Folder>(Query::RequestedProperties(QByteArrayList() << Folder::Name::name << Folder::Icon::name))
133 .then<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) { 133 .syncThen<void, QList<Folder::Ptr>>([=](const QList<Folder::Ptr> &folders) {
134 QCOMPARE(folders.size(), baseCount); 134 QCOMPARE(folders.size(), baseCount);
135 }); 135 });
136 VERIFYEXEC(job); 136 VERIFYEXEC(job);
@@ -160,7 +160,7 @@ void MailTest::testCreateModifyDeleteMail()
160 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); 160 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier));
161 { 161 {
162 auto job = Store::fetchAll<Mail>(Query::RequestedProperties(QByteArrayList() << Mail::Folder::name << Mail::Subject::name << Mail::MimeMessage::name)) 162 auto job = Store::fetchAll<Mail>(Query::RequestedProperties(QByteArrayList() << Mail::Folder::name << Mail::Subject::name << Mail::MimeMessage::name))
163 .then<void, QList<Mail::Ptr>>([=](const QList<Mail::Ptr> &mails) { 163 .syncThen<void, QList<Mail::Ptr>>([=](const QList<Mail::Ptr> &mails) {
164 QCOMPARE(mails.size(), 1); 164 QCOMPARE(mails.size(), 1);
165 auto mail = *mails.first(); 165 auto mail = *mails.first();
166 QCOMPARE(mail.getSubject(), subject); 166 QCOMPARE(mail.getSubject(), subject);
@@ -189,7 +189,7 @@ void MailTest::testCreateModifyDeleteMail()
189 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); 189 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier));
190 { 190 {
191 auto job = Store::fetchAll<Mail>(Query::RequestedProperties(QByteArrayList() << Mail::Folder::name << Mail::Subject::name << Mail::MimeMessage::name)) 191 auto job = Store::fetchAll<Mail>(Query::RequestedProperties(QByteArrayList() << Mail::Folder::name << Mail::Subject::name << Mail::MimeMessage::name))
192 .then<void, QList<Mail::Ptr>>([=](const QList<Mail::Ptr> &mails) { 192 .syncThen<void, QList<Mail::Ptr>>([=](const QList<Mail::Ptr> &mails) {
193 QCOMPARE(mails.size(), 1); 193 QCOMPARE(mails.size(), 1);
194 auto mail = *mails.first(); 194 auto mail = *mails.first();
195 QCOMPARE(mail.getSubject(), subject2); 195 QCOMPARE(mail.getSubject(), subject2);
@@ -211,7 +211,7 @@ void MailTest::testCreateModifyDeleteMail()
211 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); 211 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier));
212 { 212 {
213 auto job = Store::fetchAll<Mail>(Query::RequestedProperties(QByteArrayList() << Mail::Folder::name << Mail::Subject::name)) 213 auto job = Store::fetchAll<Mail>(Query::RequestedProperties(QByteArrayList() << Mail::Folder::name << Mail::Subject::name))
214 .then<void, QList<Mail::Ptr>>([=](const QList<Mail::Ptr> &mails) { 214 .syncThen<void, QList<Mail::Ptr>>([=](const QList<Mail::Ptr> &mails) {
215 QCOMPARE(mails.size(), 0); 215 QCOMPARE(mails.size(), 0);
216 }); 216 });
217 VERIFYEXEC(job); 217 VERIFYEXEC(job);
@@ -247,7 +247,7 @@ void MailTest::testMoveMail()
247 Mail modifiedMail; 247 Mail modifiedMail;
248 { 248 {
249 auto job = Store::fetchAll<Mail>(Query::RequestedProperties(QByteArrayList() << Mail::Folder::name << Mail::Subject::name << Mail::MimeMessage::name)) 249 auto job = Store::fetchAll<Mail>(Query::RequestedProperties(QByteArrayList() << Mail::Folder::name << Mail::Subject::name << Mail::MimeMessage::name))
250 .then<void, QList<Mail::Ptr>>([=, &modifiedMail](const QList<Mail::Ptr> &mails) { 250 .syncThen<void, QList<Mail::Ptr>>([=, &modifiedMail](const QList<Mail::Ptr> &mails) {
251 QCOMPARE(mails.size(), 1); 251 QCOMPARE(mails.size(), 1);
252 auto mail = *mails.first(); 252 auto mail = *mails.first();
253 modifiedMail = mail; 253 modifiedMail = mail;
@@ -266,7 +266,7 @@ void MailTest::testMoveMail()
266 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); 266 VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier));
267 { 267 {
268 auto job = Store::fetchAll<Mail>(Query::RequestedProperties(QByteArrayList() << Mail::Folder::name << Mail::Subject::name << Mail::MimeMessage::name)) 268 auto job = Store::fetchAll<Mail>(Query::RequestedProperties(QByteArrayList() << Mail::Folder::name << Mail::Subject::name << Mail::MimeMessage::name))
269 .then<void, QList<Mail::Ptr>>([=](const QList<Mail::Ptr> &mails) { 269 .syncThen<void, QList<Mail::Ptr>>([=](const QList<Mail::Ptr> &mails) {
270 QCOMPARE(mails.size(), 1); 270 QCOMPARE(mails.size(), 1);
271 auto mail = *mails.first(); 271 auto mail = *mails.first();
272 QCOMPARE(mail.getFolder(), folder1.identifier()); 272 QCOMPARE(mail.getFolder(), folder1.identifier());
@@ -299,7 +299,7 @@ void MailTest::testMarkMailAsRead()
299 auto job = Store::fetchAll<Mail>(Query::ResourceFilter(mResourceInstanceIdentifier) + 299 auto job = Store::fetchAll<Mail>(Query::ResourceFilter(mResourceInstanceIdentifier) +
300 Query::RequestedProperties(QByteArrayList() << Mail::Folder::name 300 Query::RequestedProperties(QByteArrayList() << Mail::Folder::name
301 << Mail::Subject::name)) 301 << Mail::Subject::name))
302 .then<void, KAsync::Job<void>, QList<Mail::Ptr>>([this](const QList<Mail::Ptr> &mails) { 302 .then<void, QList<Mail::Ptr>>([this](const QList<Mail::Ptr> &mails) {
303 ASYNCCOMPARE(mails.size(), 1); 303 ASYNCCOMPARE(mails.size(), 1);
304 auto mail = mails.first(); 304 auto mail = mails.first();
305 mail->setUnread(false); 305 mail->setUnread(false);
@@ -316,7 +316,7 @@ void MailTest::testMarkMailAsRead()
316 << Mail::Subject::name 316 << Mail::Subject::name
317 << Mail::MimeMessage::name 317 << Mail::MimeMessage::name
318 << Mail::Unread::name)) 318 << Mail::Unread::name))
319 .then<void, KAsync::Job<void>, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { 319 .then<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) {
320 ASYNCCOMPARE(mails.size(), 1); 320 ASYNCCOMPARE(mails.size(), 1);
321 auto mail = mails.first(); 321 auto mail = mails.first();
322 ASYNCVERIFY(!mail->getSubject().isEmpty()); 322 ASYNCVERIFY(!mail->getSubject().isEmpty());
diff --git a/tests/resourcecommunicationtest.cpp b/tests/resourcecommunicationtest.cpp
index 1530f63..201db53 100644
--- a/tests/resourcecommunicationtest.cpp
+++ b/tests/resourcecommunicationtest.cpp
@@ -51,13 +51,14 @@ private slots:
51 int errors = 0; 51 int errors = 0;
52 for (int i = 0; i < count; i++) { 52 for (int i = 0; i < count; i++) {
53 auto result = resourceAccess.sendCommand(Sink::Commands::PingCommand) 53 auto result = resourceAccess.sendCommand(Sink::Commands::PingCommand)
54 .then<void>([&complete]() { complete++; }, 54 .syncThen<void>([&resourceAccess, &errors, &complete](const KAsync::Error &error) {
55 [&errors, &complete](int error, const QString &msg) { 55 complete++;
56 qWarning() << msg; 56 if (error) {
57 errors++; 57 qWarning() << error.errorMessage;
58 complete++; 58 errors++;
59 }) 59 }
60 .exec(); 60 })
61 .exec();
61 } 62 }
62 QTRY_COMPARE(complete, count); 63 QTRY_COMPARE(complete, count);
63 QVERIFY(!errors); 64 QVERIFY(!errors);
@@ -76,13 +77,12 @@ private slots:
76 int errors = 0; 77 int errors = 0;
77 for (int i = 0; i < count; i++) { 78 for (int i = 0; i < count; i++) {
78 resourceAccess.sendCommand(Sink::Commands::PingCommand) 79 resourceAccess.sendCommand(Sink::Commands::PingCommand)
79 .then<void>([&complete]() { complete++; }, 80 .syncThen<void>([&resourceAccess, &errors, &complete](const KAsync::Error &error) {
80 [&errors, &complete](int error, const QString &msg) { 81 complete++;
81 qWarning() << msg; 82 if (error) {
83 qWarning() << error.errorMessage;
82 errors++; 84 errors++;
83 complete++; 85 }
84 })
85 .then<void>([&resourceAccess]() {
86 resourceAccess.close(); 86 resourceAccess.close();
87 resourceAccess.open(); 87 resourceAccess.open();
88 }) 88 })
@@ -104,7 +104,7 @@ private slots:
104 auto resourceAccess = Sink::ResourceAccessFactory::instance().getAccess(resourceIdentifier, ""); 104 auto resourceAccess = Sink::ResourceAccessFactory::instance().getAccess(resourceIdentifier, "");
105 weakRef = resourceAccess.toWeakRef(); 105 weakRef = resourceAccess.toWeakRef();
106 resourceAccess->open(); 106 resourceAccess->open();
107 resourceAccess->sendCommand(Sink::Commands::PingCommand).then<void>([resourceAccess]() { qDebug() << "Pind complete"; }).exec(); 107 resourceAccess->sendCommand(Sink::Commands::PingCommand).syncThen<void>([resourceAccess]() { qDebug() << "Ping complete"; }).exec();
108 } 108 }
109 QVERIFY(weakRef.toStrongRef()); 109 QVERIFY(weakRef.toStrongRef());
110 QTRY_VERIFY(!weakRef.toStrongRef()); 110 QTRY_VERIFY(!weakRef.toStrongRef());