diff options
Diffstat (limited to 'tests/maildirresourcetest.cpp')
-rw-r--r-- | tests/maildirresourcetest.cpp | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index 9b014e3..7b7f819 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -12,6 +12,18 @@ | |||
12 | #include "pipeline.h" | 12 | #include "pipeline.h" |
13 | #include "log.h" | 13 | #include "log.h" |
14 | 14 | ||
15 | #define ASYNCCOMPARE(actual, expected) \ | ||
16 | do {\ | ||
17 | if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ | ||
18 | return KAsync::error<void>(1, "Comparison failed.");\ | ||
19 | } while (0) | ||
20 | |||
21 | #define ASYNCVERIFY(statement) \ | ||
22 | do {\ | ||
23 | if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\ | ||
24 | return KAsync::error<void>(1, "Verify failed.");\ | ||
25 | } while (0) | ||
26 | |||
15 | static bool copyRecursively(const QString &srcFilePath, const QString &tgtFilePath) | 27 | static bool copyRecursively(const QString &srcFilePath, const QString &tgtFilePath) |
16 | { | 28 | { |
17 | QFileInfo srcFileInfo(srcFilePath); | 29 | QFileInfo srcFileInfo(srcFilePath); |
@@ -314,10 +326,7 @@ private slots: | |||
314 | return Store::fetchAll<Mail>(Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" | 326 | return Store::fetchAll<Mail>(Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" |
315 | << "subject")) | 327 | << "subject")) |
316 | .then<void, KAsync::Job<void>, QList<Mail::Ptr>>([query](const QList<Mail::Ptr> &mails) { | 328 | .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 | 329 | ASYNCCOMPARE(mails.size(), 1); |
318 | if (mails.size() != 1) { | ||
319 | return KAsync::error<void>(1, "Wrong number of mails."); | ||
320 | } | ||
321 | auto mail = mails.first(); | 330 | auto mail = mails.first(); |
322 | 331 | ||
323 | return Store::remove(*mail) | 332 | return Store::remove(*mail) |
@@ -349,10 +358,7 @@ private slots: | |||
349 | Query::RequestedProperties(QByteArrayList() << "folder" | 358 | Query::RequestedProperties(QByteArrayList() << "folder" |
350 | << "subject")) | 359 | << "subject")) |
351 | .then<void, KAsync::Job<void>, QList<Mail::Ptr>>([query](const QList<Mail::Ptr> &mails) { | 360 | .then<void, KAsync::Job<void>, QList<Mail::Ptr>>([query](const QList<Mail::Ptr> &mails) { |
352 | // Can't use QCOMPARE because it tries to return FIXME Implement ASYNCCOMPARE | 361 | ASYNCCOMPARE(mails.size(), 1); |
353 | if (mails.size() != 1) { | ||
354 | return KAsync::error<void>(1, "Wrong number of mails."); | ||
355 | } | ||
356 | auto mail = mails.first(); | 362 | auto mail = mails.first(); |
357 | mail->setProperty("unread", true); | 363 | mail->setProperty("unread", true); |
358 | return Store::modify(*mail) | 364 | return Store::modify(*mail) |
@@ -372,25 +378,11 @@ private slots: | |||
372 | << "mimeMessage" | 378 | << "mimeMessage" |
373 | << "unread")) | 379 | << "unread")) |
374 | .then<void, KAsync::Job<void>, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { | 380 | .then<void, KAsync::Job<void>, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { |
375 | // Can't use QCOMPARE because it tries to return FIXME Implement ASYNCCOMPARE | 381 | ASYNCCOMPARE(mails.size(), 1); |
376 | if (mails.size() != 1) { | ||
377 | qWarning() << "Wrong number of mails"; | ||
378 | return KAsync::error<void>(1, "Wrong number of mails."); | ||
379 | } | ||
380 | auto mail = mails.first(); | 382 | auto mail = mails.first(); |
381 | if (mail->getProperty("subject").toString().isEmpty()) { | 383 | ASYNCVERIFY(!mail->getProperty("subject").toString().isEmpty()); |
382 | qWarning() << "Wrong subject"; | 384 | ASYNCCOMPARE(mail->getProperty("unread").toBool(), true); |
383 | return KAsync::error<void>(1, "Wrong subject."); | 385 | ASYNCVERIFY(QFileInfo(mail->getProperty("mimeMessage").toString()).exists()); |
384 | } | ||
385 | if (mail->getProperty("unread").toBool() != true) { | ||
386 | qWarning() << "Not unread"; | ||
387 | return KAsync::error<void>(1, "Not unread."); | ||
388 | } | ||
389 | QFileInfo info(mail->getProperty("mimeMessage").toString()); | ||
390 | if (!info.exists()) { | ||
391 | qWarning() << "Wrong subject"; | ||
392 | return KAsync::error<void>(1, "Can't find mime message."); | ||
393 | } | ||
394 | return KAsync::null<void>(); | 386 | return KAsync::null<void>(); |
395 | }) | 387 | }) |
396 | .exec(); | 388 | .exec(); |