From ed42bdd74d70c7bcb9e1fb8f071ccb92b1515406 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 20 Feb 2016 20:49:17 +0100 Subject: 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. --- tests/querytest.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') 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: query.propertyFilter.insert("folder", folderEntity->identifier()); query.sortProperty = "date"; query.limit = 1; + query.liveQuery = false; //Ensure all local data is processed Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); - //We fetch before the data is available and rely on the live query mechanism to deliver the actual data auto model = Sink::Store::loadModel(query); QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); //The model is not sorted, but the limited set is sorted, so we can only test for the latest result. QCOMPARE(model->rowCount(), 1); QCOMPARE(model->index(0, 0).data(Sink::Store::DomainObjectRole).value()->getProperty("uid").toByteArray(), QByteArray("testLatest")); + + model->fetchMore(QModelIndex()); + QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); + QCOMPARE(model->rowCount(), 2); + //We can't make any assumptions about the order of the indexes + // QCOMPARE(model->index(1, 0).data(Sink::Store::DomainObjectRole).value()->getProperty("uid").toByteArray(), QByteArray("testSecond")); } }; -- cgit v1.2.3