From d4b10a3de396eebc6c815093e9e1725ece270e9e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 15 Nov 2015 11:09:31 +0100 Subject: Working folder tree query --- tests/querytest.cpp | 98 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 32 deletions(-) (limited to 'tests/querytest.cpp') diff --git a/tests/querytest.cpp b/tests/querytest.cpp index e4f1d0d..677dbac 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -90,38 +90,72 @@ private Q_SLOTS: QTRY_COMPARE(model->rowCount(), 1); } - // void testTree() - // { - // //Setup - // { - // 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; - // - // auto model = new ModelResult(query, QList() << "summary" << "uid"); - // QTRY_COMPARE(model->rowCount(), 1); - // - // auto folderEntity = model->index(0, 0).data(ModelResult::DomainObjectRole).value(); - // - // Akonadi2::ApplicationDomain::Folder subfolder("org.kde.dummy.instance1"); - // subfolder.setProperty("parent", folderEntity.identifier()); - // Akonadi2::Store::create(subfolder).exec().waitForFinished(); - // } - // - // //Test - // Akonadi2::Query query; - // query.resources << "org.kde.dummy.instance1"; - // query.syncOnDemand = false; - // query.processAll = true; - // - // auto model = new ModelResult(query, QList() << "summary" << "uid"); - // QTRY_COMPARE(model->rowCount(), 1); - // QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); - // } + void testFolder() + { + //Setup + { + Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); + Akonadi2::Store::create(folder).exec().waitForFinished(); + } + + //Test + Akonadi2::Query query; + query.resources << "org.kde.dummy.instance1"; + query.syncOnDemand = false; + query.processAll = false; + query.liveQuery = true; + + //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); + model->fetchMore(QModelIndex()); + QTRY_COMPARE(model->rowCount(), 1); + auto folderEntity = model->index(0, 0).data(ModelResult::DomainObjectRole).value(); + QVERIFY(!folderEntity->identifier().isEmpty()); + } + + void testFolderTree() + { + //Setup + { + 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); + model->fetchMore(QModelIndex()); + QTRY_COMPARE(model->rowCount(), 1); + + auto folderEntity = model->index(0, 0).data(ModelResult::DomainObjectRole).value(); + QVERIFY(!folderEntity->identifier().isEmpty()); + + Akonadi2::ApplicationDomain::Folder subfolder("org.kde.dummy.instance1"); + subfolder.setProperty("parent", folderEntity->identifier()); + Akonadi2::Store::create(subfolder).exec().waitForFinished(); + } + + //Test + 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(); + + //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data + auto model = Akonadi2::Store::loadModel(query); + model->fetchMore(QModelIndex()); + QTRY_COMPARE(model->rowCount(), 1); + model->fetchMore(model->index(0, 0)); + QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); + } }; QTEST_MAIN(QueryTest) -- cgit v1.2.3