diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-11 11:55:29 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-07-11 11:55:29 +0200 |
commit | 3a3118e768e1447dc7524328e84b8d7faef81fe1 (patch) | |
tree | af5582170ed6164fffc9365f34b17bf449c0db40 /tests/querytest.cpp | |
parent | f9379318d801df204cc50385c5eca1f28e91755e (diff) | |
parent | ce2fd2666f084eebe443598f6f3740a02913091e (diff) | |
download | sink-3a3118e768e1447dc7524328e84b8d7faef81fe1.tar.gz sink-3a3118e768e1447dc7524328e84b8d7faef81fe1.zip |
Merge branch 'feature/notifications' into develop
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r-- | tests/querytest.cpp | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 6d7746e..d3a97f6 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -23,16 +23,15 @@ private slots: | |||
23 | void initTestCase() | 23 | void initTestCase() |
24 | { | 24 | { |
25 | Sink::Test::initTest(); | 25 | Sink::Test::initTest(); |
26 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); | 26 | auto factory = Sink::ResourceFactory::load("sink.dummy"); |
27 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); | ||
28 | QVERIFY(factory); | 27 | QVERIFY(factory); |
29 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | 28 | ResourceConfig::addResource("sink.dummy.instance1", "sink.dummy"); |
30 | Sink::Store::removeDataFromDisk(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 29 | Sink::Store::removeDataFromDisk(QByteArray("sink.dummy.instance1")).exec().waitForFinished(); |
31 | } | 30 | } |
32 | 31 | ||
33 | void cleanup() | 32 | void cleanup() |
34 | { | 33 | { |
35 | Sink::Store::removeDataFromDisk(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 34 | Sink::Store::removeDataFromDisk(QByteArray("sink.dummy.instance1")).exec().waitForFinished(); |
36 | } | 35 | } |
37 | 36 | ||
38 | void init() | 37 | void init() |
@@ -60,13 +59,13 @@ private slots: | |||
60 | { | 59 | { |
61 | // Setup | 60 | // Setup |
62 | { | 61 | { |
63 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 62 | Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); |
64 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 63 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
65 | } | 64 | } |
66 | 65 | ||
67 | // Test | 66 | // Test |
68 | Sink::Query query; | 67 | Sink::Query query; |
69 | query.resources << "org.kde.dummy.instance1"; | 68 | query.resources << "sink.dummy.instance1"; |
70 | query.liveQuery = true; | 69 | query.liveQuery = true; |
71 | 70 | ||
72 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 71 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
@@ -78,13 +77,13 @@ private slots: | |||
78 | { | 77 | { |
79 | // Setup | 78 | // Setup |
80 | { | 79 | { |
81 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 80 | Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); |
82 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 81 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
83 | } | 82 | } |
84 | 83 | ||
85 | // Test | 84 | // Test |
86 | Sink::Query query; | 85 | Sink::Query query; |
87 | query.resources << "org.kde.dummy.instance1"; | 86 | query.resources << "sink.dummy.instance1"; |
88 | query.liveQuery = false; | 87 | query.liveQuery = false; |
89 | 88 | ||
90 | // Ensure all local data is processed | 89 | // Ensure all local data is processed |
@@ -102,12 +101,12 @@ private slots: | |||
102 | QByteArray id; | 101 | QByteArray id; |
103 | // Setup | 102 | // Setup |
104 | { | 103 | { |
105 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 104 | Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); |
106 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 105 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
107 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 106 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
108 | 107 | ||
109 | Sink::Query query; | 108 | Sink::Query query; |
110 | query.resources << "org.kde.dummy.instance1"; | 109 | query.resources << "sink.dummy.instance1"; |
111 | 110 | ||
112 | // Ensure all local data is processed | 111 | // Ensure all local data is processed |
113 | Sink::Store::synchronize(query).exec().waitForFinished(); | 112 | Sink::Store::synchronize(query).exec().waitForFinished(); |
@@ -121,7 +120,7 @@ private slots: | |||
121 | 120 | ||
122 | // Test | 121 | // Test |
123 | Sink::Query query; | 122 | Sink::Query query; |
124 | query.resources << "org.kde.dummy.instance1"; | 123 | query.resources << "sink.dummy.instance1"; |
125 | query.ids << id; | 124 | query.ids << id; |
126 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 125 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
127 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 126 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -132,13 +131,13 @@ private slots: | |||
132 | { | 131 | { |
133 | // Setup | 132 | // Setup |
134 | { | 133 | { |
135 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 134 | Sink::ApplicationDomain::Folder folder("sink.dummy.instance1"); |
136 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); | 135 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); |
137 | } | 136 | } |
138 | 137 | ||
139 | // Test | 138 | // Test |
140 | Sink::Query query; | 139 | Sink::Query query; |
141 | query.resources << "org.kde.dummy.instance1"; | 140 | query.resources << "sink.dummy.instance1"; |
142 | query.liveQuery = true; | 141 | query.liveQuery = true; |
143 | 142 | ||
144 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 143 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
@@ -152,11 +151,11 @@ private slots: | |||
152 | { | 151 | { |
153 | // Setup | 152 | // Setup |
154 | { | 153 | { |
155 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 154 | Sink::ApplicationDomain::Folder folder("sink.dummy.instance1"); |
156 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); | 155 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); |
157 | 156 | ||
158 | Sink::Query query; | 157 | Sink::Query query; |
159 | query.resources << "org.kde.dummy.instance1"; | 158 | query.resources << "sink.dummy.instance1"; |
160 | 159 | ||
161 | // Ensure all local data is processed | 160 | // Ensure all local data is processed |
162 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 161 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
@@ -168,14 +167,14 @@ private slots: | |||
168 | auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); | 167 | auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); |
169 | QVERIFY(!folderEntity->identifier().isEmpty()); | 168 | QVERIFY(!folderEntity->identifier().isEmpty()); |
170 | 169 | ||
171 | Sink::ApplicationDomain::Folder subfolder("org.kde.dummy.instance1"); | 170 | Sink::ApplicationDomain::Folder subfolder("sink.dummy.instance1"); |
172 | subfolder.setProperty("parent", folderEntity->identifier()); | 171 | subfolder.setProperty("parent", folderEntity->identifier()); |
173 | Sink::Store::create<Sink::ApplicationDomain::Folder>(subfolder).exec().waitForFinished(); | 172 | Sink::Store::create<Sink::ApplicationDomain::Folder>(subfolder).exec().waitForFinished(); |
174 | } | 173 | } |
175 | 174 | ||
176 | // Test | 175 | // Test |
177 | Sink::Query query; | 176 | Sink::Query query; |
178 | query.resources << "org.kde.dummy.instance1"; | 177 | query.resources << "sink.dummy.instance1"; |
179 | query.parentProperty = "parent"; | 178 | query.parentProperty = "parent"; |
180 | 179 | ||
181 | // Ensure all local data is processed | 180 | // Ensure all local data is processed |
@@ -194,7 +193,7 @@ private slots: | |||
194 | { | 193 | { |
195 | // Setup | 194 | // Setup |
196 | { | 195 | { |
197 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 196 | Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); |
198 | mail.setProperty("uid", "test1"); | 197 | mail.setProperty("uid", "test1"); |
199 | mail.setProperty("sender", "doe@example.org"); | 198 | mail.setProperty("sender", "doe@example.org"); |
200 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 199 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
@@ -202,7 +201,7 @@ private slots: | |||
202 | 201 | ||
203 | // Test | 202 | // Test |
204 | Sink::Query query; | 203 | Sink::Query query; |
205 | query.resources << "org.kde.dummy.instance1"; | 204 | query.resources << "sink.dummy.instance1"; |
206 | query.liveQuery = false; | 205 | query.liveQuery = false; |
207 | query += Sink::Query::PropertyFilter("uid", "test1"); | 206 | query += Sink::Query::PropertyFilter("uid", "test1"); |
208 | 207 | ||
@@ -220,11 +219,11 @@ private slots: | |||
220 | // Setup | 219 | // Setup |
221 | Sink::ApplicationDomain::Folder::Ptr folderEntity; | 220 | Sink::ApplicationDomain::Folder::Ptr folderEntity; |
222 | { | 221 | { |
223 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 222 | Sink::ApplicationDomain::Folder folder("sink.dummy.instance1"); |
224 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); | 223 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); |
225 | 224 | ||
226 | Sink::Query query; | 225 | Sink::Query query; |
227 | query.resources << "org.kde.dummy.instance1"; | 226 | query.resources << "sink.dummy.instance1"; |
228 | 227 | ||
229 | // Ensure all local data is processed | 228 | // Ensure all local data is processed |
230 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 229 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
@@ -236,7 +235,7 @@ private slots: | |||
236 | folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); | 235 | folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); |
237 | QVERIFY(!folderEntity->identifier().isEmpty()); | 236 | QVERIFY(!folderEntity->identifier().isEmpty()); |
238 | 237 | ||
239 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 238 | Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); |
240 | mail.setProperty("uid", "test1"); | 239 | mail.setProperty("uid", "test1"); |
241 | mail.setProperty("folder", folderEntity->identifier()); | 240 | mail.setProperty("folder", folderEntity->identifier()); |
242 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 241 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
@@ -244,7 +243,7 @@ private slots: | |||
244 | 243 | ||
245 | // Test | 244 | // Test |
246 | Sink::Query query; | 245 | Sink::Query query; |
247 | query.resources << "org.kde.dummy.instance1"; | 246 | query.resources << "sink.dummy.instance1"; |
248 | query += Sink::Query::PropertyFilter("folder", *folderEntity); | 247 | query += Sink::Query::PropertyFilter("folder", *folderEntity); |
249 | 248 | ||
250 | // Ensure all local data is processed | 249 | // Ensure all local data is processed |
@@ -261,11 +260,11 @@ private slots: | |||
261 | // Setup | 260 | // Setup |
262 | Sink::ApplicationDomain::Folder::Ptr folderEntity; | 261 | Sink::ApplicationDomain::Folder::Ptr folderEntity; |
263 | { | 262 | { |
264 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 263 | Sink::ApplicationDomain::Folder folder("sink.dummy.instance1"); |
265 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); | 264 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); |
266 | 265 | ||
267 | Sink::Query query; | 266 | Sink::Query query; |
268 | query.resources << "org.kde.dummy.instance1"; | 267 | query.resources << "sink.dummy.instance1"; |
269 | 268 | ||
270 | // Ensure all local data is processed | 269 | // Ensure all local data is processed |
271 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 270 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
@@ -279,21 +278,21 @@ private slots: | |||
279 | 278 | ||
280 | const auto date = QDateTime(QDate(2015, 7, 7), QTime(12, 0)); | 279 | const auto date = QDateTime(QDate(2015, 7, 7), QTime(12, 0)); |
281 | { | 280 | { |
282 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 281 | Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); |
283 | mail.setProperty("uid", "testSecond"); | 282 | mail.setProperty("uid", "testSecond"); |
284 | mail.setProperty("folder", folderEntity->identifier()); | 283 | mail.setProperty("folder", folderEntity->identifier()); |
285 | mail.setProperty("date", date.addDays(-1)); | 284 | mail.setProperty("date", date.addDays(-1)); |
286 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 285 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
287 | } | 286 | } |
288 | { | 287 | { |
289 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 288 | Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); |
290 | mail.setProperty("uid", "testLatest"); | 289 | mail.setProperty("uid", "testLatest"); |
291 | mail.setProperty("folder", folderEntity->identifier()); | 290 | mail.setProperty("folder", folderEntity->identifier()); |
292 | mail.setProperty("date", date); | 291 | mail.setProperty("date", date); |
293 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 292 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
294 | } | 293 | } |
295 | { | 294 | { |
296 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 295 | Sink::ApplicationDomain::Mail mail("sink.dummy.instance1"); |
297 | mail.setProperty("uid", "testLast"); | 296 | mail.setProperty("uid", "testLast"); |
298 | mail.setProperty("folder", folderEntity->identifier()); | 297 | mail.setProperty("folder", folderEntity->identifier()); |
299 | mail.setProperty("date", date.addDays(-2)); | 298 | mail.setProperty("date", date.addDays(-2)); |
@@ -303,7 +302,7 @@ private slots: | |||
303 | 302 | ||
304 | // Test | 303 | // Test |
305 | Sink::Query query; | 304 | Sink::Query query; |
306 | query.resources << "org.kde.dummy.instance1"; | 305 | query.resources << "sink.dummy.instance1"; |
307 | query += Sink::Query::PropertyFilter("folder", *folderEntity); | 306 | query += Sink::Query::PropertyFilter("folder", *folderEntity); |
308 | query.sortProperty = "date"; | 307 | query.sortProperty = "date"; |
309 | query.limit = 1; | 308 | query.limit = 1; |