summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/clientapitest.cpp6
-rw-r--r--tests/dummyresourcebenchmark.cpp2
-rw-r--r--tests/dummyresourcetest.cpp38
-rw-r--r--tests/maildirresourcetest.cpp2
-rw-r--r--tests/mailquerybenchmark.cpp2
-rw-r--r--tests/querytest.cpp6
6 files changed, 22 insertions, 34 deletions
diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp
index 172232f..96982ca 100644
--- a/tests/clientapitest.cpp
+++ b/tests/clientapitest.cpp
@@ -58,7 +58,7 @@ public:
58 } 58 }
59 Trace() << "-------------------------."; 59 Trace() << "-------------------------.";
60 for (const auto &res : results) { 60 for (const auto &res : results) {
61 qDebug() << "Parent filter " << query.propertyFilter.value("parent").toByteArray() << res->identifier() << res->getProperty("parent").toByteArray(); 61 qDebug() << "Parent filter " << query.propertyFilter.value("parent").value.toByteArray() << res->identifier() << res->getProperty("parent").toByteArray();
62 auto parentProperty = res->getProperty("parent").toByteArray(); 62 auto parentProperty = res->getProperty("parent").toByteArray();
63 if ((!parent && parentProperty.isEmpty()) || (parent && parentProperty == parent->identifier()) || query.parentProperty.isEmpty()) { 63 if ((!parent && parentProperty.isEmpty()) || (parent && parentProperty == parent->identifier()) || query.parentProperty.isEmpty()) {
64 qDebug() << "Found a hit" << res->identifier(); 64 qDebug() << "Found a hit" << res->identifier();
@@ -132,7 +132,7 @@ private slots:
132 Sink::Store::create(res).exec().waitForFinished(); 132 Sink::Store::create(res).exec().waitForFinished();
133 { 133 {
134 Sink::Query query; 134 Sink::Query query;
135 query.propertyFilter.insert("type", "dummyresource"); 135 query.propertyFilter.insert("type", Sink::Query::Comparator("dummyresource"));
136 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(query); 136 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(query);
137 QTRY_COMPARE(model->rowCount(QModelIndex()), 1); 137 QTRY_COMPARE(model->rowCount(QModelIndex()), 1);
138 } 138 }
@@ -140,7 +140,7 @@ private slots:
140 Sink::Store::remove(res).exec().waitForFinished(); 140 Sink::Store::remove(res).exec().waitForFinished();
141 { 141 {
142 Sink::Query query; 142 Sink::Query query;
143 query.propertyFilter.insert("type", "dummyresource"); 143 query.propertyFilter.insert("type", Sink::Query::Comparator("dummyresource"));
144 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(query); 144 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(query);
145 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 145 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
146 QCOMPARE(model->rowCount(QModelIndex()), 0); 146 QCOMPARE(model->rowCount(QModelIndex()), 0);
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp
index 1e71fc2..d5f98c3 100644
--- a/tests/dummyresourcebenchmark.cpp
+++ b/tests/dummyresourcebenchmark.cpp
@@ -157,7 +157,7 @@ private slots:
157 Sink::Query query; 157 Sink::Query query;
158 query.resources << "org.kde.dummy.instance1"; 158 query.resources << "org.kde.dummy.instance1";
159 159
160 query.propertyFilter.insert("uid", "testuid"); 160 query.propertyFilter.insert("uid", Sink::Query::Comparator("testuid"));
161 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); 161 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query);
162 QTRY_COMPARE(model->rowCount(QModelIndex()), num); 162 QTRY_COMPARE(model->rowCount(QModelIndex()), num);
163 } 163 }
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp
index 33304e1..58df2da 100644
--- a/tests/dummyresourcetest.cpp
+++ b/tests/dummyresourcetest.cpp
@@ -12,6 +12,8 @@
12#include "pipeline.h" 12#include "pipeline.h"
13#include "log.h" 13#include "log.h"
14 14
15using namespace Sink;
16
15/** 17/**
16 * Test of complete system using the dummy resource. 18 * Test of complete system using the dummy resource.
17 * 19 *
@@ -62,14 +64,12 @@ private slots:
62 event.setProperty("summary", "summaryValue"); 64 event.setProperty("summary", "summaryValue");
63 Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); 65 Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished();
64 66
65 Sink::Query query; 67 const auto query = Query::ResourceFilter("org.kde.dummy.instance1") ;
66 query.resources << "org.kde.dummy.instance1";
67 68
68 // Ensure all local data is processed 69 // Ensure all local data is processed
69 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 70 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
70 71
71 query.propertyFilter.insert("uid", "testuid"); 72 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query + Query::PropertyFilter("uid", "testuid"));
72 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query);
73 QTRY_COMPARE(model->rowCount(QModelIndex()), 1); 73 QTRY_COMPARE(model->rowCount(QModelIndex()), 1);
74 auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); 74 auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>();
75 QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); 75 QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid"));
@@ -86,15 +86,12 @@ private slots:
86 event.setProperty("uid", "testuid2"); 86 event.setProperty("uid", "testuid2");
87 Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); 87 Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished();
88 88
89 Sink::Query query; 89 const auto query = Query::ResourceFilter("org.kde.dummy.instance1") ;
90 query.resources << "org.kde.dummy.instance1";
91 90
92 // Ensure all local data is processed 91 // Ensure all local data is processed
93 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 92 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
94 93
95 query.propertyFilter.insert("uid", "testuid"); 94 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query + Query::PropertyFilter("uid", "testuid"));
96
97 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query);
98 QTRY_COMPARE(model->rowCount(QModelIndex()), 1); 95 QTRY_COMPARE(model->rowCount(QModelIndex()), 1);
99 auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); 96 auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>();
100 97
@@ -114,15 +111,12 @@ private slots:
114 event.setProperty("summary", "summaryValue2"); 111 event.setProperty("summary", "summaryValue2");
115 Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); 112 Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished();
116 113
117 Sink::Query query; 114 const auto query = Query::ResourceFilter("org.kde.dummy.instance1") ;
118 query.resources << "org.kde.dummy.instance1";
119 115
120 // Ensure all local data is processed 116 // Ensure all local data is processed
121 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 117 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
122 118
123 query.propertyFilter.insert("summary", "summaryValue2"); 119 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query + Query::PropertyFilter("summary", "summaryValue2"));
124
125 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query);
126 QTRY_COMPARE(model->rowCount(QModelIndex()), 1); 120 QTRY_COMPARE(model->rowCount(QModelIndex()), 1);
127 auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); 121 auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>();
128 122
@@ -147,8 +141,7 @@ private slots:
147 141
148 void testSyncAndFacade() 142 void testSyncAndFacade()
149 { 143 {
150 Sink::Query query; 144 const auto query = Query::ResourceFilter("org.kde.dummy.instance1");
151 query.resources << "org.kde.dummy.instance1";
152 145
153 // Ensure all local data is processed 146 // Ensure all local data is processed
154 Sink::Store::synchronize(query).exec().waitForFinished(); 147 Sink::Store::synchronize(query).exec().waitForFinished();
@@ -164,8 +157,7 @@ private slots:
164 157
165 void testSyncAndFacadeMail() 158 void testSyncAndFacadeMail()
166 { 159 {
167 Sink::Query query; 160 const auto query = Query::ResourceFilter("org.kde.dummy.instance1");
168 query.resources << "org.kde.dummy.instance1";
169 161
170 // Ensure all local data is processed 162 // Ensure all local data is processed
171 Sink::Store::synchronize(query).exec().waitForFinished(); 163 Sink::Store::synchronize(query).exec().waitForFinished();
@@ -187,9 +179,7 @@ private slots:
187 event.setProperty("summary", "summaryValue"); 179 event.setProperty("summary", "summaryValue");
188 Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); 180 Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished();
189 181
190 Sink::Query query; 182 const auto query = Query::ResourceFilter("org.kde.dummy.instance1") + Query::PropertyFilter("uid", "testuid");
191 query.resources << "org.kde.dummy.instance1";
192 query.propertyFilter.insert("uid", "testuid");
193 183
194 // Ensure all local data is processed 184 // Ensure all local data is processed
195 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 185 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
@@ -238,11 +228,9 @@ private slots:
238 228
239 void testWriteModifyDeleteLive() 229 void testWriteModifyDeleteLive()
240 { 230 {
241 231 auto query = Query::ResourceFilter("org.kde.dummy.instance1");
242 Sink::Query query;
243 query.resources << "org.kde.dummy.instance1";
244 query.liveQuery = true; 232 query.liveQuery = true;
245 query.propertyFilter.insert("uid", "testuid"); 233 query += Query::PropertyFilter("uid", "testuid");
246 234
247 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); 235 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query);
248 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 236 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp
index b5c1c3c..9b014e3 100644
--- a/tests/maildirresourcetest.cpp
+++ b/tests/maildirresourcetest.cpp
@@ -265,7 +265,7 @@ private slots:
265 265
266 Sink::Query folderQuery; 266 Sink::Query folderQuery;
267 folderQuery.resources << "org.kde.maildir.instance1"; 267 folderQuery.resources << "org.kde.maildir.instance1";
268 folderQuery.propertyFilter.insert("name", "testCreateFolder"); 268 folderQuery += Sink::Query::PropertyFilter("name", "testCreateFolder");
269 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(folderQuery); 269 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(folderQuery);
270 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); 270 QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool());
271 QCOMPARE(model->rowCount(QModelIndex()), 1); 271 QCOMPARE(model->rowCount(QModelIndex()), 1);
diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp
index 6b93863..20ee63c 100644
--- a/tests/mailquerybenchmark.cpp
+++ b/tests/mailquerybenchmark.cpp
@@ -159,7 +159,7 @@ private slots:
159 << "subject" 159 << "subject"
160 << "date"; 160 << "date";
161 query.sortProperty = "date"; 161 query.sortProperty = "date";
162 query.propertyFilter.insert("folder", "folder1"); 162 query += Sink::Query::PropertyFilter("folder", "folder1");
163 query.limit = 1000; 163 query.limit = 1000;
164 164
165 populateDatabase(50000); 165 populateDatabase(50000);
diff --git a/tests/querytest.cpp b/tests/querytest.cpp
index 7b9129e..a654931 100644
--- a/tests/querytest.cpp
+++ b/tests/querytest.cpp
@@ -202,7 +202,7 @@ private slots:
202 Sink::Query query; 202 Sink::Query query;
203 query.resources << "org.kde.dummy.instance1"; 203 query.resources << "org.kde.dummy.instance1";
204 query.liveQuery = false; 204 query.liveQuery = false;
205 query.propertyFilter.insert("uid", "test1"); 205 query += Sink::Query::PropertyFilter("uid", "test1");
206 206
207 // Ensure all local data is processed 207 // Ensure all local data is processed
208 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 208 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
@@ -243,7 +243,7 @@ private slots:
243 // Test 243 // Test
244 Sink::Query query; 244 Sink::Query query;
245 query.resources << "org.kde.dummy.instance1"; 245 query.resources << "org.kde.dummy.instance1";
246 query.propertyFilter.insert("folder", folderEntity->identifier()); 246 query += Sink::Query::PropertyFilter("folder", *folderEntity);
247 247
248 // Ensure all local data is processed 248 // Ensure all local data is processed
249 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); 249 Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished();
@@ -302,7 +302,7 @@ private slots:
302 // Test 302 // Test
303 Sink::Query query; 303 Sink::Query query;
304 query.resources << "org.kde.dummy.instance1"; 304 query.resources << "org.kde.dummy.instance1";
305 query.propertyFilter.insert("folder", folderEntity->identifier()); 305 query += Sink::Query::PropertyFilter("folder", *folderEntity);
306 query.sortProperty = "date"; 306 query.sortProperty = "date";
307 query.limit = 1; 307 query.limit = 1;
308 query.liveQuery = false; 308 query.liveQuery = false;