From 75c231f0758603120ec562af772b48b5f6ac0e24 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 13 Nov 2015 23:31:41 +0100 Subject: DummyResourceTest and QueryTest are passing sync has been removed from the query code and is now a separate step --- tests/dummyresourcetest.cpp | 24 ++++++++++++++++++++++++ tests/querytest.cpp | 24 +++++++++++++++++++++++- tests/testimplementations.h | 4 ++-- 3 files changed, 49 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index d027266..3b90e6c 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp @@ -64,6 +64,9 @@ private Q_SLOTS: query.syncOnDemand = false; query.processAll = true; + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + query.propertyFilter.insert("uid", "testuid"); async::SyncListResult result(Akonadi2::Store::load(query)); result.exec(); @@ -88,6 +91,9 @@ private Q_SLOTS: query.syncOnDemand = false; query.processAll = true; + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + query.propertyFilter.insert("uid", "testuid"); async::SyncListResult result(Akonadi2::Store::load(query)); result.exec(); @@ -114,6 +120,9 @@ private Q_SLOTS: query.syncOnDemand = false; query.processAll = true; + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + query.propertyFilter.insert("summary", "summaryValue2"); async::SyncListResult result(Akonadi2::Store::load(query)); result.exec(); @@ -145,6 +154,9 @@ private Q_SLOTS: query.syncOnDemand = true; query.processAll = true; + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + async::SyncListResult result(Akonadi2::Store::load(query)); result.exec(); QVERIFY(!result.isEmpty()); @@ -160,6 +172,9 @@ private Q_SLOTS: query.syncOnDemand = true; query.processAll = true; + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + async::SyncListResult result(Akonadi2::Store::load(query)); result.exec(); QVERIFY(!result.isEmpty()); @@ -182,6 +197,9 @@ private Q_SLOTS: query.processAll = true; query.propertyFilter.insert("uid", "testuid"); + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + //Test create Akonadi2::ApplicationDomain::Event event2; { @@ -198,6 +216,9 @@ private Q_SLOTS: event2.setProperty("summary", "summaryValue2"); Akonadi2::Store::modify(event2).exec().waitForFinished(); + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + //Test modify { async::SyncListResult result(Akonadi2::Store::load(query)); @@ -210,6 +231,9 @@ private Q_SLOTS: Akonadi2::Store::remove(event2).exec().waitForFinished(); + //Ensure all local data is processed + Akonadi2::Store::synchronize(query).exec().waitForFinished(); + //Test remove { async::SyncListResult result(Akonadi2::Store::load(query)); diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 9f4b3bb..47d977b 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -57,11 +57,33 @@ private Q_SLOTS: query.syncOnDemand = false; query.processAll = true; - auto model = new ModelResult(query, QList() << "summary" << "uid"); + auto model = Akonadi2::Store::loadModel(query); model->fetchMore(QModelIndex()); QTRY_COMPARE(model->rowCount(), 1); } + void testSingleWithDelay() + { + //Setup + { + Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); + Akonadi2::Store::create(mail).exec().waitForFinished(); + } + + //Test + Akonadi2::Query query; + query.resources << "org.kde.dummy.instance1"; + query.syncOnDemand = false; + query.processAll = true; + query.liveQuery = true; + + auto model = Akonadi2::Store::loadModel(query); + QTest::qWait(200); + model->fetchMore(QModelIndex()); + QVERIFY(model->rowCount() < 2); + QTRY_COMPARE(model->rowCount(), 1); + } + // void testTree() // { // //Setup diff --git a/tests/testimplementations.h b/tests/testimplementations.h index eee78b0..1436c68 100644 --- a/tests/testimplementations.h +++ b/tests/testimplementations.h @@ -85,8 +85,8 @@ public Q_SLOTS: class TestResourceFacade : public Akonadi2::GenericFacade { public: - TestResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer > storage, const QSharedPointer resourceAccess) - : Akonadi2::GenericFacade(instanceIdentifier, QSharedPointer::create(), storage, resourceAccess) + TestResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer resourceAccess) + : Akonadi2::GenericFacade(instanceIdentifier, QSharedPointer::create(), resourceAccess) { } -- cgit v1.2.3