diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-20 20:49:17 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-20 20:49:17 +0100 |
commit | ed42bdd74d70c7bcb9e1fb8f071ccb92b1515406 (patch) | |
tree | fc068b2f678d3d38d5ad398e6c85474306a0aa02 /tests/querytest.cpp | |
parent | bc06643cd0c16140f6013be35b64732c1676e794 (diff) | |
download | sink-ed42bdd74d70c7bcb9e1fb8f071ccb92b1515406.tar.gz sink-ed42bdd74d70c7bcb9e1fb8f071ccb92b1515406.zip |
Fetch more data on demand
We skip values we've already seen and only retrieve the new ones.
This currently only properly works in a non-live query and we don't
give the model any feedback when we can't fetch more data anymore.
However, it generally works and we get the desired effect.
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r-- | tests/querytest.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 3bb0427..2531c25 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -305,16 +305,22 @@ private slots: | |||
305 | query.propertyFilter.insert("folder", folderEntity->identifier()); | 305 | query.propertyFilter.insert("folder", folderEntity->identifier()); |
306 | query.sortProperty = "date"; | 306 | query.sortProperty = "date"; |
307 | query.limit = 1; | 307 | query.limit = 1; |
308 | query.liveQuery = false; | ||
308 | 309 | ||
309 | //Ensure all local data is processed | 310 | //Ensure all local data is processed |
310 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 311 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
311 | 312 | ||
312 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | ||
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 | |||
319 | model->fetchMore(QModelIndex()); | ||
320 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | ||
321 | QCOMPARE(model->rowCount(), 2); | ||
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")); | ||
318 | } | 324 | } |
319 | }; | 325 | }; |
320 | 326 | ||