diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-12-28 12:05:34 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-02 13:31:14 +0100 |
commit | 625190d311adfcf3f0436cfece82249a92489348 (patch) | |
tree | 1010950e14b57560ae90abe20a5657750ad27137 /tests | |
parent | 11b790ba6f06141db802273628ce2d191982677e (diff) | |
download | sink-625190d311adfcf3f0436cfece82249a92489348.tar.gz sink-625190d311adfcf3f0436cfece82249a92489348.zip |
No parent query
Diffstat (limited to 'tests')
-rw-r--r-- | tests/clientapitest.cpp | 22 | ||||
-rw-r--r-- | tests/databasepopulationandfacadequerybenchmark.cpp | 4 | ||||
-rw-r--r-- | tests/mailquerybenchmark.cpp | 8 | ||||
-rw-r--r-- | tests/querytest.cpp | 7 |
4 files changed, 13 insertions, 28 deletions
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 @@ | |||
13 | 13 | ||
14 | template <typename T> | 14 | template <typename T> |
15 | struct Result { | 15 | struct Result { |
16 | QSharedPointer<T> parent; | ||
17 | bool fetchedAll; | 16 | bool fetchedAll; |
18 | }; | 17 | }; |
19 | 18 | ||
@@ -73,37 +72,28 @@ public: | |||
73 | // We have to do it this way, otherwise we're not setting the fetcher right | 72 | // We have to do it this way, otherwise we're not setting the fetcher right |
74 | auto emitter = resultProvider->emitter(); | 73 | auto emitter = resultProvider->emitter(); |
75 | 74 | ||
76 | resultProvider->setFetcher([query, resultProvider, this, ctx](const typename T::Ptr &parent) { | 75 | resultProvider->setFetcher([query, resultProvider, this, ctx]() { |
77 | async::run<Result<T>>([=] { | 76 | async::run<Result<T>>([=] { |
78 | if (parent) { | 77 | SinkTraceCtx(ctx) << "Running the fetcher."; |
79 | SinkTraceCtx(ctx) << "Running the fetcher " << parent->identifier(); | ||
80 | } else { | ||
81 | SinkTraceCtx(ctx) << "Running the fetcher."; | ||
82 | } | ||
83 | SinkTraceCtx(ctx) << "-------------------------."; | 78 | SinkTraceCtx(ctx) << "-------------------------."; |
84 | int count = 0; | 79 | int count = 0; |
85 | for (int i = offset; i < results.size(); i++) { | 80 | for (int i = offset; i < results.size(); i++) { |
86 | const auto res = results.at(i); | 81 | const auto res = results.at(i); |
87 | count++; | 82 | count++; |
88 | // SinkTraceCtx(ctx) << "Parent filter " << query.getFilter("parent").value.toByteArray() << res->identifier() << res->getProperty("parent").toByteArray(); | 83 | resultProvider->add(res); |
89 | auto parentProperty = res->getProperty("parent").toByteArray(); | ||
90 | if ((!parent && parentProperty.isEmpty()) || (parent && parentProperty == parent->identifier()) || query.parentProperty().isEmpty()) { | ||
91 | // SinkTraceCtx(ctx) << "Found a hit" << res->identifier(); | ||
92 | resultProvider->add(res); | ||
93 | } | ||
94 | if (query.limit()) { | 84 | if (query.limit()) { |
95 | if (count >= query.limit()) { | 85 | if (count >= query.limit()) { |
96 | SinkTraceCtx(ctx) << "Aborting early after " << count << "results."; | 86 | SinkTraceCtx(ctx) << "Aborting early after " << count << "results."; |
97 | offset = i + 1; | 87 | offset = i + 1; |
98 | bool fetchedAll = (i + 1 >= results.size()); | 88 | bool fetchedAll = (i + 1 >= results.size()); |
99 | return Result<T>{parent, fetchedAll}; | 89 | return Result<T>{fetchedAll}; |
100 | } | 90 | } |
101 | } | 91 | } |
102 | } | 92 | } |
103 | return Result<T>{parent, true}; | 93 | return Result<T>{true}; |
104 | }, runAsync) | 94 | }, runAsync) |
105 | .then([=] (const Result<T> &r) { | 95 | .then([=] (const Result<T> &r) { |
106 | resultProvider->initialResultSetComplete(r.parent, r.fetchedAll); | 96 | resultProvider->initialResultSetComplete(r.fetchedAll); |
107 | }) | 97 | }) |
108 | .exec(); | 98 | .exec(); |
109 | }); | 99 | }); |
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 | |||
113 | QList<Sink::ApplicationDomain::Event::Ptr> list; | 113 | QList<Sink::ApplicationDomain::Event::Ptr> list; |
114 | emitter->onAdded([&list](const Sink::ApplicationDomain::Event::Ptr &event) { list << event; }); | 114 | emitter->onAdded([&list](const Sink::ApplicationDomain::Event::Ptr &event) { list << event; }); |
115 | bool done = false; | 115 | bool done = false; |
116 | emitter->onInitialResultSetComplete([&done](const Sink::ApplicationDomain::Event::Ptr &event, bool) { done = true; }); | 116 | emitter->onInitialResultSetComplete([&done](bool) { done = true; }); |
117 | emitter->fetch(Sink::ApplicationDomain::Event::Ptr()); | 117 | emitter->fetch(); |
118 | QUICK_TRY_VERIFY(done); | 118 | QUICK_TRY_VERIFY(done); |
119 | QCOMPARE(list.size(), count); | 119 | QCOMPARE(list.size(), count); |
120 | 120 | ||
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 | |||
96 | int i = 0; | 96 | int i = 0; |
97 | emitter->onAdded([&](const Mail::Ptr &) { i++; }); | 97 | emitter->onAdded([&](const Mail::Ptr &) { i++; }); |
98 | bool done = false; | 98 | bool done = false; |
99 | emitter->onInitialResultSetComplete([&done](const Mail::Ptr &mail, bool) { done = true; }); | 99 | emitter->onInitialResultSetComplete([&done](bool) { done = true; }); |
100 | emitter->fetch(Mail::Ptr()); | 100 | emitter->fetch(); |
101 | QUICK_TRY_VERIFY(done); | 101 | QUICK_TRY_VERIFY(done); |
102 | return i; | 102 | return i; |
103 | } | 103 | } |
@@ -273,8 +273,8 @@ private slots: | |||
273 | emitter->onRemoved([&](const Mail::Ptr &mail) { removed << mail; /*qWarning() << "Removed";*/ }); | 273 | emitter->onRemoved([&](const Mail::Ptr &mail) { removed << mail; /*qWarning() << "Removed";*/ }); |
274 | emitter->onModified([&](const Mail::Ptr &mail) { modified << mail; /*qWarning() << "Modified";*/ }); | 274 | emitter->onModified([&](const Mail::Ptr &mail) { modified << mail; /*qWarning() << "Modified";*/ }); |
275 | bool done = false; | 275 | bool done = false; |
276 | emitter->onInitialResultSetComplete([&done](const Mail::Ptr &mail, bool) { done = true; }); | 276 | emitter->onInitialResultSetComplete([&done](bool) { done = true; }); |
277 | emitter->fetch(Mail::Ptr()); | 277 | emitter->fetch(); |
278 | QUICK_TRY_VERIFY(done); | 278 | QUICK_TRY_VERIFY(done); |
279 | QCOMPARE(added.size(), expectedSize); | 279 | QCOMPARE(added.size(), expectedSize); |
280 | 280 | ||
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: | |||
245 | auto model = Sink::Store::loadModel<Folder>(query); | 245 | auto model = Sink::Store::loadModel<Folder>(query); |
246 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 246 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
247 | QCOMPARE(model->rowCount(), 1); | 247 | QCOMPARE(model->rowCount(), 1); |
248 | model->fetchMore(model->index(0, 0)); | ||
249 | QTRY_VERIFY(model->data(model->index(0, 0), Sink::Store::ChildrenFetchedRole).toBool()); | ||
250 | QCOMPARE(model->rowCount(model->index(0, 0)), 1); | 248 | QCOMPARE(model->rowCount(model->index(0, 0)), 1); |
251 | } | 249 | } |
252 | 250 | ||
@@ -266,7 +264,6 @@ private slots: | |||
266 | auto model = Sink::Store::loadModel<Folder>(query); | 264 | auto model = Sink::Store::loadModel<Folder>(query); |
267 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 265 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
268 | QCOMPARE(model->rowCount(), 1); | 266 | QCOMPARE(model->rowCount(), 1); |
269 | model->fetchMore(model->index(0, 0)); | ||
270 | 267 | ||
271 | auto subfolder = ApplicationDomainType::createEntity<Folder>("sink.dummy.instance1"); | 268 | auto subfolder = ApplicationDomainType::createEntity<Folder>("sink.dummy.instance1"); |
272 | subfolder.setParent(folder.identifier()); | 269 | subfolder.setParent(folder.identifier()); |
@@ -274,9 +271,7 @@ private slots: | |||
274 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); | 271 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); |
275 | 272 | ||
276 | //Ensure the folder appears | 273 | //Ensure the folder appears |
277 | model->fetchMore(model->index(0, 0)); | 274 | QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); |
278 | QTRY_VERIFY(model->data(model->index(0, 0), Sink::Store::ChildrenFetchedRole).toBool()); | ||
279 | QCOMPARE(model->rowCount(model->index(0, 0)), 1); | ||
280 | 275 | ||
281 | //...and dissapears again after removal | 276 | //...and dissapears again after removal |
282 | VERIFYEXEC(Sink::Store::remove<Folder>(subfolder)); | 277 | VERIFYEXEC(Sink::Store::remove<Folder>(subfolder)); |