summaryrefslogtreecommitdiff
path: root/tests/auto/declarative_core/utils.js
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@jollamobile.com>2014-01-20 10:57:08 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-22 01:47:34 +0100
commit0b36e73112b099090f5dcbbc21d172dcc7c97f30 (patch)
tree92779dfa9e00b8933e53dd0aafebf6947fbf5905 /tests/auto/declarative_core/utils.js
parentbdcc97c444fadc566b4476f5f91b02bd8be21ec3 (diff)
downloadqtlocation-0b36e73112b099090f5dcbbc21d172dcc7c97f30.tar.gz
Remove offset attribute from place content requests.
This complements 1d0966c6924876655c52725e779a7aa24866ff60 Not all service providers support arbitrary offsets when requesting place content. The offset attribute has been removed, instead service providers can supply a previous and next content request query in the form of a QPlaceContentRequest. Change-Id: I6239b42c31bed5dcd6645d86d5a48d7e6a667f46 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'tests/auto/declarative_core/utils.js')
-rw-r--r--tests/auto/declarative_core/utils.js38
1 files changed, 17 insertions, 21 deletions
diff --git a/tests/auto/declarative_core/utils.js b/tests/auto/declarative_core/utils.js
index 0a659ab2..5370bab5 100644
--- a/tests/auto/declarative_core/utils.js
+++ b/tests/auto/declarative_core/utils.js
@@ -91,7 +91,7 @@ function compareObj(testCase, obj1, obj2) {
}
}
-function testConsecutiveFetch(testCase, model, place, expectedValues)
+function testConsecutiveFetch(testCase, model, place, expectedValues, data)
{
var signalSpy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', testCase, "SignalSpy");
signalSpy.target = model;
@@ -108,35 +108,31 @@ function testConsecutiveFetch(testCase, model, place, expectedValues)
testCase.compare(visDataModel.items.count, 0);
//perform an initial fetch with the default batch size
+ model.batchSize = data.batchSize
model.place = place;
testCase.tryCompare(signalSpy, "count", 1);
signalSpy.clear();
var totalCount = model.totalCount;
testCase.compare(totalCount, 5);
- testCase.compare(visDataModel.items.count, 1);
+ testCase.compare(visDataModel.items.count, Math.min(data.batchSize, totalCount));
compareObj(testCase, visDataModel.items.get(0).model, expectedValues[0]);
- //set a non-default batch size and fetch the next batch
- model.batchSize = 2;
- visDataModel.items.create(0); //'creating' the last item will trigger a fetch
- testCase.tryCompare(visDataModel.items, "count", 3);
- testCase.compare(signalSpy.count, 0);
- testCase.compare(model.totalCount, totalCount);
-
- compareObj(testCase, visDataModel.items.get(1).model, expectedValues[1]);
- compareObj(testCase, visDataModel.items.get(2).model, expectedValues[2]);
-
- //set a batch size greater than the number of remaining items and fetch that batch
- model.batchSize = 10;
- visDataModel.items.create(2);
- testCase.tryCompare(visDataModel.items, "count", totalCount);
- testCase.compare(signalSpy.count, 0);
- testCase.compare(model.totalCount, totalCount);
-
- compareObj(testCase, visDataModel.items.get(3).model, expectedValues[3]);
- compareObj(testCase, visDataModel.items.get(4).model, expectedValues[4]);
+ //fetch remaining items, in batchSize batches
+ while (visDataModel.items.count < totalCount) {
+ var startIndex = visDataModel.items.count
+
+ //'creating' the last item will trigger a fetch
+ visDataModel.items.create(visDataModel.items.count - 1);
+
+ testCase.tryCompare(visDataModel.items, "count", Math.min(totalCount, startIndex + data.batchSize));
+ testCase.compare(signalSpy.count, 0);
+ testCase.compare(model.totalCount, totalCount);
+
+ for (var i = startIndex; i < Math.min(totalCount, startIndex + data.batchSize); ++i)
+ compareObj(testCase, visDataModel.items.get(i).model, expectedValues[i]);
+ }
visDataModel.destroy();
signalSpy.destroy();