summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-12-01 23:00:31 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-12-01 23:00:31 +0100
commit99a1ba7c488939f606628593e7d21e42aa583502 (patch)
tree4ed34a0bc7500a9a429d8009f4777fb7250ab65f /tests
parentf87ba0409856a678e8a940b70f7452c3a1b730c3 (diff)
parenteea315187d1add70aaf69745c031b8d6342b2303 (diff)
downloadqtlocation-99a1ba7c488939f606628593e7d21e42aa583502.tar.gz
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/imports/location/qdeclarativegeomap.cpp src/imports/location/qdeclarativegeomap_p.h Change-Id: Iaf232acbe9098eb1b57f571638dd37f75b2ff345
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_core/tst_geocoding.qml75
-rw-r--r--tests/auto/declarative_ui/tst_map_coordinateanimation.qml8
-rw-r--r--tests/auto/declarative_ui/tst_map_error.qml10
-rw-r--r--tests/auto/declarative_ui/tst_map_flick.qml106
-rw-r--r--tests/auto/declarative_ui/tst_map_item.qml43
-rw-r--r--tests/auto/declarative_ui/tst_map_item_details.qml17
-rw-r--r--tests/auto/declarative_ui/tst_map_item_fit_viewport.qml10
-rw-r--r--tests/auto/declarative_ui/tst_map_mouse.qml54
-rw-r--r--tests/auto/geotestplugin/qgeotilefetcher_test.h63
-rw-r--r--tests/auto/qgeomapscene/tst_qgeomapscene.cpp2
10 files changed, 221 insertions, 167 deletions
diff --git a/tests/auto/declarative_core/tst_geocoding.qml b/tests/auto/declarative_core/tst_geocoding.qml
index 984fde65..657eb512 100644
--- a/tests/auto/declarative_core/tst_geocoding.qml
+++ b/tests/auto/declarative_core/tst_geocoding.qml
@@ -343,19 +343,16 @@ Item {
slackModel.query = slackAddress1
slackAddress1.county = "5"
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (locationsSlackSpy.count, 0)
compare (slackModel.count, 0)
slackModel.reset()
- wait (200)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (locationsSlackSpy.count, 0)
compare (slackModel.count, 0)
// Check that results are cleared
slackModel.update()
- wait (300)
- compare (slackModel.count, 5) // slackAddress1.county)
+ tryCompare(slackModel, "count", 5)
slackModel.reset()
compare (slackModel.count, 0)
// Check that changing plugin resets any ongoing requests
@@ -364,20 +361,16 @@ Item {
slackAddress1.county = "7"
compare (pluginSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
slackModel.plugin = errorPlugin
- wait (200)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (pluginSlackSpy.count, 1)
// switch back and check that works
slackModel.plugin = slackPlugin
compare (pluginSlackSpy.count, 2)
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
- wait (200)
- compare (countSlackSpy.count, 1)
+ tryCompare(countSlackSpy, "count", 0)
+ tryCompare(countSlackSpy, "count", 1)
}
function test_error_geocode() {
// basic immediate geocode error
@@ -516,8 +509,7 @@ Item {
slackModel.query = "freetext geocode"
compare (querySlackSpy.count, 1)
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (locationsSlackSpy.count, 0)
compare (slackModel.count, 0)
tryCompare(countSlackSpy, "count", 1); //waits up to 5s
@@ -528,20 +520,16 @@ Item {
locationsSlackSpy.clear()
countSlackSpy.clear()
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
tryCompare(countSlackSpy, "count", 1); //waits up to 5s
compare (locationsSlackSpy.count, 1)
@@ -553,16 +541,13 @@ Item {
compare (automaticLocationsSpy.count, 1)
// change query and its contents and verify that autoupdate occurs
automaticAddress1.county = 6
- wait (300)
- compare (automaticLocationsSpy.count, 2)
+ tryCompare(automaticLocationsSpy, "count", 2)
compare (automaticModel.count, 6)
automaticAddress1.street = "The Avenue"
- wait (300)
- compare (automaticLocationsSpy.count, 3)
+ tryCompare(automaticLocationsSpy, "count", 3)
compare (automaticModel.count, 6)
automaticModel.query = automaticCoordinate1
- wait (300)
- compare (automaticLocationsSpy.count, 4)
+ tryCompare(automaticLocationsSpy, "count", 4)
compare (automaticModel.count, 3)
}
@@ -576,8 +561,7 @@ Item {
slackAddress1.county = "7"
compare (querySlackSpy.count, 1)
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (locationsSlackSpy.count, 0)
compare (slackModel.count, 0)
tryCompare(countSlackSpy, "count", 1); //waits up to 5s
@@ -588,20 +572,16 @@ Item {
locationsSlackSpy.clear()
countSlackSpy.clear()
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
tryCompare(countSlackSpy, "count", 1); //waits up to 5s
compare (locationsSlackSpy.count, 1)
@@ -634,8 +614,7 @@ Item {
slackModel.query = slackCoordinate1
compare (querySlackSpy.count, 1)
slackModel.update()
- wait (100)
- compare (countSlackSpy.count, 0)
+ tryCompare(countSlackSpy, "count", 0)
compare (locationsSlackSpy.count, 0)
compare (slackModel.count, 0)
@@ -647,20 +626,16 @@ Item {
locationsSlackSpy.clear()
countSlackSpy.clear()
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
slackModel.update()
- wait (100)
- compare(locationsSlackSpy.count, 0)
+ tryCompare(locationsSlackSpy, "count", 0)
compare(countSlackSpy.count, 0)
tryCompare(countSlackSpy, "count", 1); //waits up to 5s
diff --git a/tests/auto/declarative_ui/tst_map_coordinateanimation.qml b/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
index ec8042fd..7b0e46f8 100644
--- a/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
+++ b/tests/auto/declarative_ui/tst_map_coordinateanimation.qml
@@ -55,7 +55,10 @@ Item {
Behavior on center {
id: centerBehavior
enabled: false
- CoordinateAnimation { duration: animationDuration }
+ CoordinateAnimation {
+ id: coordinateAnimation
+ duration: animationDuration
+ }
}
onCenterChanged: {
@@ -107,7 +110,8 @@ Item {
// Set to coordinate with animation enabled
centerBehavior.enabled = true
map.center = QtPositioning.coordinate(to.latitude, to.longitude)
- wait(animationDuration * 2)
+ wait(animationDuration)
+ tryCompare(coordinateAnimation,"running",false)
//check correct start position
compare(coordinateList[0].latitude, from.latitude)
diff --git a/tests/auto/declarative_ui/tst_map_error.qml b/tests/auto/declarative_ui/tst_map_error.qml
index 68752f11..c102db6e 100644
--- a/tests/auto/declarative_ui/tst_map_error.qml
+++ b/tests/auto/declarative_ui/tst_map_error.qml
@@ -100,7 +100,7 @@ Item {
mouseClick(map, 50, 50)
mouseClick(map, 50, 50)
mouseClick(map, 50, 50)
- compare(map.mouseClickedSpy.count, 3)
+ tryCompare(map.mouseClickedSpy, "count", 3)
}
function test_map_clicked_wiht_no_plugin()
@@ -193,14 +193,6 @@ Item {
map_no_plugin.fitViewportToMapItems()
}
- function test_map_fitViewportToGeoShape()
- {
- map_no_plugin.fitViewportToGeoShape(QtPositioning.circle(coordinate,1000))
- verify(map_no_plugin.center != coordinate)
- map_error_plugin.fitViewportToGeoShape(QtPositioning.circle(coordinate,1000))
- verify(map_error_plugin.center != coordinate)
- }
-
function test_map_setVisibleRegion()
{
map_no_plugin.visibleRegion = QtPositioning.circle(coordinate,1000)
diff --git a/tests/auto/declarative_ui/tst_map_flick.qml b/tests/auto/declarative_ui/tst_map_flick.qml
index 526cbb6f..e225480d 100644
--- a/tests/auto/declarative_ui/tst_map_flick.qml
+++ b/tests/auto/declarative_ui/tst_map_flick.qml
@@ -61,17 +61,24 @@ Item {
property real flickStartedLatitude
property real flickStartedLongitude
- property bool disableFlickOnStarted: false
- property bool disableFlickOnMovementStarted: false
+ property bool disableOnPanStartedWithNoGesture: false
+ property bool disableOnFlickStartedWithNoGesture: false
+ property bool disableOnPanStartedWithDisabled: false
+ property bool disableOnFlickStartedWithDisabled: false
+
gesture.onPanStarted: {
- if (disableFlickOnMovementStarted)
- map.gesture.panEnabled = false
+ if (disableOnPanStartedWithNoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ if (disableOnPanStartedWithDisabled)
+ map.gesture.enabled = false
}
gesture.onFlickStarted: {
flickStartedLatitude = map.center.latitude
flickStartedLatitude = map.center.longitude
- if (disableFlickOnStarted)
- map.gesture.panEnabled = false
+ if (disableOnFlickStartedWithNoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ if (disableOnFlickStartedWithDisabled)
+ map.gesture.enabled = false
}
MouseArea {
id: mouseAreaTop
@@ -81,6 +88,7 @@ Item {
}
SignalSpy {id: centerSpy; target: map; signalName: 'centerChanged'}
+ SignalSpy {id: panStartedSpy; target: map.gesture; signalName: 'panStarted'}
SignalSpy {id: panFinishedSpy; target: map.gesture; signalName: 'panFinished'}
SignalSpy {id: gestureEnabledSpy; target: map.gesture; signalName: 'enabledChanged'}
SignalSpy {id: flickDecelerationSpy; target: map.gesture; signalName: 'flickDecelerationChanged'}
@@ -95,16 +103,19 @@ Item {
function init()
{
- map.gesture.activeGestures = MapGestureArea.PanGesture | MapGestureArea.FlickGesture;
+ map.gesture.acceptedGestures = MapGestureArea.PanGesture | MapGestureArea.FlickGesture;
map.gesture.enabled = true
map.gesture.panEnabled = true
map.gesture.flickDeceleration = 500
map.zoomLevel = 0
- map.disableFlickOnStarted = false
- map.disableFlickOnMovementStarted = false
+ map.disableOnPanStartedWithNoGesture = false
+ map.disableOnFlickStartedWithNoGesture = false
+ map.disableOnPanStartedWithDisabled = false
+ map.disableOnFlickStartedWithDisabled = false
centerSpy.clear()
gestureEnabledSpy.clear()
flickDecelerationSpy.clear()
+ panStartedSpy.clear()
panFinishedSpy.clear()
flickStartedSpy.clear()
flickFinishedSpy.clear()
@@ -112,6 +123,8 @@ Item {
mouseAreaBottomSpy.clear()
mouseAreaBottom.visible = false
mouseAreaTop.visible = false
+ compare(map.gesture.pinchActive, false)
+ compare(map.gesture.panActive, false)
}
function initTestCase()
@@ -127,16 +140,17 @@ Item {
map.gesture.enabled = true
compare(gestureEnabledSpy.count, 2)
compare(map.gesture.enabled, true)
- compare(map.gesture.isPinchActive, false)
- verify(map.gesture.activeGestures & MapGestureArea.ZoomGesture)
- map.gesture.activeGestures = MapGestureArea.NoGesture
- compare(map.gesture.activeGestures, MapGestureArea.NoGesture)
- map.gesture.activeGestures = MapGestureArea.NoGesture
- compare(map.gesture.activeGestures, MapGestureArea.NoGesture)
- map.gesture.activeGestures = MapGestureArea.ZoomGesture | MapGestureArea.PanGesture
- compare(map.gesture.activeGestures, MapGestureArea.ZoomGesture | MapGestureArea.PanGesture)
- map.gesture.activeGestures = MapGestureArea.PanGesture
- compare(map.gesture.activeGestures, MapGestureArea.PanGesture)
+ compare(map.gesture.pinchActive, false)
+ compare(map.gesture.panActive, false)
+ verify(map.gesture.acceptedGestures & MapGestureArea.PinchGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.NoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.NoGesture)
+ map.gesture.acceptedGestures = MapGestureArea.PinchGesture | MapGestureArea.PanGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.PinchGesture | MapGestureArea.PanGesture)
+ map.gesture.acceptedGestures = MapGestureArea.PanGesture
+ compare(map.gesture.acceptedGestures, MapGestureArea.PanGesture)
compare(map.gesture.flickDeceleration, 2500)
map.gesture.flickDeceleration = 2600
compare(flickDecelerationSpy.count, 1)
@@ -222,7 +236,6 @@ Item {
tryCompare(mouseAreaBottomSpy, "count",0)
}
-
function test_flick_diagonal()
{
map.center.latitude = 50
@@ -244,9 +257,8 @@ Item {
verify(map.center.longitude < moveLongitude)
}
- function test_flicking_while_disabled()
+ function disabled_flicking()
{
- map.gesture.panEnabled = false
map.center.latitude = 50
map.center.longitude = 50
mousePress(page, 0, 0)
@@ -255,16 +267,28 @@ Item {
mouseMove(page, i, i, 0, Qt.LeftButton);
}
mouseRelease(page, 50, 50)
+ compare(panStartedSpy.count, 0)
+ compare(panFinishedSpy.count, 0)
compare(flickStartedSpy.count, 0)
compare(flickFinishedSpy.count, 0)
- compare(panFinishedSpy.count, 0)
}
- function test_disable_onFlickStarted()
+ function test_disabled_flicking_with_nogesture()
+ {
+ map.gesture.acceptedGestures = MapGestureArea.NoGesture
+ }
+
+ function test_disabled_flicking_with_disabled()
+ {
+ map.gesture.enabled = false
+ disabled_flicking()
+ }
+
+ function disable_onFlickStarted()
{
- map.disableFlickOnStarted = true
map.center.latitude = 50
map.center.longitude = 50
+ waitForRendering(map)
mousePress(page, 0, 0)
for (var i = 0; i < 50; i += 5) {
wait(20)
@@ -273,21 +297,30 @@ Item {
mouseRelease(page, 50, 50)
var latitude = map.center.latitude;
var longitude = map.center.longitude
+ tryCompare(panStartedSpy, "count", 1)
tryCompare(flickStartedSpy, "count", 1)
verify(map.center.latitude > 50)
- tryCompare(flickStartedSpy, "count", 1)
tryCompare(panFinishedSpy, "count", 1)
tryCompare(flickFinishedSpy, "count", 1)
// compare that flick was interrupted (less movement than without interrupting)
compare(latitude, map.center.latitude)
compare(longitude, map.center.longitude)
- map.disableFlickOnStarted = false
- map.gesture.panEnabled = true
}
- function test_disable_onMovementStarted()
+ function test_disable_onFlickStarted_with_disabled()
+ {
+ map.disableOnFlickStartedWithDisabled = true
+ disable_onFlickStarted()
+ }
+
+ function test_disable_onFlickStarted_with_nogesture()
+ {
+ map.disableOnFlickStartedWithNoGesture = true
+ disable_onFlickStarted()
+ }
+
+ function disable_onPanStarted()
{
- map.disableFlickOnMovementStarted = true
map.center.latitude = 50
map.center.longitude = 50
mousePress(page, 0, 0)
@@ -302,6 +335,19 @@ Item {
// compare that flick was interrupted (less movement than without interrupting)
compare(map.center.latitude,50)
compare(map.center.longitude,50)
+ compare(map.gesture.panActive, false)
+ }
+
+ function test_disable_onPanStarted_with_disabled()
+ {
+ map.disableOnPanStartedWithDisabled = true
+ disable_onPanStarted()
+ }
+
+ function test_disable_onPanStarted_with_nogesture()
+ {
+ map.disableOnPanStartedWithNoGesture = true
+ disable_onPanStarted()
}
}
}
diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml
index 32de8efd..5be8896f 100644
--- a/tests/auto/declarative_ui/tst_map_item.qml
+++ b/tests/auto/declarative_ui/tst_map_item.qml
@@ -257,37 +257,40 @@ Item {
map.center = preMapRect.topLeft
var point = map.fromCoordinate(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
- compare(preMapRectClicked.count, 1)
+ tryCompare(preMapRectClicked, "count", 1)
mouseClick(map, 1, 1) // no item hit
- compare(preMapRectClicked.count, 1)
+ tryCompare(preMapRectClicked, "count", 1)
compare(preMapCircleClicked.count, 0)
// click circle, overlaps and is above rect
map.center = preMapCircle.center
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
- compare(preMapRectClicked.count, 1)
+ tryCompare(preMapRectClicked, "count", 1)
compare(preMapCircleClicked.count, 1)
// click within circle bounding rect but not inside the circle geometry
map.center = preMapCircle.center.atDistanceAndAzimuth(preMapCircle.radius, -45)
mouseClick(map, preMapCircle.x + 4, preMapCircle.y + 4)
- compare(preMapRectClicked.count, 2)
+ tryCompare(preMapRectClicked, "count", 2)
compare(preMapCircleClicked.count, 1)
// click quick item
compare(preMapQuickItemClicked.count, 0)
map.center = preMapQuickItem.coordinate
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
- compare(preMapQuickItemClicked.count, 1)
+ tryCompare(preMapQuickItemClicked, "count", 1)
// click polygon
compare (preMapPolygonClicked.count, 0)
map.center = preMapPolygon.path[1]
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
- compare(preMapPolygonClicked.count, 1)
+ tryCompare(preMapPolygonClicked, "count", 1)
// remove items and repeat clicks to verify they are gone
map.clearMapItems()
@@ -328,48 +331,54 @@ Item {
compare (map.mapItems.length, 6)
visualInspectionPoint()
map.center = preMapRect.topLeft
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapRect.topLeft)
mouseClick(map, point.x + 5, point.y + 5)
- compare(preMapRectClicked.count, 1)
+ tryCompare(preMapRectClicked, "count", 1)
map.center = preMapCircle.center
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapCircle.center)
mouseClick(map, point.x - 5, point.y - 5)
- compare(preMapRectClicked.count, 1)
+ tryCompare(preMapRectClicked, "count", 1)
compare(preMapCircleClicked.count, 1)
map.center = preMapCircle.center.atDistanceAndAzimuth(preMapCircle.radius, -45)
mouseClick(map, preMapCircle.x + 4, preMapCircle.y + 4)
- compare(preMapRectClicked.count, 2)
+ tryCompare(preMapRectClicked, "count", 2)
compare(preMapCircleClicked.count, 1)
compare(preMapQuickItemClicked.count, 0)
map.center = preMapQuickItem.coordinate
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
- compare(preMapQuickItemClicked.count, 1)
+ tryCompare(preMapQuickItemClicked, "count", 1)
map.center = preMapPolygon.path[1]
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapPolygon.path[1])
mouseClick(map, point.x - 5, point.y)
- compare(preMapPolygonClicked.count, 1)
+ tryCompare(preMapPolygonClicked, "count", 1)
// item clips to map. not sure if this is sensible test
map.addMapItem(extMapCircle)
map.center = extMapCircle.center
+ verify(waitForRendering(map))
visualInspectionPoint();
point = map.fromCoordinate(extMapCircle.center)
mouseClick(map, point.x, point.y)
- compare(extMapCircleClicked.count, 1)
+ tryCompare(extMapCircleClicked, "count", 1)
mouseClick(map, point.x, -5)
- compare(extMapCircleClicked.count, 1)
+ tryCompare(extMapCircleClicked, "count", 1)
map.removeMapItem(extMapCircle)
map.addMapItem(extMapQuickItem)
map.center = extMapQuickItem.coordinate
+ verify(waitForRendering(map))
visualInspectionPoint();
point = map.fromCoordinate(extMapQuickItem.coordinate)
mouseClick(map, point.x + 5, point.y + 5)
- compare(extMapQuickItemClicked.count, 1)
+ tryCompare(extMapQuickItemClicked, "count", 1)
mouseClick(map, map.width + 5, point.y + 5)
- compare(extMapQuickItemClicked.count, 1)
+ tryCompare(extMapQuickItemClicked, "count", 1)
map.removeMapItem(extMapQuickItem)
}
@@ -378,6 +387,8 @@ Item {
// basic drags, drag rectangle
compare (preMapRectActiveChanged.count, 0)
map.center = preMapRect.topLeft
+ verify(waitForRendering(map))
+
var i
var point = map.fromCoordinate(preMapRect.topLeft)
var targetCoordinate = map.toCoordinate(51, 51)
@@ -400,6 +411,7 @@ Item {
// drag circle
compare (preMapCircleActiveChanged.count, 0)
map.center = preMapCircle.center
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapCircle.center)
targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x, point.y)
@@ -418,6 +430,7 @@ Item {
// drag quick item
compare (preMapQuickItemActiveChanged.count, 0)
map.center = preMapQuickItem.coordinate
+ verify(waitForRendering(map))
point = map.fromCoordinate(preMapQuickItem.coordinate)
targetCoordinate = map.toCoordinate(51, 51)
mousePress(map, point.x + 5, point.y + 5)
diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml
index b4468301..20849079 100644
--- a/tests/auto/declarative_ui/tst_map_item_details.qml
+++ b/tests/auto/declarative_ui/tst_map_item_details.qml
@@ -41,7 +41,11 @@ Item {
x: 0; y: 0;
width: 240
height: 240
- Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true }
+ Plugin { id: testPlugin
+ name : "qmlgeo.test.plugin"
+ allowExperimental: true
+ parameters: [ PluginParameter { name: "finishRequestImmediately"; value: true}]
+ }
property variant mapDefaultCenter: QtPositioning.coordinate(20, 20)
@@ -327,8 +331,9 @@ Item {
verify(extMapPolygon0.path.length == 0)
extMapPolygon.addCoordinate(polyCoordinate)
verify(extMapPolygon.path.length == 3)
+ verify(waitForRendering(map))
mouseClick(map, point.x - 5, point.y)
- compare(extMapPolygonClicked.count, 1)
+ tryCompare(extMapPolygonClicked, "count", 1)
extMapPolygon.path[0].latitude = 10
verify(extMapPolygon.path[0].latitude, 10)
@@ -427,6 +432,7 @@ Item {
verify(point.x > map.width / 2.0)
// move item edge onto dateline
extMapRectDateline.topLeft.longitude = datelineCoordinate.longitude
+ verify(waitForRendering(map))
point = map.fromCoordinate(extMapRectDateline.topLeft)
verify(point.x == map.width / 2.0)
// drag item back onto dateline
@@ -450,6 +456,7 @@ Item {
point = map.fromCoordinate(extMapCircleDateline.center)
verify(point.x == map.width / 2.0)
extMapCircleDateline.center.longitude = datelineCoordinateRight.longitude
+ verify(waitForRendering(map))
point = map.fromCoordinate(extMapCircleDateline.center)
verify(point.x > map.width / 2.0)
mousePress(map, point.x, point.y)
@@ -469,6 +476,7 @@ Item {
point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
verify(point.x < map.width / 2.0)
extMapQuickItemDateline.coordinate.longitude = datelineCoordinateRight.longitude
+ verify(waitForRendering(map))
point = map.fromCoordinate(extMapQuickItemDateline.coordinate)
verify(point.x > map.width / 2.0)
mousePress(map, point.x + 5, point.y + 5)
@@ -510,6 +518,7 @@ Item {
path = extMapPolygonDateline.path;
path[3].longitude = datelineCoordinate.longitude;
extMapPolygonDateline.path = path;
+ verify(waitForRendering(map))
point = map.fromCoordinate(extMapPolygonDateline.path[3])
verify(point.x == map.width / 2.0)
mousePress(map, point.x + 5, point.y - 5)
@@ -518,6 +527,7 @@ Item {
mouseMove(map, point.x + 5 - i, point.y - 5 )
}
mouseRelease(map, point.x + 5 - i, point.y - 5)
+ verify(waitForRendering(map,10000))
point = map.fromCoordinate(extMapPolygonDateline.path[0])
verify(point.x < map.width / 2.0)
point = map.fromCoordinate(extMapPolygonDateline.path[1])
@@ -596,6 +606,7 @@ Item {
// rectangle
map.addMapItem(extMapRectEdge)
+ verify(waitForRendering(map))
verify(extMapRectEdge.topLeft.longitude == -15)
verify(extMapRectEdge.bottomRight.longitude == -5)
var point = map.fromCoordinate(extMapRectEdge.topLeft)
@@ -650,6 +661,7 @@ Item {
// quickitem
map.addMapItem(extMapQuickItemEdge)
map.center = datelineCoordinate
+ verify(waitForRendering(map))
verify(extMapQuickItemEdge.coordinate.longitude == -15)
point = map.fromCoordinate(extMapQuickItemEdge.coordinate)
verify(point.x < map.width)
@@ -671,6 +683,7 @@ Item {
// polygon
map.center = datelineCoordinate
map.addMapItem(extMapPolygonEdge)
+ verify(waitForRendering(map))
verify(extMapPolygonEdge.path[0].longitude == -15)
verify(extMapPolygonEdge.path[1].longitude == -5)
verify(extMapPolygonEdge.path[2].longitude == -5)
diff --git a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
index 55fbd348..b3ac1d8f 100644
--- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
+++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml
@@ -240,6 +240,7 @@ Item {
// normal case - fit viewport to items which are all already visible
verify_visibility_all_items()
map.fitViewportToMapItems()
+ verify(waitForRendering(map))
visualInspectionPoint()
verify_visibility_all_items()
}
@@ -322,7 +323,7 @@ Item {
verify(!is_coord_on_screen(fitRect.topLeft))
verify(!is_coord_on_screen(fitRect.bottomRight))
- map.fitViewportToGeoShape(fitRect)
+ map.visibleRegion = fitRect
visualInspectionPoint()
calculate_fit_circle_bounds()
//Rectangle should be visible, not circle
@@ -331,7 +332,7 @@ Item {
verify(is_coord_on_screen(fitRect.topLeft))
verify(is_coord_on_screen(fitRect.bottomRight))
- map.fitViewportToGeoShape(fitCircle)
+ map.visibleRegion = fitCircle
visualInspectionPoint()
calculate_fit_circle_bounds()
//Circle should be visible, not rectangle
@@ -340,7 +341,7 @@ Item {
verify(!is_coord_on_screen(fitRect.topLeft))
verify(!is_coord_on_screen(fitRect.bottomRight))
- map.fitViewportToGeoShape(fitInvalidShape)
+ map.visibleRegion = fitInvalidShape
visualInspectionPoint()
calculate_fit_circle_bounds()
//Invalid shape, map should be in the same position as before
@@ -349,7 +350,7 @@ Item {
verify(!is_coord_on_screen(fitRect.topLeft))
verify(!is_coord_on_screen(fitRect.bottomRight))
- map.fitViewportToGeoShape(fitEmptyRect)
+ map.visibleRegion = fitEmptyRect
visualInspectionPoint()
calculate_fit_circle_bounds()
//Empty shape, map should change centerlocation, empty rect visible
@@ -577,6 +578,7 @@ Item {
map.addMapItem(preMapPolygon)
map.addMapItem(preMapPolyline)
map.addMapItem(preMapRoute)
+ verify(waitForRendering(map))
compare (map.mapItems.length, 6)
calculate_bounds()
}
diff --git a/tests/auto/declarative_ui/tst_map_mouse.qml b/tests/auto/declarative_ui/tst_map_mouse.qml
index fe02f81d..57cde142 100644
--- a/tests/auto/declarative_ui/tst_map_mouse.qml
+++ b/tests/auto/declarative_ui/tst_map_mouse.qml
@@ -267,25 +267,25 @@ Item {
compare(mouseUpperClickedSpy.count, 0)
mouseUpper.enabled = true
mouseClick(map, 5, 25)
- compare(mouseUpperClickedSpy.count, 1)
+ tryCompare(mouseUpperClickedSpy, "count", 1)
compare(mouseUpperEnabledChangedSpy.count, 2)
// when overlapping are is disabled, the event should flow through
compare(mouseOverlapperClickedSpy.count, 0)
mouseClick(map, 55, 25)
- compare(mouseUpperClickedSpy.count, 1)
+ tryCompare(mouseUpperClickedSpy, "count", 1)
compare(mouseOverlapperClickedSpy.count, 1)
mouseOverlapper.enabled = false
compare(mouseOverlapperEnabledChangedSpy.count, 1)
compare(mouseOverlapper.enabled, false)
mouseClick(map, 55, 25)
- compare(mouseOverlapperClickedSpy.count, 1)
+ tryCompare(mouseOverlapperClickedSpy, "count", 1)
compare(mouseUpperClickedSpy.count, 2)
// re-enable and verify that still works
mouseOverlapper.enabled = true
compare(mouseOverlapperEnabledChangedSpy.count, 2)
compare(mouseOverlapper.enabled, true)
mouseClick(map, 55, 25)
- compare(mouseOverlapperClickedSpy.count, 2) // should consume again
+ tryCompare(mouseOverlapperClickedSpy, "count", 2) // should consume again
compare(mouseUpperClickedSpy.count, 2)
}
@@ -338,7 +338,7 @@ Item {
mouseUpper.acceptedButtons = Qt.LeftButton
compare(mouseUpperAcceptedButtonsChangedSpy.count, 2)
mouseClick(map, 5, 25)
- compare(mouseUpperClickedSpy.count, 1)
+ tryCompare(mouseUpperClickedSpy, "count", 1)
}
function test_basic_position_changed() {
@@ -574,40 +574,40 @@ Item {
// mouse click with unaccepted buttons should not cause click
mouseUpper.acceptedButtons = Qt.LeftButton
mouseClick(map, 5, 25, Qt.RightButton, Qt.AltModifier)
- compare(mouseUpperClickedSpy.count, 1)
+ tryCompare(mouseUpperClickedSpy, "count", 1)
compare(mouseLowerClickedSpy.count, 0)
compare(mouseOverlapperClickedSpy.count, 0)
mouseClick(map, 5, 25)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 0)
compare(mouseOverlapperClickedSpy.count, 0)
compare(mouseUpper.lastModifiers, Qt.NoModifier)
compare(mouseUpper.lastButton, Qt.LeftButton)
mouseClick(map, 5, 55)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 1)
compare(mouseOverlapperClickedSpy.count, 0)
mouseClick(map, 5, 55)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy,"count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 0)
// declaration order counts on overlap case; overlapping area
// declared later will get the events
mouseClick(map, 55, 25)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 1)
mouseClick(map, 55, 75)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 2)
real_click(map, 55, 25)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 3)
real_click(map, 55, 75)
- compare(mouseUpperClickedSpy.count, 2)
+ tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 4)
}
@@ -621,7 +621,7 @@ Item {
compare(mouseLowerDoubleClickedSpy.count, 0)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
real_double_click(map, 5, 25)
- compare(mouseUpper.lastAccepted, true)
+ tryCompare(mouseUpper, "lastAccepted", true)
compare(mouseUpper.lastButton, Qt.LeftButton)
compare(mouseUpper.lastModifiers, Qt.NoModifier)
compare(mouseUpper.lastWasHeld, false)
@@ -632,26 +632,26 @@ Item {
compare(mouseLowerDoubleClickedSpy.count, 0)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
real_double_click(map, 5, 25)
- compare(mouseUpperDoubleClickedSpy.count, 2)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 0)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
real_double_click(map, 5, 55)
- compare(mouseUpperDoubleClickedSpy.count, 2)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 1)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
real_double_click(map, 5, 55)
- compare(mouseUpperDoubleClickedSpy.count, 2)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 2)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
// declaration order counts on overlap case; overlapping area declared later will get the events
real_double_click(map, 55, 25)
- compare(mouseUpperDoubleClickedSpy.count, 2)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 2)
compare(mouseOverlapperDoubleClickedSpy.count, 1)
compare(mouseOverlapperPressedSpy.count, 2)
compare(mouseOverlapperReleasedSpy.count, 2)
real_double_click(map, 55, 75)
- compare(mouseUpperDoubleClickedSpy.count, 2)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 2)
compare(mouseOverlapperDoubleClickedSpy.count, 2)
compare(mouseOverlapperPressedSpy.count, 4)
@@ -659,20 +659,20 @@ Item {
// disable overlapping area and check event is delivered to the ones beneath
mouseOverlapper.enabled = false
real_double_click(map, 55, 25)
- compare(mouseUpperDoubleClickedSpy.count, 3)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 2)
compare(mouseOverlapperDoubleClickedSpy.count, 2)
real_double_click(map, 55, 75)
- compare(mouseUpperDoubleClickedSpy.count, 3)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 3)
compare(mouseOverlapperDoubleClickedSpy.count, 2)
mouseOverlapper.enabled = true
real_double_click(map, 55, 25)
- compare(mouseUpperDoubleClickedSpy.count, 3)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 3)
compare(mouseOverlapperDoubleClickedSpy.count, 3)
real_double_click(map, 55, 75)
- compare(mouseUpperDoubleClickedSpy.count, 3)
+ tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 3)
compare(mouseOverlapperDoubleClickedSpy.count, 4)
}
@@ -698,11 +698,11 @@ Item {
compare(mouseUpper.lastY, 5) // remember 20 offset of the mouse area
mouseRelease(map,5,25)
real_press_and_hold(map, 5, 55)
- compare(mouseUpperPressAndHoldSpy.count, 1)
+ tryCompare(mouseUpperPressAndHoldSpy, "count", 1)
compare(mouseLowerPressAndHoldSpy.count, 1)
compare(mouseOverlapperPressAndHoldSpy.count, 0)
real_press_and_hold(map, 55, 75)
- compare(mouseUpperPressAndHoldSpy.count, 1)
+ tryCompare(mouseUpperPressAndHoldSpy, "count", 1)
compare(mouseLowerPressAndHoldSpy.count, 1)
compare(mouseOverlapperPressAndHoldSpy.count, 1)
compare(mouseOverlapper.lastAccepted, true)
@@ -713,14 +713,14 @@ Item {
compare(mouseOverlapper.lastY, 75)
// make sure that the wasHeld is cleared
mouseClick(map, 55, 75)
- compare(mouseOverlapper.lastAccepted, true)
+ tryCompare(mouseOverlapper, "lastAccepted", true)
compare(mouseOverlapper.lastButton, Qt.LeftButton)
compare(mouseOverlapper.lastModifiers, Qt.NoModifier)
compare(mouseOverlapper.lastWasHeld, false)
compare(mouseOverlapper.lastX, 5)
compare(mouseOverlapper.lastY, 75)
real_press_and_hold(map, 55, 25)
- compare(mouseUpperPressAndHoldSpy.count, 1)
+ tryCompare(mouseUpperPressAndHoldSpy, "count", 1)
compare(mouseLowerPressAndHoldSpy.count, 1)
compare(mouseOverlapperPressAndHoldSpy.count, 2)
}
diff --git a/tests/auto/geotestplugin/qgeotilefetcher_test.h b/tests/auto/geotestplugin/qgeotilefetcher_test.h
index 4d0ff750..18fe8650 100644
--- a/tests/auto/geotestplugin/qgeotilefetcher_test.h
+++ b/tests/auto/geotestplugin/qgeotilefetcher_test.h
@@ -68,23 +68,21 @@ Q_SIGNALS:
class QGeoTileFetcherTest: public QGeoTileFetcher
{
-Q_OBJECT
+ Q_OBJECT
public:
QGeoTileFetcherTest(QObject *parent = 0)
- : QGeoTileFetcher(parent), finishRequestImmediately_(false), mappingReply_(0),
- errorCode_(QGeoTiledMapReply::NoError)
+ : QGeoTileFetcher(parent), finishRequestImmediately_(false), errorCode_(QGeoTiledMapReply::NoError)
{
}
bool init()
{
-
return true;
}
QGeoTiledMapReply* getTileImage(const QGeoTileSpec &spec)
{
- mappingReply_ = new TiledMapReplyTest(spec, this);
+ TiledMapReplyTest* mappingReply = new TiledMapReplyTest(spec, this);
QImage im(256, 256, QImage::Format_RGB888);
im.fill(QColor("lightgray"));
@@ -113,12 +111,19 @@ public:
buffer.open(QIODevice::WriteOnly);
pm.save(&buffer, "PNG");
- mappingReply_->callSetMapImageData(bytes);
- mappingReply_->callSetMapImageFormat("png");
+ mappingReply->callSetMapImageData(bytes);
+ mappingReply->callSetMapImageFormat("png");
- timer_.start(500, this);
+ if (finishRequestImmediately_) {
+ updateRequest(mappingReply);
+ return mappingReply;
+ } else {
+ if (m_queue.isEmpty())
+ timer_.start(500, this);
+ m_queue.append(mappingReply);
+ }
- return mappingReply_;
+ return mappingReply;
}
void setParams(const QVariantMap &parameters)
@@ -141,31 +146,35 @@ public Q_SLOTS:
}
protected:
- void timerEvent(QTimerEvent *event)
- {
- if (event->timerId() != timer_.timerId()) {
- QGeoTileFetcher::timerEvent(event);
- return;
- }
-
- Q_ASSERT(mappingReply_);
- timer_.stop();
- if (errorCode_) {
- mappingReply_->callSetError(errorCode_, errorString_);
- emit tileError(mappingReply_->tileSpec(), errorString_);
- } else {
- mappingReply_->callSetError(QGeoTiledMapReply::NoError, "no error");
- mappingReply_->callSetFinished(true);
- }
- }
+ void updateRequest(TiledMapReplyTest* mappingReply)
+ {
+ if (errorCode_) {
+ mappingReply->callSetError(errorCode_, errorString_);
+ emit tileError(mappingReply->tileSpec(), errorString_);
+ } else {
+ mappingReply->callSetError(QGeoTiledMapReply::NoError, "no error");
+ mappingReply->callSetFinished(true);
+ }
+ }
+
+ void timerEvent(QTimerEvent *event)
+ {
+ if (event->timerId() != timer_.timerId()) {
+ QGeoTileFetcher::timerEvent(event);
+ return;
+ }
+ updateRequest(m_queue.takeFirst());
+ if (m_queue.isEmpty())
+ timer_.stop();
+ }
private:
bool finishRequestImmediately_;
- TiledMapReplyTest* mappingReply_;
QBasicTimer timer_;
QGeoTiledMapReply::Error errorCode_;
QString errorString_;
QSize tileSize_;
+ QList<TiledMapReplyTest*> m_queue;
};
#endif
diff --git a/tests/auto/qgeomapscene/tst_qgeomapscene.cpp b/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
index ac12d986..5977e82f 100644
--- a/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
+++ b/tests/auto/qgeomapscene/tst_qgeomapscene.cpp
@@ -37,7 +37,7 @@
#include "qgeomapscene_p.h"
#include "qgeocameratiles_p.h"
#include "qgeocameradata_p.h"
-#include "qgeotilecache_p.h"
+#include "qabstractgeotilecache_p.h"
#include <QtPositioning/private/qgeoprojection_p.h>
#include <QtPositioning/private/qdoublevector2d_p.h>