diff options
Diffstat (limited to 'examples/imapresource/tests/imapmailsynctest.cpp')
-rw-r--r-- | examples/imapresource/tests/imapmailsynctest.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
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: | |||
135 | private slots: | 135 | private slots: |
136 | void testNewMailNotification() | 136 | void testNewMailNotification() |
137 | { | 137 | { |
138 | createFolder(QStringList() << "testNewMailNotification"); | ||
139 | createMessage(QStringList() << "testNewMailNotification", newMessage("Foobar")); | ||
140 | |||
138 | const auto syncFolders = Sink::SyncScope{ApplicationDomain::getTypeName<Folder>()}.resourceFilter(mResourceInstanceIdentifier); | 141 | const auto syncFolders = Sink::SyncScope{ApplicationDomain::getTypeName<Folder>()}.resourceFilter(mResourceInstanceIdentifier); |
139 | //Fetch folders initially | 142 | //Fetch folders initially |
140 | VERIFYEXEC(Store::synchronize(syncFolders)); | 143 | VERIFYEXEC(Store::synchronize(syncFolders)); |
141 | VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier)); | 144 | VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier)); |
142 | 145 | ||
143 | auto folder = Store::readOne<Folder>(Sink::Query{}.resourceFilter(mResourceInstanceIdentifier).filter<Folder::Name>("test")); | 146 | auto folder = Store::readOne<Folder>(Sink::Query{}.resourceFilter(mResourceInstanceIdentifier).filter<Folder::Name>("testNewMailNotification")); |
144 | Q_ASSERT(!folder.identifier().isEmpty()); | 147 | Q_ASSERT(!folder.identifier().isEmpty()); |
145 | 148 | ||
146 | const auto syncTestMails = Sink::SyncScope{ApplicationDomain::getTypeName<Mail>()}.resourceFilter(mResourceInstanceIdentifier).filter<Mail::Folder>(QVariant::fromValue(folder.identifier())); | 149 | const auto syncTestMails = Sink::SyncScope{ApplicationDomain::getTypeName<Mail>()}.resourceFilter(mResourceInstanceIdentifier).filter<Mail::Folder>(QVariant::fromValue(folder.identifier())); |
@@ -172,7 +175,7 @@ private slots: | |||
172 | QVERIFY(!notificationReceived); | 175 | QVERIFY(!notificationReceived); |
173 | 176 | ||
174 | //Create message and retry | 177 | //Create message and retry |
175 | createMessage(QStringList() << "test", newMessage("This is a Subject.")); | 178 | createMessage(QStringList() << "testNewMailNotification", newMessage("This is a Subject.")); |
176 | 179 | ||
177 | //Should result in change notification | 180 | //Should result in change notification |
178 | VERIFYEXEC(Store::synchronize(syncFolders)); | 181 | VERIFYEXEC(Store::synchronize(syncFolders)); |
@@ -180,6 +183,24 @@ private slots: | |||
180 | 183 | ||
181 | QTRY_VERIFY(notificationReceived); | 184 | QTRY_VERIFY(notificationReceived); |
182 | } | 185 | } |
186 | |||
187 | void testSyncFolderBeforeFetchingNewMessages() | ||
188 | { | ||
189 | const auto syncScope = Sink::Query{}.resourceFilter(mResourceInstanceIdentifier); | ||
190 | |||
191 | createFolder(QStringList() << "test3"); | ||
192 | |||
193 | VERIFYEXEC(Store::synchronize(syncScope)); | ||
194 | VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier)); | ||
195 | |||
196 | createMessage(QStringList() << "test3", newMessage("Foobar")); | ||
197 | |||
198 | VERIFYEXEC(Store::synchronize(syncScope)); | ||
199 | VERIFYEXEC(ResourceControl::flushMessageQueue(mResourceInstanceIdentifier)); | ||
200 | |||
201 | auto mailQuery = Sink::Query{}.resourceFilter(mResourceInstanceIdentifier).request<Mail::Subject>().filter<Mail::Folder>(Sink::Query{}.filter<Folder::Name>("test3")); | ||
202 | QCOMPARE(Store::read<Mail>(mailQuery).size(), 1); | ||
203 | } | ||
183 | }; | 204 | }; |
184 | 205 | ||
185 | QTEST_MAIN(ImapMailSyncTest) | 206 | QTEST_MAIN(ImapMailSyncTest) |