diff options
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r-- | tests/querytest.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 2531c25..7b9129e 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -42,12 +42,12 @@ private slots: | |||
42 | 42 | ||
43 | void testNoResources() | 43 | void testNoResources() |
44 | { | 44 | { |
45 | //Test | 45 | // Test |
46 | Sink::Query query; | 46 | Sink::Query query; |
47 | query.resources << "foobar"; | 47 | query.resources << "foobar"; |
48 | query.liveQuery = true; | 48 | query.liveQuery = true; |
49 | 49 | ||
50 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 50 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
51 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 51 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
52 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 52 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
53 | QCOMPARE(model->rowCount(), 0); | 53 | QCOMPARE(model->rowCount(), 0); |
@@ -56,39 +56,39 @@ private slots: | |||
56 | 56 | ||
57 | void testSingle() | 57 | void testSingle() |
58 | { | 58 | { |
59 | //Setup | 59 | // Setup |
60 | { | 60 | { |
61 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 61 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); |
62 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 62 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
63 | } | 63 | } |
64 | 64 | ||
65 | //Test | 65 | // Test |
66 | Sink::Query query; | 66 | Sink::Query query; |
67 | query.resources << "org.kde.dummy.instance1"; | 67 | query.resources << "org.kde.dummy.instance1"; |
68 | query.liveQuery = true; | 68 | query.liveQuery = true; |
69 | 69 | ||
70 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 70 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
71 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 71 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
72 | QTRY_COMPARE(model->rowCount(), 1); | 72 | QTRY_COMPARE(model->rowCount(), 1); |
73 | } | 73 | } |
74 | 74 | ||
75 | void testSingleWithDelay() | 75 | void testSingleWithDelay() |
76 | { | 76 | { |
77 | //Setup | 77 | // Setup |
78 | { | 78 | { |
79 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 79 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); |
80 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 80 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
81 | } | 81 | } |
82 | 82 | ||
83 | //Test | 83 | // Test |
84 | Sink::Query query; | 84 | Sink::Query query; |
85 | query.resources << "org.kde.dummy.instance1"; | 85 | query.resources << "org.kde.dummy.instance1"; |
86 | query.liveQuery = false; | 86 | query.liveQuery = false; |
87 | 87 | ||
88 | //Ensure all local data is processed | 88 | // Ensure all local data is processed |
89 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 89 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
90 | 90 | ||
91 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data | 91 | // We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data |
92 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 92 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
93 | 93 | ||
94 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 94 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -98,7 +98,7 @@ private slots: | |||
98 | void testById() | 98 | void testById() |
99 | { | 99 | { |
100 | QByteArray id; | 100 | QByteArray id; |
101 | //Setup | 101 | // Setup |
102 | { | 102 | { |
103 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 103 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); |
104 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 104 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
@@ -107,17 +107,17 @@ private slots: | |||
107 | Sink::Query query; | 107 | Sink::Query query; |
108 | query.resources << "org.kde.dummy.instance1"; | 108 | query.resources << "org.kde.dummy.instance1"; |
109 | 109 | ||
110 | //Ensure all local data is processed | 110 | // Ensure all local data is processed |
111 | Sink::Store::synchronize(query).exec().waitForFinished(); | 111 | Sink::Store::synchronize(query).exec().waitForFinished(); |
112 | 112 | ||
113 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 113 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
114 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 114 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
115 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 115 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
116 | QVERIFY(model->rowCount() >= 1); | 116 | QVERIFY(model->rowCount() >= 1); |
117 | id = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->identifier(); | 117 | id = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->identifier(); |
118 | } | 118 | } |
119 | 119 | ||
120 | //Test | 120 | // Test |
121 | Sink::Query query; | 121 | Sink::Query query; |
122 | query.resources << "org.kde.dummy.instance1"; | 122 | query.resources << "org.kde.dummy.instance1"; |
123 | query.ids << id; | 123 | query.ids << id; |
@@ -128,18 +128,18 @@ private slots: | |||
128 | 128 | ||
129 | void testFolder() | 129 | void testFolder() |
130 | { | 130 | { |
131 | //Setup | 131 | // Setup |
132 | { | 132 | { |
133 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 133 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); |
134 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); | 134 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); |
135 | } | 135 | } |
136 | 136 | ||
137 | //Test | 137 | // Test |
138 | Sink::Query query; | 138 | Sink::Query query; |
139 | query.resources << "org.kde.dummy.instance1"; | 139 | query.resources << "org.kde.dummy.instance1"; |
140 | query.liveQuery = true; | 140 | query.liveQuery = true; |
141 | 141 | ||
142 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 142 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
143 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 143 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
144 | QTRY_COMPARE(model->rowCount(), 1); | 144 | QTRY_COMPARE(model->rowCount(), 1); |
145 | auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); | 145 | auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); |
@@ -148,7 +148,7 @@ private slots: | |||
148 | 148 | ||
149 | void testFolderTree() | 149 | void testFolderTree() |
150 | { | 150 | { |
151 | //Setup | 151 | // Setup |
152 | { | 152 | { |
153 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 153 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); |
154 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); | 154 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); |
@@ -156,7 +156,7 @@ private slots: | |||
156 | Sink::Query query; | 156 | Sink::Query query; |
157 | query.resources << "org.kde.dummy.instance1"; | 157 | query.resources << "org.kde.dummy.instance1"; |
158 | 158 | ||
159 | //Ensure all local data is processed | 159 | // Ensure all local data is processed |
160 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 160 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
161 | 161 | ||
162 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 162 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
@@ -171,15 +171,15 @@ private slots: | |||
171 | Sink::Store::create<Sink::ApplicationDomain::Folder>(subfolder).exec().waitForFinished(); | 171 | Sink::Store::create<Sink::ApplicationDomain::Folder>(subfolder).exec().waitForFinished(); |
172 | } | 172 | } |
173 | 173 | ||
174 | //Test | 174 | // Test |
175 | Sink::Query query; | 175 | Sink::Query query; |
176 | query.resources << "org.kde.dummy.instance1"; | 176 | query.resources << "org.kde.dummy.instance1"; |
177 | query.parentProperty = "parent"; | 177 | query.parentProperty = "parent"; |
178 | 178 | ||
179 | //Ensure all local data is processed | 179 | // Ensure all local data is processed |
180 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 180 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
181 | 181 | ||
182 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data | 182 | // We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data |
183 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 183 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
184 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 184 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
185 | QCOMPARE(model->rowCount(), 1); | 185 | QCOMPARE(model->rowCount(), 1); |
@@ -190,7 +190,7 @@ private slots: | |||
190 | 190 | ||
191 | void testMailByUid() | 191 | void testMailByUid() |
192 | { | 192 | { |
193 | //Setup | 193 | // Setup |
194 | { | 194 | { |
195 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 195 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); |
196 | mail.setProperty("uid", "test1"); | 196 | mail.setProperty("uid", "test1"); |
@@ -198,16 +198,16 @@ private slots: | |||
198 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 198 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
199 | } | 199 | } |
200 | 200 | ||
201 | //Test | 201 | // Test |
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.propertyFilter.insert("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(); |
209 | 209 | ||
210 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 210 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
211 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 211 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
212 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 212 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
213 | QCOMPARE(model->rowCount(), 1); | 213 | QCOMPARE(model->rowCount(), 1); |
@@ -215,7 +215,7 @@ private slots: | |||
215 | 215 | ||
216 | void testMailByFolder() | 216 | void testMailByFolder() |
217 | { | 217 | { |
218 | //Setup | 218 | // Setup |
219 | Sink::ApplicationDomain::Folder::Ptr folderEntity; | 219 | Sink::ApplicationDomain::Folder::Ptr folderEntity; |
220 | { | 220 | { |
221 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 221 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); |
@@ -224,7 +224,7 @@ private slots: | |||
224 | Sink::Query query; | 224 | Sink::Query query; |
225 | query.resources << "org.kde.dummy.instance1"; | 225 | query.resources << "org.kde.dummy.instance1"; |
226 | 226 | ||
227 | //Ensure all local data is processed | 227 | // Ensure all local data is processed |
228 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 228 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
229 | 229 | ||
230 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 230 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
@@ -240,15 +240,15 @@ private slots: | |||
240 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 240 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
241 | } | 241 | } |
242 | 242 | ||
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.propertyFilter.insert("folder", folderEntity->identifier()); |
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(); |
250 | 250 | ||
251 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 251 | // We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
252 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 252 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
253 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 253 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
254 | QCOMPARE(model->rowCount(), 1); | 254 | QCOMPARE(model->rowCount(), 1); |
@@ -256,7 +256,7 @@ private slots: | |||
256 | 256 | ||
257 | void testMailByFolderSortedByDate() | 257 | void testMailByFolderSortedByDate() |
258 | { | 258 | { |
259 | //Setup | 259 | // Setup |
260 | Sink::ApplicationDomain::Folder::Ptr folderEntity; | 260 | Sink::ApplicationDomain::Folder::Ptr folderEntity; |
261 | { | 261 | { |
262 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 262 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); |
@@ -265,7 +265,7 @@ private slots: | |||
265 | Sink::Query query; | 265 | Sink::Query query; |
266 | query.resources << "org.kde.dummy.instance1"; | 266 | query.resources << "org.kde.dummy.instance1"; |
267 | 267 | ||
268 | //Ensure all local data is processed | 268 | // Ensure all local data is processed |
269 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 269 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
270 | 270 | ||
271 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 271 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
@@ -299,7 +299,7 @@ private slots: | |||
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
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.propertyFilter.insert("folder", folderEntity->identifier()); |
@@ -307,19 +307,19 @@ private slots: | |||
307 | query.limit = 1; | 307 | query.limit = 1; |
308 | query.liveQuery = false; | 308 | query.liveQuery = false; |
309 | 309 | ||
310 | //Ensure all local data is processed | 310 | // Ensure all local data is processed |
311 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 311 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
312 | 312 | ||
313 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 313 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
314 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 314 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
315 | //The model is not sorted, but the limited set is sorted, so we can only test for the latest result. | 315 | // The model is not sorted, but the limited set is sorted, so we can only test for the latest result. |
316 | QCOMPARE(model->rowCount(), 1); | 316 | QCOMPARE(model->rowCount(), 1); |
317 | QCOMPARE(model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->getProperty("uid").toByteArray(), QByteArray("testLatest")); | 317 | QCOMPARE(model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->getProperty("uid").toByteArray(), QByteArray("testLatest")); |
318 | 318 | ||
319 | model->fetchMore(QModelIndex()); | 319 | model->fetchMore(QModelIndex()); |
320 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 320 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
321 | QCOMPARE(model->rowCount(), 2); | 321 | QCOMPARE(model->rowCount(), 2); |
322 | //We can't make any assumptions about the order of the indexes | 322 | // We can't make any assumptions about the order of the indexes |
323 | // QCOMPARE(model->index(1, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->getProperty("uid").toByteArray(), QByteArray("testSecond")); | 323 | // QCOMPARE(model->index(1, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->getProperty("uid").toByteArray(), QByteArray("testSecond")); |
324 | } | 324 | } |
325 | }; | 325 | }; |