summaryrefslogtreecommitdiffstats
path: root/tests/clientapitest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/clientapitest.cpp')
-rw-r--r--tests/clientapitest.cpp22
1 files changed, 6 insertions, 16 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
14template <typename T> 14template <typename T>
15struct Result { 15struct 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 });