diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-19 19:39:53 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-20 13:27:44 +0100 |
commit | b1e5525be34850ef4d11cccbf23e118c93e93506 (patch) | |
tree | 68283fe123be3b1670eccc6a8e3711a9dda3f35e /tests/maildirresourcetest.cpp | |
parent | 355ed15b1200dfb6ab5ecd320a3278105007ad9c (diff) | |
download | sink-b1e5525be34850ef4d11cccbf23e118c93e93506.tar.gz sink-b1e5525be34850ef4d11cccbf23e118c93e93506.zip |
Generalized the sync algorithms and applied them to mail.
Not necessarily the smartest algorithms, but at least they work and
are generally applicable.
Diffstat (limited to 'tests/maildirresourcetest.cpp')
-rw-r--r-- | tests/maildirresourcetest.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index e6b6849..a4856ce 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -149,6 +149,26 @@ private Q_SLOTS: | |||
149 | QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); | 149 | QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); |
150 | } | 150 | } |
151 | 151 | ||
152 | void testMailContent() | ||
153 | { | ||
154 | Akonadi2::Query query; | ||
155 | query.resources << "org.kde.maildir.instance1"; | ||
156 | query.requestedProperties << "folder" << "subject" << "mimeMessage"; | ||
157 | query.syncOnDemand = true; | ||
158 | query.processAll = true; | ||
159 | |||
160 | //Ensure all local data is processed | ||
161 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
162 | |||
163 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | ||
164 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
165 | QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); | ||
166 | auto mail = mailModel->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>(); | ||
167 | QVERIFY(!mail->getProperty("subject").toString().isEmpty()); | ||
168 | QVERIFY(!mail->getProperty("mimeMessage").toString().isEmpty()); | ||
169 | } | ||
170 | |||
171 | |||
152 | void testSyncFolderMove() | 172 | void testSyncFolderMove() |
153 | { | 173 | { |
154 | Akonadi2::Query query; | 174 | Akonadi2::Query query; |
@@ -173,6 +193,29 @@ private Q_SLOTS: | |||
173 | QCOMPARE(model->match(model->index(0, 0, QModelIndex()), Qt::DisplayRole, QStringLiteral("newbox"), 1).size(), 1); | 193 | QCOMPARE(model->match(model->index(0, 0, QModelIndex()), Qt::DisplayRole, QStringLiteral("newbox"), 1).size(), 1); |
174 | } | 194 | } |
175 | 195 | ||
196 | void testSyncMailMove() | ||
197 | { | ||
198 | Akonadi2::Query query; | ||
199 | query.resources << "org.kde.maildir.instance1"; | ||
200 | query.syncOnDemand = true; | ||
201 | query.processAll = true; | ||
202 | query.requestedProperties << "folder" << "summary"; | ||
203 | |||
204 | //Ensure all local data is processed | ||
205 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
206 | |||
207 | auto targetPath = tempDir.path() + QDir::separator() + "maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; | ||
208 | QFile file(targetPath); | ||
209 | QVERIFY(file.remove()); | ||
210 | |||
211 | //Ensure all local data is processed | ||
212 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
213 | |||
214 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | ||
215 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
216 | QCOMPARE(mailModel->rowCount(QModelIndex()), 1); | ||
217 | } | ||
218 | |||
176 | }; | 219 | }; |
177 | 220 | ||
178 | QTEST_MAIN(MaildirResourceTest) | 221 | QTEST_MAIN(MaildirResourceTest) |