summaryrefslogtreecommitdiffstats
path: root/tests/querytest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-10 16:43:41 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-12-10 16:43:41 +0100
commit84f95d703df5ba607f5f1c6dde9e0c17290b4968 (patch)
treefd0930aeb84a08cdbde0805ba254edad816a0e2a /tests/querytest.cpp
parentf2f26869ed6efc4faf173b9a5cd5d2f15cec1e06 (diff)
downloadsink-84f95d703df5ba607f5f1c6dde9e0c17290b4968.tar.gz
sink-84f95d703df5ba607f5f1c6dde9e0c17290b4968.zip
Mail by folder query test
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r--tests/querytest.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp
index 1192b87..1ba37f4 100644
--- a/tests/querytest.cpp
+++ b/tests/querytest.cpp
@@ -202,6 +202,52 @@ private Q_SLOTS:
202 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); 202 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool());
203 QCOMPARE(model->rowCount(), 1); 203 QCOMPARE(model->rowCount(), 1);
204 } 204 }
205
206 void testMailByFolder()
207 {
208 //Setup
209 Akonadi2::ApplicationDomain::Folder::Ptr folderEntity;
210 {
211 Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1");
212 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(folder).exec().waitForFinished();
213
214 Akonadi2::Query query;
215 query.resources << "org.kde.dummy.instance1";
216 query.syncOnDemand = false;
217 query.processAll = true;
218
219 //Ensure all local data is processed
220 Akonadi2::Store::synchronize(query).exec().waitForFinished();
221
222 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query);
223 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool());
224 QCOMPARE(model->rowCount(), 1);
225
226 folderEntity = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>();
227 QVERIFY(!folderEntity->identifier().isEmpty());
228
229 Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1");
230 mail.setProperty("uid", "test1");
231 mail.setProperty("folder", folderEntity->identifier());
232 Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished();
233 }
234
235 //Test
236 Akonadi2::Query query;
237 query.resources << "org.kde.dummy.instance1";
238 query.syncOnDemand = false;
239 query.processAll = true;
240 query.liveQuery = false;
241 query.propertyFilter.insert("folder", folderEntity->identifier());
242
243 //Ensure all local data is processed
244 Akonadi2::Store::synchronize(query).exec().waitForFinished();
245
246 //We fetch before the data is available and rely on the live query mechanism to deliver the actual data
247 auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query);
248 QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool());
249 QCOMPARE(model->rowCount(), 1);
250 }
205}; 251};
206 252
207QTEST_MAIN(QueryTest) 253QTEST_MAIN(QueryTest)