diff options
Diffstat (limited to 'tests/maildirresourcetest.cpp')
-rw-r--r-- | tests/maildirresourcetest.cpp | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index b61190d..3e07d93 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -87,11 +87,10 @@ private Q_SLOTS: | |||
87 | { | 87 | { |
88 | Akonadi2::Query query; | 88 | Akonadi2::Query query; |
89 | query.resources << "org.kde.maildir.instance1"; | 89 | query.resources << "org.kde.maildir.instance1"; |
90 | query.syncOnDemand = true; | ||
91 | query.processAll = true; | ||
92 | 90 | ||
93 | //Ensure all local data is processed | 91 | //Ensure all local data is processed |
94 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 92 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
93 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
95 | 94 | ||
96 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 95 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); |
97 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 96 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -102,12 +101,11 @@ private Q_SLOTS: | |||
102 | { | 101 | { |
103 | Akonadi2::Query query; | 102 | Akonadi2::Query query; |
104 | query.resources << "org.kde.maildir.instance1"; | 103 | query.resources << "org.kde.maildir.instance1"; |
105 | query.syncOnDemand = true; | ||
106 | query.processAll = true; | ||
107 | query.parentProperty = "parent"; | 104 | query.parentProperty = "parent"; |
108 | 105 | ||
109 | //Ensure all local data is processed | 106 | //Ensure all local data is processed |
110 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 107 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
108 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
111 | 109 | ||
112 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 110 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); |
113 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 111 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -124,10 +122,8 @@ private Q_SLOTS: | |||
124 | using namespace Akonadi2::ApplicationDomain; | 122 | using namespace Akonadi2::ApplicationDomain; |
125 | //Ensure all local data is processed | 123 | //Ensure all local data is processed |
126 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); | 124 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
127 | query.processAll = true; | ||
128 | query.syncOnDemand = true; | ||
129 | Store::synchronize(query).exec().waitForFinished(); | 125 | Store::synchronize(query).exec().waitForFinished(); |
130 | // Store::flushMessageQueues(Query::ResourceFilter("org.kde.maildir.instance1")).exec().waitForFinished(); | 126 | Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
131 | auto result = Store::fetchOne<Folder>( | 127 | auto result = Store::fetchOne<Folder>( |
132 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::RequestedProperties(QByteArrayList() << "name") | 128 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::RequestedProperties(QByteArrayList() << "name") |
133 | ) | 129 | ) |
@@ -150,11 +146,10 @@ private Q_SLOTS: | |||
150 | Akonadi2::Query query; | 146 | Akonadi2::Query query; |
151 | query.resources << "org.kde.maildir.instance1"; | 147 | query.resources << "org.kde.maildir.instance1"; |
152 | query.requestedProperties << "folder" << "subject" << "mimeMessage" << "date"; | 148 | query.requestedProperties << "folder" << "subject" << "mimeMessage" << "date"; |
153 | query.syncOnDemand = true; | ||
154 | query.processAll = true; | ||
155 | 149 | ||
156 | //Ensure all local data is processed | 150 | //Ensure all local data is processed |
157 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 151 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
152 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
158 | 153 | ||
159 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 154 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); |
160 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 155 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -170,12 +165,11 @@ private Q_SLOTS: | |||
170 | { | 165 | { |
171 | Akonadi2::Query query; | 166 | Akonadi2::Query query; |
172 | query.resources << "org.kde.maildir.instance1"; | 167 | query.resources << "org.kde.maildir.instance1"; |
173 | query.syncOnDemand = true; | ||
174 | query.processAll = true; | ||
175 | query.requestedProperties << "name"; | 168 | query.requestedProperties << "name"; |
176 | 169 | ||
177 | //Ensure all local data is processed | 170 | //Ensure all local data is processed |
178 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 171 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
172 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
179 | 173 | ||
180 | auto targetPath = tempDir.path() + "/maildir1/"; | 174 | auto targetPath = tempDir.path() + "/maildir1/"; |
181 | QDir dir(targetPath); | 175 | QDir dir(targetPath); |
@@ -183,6 +177,7 @@ private Q_SLOTS: | |||
183 | 177 | ||
184 | //Ensure all local data is processed | 178 | //Ensure all local data is processed |
185 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 179 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
180 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
186 | 181 | ||
187 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 182 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); |
188 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 183 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -194,15 +189,15 @@ private Q_SLOTS: | |||
194 | { | 189 | { |
195 | Akonadi2::Query query; | 190 | Akonadi2::Query query; |
196 | query.resources << "org.kde.maildir.instance1"; | 191 | query.resources << "org.kde.maildir.instance1"; |
197 | query.syncOnDemand = true; | ||
198 | query.processAll = true; | ||
199 | query.requestedProperties << "folder" << "subject"; | 192 | query.requestedProperties << "folder" << "subject"; |
200 | 193 | ||
201 | //Ensure all local data is processed | 194 | //Ensure all local data is processed |
202 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 195 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
196 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
203 | 197 | ||
204 | //Ensure all local data is processed | 198 | //Ensure all local data is processed |
205 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 199 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
200 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
206 | 201 | ||
207 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 202 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); |
208 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 203 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -213,12 +208,11 @@ private Q_SLOTS: | |||
213 | { | 208 | { |
214 | Akonadi2::Query query; | 209 | Akonadi2::Query query; |
215 | query.resources << "org.kde.maildir.instance1"; | 210 | query.resources << "org.kde.maildir.instance1"; |
216 | query.syncOnDemand = true; | ||
217 | query.processAll = true; | ||
218 | query.requestedProperties << "folder" << "subject"; | 211 | query.requestedProperties << "folder" << "subject"; |
219 | 212 | ||
220 | //Ensure all local data is processed | 213 | //Ensure all local data is processed |
221 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 214 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
215 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
222 | 216 | ||
223 | auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; | 217 | auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; |
224 | QFile file(targetPath); | 218 | QFile file(targetPath); |
@@ -226,6 +220,7 @@ private Q_SLOTS: | |||
226 | 220 | ||
227 | //Ensure all local data is processed | 221 | //Ensure all local data is processed |
228 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 222 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
223 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
229 | 224 | ||
230 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 225 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); |
231 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 226 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); |
@@ -236,11 +231,9 @@ private Q_SLOTS: | |||
236 | { | 231 | { |
237 | Akonadi2::Query query; | 232 | Akonadi2::Query query; |
238 | query.resources << "org.kde.maildir.instance1"; | 233 | query.resources << "org.kde.maildir.instance1"; |
239 | query.syncOnDemand = false; | ||
240 | query.processAll = true; | ||
241 | 234 | ||
242 | //Ensure all local data is processed | 235 | //Ensure all local data is processed |
243 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 236 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
244 | 237 | ||
245 | Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); | 238 | Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); |
246 | folder.setProperty("name", "testCreateFolder"); | 239 | folder.setProperty("name", "testCreateFolder"); |
@@ -248,7 +241,7 @@ private Q_SLOTS: | |||
248 | Akonadi2::Store::create(folder).exec().waitForFinished(); | 241 | Akonadi2::Store::create(folder).exec().waitForFinished(); |
249 | 242 | ||
250 | //Ensure all local data is processed | 243 | //Ensure all local data is processed |
251 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 244 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
252 | 245 | ||
253 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; | 246 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; |
254 | QFileInfo file(targetPath); | 247 | QFileInfo file(targetPath); |
@@ -260,15 +253,13 @@ private Q_SLOTS: | |||
260 | { | 253 | { |
261 | Akonadi2::Query query; | 254 | Akonadi2::Query query; |
262 | query.resources << "org.kde.maildir.instance1"; | 255 | query.resources << "org.kde.maildir.instance1"; |
263 | query.syncOnDemand = false; | ||
264 | query.processAll = true; | ||
265 | 256 | ||
266 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; | 257 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; |
267 | 258 | ||
268 | Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); | 259 | Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); |
269 | folder.setProperty("name", "testCreateFolder"); | 260 | folder.setProperty("name", "testCreateFolder"); |
270 | Akonadi2::Store::create(folder).exec().waitForFinished(); | 261 | Akonadi2::Store::create(folder).exec().waitForFinished(); |
271 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 262 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
272 | QTRY_VERIFY(QFileInfo(targetPath).exists()); | 263 | QTRY_VERIFY(QFileInfo(targetPath).exists()); |
273 | 264 | ||
274 | Akonadi2::Query folderQuery; | 265 | Akonadi2::Query folderQuery; |
@@ -280,7 +271,7 @@ private Q_SLOTS: | |||
280 | auto createdFolder = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | 271 | auto createdFolder = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); |
281 | 272 | ||
282 | Akonadi2::Store::remove(*createdFolder).exec().waitForFinished(); | 273 | Akonadi2::Store::remove(*createdFolder).exec().waitForFinished(); |
283 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 274 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
284 | QTRY_VERIFY(!QFileInfo(targetPath).exists()); | 275 | QTRY_VERIFY(!QFileInfo(targetPath).exists()); |
285 | } | 276 | } |
286 | 277 | ||
@@ -288,11 +279,9 @@ private Q_SLOTS: | |||
288 | { | 279 | { |
289 | Akonadi2::Query query; | 280 | Akonadi2::Query query; |
290 | query.resources << "org.kde.maildir.instance1"; | 281 | query.resources << "org.kde.maildir.instance1"; |
291 | query.syncOnDemand = false; | ||
292 | query.processAll = true; | ||
293 | 282 | ||
294 | //Ensure all local data is processed | 283 | //Ensure all local data is processed |
295 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 284 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
296 | 285 | ||
297 | Akonadi2::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); | 286 | Akonadi2::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); |
298 | mail.setProperty("name", "testCreateMail"); | 287 | mail.setProperty("name", "testCreateMail"); |
@@ -300,7 +289,7 @@ private Q_SLOTS: | |||
300 | Akonadi2::Store::create(mail).exec().waitForFinished(); | 289 | Akonadi2::Store::create(mail).exec().waitForFinished(); |
301 | 290 | ||
302 | //Ensure all local data is processed | 291 | //Ensure all local data is processed |
303 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 292 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
304 | 293 | ||
305 | auto targetPath = tempDir.path() + "/maildir1/new"; | 294 | auto targetPath = tempDir.path() + "/maildir1/new"; |
306 | QDir dir(targetPath); | 295 | QDir dir(targetPath); |
@@ -312,9 +301,8 @@ private Q_SLOTS: | |||
312 | { | 301 | { |
313 | Akonadi2::Query query; | 302 | Akonadi2::Query query; |
314 | query.resources << "org.kde.maildir.instance1"; | 303 | query.resources << "org.kde.maildir.instance1"; |
315 | query.syncOnDemand = true; | ||
316 | query.processAll = true; | ||
317 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 304 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
305 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
318 | 306 | ||
319 | Akonadi2::Query folderQuery; | 307 | Akonadi2::Query folderQuery; |
320 | folderQuery.resources << "org.kde.maildir.instance1"; | 308 | folderQuery.resources << "org.kde.maildir.instance1"; |
@@ -334,6 +322,7 @@ private Q_SLOTS: | |||
334 | 322 | ||
335 | Akonadi2::Store::remove(*mail).exec().waitForFinished(); | 323 | Akonadi2::Store::remove(*mail).exec().waitForFinished(); |
336 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 324 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); |
325 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | ||
337 | 326 | ||
338 | QTRY_COMPARE(QDir(tempDir.path() + "/maildir1/cur", QString(), QDir::NoSort, QDir::Files).count(), static_cast<unsigned int>(0)); | 327 | QTRY_COMPARE(QDir(tempDir.path() + "/maildir1/cur", QString(), QDir::NoSort, QDir::Files).count(), static_cast<unsigned int>(0)); |
339 | } | 328 | } |