summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@jollamobile.com>2015-08-18 14:30:32 +1000
committerAaron McCarthy <mccarthy.aaron@gmail.com>2015-09-09 01:04:14 +0000
commitf72a9398e5699b6aa417540e04bf5a0a911b7d0a (patch)
tree9c47c26d94941ad2f92d8fcb683a8e384498c7f9 /tests
parentd6108626faa614348dc872633434f4d8a7dde734 (diff)
downloadqtlocation-f72a9398e5699b6aa417540e04bf5a0a911b7d0a.tar.gz
Make use of incubator to asynchronously instantiate delegates
This has the side effect that map items instantiated by the view are no longer be added to the map in a deterministic order. Change-Id: I5933136e8d9dbf0e698353370b9bfc0affe146ac Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_ui/tst_map_itemview.qml99
1 files changed, 62 insertions, 37 deletions
diff --git a/tests/auto/declarative_ui/tst_map_itemview.qml b/tests/auto/declarative_ui/tst_map_itemview.qml
index 522d46ed..33276198 100644
--- a/tests/auto/declarative_ui/tst_map_itemview.qml
+++ b/tests/auto/declarative_ui/tst_map_itemview.qml
@@ -176,11 +176,15 @@ Item {
SignalSpy {id: mapItemsChangedSpy; target: mapForTestingRouteModel; signalName: "mapItemsChanged"}
Map {
- id: mapForView;
- center: mapDefaultCenter;
- plugin: testPlugin;
- anchors.fill: parent;
+ id: mapForView
+
+ property int mapItemsLength: mapItems.length
+
+ center: mapDefaultCenter
+ plugin: testPlugin
+ anchors.fill: parent
zoomLevel: 2
+
MapCircle {
id: internalCircle
radius: 2000000
@@ -203,14 +207,19 @@ Item {
}
Map {
- id: mapForTestingListModel;
- center: mapDefaultCenter;
- plugin: testPlugin;
- anchors.fill: parent;
+ id: mapForTestingListModel
+
+ center: mapDefaultCenter
+ plugin: testPlugin
+ anchors.fill: parent
zoomLevel: 2
- property variant firstItemCoord: QtPositioning.coordinate(11, 31)
- property variant secondItemCoord: QtPositioning.coordinate(12, 32)
+ property int mapItemsLength: mapItems.length
+ property variant itemCoordinates: [
+ QtPositioning.coordinate(11, 31),
+ QtPositioning.coordinate(12, 32),
+ QtPositioning.coordinate(13, 33)
+ ]
MapItemView {
id: listModelItemView
@@ -233,11 +242,15 @@ Item {
}
Map {
- id: mapForTestingRouteModel;
- plugin: testPlugin;
- center: mapDefaultCenter;
- anchors.fill: parent;
+ id: mapForTestingRouteModel
+
+ property int mapItemsLength: mapItems.length
+
+ plugin: testPlugin
+ center: mapDefaultCenter
+ anchors.fill: parent
zoomLevel: 2
+
MapItemView {
id: routeItemView
model: routeModel
@@ -355,7 +368,7 @@ Item {
function test_add_and_remove_with_view() {
// Basic adding and removing of static object
- compare(mapForView.mapItems.length, 8) // 1 declared and 7 from model
+ tryCompare(mapForView, "mapItemsLength", 8) // 1 declared and 7 from model
mapForView.addMapItem(internalCircle)
compare(mapForView.mapItems.length, 8)
mapForView.removeMapItem(internalCircle)
@@ -374,37 +387,49 @@ Item {
SignalSpy {id: model1Spy; target: testModel; signalName: "modelChanged"}
SignalSpy {id: model2Spy; target: testModel2; signalName: "modelChanged"}
function test_model_change() {
+ // Ensure that internalCircle is removed
+ mapForView.removeMapItem(internalCircle)
+
// Change the model of an MapItemView on the fly
// and verify that object counts change accordingly.
testModel.datacount = 7
testModel.update()
- compare(mapForView.mapItems.length, 7)
+
+ tryCompare(mapForView, "mapItemsLength", 7)
testModel.datacount += 2
testModel2.datacount += 1
- compare(mapForView.mapItems.length, 9)
+ tryCompare(mapForView, "mapItemsLength", 9)
+
theItemView.model = testModel
compare(mapForView.mapItems.length, 9)
theItemView.model = testModel2
- compare(mapForView.mapItems.length, 4)
+ tryCompare(mapForView, "mapItemsLength", 4)
}
function test_listmodel() {
- compare(mapForTestingListModel.mapItems.length, 3);
- compare(mapForTestingListModel.mapItems[0].center.longitude,
- mapForTestingListModel.firstItemCoord.longitude);
- compare(mapForTestingListModel.mapItems[0].center.latitude,
- mapForTestingListModel.firstItemCoord.latitude);
- testingListModel.remove(0);
- compare(mapForTestingListModel.mapItems.length, 2);
- compare(mapForTestingListModel.mapItems[0].center.longitude,
- mapForTestingListModel.secondItemCoord.longitude);
- compare(mapForTestingListModel.mapItems[0].center.latitude,
- mapForTestingListModel.secondItemCoord.latitude);
- testingListModel.append({ lat: 1, lon: 1 });
- compare(mapForTestingListModel.mapItems.length, 3);
- compare(mapForTestingListModel.mapItems[2].center.latitude, 1);
- testingListModel.clear();
- compare(mapForTestingListModel.mapItems.length, 0);
+ tryCompare(mapForTestingListModel, "mapItemsLength", 3)
+
+ for (var i = 0; i < 3; ++i) {
+ var itemCoord = mapForTestingListModel.mapItems[i].center
+ var index = mapForTestingListModel.itemCoordinates.indexOf(itemCoord)
+ verify(0 <= index && index < 3)
+ }
+
+ testingListModel.remove(0)
+ compare(mapForTestingListModel.mapItems.length, 2)
+
+ for (var i = 0; i < 2; ++i) {
+ itemCoord = mapForTestingListModel.mapItems[i].center
+ index = mapForTestingListModel.itemCoordinates.indexOf(itemCoord)
+ verify(1 <= index && index < 3)
+ }
+
+ testingListModel.append({ lat: 1, lon: 1 })
+ tryCompare(mapForTestingListModel, "mapItemsLength", 3)
+ compare(mapForTestingListModel.mapItems[2].center, QtPositioning.coordinate(1, 1))
+
+ testingListModel.clear()
+ compare(mapForTestingListModel.mapItems.length, 0)
}
function test_routemodel() {
@@ -414,16 +439,16 @@ Item {
compare(mapItemsChangedSpy.count, 0)
routeQuery.numberAlternativeRoutes = 4
routeModel.update();
- compare(mapForTestingRouteModel.mapItems.length, 4)
+ tryCompare(mapForTestingRouteModel, "mapItemsLength", 4)
routeQuery.numberAlternativeRoutes = 3
routeModel.update();
- compare(mapForTestingRouteModel.mapItems.length, 3)
+ tryCompare(mapForTestingRouteModel, "mapItemsLength", 3)
routeModel.reset();
compare(mapForTestingRouteModel.mapItems.length, 0)
routeModel.reset(); // clear empty model
routeQuery.numberAlternativeRoutes = 3
routeModel.update();
- compare(mapForTestingRouteModel.mapItems.length, 3)
+ tryCompare(mapForTestingRouteModel, "mapItemsLength", 3)
mapForTestingRouteModel.addMapItem(externalCircle2)
compare(mapForTestingRouteModel.mapItems.length, 4)
compare(mapForTestingRouteModel.mapItems[3], externalCircle2)