From 84f95d703df5ba607f5f1c6dde9e0c17290b4968 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 10 Dec 2015 16:43:41 +0100 Subject: Mail by folder query test --- tests/querytest.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) 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: QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); QCOMPARE(model->rowCount(), 1); } + + void testMailByFolder() + { + //Setup + Akonadi2::ApplicationDomain::Folder::Ptr folderEntity; + { + Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); + Akonadi2::Store::create(folder).exec().waitForFinished(); + + Akonadi2::Query query; + query.resources << "org.kde.dummy.instance1"; + query.syncOnDemand = false; + query.processAll = true; + + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + + auto model = Akonadi2::Store::loadModel(query); + QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); + QCOMPARE(model->rowCount(), 1); + + folderEntity = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value(); + QVERIFY(!folderEntity->identifier().isEmpty()); + + Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); + mail.setProperty("uid", "test1"); + mail.setProperty("folder", folderEntity->identifier()); + Akonadi2::Store::create(mail).exec().waitForFinished(); + } + + //Test + Akonadi2::Query query; + query.resources << "org.kde.dummy.instance1"; + query.syncOnDemand = false; + query.processAll = true; + query.liveQuery = false; + query.propertyFilter.insert("folder", folderEntity->identifier()); + + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + + //We fetch before the data is available and rely on the live query mechanism to deliver the actual data + auto model = Akonadi2::Store::loadModel(query); + QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); + QCOMPARE(model->rowCount(), 1); + } }; QTEST_MAIN(QueryTest) -- cgit v1.2.3