From db36ceabeb698b1988f7f6ecfe694c226eb156d7 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 2 Mar 2018 11:58:18 +0100 Subject: Fixed synchronization with new mail notifications --- examples/imapresource/tests/imapmailsynctest.cpp | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'examples/imapresource/tests') diff --git a/examples/imapresource/tests/imapmailsynctest.cpp b/examples/imapresource/tests/imapmailsynctest.cpp index 1d62a80..06369f3 100644 --- a/examples/imapresource/tests/imapmailsynctest.cpp +++ b/examples/imapresource/tests/imapmailsynctest.cpp @@ -135,12 +135,15 @@ protected: private slots: void testNewMailNotification() { + createFolder(QStringList() << "testNewMailNotification"); + createMessage(QStringList() << "testNewMailNotification", newMessage("Foobar")); + const auto syncFolders = Sink::SyncScope{ApplicationDomain::getTypeName()}.resourceFilter(mResourceInstanceIdentifier); //Fetch folders initially VERIFYEXEC(Store::synchronize(syncFolders)); VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier)); - auto folder = Store::readOne(Sink::Query{}.resourceFilter(mResourceInstanceIdentifier).filter("test")); + auto folder = Store::readOne(Sink::Query{}.resourceFilter(mResourceInstanceIdentifier).filter("testNewMailNotification")); Q_ASSERT(!folder.identifier().isEmpty()); const auto syncTestMails = Sink::SyncScope{ApplicationDomain::getTypeName()}.resourceFilter(mResourceInstanceIdentifier).filter(QVariant::fromValue(folder.identifier())); @@ -172,7 +175,7 @@ private slots: QVERIFY(!notificationReceived); //Create message and retry - createMessage(QStringList() << "test", newMessage("This is a Subject.")); + createMessage(QStringList() << "testNewMailNotification", newMessage("This is a Subject.")); //Should result in change notification VERIFYEXEC(Store::synchronize(syncFolders)); @@ -180,6 +183,24 @@ private slots: QTRY_VERIFY(notificationReceived); } + + void testSyncFolderBeforeFetchingNewMessages() + { + const auto syncScope = Sink::Query{}.resourceFilter(mResourceInstanceIdentifier); + + createFolder(QStringList() << "test3"); + + VERIFYEXEC(Store::synchronize(syncScope)); + VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier)); + + createMessage(QStringList() << "test3", newMessage("Foobar")); + + VERIFYEXEC(Store::synchronize(syncScope)); + VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier)); + + auto mailQuery = Sink::Query{}.resourceFilter(mResourceInstanceIdentifier).request().filter(Sink::Query{}.filter("test3")); + QCOMPARE(Store::read(mailQuery).size(), 1); + } }; QTEST_MAIN(ImapMailSyncTest) -- cgit v1.2.3