summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mailsynctest.cpp38
-rw-r--r--tests/mailsynctest.h2
2 files changed, 39 insertions, 1 deletions
diff --git a/tests/mailsynctest.cpp b/tests/mailsynctest.cpp
index 9c57f0a..8260978 100644
--- a/tests/mailsynctest.cpp
+++ b/tests/mailsynctest.cpp
@@ -344,7 +344,43 @@ void MailSyncTest::testFetchNewRemovedMessages()
344 } 344 }
345} 345}
346 346
347//TODO test flag sync 347void MailSyncTest::testFlagChange()
348{
349 Sink::Query query;
350 query.resources << mResourceInstanceIdentifier;
351 query.request<Mail::Subject>().request<Mail::Important>();
352
353 auto msg = KMime::Message::Ptr::create();
354 msg->subject(true)->fromUnicodeString("Foobar", "utf8");
355 msg->assemble();
356 auto messageIdentifier = createMessage(QStringList() << "test", msg->encodedContent(true));
357
358 Store::synchronize(query).exec().waitForFinished();
359 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
360
361 {
362 auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) {
363 QCOMPARE(mails.size(), 2);
364 QVERIFY(!mails.at(1)->getImportant());
365 });
366 VERIFYEXEC(job);
367 }
368
369 markAsImportant(QStringList() << "test", messageIdentifier);
370
371 // Ensure all local data is processed
372 VERIFYEXEC(Store::synchronize(query));
373 ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
374
375 {
376 auto job = Store::fetchAll<Mail>(query).syncThen<void, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) {
377 QCOMPARE(mails.size(), 2);
378 QVERIFY(mails.at(1)->getImportant());
379 });
380 VERIFYEXEC(job);
381 }
382
383}
348 384
349void MailSyncTest::testFailingSync() 385void MailSyncTest::testFailingSync()
350{ 386{
diff --git a/tests/mailsynctest.h b/tests/mailsynctest.h
index 31d3f03..94643f6 100644
--- a/tests/mailsynctest.h
+++ b/tests/mailsynctest.h
@@ -50,6 +50,7 @@ protected:
50 virtual void removeFolder(const QStringList &folderPath) = 0; 50 virtual void removeFolder(const QStringList &folderPath) = 0;
51 virtual QByteArray createMessage(const QStringList &folderPath, const QByteArray &message) = 0; 51 virtual QByteArray createMessage(const QStringList &folderPath, const QByteArray &message) = 0;
52 virtual void removeMessage(const QStringList &folderPath, const QByteArray &messageIdentifier) = 0; 52 virtual void removeMessage(const QStringList &folderPath, const QByteArray &messageIdentifier) = 0;
53 virtual void markAsImportant(const QStringList &folderPath, const QByteArray &messageIdentifier) = 0;
53 54
54private slots: 55private slots:
55 void initTestCase(); 56 void initTestCase();
@@ -66,6 +67,7 @@ private slots:
66 void testListMails(); 67 void testListMails();
67 void testResyncMails(); 68 void testResyncMails();
68 void testFetchNewRemovedMessages(); 69 void testFetchNewRemovedMessages();
70 void testFlagChange();
69 71
70 void testFailingSync(); 72 void testFailingSync();
71}; 73};