From 625190d311adfcf3f0436cfece82249a92489348 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 28 Dec 2017 12:05:34 +0100 Subject: No parent query --- tests/clientapitest.cpp | 22 ++++++---------------- .../databasepopulationandfacadequerybenchmark.cpp | 4 ++-- tests/mailquerybenchmark.cpp | 8 ++++---- tests/querytest.cpp | 7 +------ 4 files changed, 13 insertions(+), 28 deletions(-) (limited to 'tests') diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp index 7e348c2..94818e1 100644 --- a/tests/clientapitest.cpp +++ b/tests/clientapitest.cpp @@ -13,7 +13,6 @@ template struct Result { - QSharedPointer parent; bool fetchedAll; }; @@ -73,37 +72,28 @@ public: // We have to do it this way, otherwise we're not setting the fetcher right auto emitter = resultProvider->emitter(); - resultProvider->setFetcher([query, resultProvider, this, ctx](const typename T::Ptr &parent) { + resultProvider->setFetcher([query, resultProvider, this, ctx]() { async::run>([=] { - if (parent) { - SinkTraceCtx(ctx) << "Running the fetcher " << parent->identifier(); - } else { - SinkTraceCtx(ctx) << "Running the fetcher."; - } + SinkTraceCtx(ctx) << "Running the fetcher."; SinkTraceCtx(ctx) << "-------------------------."; int count = 0; for (int i = offset; i < results.size(); i++) { const auto res = results.at(i); count++; - // SinkTraceCtx(ctx) << "Parent filter " << query.getFilter("parent").value.toByteArray() << res->identifier() << res->getProperty("parent").toByteArray(); - auto parentProperty = res->getProperty("parent").toByteArray(); - if ((!parent && parentProperty.isEmpty()) || (parent && parentProperty == parent->identifier()) || query.parentProperty().isEmpty()) { - // SinkTraceCtx(ctx) << "Found a hit" << res->identifier(); - resultProvider->add(res); - } + resultProvider->add(res); if (query.limit()) { if (count >= query.limit()) { SinkTraceCtx(ctx) << "Aborting early after " << count << "results."; offset = i + 1; bool fetchedAll = (i + 1 >= results.size()); - return Result{parent, fetchedAll}; + return Result{fetchedAll}; } } } - return Result{parent, true}; + return Result{true}; }, runAsync) .then([=] (const Result &r) { - resultProvider->initialResultSetComplete(r.parent, r.fetchedAll); + resultProvider->initialResultSetComplete(r.fetchedAll); }) .exec(); }); diff --git a/tests/databasepopulationandfacadequerybenchmark.cpp b/tests/databasepopulationandfacadequerybenchmark.cpp index 4f81d1d..7f478cf 100644 --- a/tests/databasepopulationandfacadequerybenchmark.cpp +++ b/tests/databasepopulationandfacadequerybenchmark.cpp @@ -113,8 +113,8 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject QList list; emitter->onAdded([&list](const Sink::ApplicationDomain::Event::Ptr &event) { list << event; }); bool done = false; - emitter->onInitialResultSetComplete([&done](const Sink::ApplicationDomain::Event::Ptr &event, bool) { done = true; }); - emitter->fetch(Sink::ApplicationDomain::Event::Ptr()); + emitter->onInitialResultSetComplete([&done](bool) { done = true; }); + emitter->fetch(); QUICK_TRY_VERIFY(done); QCOMPARE(list.size(), count); diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp index 1d295b5..3eccfc3 100644 --- a/tests/mailquerybenchmark.cpp +++ b/tests/mailquerybenchmark.cpp @@ -96,8 +96,8 @@ class MailQueryBenchmark : public QObject int i = 0; emitter->onAdded([&](const Mail::Ptr &) { i++; }); bool done = false; - emitter->onInitialResultSetComplete([&done](const Mail::Ptr &mail, bool) { done = true; }); - emitter->fetch(Mail::Ptr()); + emitter->onInitialResultSetComplete([&done](bool) { done = true; }); + emitter->fetch(); QUICK_TRY_VERIFY(done); return i; } @@ -273,8 +273,8 @@ private slots: emitter->onRemoved([&](const Mail::Ptr &mail) { removed << mail; /*qWarning() << "Removed";*/ }); emitter->onModified([&](const Mail::Ptr &mail) { modified << mail; /*qWarning() << "Modified";*/ }); bool done = false; - emitter->onInitialResultSetComplete([&done](const Mail::Ptr &mail, bool) { done = true; }); - emitter->fetch(Mail::Ptr()); + emitter->onInitialResultSetComplete([&done](bool) { done = true; }); + emitter->fetch(); QUICK_TRY_VERIFY(done); QCOMPARE(added.size(), expectedSize); diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 6279fa9..5af8a99 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -245,8 +245,6 @@ private slots: auto model = Sink::Store::loadModel(query); QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); QCOMPARE(model->rowCount(), 1); - model->fetchMore(model->index(0, 0)); - QTRY_VERIFY(model->data(model->index(0, 0), Sink::Store::ChildrenFetchedRole).toBool()); QCOMPARE(model->rowCount(model->index(0, 0)), 1); } @@ -266,7 +264,6 @@ private slots: auto model = Sink::Store::loadModel(query); QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); QCOMPARE(model->rowCount(), 1); - model->fetchMore(model->index(0, 0)); auto subfolder = ApplicationDomainType::createEntity("sink.dummy.instance1"); subfolder.setParent(folder.identifier()); @@ -274,9 +271,7 @@ private slots: VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); //Ensure the folder appears - model->fetchMore(model->index(0, 0)); - QTRY_VERIFY(model->data(model->index(0, 0), Sink::Store::ChildrenFetchedRole).toBool()); - QCOMPARE(model->rowCount(model->index(0, 0)), 1); + QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); //...and dissapears again after removal VERIFYEXEC(Sink::Store::remove(subfolder)); -- cgit v1.2.3