From 4cd598035dcc297ad3a3af16fb5eda218c018a16 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 30 Aug 2016 00:35:03 +0200 Subject: Flag updates --- tests/mailsynctest.cpp | 38 +++++++++++++++++++++++++++++++++++++- tests/mailsynctest.h | 2 ++ 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'tests') 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() } } -//TODO test flag sync +void MailSyncTest::testFlagChange() +{ + Sink::Query query; + query.resources << mResourceInstanceIdentifier; + query.request().request(); + + auto msg = KMime::Message::Ptr::create(); + msg->subject(true)->fromUnicodeString("Foobar", "utf8"); + msg->assemble(); + auto messageIdentifier = createMessage(QStringList() << "test", msg->encodedContent(true)); + + Store::synchronize(query).exec().waitForFinished(); + ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); + + { + auto job = Store::fetchAll(query).syncThen>([](const QList &mails) { + QCOMPARE(mails.size(), 2); + QVERIFY(!mails.at(1)->getImportant()); + }); + VERIFYEXEC(job); + } + + markAsImportant(QStringList() << "test", messageIdentifier); + + // Ensure all local data is processed + VERIFYEXEC(Store::synchronize(query)); + ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); + + { + auto job = Store::fetchAll(query).syncThen>([](const QList &mails) { + QCOMPARE(mails.size(), 2); + QVERIFY(mails.at(1)->getImportant()); + }); + VERIFYEXEC(job); + } + +} void MailSyncTest::testFailingSync() { 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: virtual void removeFolder(const QStringList &folderPath) = 0; virtual QByteArray createMessage(const QStringList &folderPath, const QByteArray &message) = 0; virtual void removeMessage(const QStringList &folderPath, const QByteArray &messageIdentifier) = 0; + virtual void markAsImportant(const QStringList &folderPath, const QByteArray &messageIdentifier) = 0; private slots: void initTestCase(); @@ -66,6 +67,7 @@ private slots: void testListMails(); void testResyncMails(); void testFetchNewRemovedMessages(); + void testFlagChange(); void testFailingSync(); }; -- cgit v1.2.3