diff options
Diffstat (limited to 'tests/maildirresourcetest.cpp')
-rw-r--r-- | tests/maildirresourcetest.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index e502d10..c5c9348 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -68,7 +68,7 @@ private Q_SLOTS: | |||
68 | 68 | ||
69 | void cleanup() | 69 | void cleanup() |
70 | { | 70 | { |
71 | Sink::Store::shutdown(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); | 71 | Sink::Resources::shutdown(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); |
72 | MaildirResource::removeFromDisk("org.kde.maildir.instance1"); | 72 | MaildirResource::removeFromDisk("org.kde.maildir.instance1"); |
73 | QDir dir(targetPath); | 73 | QDir dir(targetPath); |
74 | dir.removeRecursively(); | 74 | dir.removeRecursively(); |
@@ -80,7 +80,7 @@ private Q_SLOTS: | |||
80 | qDebug() << "-----------------------------------------"; | 80 | qDebug() << "-----------------------------------------"; |
81 | qDebug(); | 81 | qDebug(); |
82 | copyRecursively(TESTDATAPATH "/maildir1", targetPath); | 82 | copyRecursively(TESTDATAPATH "/maildir1", targetPath); |
83 | Sink::Store::start(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); | 83 | Sink::Resources::start(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); |
84 | } | 84 | } |
85 | 85 | ||
86 | void testListFolders() | 86 | void testListFolders() |
@@ -90,7 +90,7 @@ private Q_SLOTS: | |||
90 | 90 | ||
91 | //Ensure all local data is processed | 91 | //Ensure all local data is processed |
92 | Sink::Store::synchronize(query).exec().waitForFinished(); | 92 | Sink::Store::synchronize(query).exec().waitForFinished(); |
93 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 93 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
94 | 94 | ||
95 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 95 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
96 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 96 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -105,7 +105,7 @@ private Q_SLOTS: | |||
105 | 105 | ||
106 | //Ensure all local data is processed | 106 | //Ensure all local data is processed |
107 | Sink::Store::synchronize(query).exec().waitForFinished(); | 107 | Sink::Store::synchronize(query).exec().waitForFinished(); |
108 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 108 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
109 | 109 | ||
110 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 110 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
111 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 111 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -123,7 +123,7 @@ private Q_SLOTS: | |||
123 | //Ensure all local data is processed | 123 | //Ensure all local data is processed |
124 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); | 124 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
125 | Store::synchronize(query).exec().waitForFinished(); | 125 | Store::synchronize(query).exec().waitForFinished(); |
126 | Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 126 | Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
127 | auto result = Store::fetchOne<Folder>( | 127 | auto result = Store::fetchOne<Folder>( |
128 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::RequestedProperties(QByteArrayList() << "name") | 128 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::RequestedProperties(QByteArrayList() << "name") |
129 | ) | 129 | ) |
@@ -149,7 +149,7 @@ private Q_SLOTS: | |||
149 | 149 | ||
150 | //Ensure all local data is processed | 150 | //Ensure all local data is processed |
151 | Sink::Store::synchronize(query).exec().waitForFinished(); | 151 | Sink::Store::synchronize(query).exec().waitForFinished(); |
152 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 152 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
153 | 153 | ||
154 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 154 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
155 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 155 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -172,7 +172,7 @@ private Q_SLOTS: | |||
172 | 172 | ||
173 | //Ensure all local data is processed | 173 | //Ensure all local data is processed |
174 | Sink::Store::synchronize(query).exec().waitForFinished(); | 174 | Sink::Store::synchronize(query).exec().waitForFinished(); |
175 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 175 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
176 | 176 | ||
177 | auto targetPath = tempDir.path() + "/maildir1/"; | 177 | auto targetPath = tempDir.path() + "/maildir1/"; |
178 | QDir dir(targetPath); | 178 | QDir dir(targetPath); |
@@ -180,7 +180,7 @@ private Q_SLOTS: | |||
180 | 180 | ||
181 | //Ensure all local data is processed | 181 | //Ensure all local data is processed |
182 | Sink::Store::synchronize(query).exec().waitForFinished(); | 182 | Sink::Store::synchronize(query).exec().waitForFinished(); |
183 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 183 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
184 | 184 | ||
185 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 185 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
186 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 186 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -196,11 +196,11 @@ private Q_SLOTS: | |||
196 | 196 | ||
197 | //Ensure all local data is processed | 197 | //Ensure all local data is processed |
198 | Sink::Store::synchronize(query).exec().waitForFinished(); | 198 | Sink::Store::synchronize(query).exec().waitForFinished(); |
199 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 199 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
200 | 200 | ||
201 | //Ensure all local data is processed | 201 | //Ensure all local data is processed |
202 | Sink::Store::synchronize(query).exec().waitForFinished(); | 202 | Sink::Store::synchronize(query).exec().waitForFinished(); |
203 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 203 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
204 | 204 | ||
205 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 205 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
206 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 206 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -215,7 +215,7 @@ private Q_SLOTS: | |||
215 | 215 | ||
216 | //Ensure all local data is processed | 216 | //Ensure all local data is processed |
217 | Sink::Store::synchronize(query).exec().waitForFinished(); | 217 | Sink::Store::synchronize(query).exec().waitForFinished(); |
218 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 218 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
219 | 219 | ||
220 | auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; | 220 | auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; |
221 | QFile file(targetPath); | 221 | QFile file(targetPath); |
@@ -223,7 +223,7 @@ private Q_SLOTS: | |||
223 | 223 | ||
224 | //Ensure all local data is processed | 224 | //Ensure all local data is processed |
225 | Sink::Store::synchronize(query).exec().waitForFinished(); | 225 | Sink::Store::synchronize(query).exec().waitForFinished(); |
226 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 226 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
227 | 227 | ||
228 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 228 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
229 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 229 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -236,7 +236,7 @@ private Q_SLOTS: | |||
236 | query.resources << "org.kde.maildir.instance1"; | 236 | query.resources << "org.kde.maildir.instance1"; |
237 | 237 | ||
238 | //Ensure all local data is processed | 238 | //Ensure all local data is processed |
239 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 239 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
240 | 240 | ||
241 | Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); | 241 | Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); |
242 | folder.setProperty("name", "testCreateFolder"); | 242 | folder.setProperty("name", "testCreateFolder"); |
@@ -244,7 +244,7 @@ private Q_SLOTS: | |||
244 | Sink::Store::create(folder).exec().waitForFinished(); | 244 | Sink::Store::create(folder).exec().waitForFinished(); |
245 | 245 | ||
246 | //Ensure all local data is processed | 246 | //Ensure all local data is processed |
247 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 247 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
248 | 248 | ||
249 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; | 249 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; |
250 | QFileInfo file(targetPath); | 250 | QFileInfo file(targetPath); |
@@ -262,7 +262,7 @@ private Q_SLOTS: | |||
262 | Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); | 262 | Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); |
263 | folder.setProperty("name", "testCreateFolder"); | 263 | folder.setProperty("name", "testCreateFolder"); |
264 | Sink::Store::create(folder).exec().waitForFinished(); | 264 | Sink::Store::create(folder).exec().waitForFinished(); |
265 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 265 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
266 | QTRY_VERIFY(QFileInfo(targetPath).exists()); | 266 | QTRY_VERIFY(QFileInfo(targetPath).exists()); |
267 | 267 | ||
268 | Sink::Query folderQuery; | 268 | Sink::Query folderQuery; |
@@ -274,7 +274,7 @@ private Q_SLOTS: | |||
274 | auto createdFolder = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); | 274 | auto createdFolder = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); |
275 | 275 | ||
276 | Sink::Store::remove(*createdFolder).exec().waitForFinished(); | 276 | Sink::Store::remove(*createdFolder).exec().waitForFinished(); |
277 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 277 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
278 | QTRY_VERIFY(!QFileInfo(targetPath).exists()); | 278 | QTRY_VERIFY(!QFileInfo(targetPath).exists()); |
279 | } | 279 | } |
280 | 280 | ||
@@ -284,15 +284,16 @@ private Q_SLOTS: | |||
284 | query.resources << "org.kde.maildir.instance1"; | 284 | query.resources << "org.kde.maildir.instance1"; |
285 | 285 | ||
286 | //Ensure all local data is processed | 286 | //Ensure all local data is processed |
287 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 287 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
288 | 288 | ||
289 | Sink::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); | 289 | Sink::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); |
290 | mail.setProperty("name", "testCreateMail"); | 290 | mail.setProperty("name", "testCreateMail"); |
291 | //FIXME instead of properties, ensure the mimeMessage property is used and the file is moved as expected | ||
291 | 292 | ||
292 | Sink::Store::create(mail).exec().waitForFinished(); | 293 | Sink::Store::create(mail).exec().waitForFinished(); |
293 | 294 | ||
294 | //Ensure all local data is processed | 295 | //Ensure all local data is processed |
295 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 296 | Sink::Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
296 | 297 | ||
297 | auto targetPath = tempDir.path() + "/maildir1/new"; | 298 | auto targetPath = tempDir.path() + "/maildir1/new"; |
298 | QDir dir(targetPath); | 299 | QDir dir(targetPath); |
@@ -307,7 +308,7 @@ private Q_SLOTS: | |||
307 | 308 | ||
308 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); | 309 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
309 | Store::synchronize(query).exec().waitForFinished(); | 310 | Store::synchronize(query).exec().waitForFinished(); |
310 | Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 311 | Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
311 | 312 | ||
312 | auto result = Store::fetchOne<Folder>( | 313 | auto result = Store::fetchOne<Folder>( |
313 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("name", "maildir1") + Query::RequestedProperties(QByteArrayList() << "name") | 314 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("name", "maildir1") + Query::RequestedProperties(QByteArrayList() << "name") |
@@ -324,7 +325,7 @@ private Q_SLOTS: | |||
324 | auto mail = mails.first(); | 325 | auto mail = mails.first(); |
325 | 326 | ||
326 | return Store::remove(*mail) | 327 | return Store::remove(*mail) |
327 | .then(Store::flushReplayQueue(query.resources)) //The change needs to be replayed already | 328 | .then(Resources::flushReplayQueue(query.resources)) //The change needs to be replayed already |
328 | .then(Resources::inspect<Mail>(Resources::Inspection::ExistenceInspection(*mail, false))); | 329 | .then(Resources::inspect<Mail>(Resources::Inspection::ExistenceInspection(*mail, false))); |
329 | }) | 330 | }) |
330 | .then<void>([](){}); | 331 | .then<void>([](){}); |
@@ -341,7 +342,7 @@ private Q_SLOTS: | |||
341 | 342 | ||
342 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); | 343 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
343 | Store::synchronize(query).exec().waitForFinished(); | 344 | Store::synchronize(query).exec().waitForFinished(); |
344 | Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 345 | Resources::flushMessageQueue(query.resources).exec().waitForFinished(); |
345 | 346 | ||
346 | Folder f; | 347 | Folder f; |
347 | 348 | ||
@@ -361,7 +362,7 @@ private Q_SLOTS: | |||
361 | auto mail = mails.first(); | 362 | auto mail = mails.first(); |
362 | mail->setProperty("unread", true); | 363 | mail->setProperty("unread", true); |
363 | return Store::modify(*mail) | 364 | return Store::modify(*mail) |
364 | .then<void>(Store::flushReplayQueue(query.resources)) //The change needs to be replayed already | 365 | .then<void>(Resources::flushReplayQueue(query.resources)) //The change needs to be replayed already |
365 | .then(Resources::inspect<Mail>(Resources::Inspection::PropertyInspection(*mail, "unread", true))) | 366 | .then(Resources::inspect<Mail>(Resources::Inspection::PropertyInspection(*mail, "unread", true))) |
366 | .then(Resources::inspect<Mail>(Resources::Inspection::PropertyInspection(*mail, "subject", mail->getProperty("subject")))); | 367 | .then(Resources::inspect<Mail>(Resources::Inspection::PropertyInspection(*mail, "subject", mail->getProperty("subject")))); |
367 | }) | 368 | }) |