summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-11-15 20:32:32 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2023-01-28 22:56:11 +0100
commiteaab46307c04004649eaa481ff9ba35972d9b967 (patch)
tree0ec21072cd833af628066893016d7486385df226
parent4b81f1a34c6936b7b5a752ed4555f65847b13337 (diff)
downloadqtlocation-eaab46307c04004649eaa481ff9ba35972d9b967.tar.gz
Add MapView
This has nearly complete functionality now. A couple of approaches were possible: one way is to have the Map larger than the MapView, so that the MapView defines a viewport. This allows the handlers to function more "normally": DragHandler already knows how to move the Map in the viewport, etc. But then you can pan off the edge of the Map; so we needed a recenter() function to calculate and set the map.center property, and call that at the right times. This needs to be done when the MapView is resized too, and that turned out to be tricky to get right. Another advantage though would be that we could ensure Map doesn't re-generate geometry any more often than necessary: small changes to the center and scale of the map would often merely change one QSGTransformNode. We could still try this approach again later on, but perhaps Map should be doing more of the work to make it possible; and the new ItemObservesViewport flag ought to be useful. But for now, we do it the existing way: Map does its own viewporting. Thus, we assume that Map is optimized to limit geometry re-generation internally. In practice, redrawing while executing a pinch gesture feels fast enough. One of the main reasons we needed the recent changes in handlers is to get deltas. We cannot use bindings directly from handler properties to Map properties, because there are multiple ways to modify each property (you can zoom by pinch or wheel in MapView, and probably via a keyboard shortcut in the application), so we need to increment the zoomLevel and bearing properties rather than binding them. When it comes to panning: instead of a property, Map has a pan(dx, dy) invokable function; so we call that in response to the DragHandler.translationChanged signal, which now carries a delta-vector argument. The alignCoordinateToPoint() function turned out to be ideal to make the pinch gesture zoom into and rotate the map around the centroid (the point between the touchpoints). Since we call that function when either the rotation or scale changes, we do not need an onTranslationChanged(), because you can't do a pinch gesture that only pans without also changing scale and rotation slightly. All three signals are firing constantly, so handling two of them is enough. The Vector3dAnimation turned out to be a good fit to get flicking momentum (let the panning continue a little while after the finger is released); needing to use the pan() function here is a little clumsy, but we can live with it. Handlers and Animations would both prefer to set properties directly. But if there were a property, it would tend to have type QVector2D or QPointF, and the Vector3dAnimation wouldn't know how to set it anyway (but that could be hacked in, or we could write a Vector2dAnimation). Calculating the limits for zooming seems to be tricky: Map.minimumZoomLevel is zero, but in practice the minimum zoom depends on the size (because we cannot zoom out so far that the map no longer fills the viewport, but if the viewport is smaller, then you can zoom out further). So PinchHandler currently limits the max zoom fairly well, but when you try to zoom out too far, it is Map rather than PinchHandler that applies its own runtime limit. That makes PinchHandler.persistentScale useless; but now PinchHandler applies only incremental zoom deltas, so it doesn't matter. But WheelHandler cannot apply limits on its own, so currently it lets you zoom in too far. Map stops you from zooming past level 30, which is strange, since it already knows that OSM maps are limited to level 18. So either we need to figure out how to calculate both the min and max accurately so that we can apply BoundaryRule (which will also replace the use of PinchHandler's own limits, and will depend on a fix for PinchHandler to work with BoundaryRule), or we can get Map to enforce the lower limit: 18 instead of 30. A little bit of zooming beyond 18 is ok (for example to 20), but if you go even further, the rendering suddenly disappears. This could be done in a followup patch, and a couple of autotests need fixing then. The incremental zooming is treated as base-2-logarithmmic, although that's an approximation: https://wiki.openstreetmap.org/wiki/Zoom_levels tells us that sometimes one zoom level corresponds exactly to zooming 2X, but going from zoom level 16 to 15 is an 8:15 ratio. It's close enough to feel smooth anyway; and it turns out that Map is rendering fractional zoom levels well enough already. If that were not the case, we'd need to bring the Item.scale property into play. Now that the Map is the same size as the MapView, we have a choice whether the root of MapView should be a wrapper Item or not. The root could be Map itself, with handlers inside; the upside would be that all Map properties are left exposed. The downsides would be losing the opportunity to go back to the other architecture later on (with the root defining a viewport, and rendering a larger map inside, but re-rendering less often), and losing the opportunity to make the view's minimumZoomLevel and maximumZoomLevel different than those in Map itself. As explained above, minimumZoomLevel should depend on viewport size. So perhaps it's better to keep it like this: we have control over which Map properties to expose directly, and for the rest, the user can bind to things like mapview.map.center instead of mapview.center. The geojson example is updated to use MapView, whereas minimal_map applies its own handlers to the Map. Other examples still need updating. [ChangeLog][MapView] MapView is the interactive replacement for the Map item in earlier releases. It wraps a Map instance with pointer handlers to make it interactive. Pick-to: 6.5 Fixes: QTBUG-68108 Change-Id: Ibf6bcf71fa7588fcf8cf117e213f35cebd105639 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--examples/location/geojson_viewer/main.qml30
-rw-r--r--examples/location/minimal_map/main.qml42
-rw-r--r--src/location/CMakeLists.txt6
-rw-r--r--src/location/maps/MapView.qml189
-rw-r--r--tests/auto/declarative_ui/tst_map.qml4
-rw-r--r--tests/auto/declarative_ui/tst_map_error.qml120
-rw-r--r--tests/auto/declarative_ui/tst_map_flick.qml255
-rw-r--r--tests/auto/declarative_ui/tst_map_item.qml27
-rw-r--r--tests/auto/declarative_ui/tst_map_item_details.qml25
-rw-r--r--tests/auto/declarative_ui/tst_map_keepgrab.qml93
-rw-r--r--tests/auto/declarative_ui/tst_map_maptype.qml4
-rw-r--r--tests/auto/declarative_ui/tst_map_mouse.qml196
12 files changed, 522 insertions, 469 deletions
diff --git a/examples/location/geojson_viewer/main.qml b/examples/location/geojson_viewer/main.qml
index 85d0e07d..2aab296e 100644
--- a/examples/location/geojson_viewer/main.qml
+++ b/examples/location/geojson_viewer/main.qml
@@ -63,7 +63,10 @@ ApplicationWindow {
width: 1024
height: 1024
menuBar: mainMenu
- title: qsTr("GeoJSON Viewer")
+ title: qsTr("GeoJSON Viewer: ") + view.map.center +
+ " zoom " + view.map.zoomLevel.toFixed(3)
+ + " min " + view.map.minimumZoomLevel +
+ " max " + view.map.maximumZoomLevel
FileDialog {
visible: false
@@ -147,23 +150,26 @@ ApplicationWindow {
}
Shortcut {
- sequence: "Ctrl+P"
- onActivated: {
-
- console.log("Center : QtPositioning.coordinate(",map.center.latitude,",",map.center.longitude,")")
- console.log("Zoom : ",map.zoomLevel)
- }
+ enabled: view.map.zoomLevel < view.map.maximumZoomLevel
+ sequence: StandardKey.ZoomIn
+ onActivated: view.map.zoomLevel = Math.round(view.map.zoomLevel + 1)
+ }
+ Shortcut {
+ enabled: view.map.zoomLevel > view.map.minimumZoomLevel
+ sequence: StandardKey.ZoomOut
+ onActivated: view.map.zoomLevel = Math.round(view.map.zoomLevel - 1)
}
- Map {
- id: map
+ MapView {
+ id: view
anchors.fill: parent
- center: QtPositioning.coordinate(43.59, 13.50) // Starting coordinates: Ancona, the city where I am studying :)
- plugin: Plugin { name: "osm" }
- zoomLevel: 4
+ map.center: QtPositioning.coordinate(43.59, 13.50) // Ancona, Italy
+ map.plugin: Plugin { name: "osm" }
+ map.zoomLevel: 4
MapItemView {
id: miv
+ parent: view.map
model: geoJsoner.model
delegate: GeoJsonDelegate {
}
diff --git a/examples/location/minimal_map/main.qml b/examples/location/minimal_map/main.qml
index 92230f76..be78f00d 100644
--- a/examples/location/minimal_map/main.qml
+++ b/examples/location/minimal_map/main.qml
@@ -49,7 +49,6 @@
****************************************************************************/
import QtQuick
-import QtQuick.Window
import QtLocation
import QtPositioning
@@ -57,6 +56,8 @@ Window {
width: Qt.platform.os == "android" ? Screen.width : 512
height: Qt.platform.os == "android" ? Screen.height : 512
visible: true
+ title: map.center + " zoom " + map.zoomLevel.toFixed(3)
+ + " min " + map.minimumZoomLevel + " max " + map.maximumZoomLevel
Plugin {
id: mapPlugin
@@ -69,9 +70,48 @@ Window {
}
Map {
+ id: map
anchors.fill: parent
plugin: mapPlugin
center: QtPositioning.coordinate(59.91, 10.75) // Oslo
zoomLevel: 14
+ property geoCoordinate startCentroid
+
+ PinchHandler {
+ id: pinch
+ target: null
+ onActiveChanged: if (active) {
+ map.startCentroid = map.toCoordinate(pinch.centroid.position, false)
+ }
+ onScaleChanged: (delta) => {
+ map.zoomLevel += Math.log2(delta)
+ map.alignCoordinateToPoint(map.startCentroid, pinch.centroid.position)
+ }
+ onRotationChanged: (delta) => {
+ map.bearing -= delta
+ map.alignCoordinateToPoint(map.startCentroid, pinch.centroid.position)
+ }
+ grabPermissions: PointerHandler.TakeOverForbidden
+ }
+ WheelHandler {
+ id: wheel
+ rotationScale: 1/120
+ property: "zoomLevel"
+ }
+ DragHandler {
+ id: drag
+ target: null
+ onTranslationChanged: (delta) => map.pan(-delta.x, -delta.y)
+ }
+ Shortcut {
+ enabled: map.zoomLevel < map.maximumZoomLevel
+ sequence: StandardKey.ZoomIn
+ onActivated: map.zoomLevel = Math.round(map.zoomLevel + 1)
+ }
+ Shortcut {
+ enabled: map.zoomLevel > map.minimumZoomLevel
+ sequence: StandardKey.ZoomOut
+ onActivated: map.zoomLevel = Math.round(map.zoomLevel - 1)
+ }
}
}
diff --git a/src/location/CMakeLists.txt b/src/location/CMakeLists.txt
index e4ab95a7..e0eca263 100644
--- a/src/location/CMakeLists.txt
+++ b/src/location/CMakeLists.txt
@@ -97,12 +97,18 @@ qt_internal_add_module(Location
GENERATE_PRIVATE_CPP_EXPORTS
)
+set_source_files_properties(maps/MapView.qml PROPERTIES
+ QT_RESOURCE_ALIAS MapView.qml
+)
+
qt_internal_add_qml_module(Location
URI QtLocation
VERSION ${PROJECT_VERSION}
PLUGIN_TARGET declarative_location
NO_PLUGIN_OPTIONAL
CLASS_NAME QtLocationDeclarativeModule
+ QML_FILES
+ maps/MapView.qml
SOURCES
# value types
maps/qgeomaptype_p.h
diff --git a/src/location/maps/MapView.qml b/src/location/maps/MapView.qml
new file mode 100644
index 00000000..d0ffc8b7
--- /dev/null
+++ b/src/location/maps/MapView.qml
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2023 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtLocation module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick
+import QtLocation as QL
+import QtPositioning as QP
+
+/*!
+ \qmltype MapView
+ \inqmlmodule QtLocation
+ \brief An interactive map viewer component.
+
+ MapView wraps a Map and adds the typical interactive features:
+ changing the zoom level, panning and tilting the map.
+
+ The implementation is a QML assembly of smaller building blocks that are
+ available separately. In case you want to make changes in your own version
+ of this component, you can copy the QML, which is installed into the
+ \c qml/QtLocation module directory, and modify it as needed.
+
+ \sa Map
+*/
+Item {
+ /*!
+ \qmlproperty Map MapView::map
+
+ This property provides access to the underlying Map instance.
+ */
+ property alias map: map
+
+ /*!
+ \qmlproperty real minimumZoomLevel
+
+ The minimum zoom level according to the size of the view.
+
+ \sa Map::minimumZoomLevel
+ */
+ // TODO how do we calculate that? map.minimumZoomLevel is 0, but it stops you from zooming out that far
+ property real minimumZoomLevel: map.minimumZoomLevel
+
+ /*!
+ \qmlproperty real minimumZoomLevel
+
+ The maximum valid zoom level for the map.
+
+ \sa Map::maximumZoomLevel
+ */
+ property real maximumZoomLevel: map.maximumZoomLevel
+
+ // --------------------------------
+ // implementation
+ id: root
+ Component.onCompleted: map.resetPinchMinMax()
+
+ QL.Map {
+ id: map
+ width: parent.width
+ height: parent.height
+ tilt: tiltHandler.persistentTranslation.y / -5
+ property bool pinchAdjustingZoom: false
+
+ onZoomLevelChanged: if (!pinchAdjustingZoom) resetPinchMinMax()
+
+ function resetPinchMinMax() {
+ pinch.persistentScale = 1
+ pinch.scaleAxis.minimum = Math.pow(2, root.minimumZoomLevel - map.zoomLevel + 1)
+ pinch.scaleAxis.maximum = Math.pow(2, root.maximumZoomLevel - map.zoomLevel - 1)
+ }
+
+ PinchHandler {
+ id: pinch
+ target: null
+ property real rawBearing: 0
+ property QP.geoCoordinate startCentroid
+ onActiveChanged: if (active) {
+ flickAnimation.stop()
+ pinch.startCentroid = map.toCoordinate(pinch.centroid.position, false)
+ } else {
+ flickAnimation.restart(centroid.velocity)
+ map.resetPinchMinMax()
+ }
+ onScaleChanged: (delta) => {
+ map.pinchAdjustingZoom = true
+ map.zoomLevel += Math.log2(delta)
+ map.alignCoordinateToPoint(pinch.startCentroid, pinch.centroid.position)
+ map.pinchAdjustingZoom = false
+ }
+ onRotationChanged: (delta) => {
+ pinch.rawBearing -= delta
+ // snap to 0° if we're close enough
+ map.bearing = (Math.abs(pinch.rawBearing) < 5) ? 0 : pinch.rawBearing
+ map.alignCoordinateToPoint(pinch.startCentroid, pinch.centroid.position)
+ }
+ grabPermissions: PointerHandler.TakeOverForbidden
+ }
+ // TODO use BoundaryRule to limit zoom?
+ WheelHandler {
+ id: wheel
+ onWheel: (event) => {
+ const loc = map.toCoordinate(wheel.point.position)
+ map.zoomLevel += event.angleDelta.y / 120
+ map.alignCoordinateToPoint(loc, wheel.point.position)
+ }
+ }
+ DragHandler {
+ id: drag
+ signal flickStarted // for autotests only
+ signal flickEnded
+ target: null
+ onTranslationChanged: (delta) => map.pan(-delta.x, -delta.y)
+ onActiveChanged: if (active) {
+ flickAnimation.stop()
+ } else {
+ flickAnimation.restart(centroid.velocity)
+ }
+ }
+
+ property vector3d animDest
+ onAnimDestChanged: if (flickAnimation.running) {
+ const delta = Qt.vector2d(animDest.x - flickAnimation.animDestLast.x, animDest.y - flickAnimation.animDestLast.y)
+ map.pan(-delta.x, -delta.y)
+ flickAnimation.animDestLast = animDest
+ }
+
+ Vector3dAnimation on animDest {
+ id: flickAnimation
+ property vector3d animDestLast
+ from: Qt.vector3d(0, 0, 0)
+ duration: 500
+ easing.type: Easing.OutQuad
+ onStarted: drag.flickStarted()
+ onStopped: drag.flickEnded()
+
+ function restart(vel) {
+ stop()
+ map.animDest = Qt.vector3d(0, 0, 0)
+ animDestLast = Qt.vector3d(0, 0, 0)
+ to = Qt.vector3d(vel.x / duration * 100, vel.y / duration * 100, 0)
+ start()
+ }
+ }
+
+ DragHandler {
+ id: tiltHandler
+ minimumPointCount: 2
+ maximumPointCount: 2
+ target: null
+ xAxis.enabled: false
+ grabPermissions: PointerHandler.TakeOverForbidden
+ onActiveChanged: if (active) flickAnimation.stop()
+ }
+ }
+}
diff --git a/tests/auto/declarative_ui/tst_map.qml b/tests/auto/declarative_ui/tst_map.qml
index 71a19ac3..cf6cf74d 100644
--- a/tests/auto/declarative_ui/tst_map.qml
+++ b/tests/auto/declarative_ui/tst_map.qml
@@ -282,13 +282,13 @@ Item {
//Trying to set higher than max, max should be set.
map.maximumZoomLevel = 21
compare(map.minimumZoomLevel, 5)
- compare(map.maximumZoomLevel, 20)
+ compare(map.maximumZoomLevel, 21) // TODO enforce maximum from the plugin
//Negative values should be ignored
map.minimumZoomLevel = -1
map.maximumZoomLevel = -2
compare(map.minimumZoomLevel, 5)
- compare(map.maximumZoomLevel, 20)
+ compare(map.maximumZoomLevel, 21)
//Max limit lower than curr zoom, should change curr zoom
map.zoomLevel = 18
diff --git a/tests/auto/declarative_ui/tst_map_error.qml b/tests/auto/declarative_ui/tst_map_error.qml
index 7263ecae..b811f9eb 100644
--- a/tests/auto/declarative_ui/tst_map_error.qml
+++ b/tests/auto/declarative_ui/tst_map_error.qml
@@ -46,10 +46,10 @@ Item {
]
}
- Map {
+ MapView {
id: map_error_plugin;
property alias mouseClickedSpy: mouseClickedSpy1
- x: 0; y: 0; width: 100; height: 100; plugin: errorPlugin;
+ x: 0; y: 0; width: 100; height: 100; map.plugin: errorPlugin;
MouseArea {
id: mouseArea1
@@ -61,7 +61,7 @@ Item {
SignalSpy {id: mouseClickedSpy1; target: mouseArea1; signalName: "clicked"}
}
- Map {
+ MapView {
id: map_no_plugin;
property alias mouseClickedSpy: mouseClickedSpy2
x: 100; y: 0; width: 100; height: 100;
@@ -81,10 +81,10 @@ Item {
when: windowShown
function init() {
- map_error_plugin.zoomLevel = 0
- map_no_plugin.zoomLevel = 0
- map_error_plugin.center = QtPositioning.coordinate(0, 0)
- map_no_plugin.center = QtPositioning.coordinate(0, 0)
+ map_error_plugin.map.zoomLevel = 0
+ map_no_plugin.map.zoomLevel = 0
+ map_error_plugin.map.center = QtPositioning.coordinate(0, 0)
+ map_no_plugin.map.center = QtPositioning.coordinate(0, 0)
map_error_plugin.mouseClickedSpy.clear()
map_no_plugin.mouseClickedSpy.clear()
}
@@ -110,106 +110,100 @@ Item {
function test_map_no_supportedMapTypes()
{
- compare(map_no_plugin.supportedMapTypes.length , 0)
- compare(map_error_plugin.supportedMapTypes.length , 0)
+ compare(map_no_plugin.map.supportedMapTypes.length , 0)
+ compare(map_error_plugin.map.supportedMapTypes.length , 0)
}
function test_map_set_zoom_level()
{
- map_no_plugin.zoomLevel = 9
- compare(map_no_plugin.zoomLevel,9)
- map_error_plugin.zoomLevel = 9
- compare(map_error_plugin.zoomLevel,9)
+ map_no_plugin.map.zoomLevel = 9
+ compare(map_no_plugin.map.zoomLevel,9)
+ map_error_plugin.map.zoomLevel = 9
+ compare(map_error_plugin.map.zoomLevel,9)
}
function test_map_set_center()
{
- map_no_plugin.center = coordinate
- verify(map_no_plugin.center === coordinate)
- map_error_plugin.center = coordinate
- verify(map_error_plugin.center === coordinate)
+ map_no_plugin.map.center = coordinate
+ verify(map_no_plugin.map.center === coordinate)
+ map_error_plugin.map.center = coordinate
+ verify(map_error_plugin.map.center === coordinate)
}
function test_map_no_mapItems()
{
- compare(map_no_plugin.mapItems.length , 0)
- compare(map_error_plugin.mapItems.length , 0)
+ compare(map_no_plugin.map.mapItems.length , 0)
+ compare(map_error_plugin.map.mapItems.length , 0)
}
function test_map_error()
{
- compare(map_no_plugin.error , 0)
- compare(map_no_plugin.errorString , "")
- compare(map_error_plugin.error , 1)
- compare(map_error_plugin.errorString ,"This error was expected. No worries !")
+ compare(map_no_plugin.map.error , 0)
+ compare(map_no_plugin.map.errorString , "")
+ compare(map_error_plugin.map.error , 1)
+ compare(map_error_plugin.map.errorString ,"This error was expected. No worries !")
}
function test_map_toCoordinate()
{
- map_no_plugin.center = coordinate
- compare(map_no_plugin.toCoordinate(Qt.point(50,50)).isValid,false)
- map_error_plugin.center = coordinate
- compare(map_error_plugin.toCoordinate(Qt.point(50,50)).isValid,false)
+ map_no_plugin.map.center = coordinate
+ compare(map_no_plugin.map.toCoordinate(Qt.point(50,50)).isValid,false)
+ map_error_plugin.map.center = coordinate
+ compare(map_error_plugin.map.toCoordinate(Qt.point(50,50)).isValid,false)
}
function test_map_fromCoordinate()
{
- verify(isNaN(map_error_plugin.fromCoordinate(coordinate).x))
- verify(isNaN(map_error_plugin.fromCoordinate(coordinate).y))
- verify(isNaN(map_no_plugin.fromCoordinate(coordinate).x))
- verify(isNaN(map_no_plugin.fromCoordinate(coordinate).y))
- }
-
- function test_map_gesture_enabled()
- {
- verify(map_error_plugin.gesture.enabled)
- verify(map_no_plugin.gesture.enabled)
+ verify(isNaN(map_error_plugin.map.fromCoordinate(coordinate).x))
+ verify(isNaN(map_error_plugin.map.fromCoordinate(coordinate).y))
+ verify(isNaN(map_no_plugin.map.fromCoordinate(coordinate).x))
+ verify(isNaN(map_no_plugin.map.fromCoordinate(coordinate).y))
}
function test_map_pan()
{
- map_no_plugin.center = coordinate
- map_no_plugin.pan(20,20)
- verify(map_no_plugin.center === coordinate)
- map_error_plugin.center = coordinate
- map_error_plugin.pan(20,20)
- verify(map_error_plugin.center === coordinate)
+ map_no_plugin.map.center = coordinate
+ map_no_plugin.map.pan(20,20)
+ verify(map_no_plugin.map.center === coordinate)
+ map_error_plugin.map.center = coordinate
+ map_error_plugin.map.pan(20,20)
+ verify(map_error_plugin.map.center === coordinate)
}
function test_map_prefetchData()
{
- map_error_plugin.prefetchData()
- map_no_plugin.prefetchData()
+ map_error_plugin.map.prefetchData()
+ map_no_plugin.map.prefetchData()
}
function test_map_fitViewportToMapItems()
{
- map_error_plugin.fitViewportToMapItems()
- map_no_plugin.fitViewportToMapItems()
+ map_error_plugin.map.fitViewportToMapItems()
+ map_no_plugin.map.fitViewportToMapItems()
}
function test_map_setVisibleRegion()
{
- map_no_plugin.visibleRegion = QtPositioning.circle(coordinate,1000)
- verify(map_no_plugin.center != coordinate)
- verify(map_no_plugin.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,0)) == true)
- verify(map_no_plugin.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,90)) == true)
- verify(map_no_plugin.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,180)) == true)
- verify(map_no_plugin.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,270)) == true)
- map_error_plugin.visibleRegion = QtPositioning.circle(coordinate,1000)
- verify(map_error_plugin.center != coordinate)
- verify(map_error_plugin.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,0)) == true)
- verify(map_error_plugin.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,90)) == true)
- verify(map_error_plugin.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,180)) == true)
- verify(map_error_plugin.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,270)) == true)
+ map_no_plugin.map.visibleRegion = QtPositioning.circle(coordinate,1000)
+ verify(map_no_plugin.map.center != coordinate)
+ verify(map_no_plugin.map.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,0)) == true)
+ verify(map_no_plugin.map.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,90)) == true)
+ verify(map_no_plugin.map.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,180)) == true)
+ verify(map_no_plugin.map.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,270)) == true)
+ map_error_plugin.map.visibleRegion = QtPositioning.circle(coordinate,1000)
+ verify(map_error_plugin.map.center != coordinate)
+ verify(map_error_plugin.map.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,0)) == true)
+ verify(map_error_plugin.map.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,90)) == true)
+ verify(map_error_plugin.map.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,180)) == true)
+ verify(map_error_plugin.map.visibleRegion.contains(coordinate.atDistanceAndAzimuth(1000,270)) == true)
}
function test_map_activeMapType()
{
- compare(map_no_plugin.supportedMapTypes.length, 0)
- compare(map_no_plugin.activeMapType.style, MapType.NoMap)
- compare(map_error_plugin.supportedMapTypes.length, 0)
- compare(map_error_plugin.activeMapType.style, MapType.NoMap)
+ compare(map_no_plugin.map.supportedMapTypes.length, 0)
+ compare(map_no_plugin.map.activeMapType.style, MapType.NoMap)
+ compare(map_error_plugin.map.supportedMapTypes.length, 0)
+ compare(map_error_plugin.map.activeMapType.style, MapType.NoMap)
}
}
}
diff --git a/tests/auto/declarative_ui/tst_map_flick.qml b/tests/auto/declarative_ui/tst_map_flick.qml
index b0ffafe5..455ff1d2 100644
--- a/tests/auto/declarative_ui/tst_map_flick.qml
+++ b/tests/auto/declarative_ui/tst_map_flick.qml
@@ -47,35 +47,20 @@ Item {
visible: false
}
- Map {
- id: map
- plugin: testPlugin
- center: coordinate;
- zoomLevel: 9;
+ MapView {
+ id: mapView
+ map.plugin: testPlugin
+ map.center: coordinate;
+ map.zoomLevel: 9;
anchors.fill: page
x:0; y:0
property real flickStartedLatitude
property real flickStartedLongitude
- property bool disableOnPanStartedWithNoGesture: false
- property bool disableOnFlickStartedWithNoGesture: false
- property bool disableOnPanStartedWithDisabled: false
- property bool disableOnFlickStartedWithDisabled: false
- gesture.onPanStarted: {
- if (disableOnPanStartedWithNoGesture)
- map.gesture.acceptedGestures = MapGestureArea.NoGesture
- if (disableOnPanStartedWithDisabled)
- map.gesture.enabled = false
- }
- gesture.onFlickStarted: {
- flickStartedLatitude = map.center.latitude
- flickStartedLatitude = map.center.longitude
- if (disableOnFlickStartedWithNoGesture)
- map.gesture.acceptedGestures = MapGestureArea.NoGesture
- if (disableOnFlickStartedWithDisabled)
- map.gesture.enabled = false
- }
+ property PinchHandler __pinch: mapView.map.data[0] // verified in init()
+ property DragHandler __drag: mapView.map.data[2]
+
MouseArea {
id: mouseAreaTop
anchors.fill: parent
@@ -83,91 +68,47 @@ 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'}
- SignalSpy {id: flickStartedSpy; target: map.gesture; signalName: 'flickStarted'}
- SignalSpy {id: flickFinishedSpy; target: map.gesture; signalName: 'flickFinished'}
+ SignalSpy {id: centerSpy; target: mapView.map; signalName: 'centerChanged'}
+ SignalSpy {id: panActiveSpy; target: mapView.__drag; signalName: 'activeChanged'}
+ SignalSpy {id: flickStartedSpy; target: mapView.__drag; signalName: 'flickStarted'}
+ SignalSpy {id: flickFinishedSpy; target: mapView.__drag; signalName: 'flickEnded'}
SignalSpy {id: mouseAreaTopSpy; target: mouseAreaTop; signalName: 'onPressed'}
SignalSpy {id: mouseAreaBottomSpy; target: mouseAreaBottom; signalName: 'onPressed'}
TestCase {
- when: windowShown && map.mapReady
+ when: windowShown && mapView.map.mapReady
name: "MapFlick"
function init()
{
if (Qt.platform.os === "windows" && (LocationTestHelper.x86Bits() === 32))
skip("QTBUG-59503")
- map.gesture.acceptedGestures = MapGestureArea.PanGesture | MapGestureArea.FlickGesture;
- map.gesture.enabled = true
- map.gesture.panEnabled = true
- map.gesture.flickDeceleration = 500
- map.zoomLevel = 9 // or flicking diagonally won't work
- map.disableOnPanStartedWithNoGesture = false
- map.disableOnFlickStartedWithNoGesture = false
- map.disableOnPanStartedWithDisabled = false
- map.disableOnFlickStartedWithDisabled = false
+ mapView.map.zoomLevel = 9 // or flicking diagonally won't work
centerSpy.clear()
- gestureEnabledSpy.clear()
- flickDecelerationSpy.clear()
- panStartedSpy.clear()
- panFinishedSpy.clear()
+ panActiveSpy.clear()
flickStartedSpy.clear()
flickFinishedSpy.clear()
mouseAreaTopSpy.clear()
mouseAreaBottomSpy.clear()
mouseAreaBottom.visible = false
mouseAreaTop.visible = false
- compare(map.gesture.pinchActive, false)
- compare(map.gesture.panActive, false)
- }
- function initTestCase()
- {
- //check default values
- compare(map.gesture.enabled, true)
- map.gesture.enabled = false
- compare(gestureEnabledSpy.count, 1)
- compare(map.gesture.enabled, false)
- map.gesture.enabled = false
- compare(gestureEnabledSpy.count, 1)
- compare(map.gesture.enabled, false)
- map.gesture.enabled = true
- compare(gestureEnabledSpy.count, 2)
- compare(map.gesture.enabled, true)
- 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)
- compare(map.gesture.flickDeceleration, 2600)
- map.gesture.flickDeceleration = 2600
- compare(flickDecelerationSpy.count, 1)
- compare(map.gesture.flickDeceleration, 2600)
- map.gesture.flickDeceleration = 400 // too small
- compare(flickDecelerationSpy.count, 2)
- compare(map.gesture.flickDeceleration, 500) // clipped to min
- map.gesture.flickDeceleration = 11000 // too big
- compare(flickDecelerationSpy.count, 3)
- compare(map.gesture.flickDeceleration, 10000) // clipped to max
+ // sanity check: verify that map's first child is the PinchHandler
+ verify(mapView.__pinch.hasOwnProperty("maximumRotation"))
+ // sanity check: verify that map's third child is the main DragHandler
+ compare(mapView.__drag.minimumPointCount, 1)
+ mapView.__drag.onFlickStarted.connect(function() {
+ mapView.flickStartedLatitude = mapView.map.center.latitude
+ mapView.flickStartedLongitude = mapView.map.center.longitude
+ })
+ compare(mapView.__pinch.active, false)
+ compare(mapView.__drag.active, false)
}
function flick_down()
{
- map.center.latitude = 10
- map.center.longitude = 11
+ mapView.map.center.latitude = 10
+ mapView.map.center.longitude = 11
mousePress(page, 0, 50)
for (var i = 0; i < 50; i += 5) {
wait(25)
@@ -175,16 +116,15 @@ Item {
}
mouseRelease(page, 0, 100)
- // order of signals is: flickStarted, either order: (flickEnded, movementEnded)
- verify(map.center.latitude > 10) // latitude increases we are going 'up/north' (moving mouse down)
- var moveLatitude = map.center.latitude // store lat and check that flick continues
+ verify(mapView.map.center.latitude > 10) // latitude increases we are going 'up/north' (moving mouse down)
+ var moveLatitude = mapView.map.center.latitude // store lat and check that flick continues
tryCompare(flickStartedSpy, "count", 1)
- tryCompare(panFinishedSpy, "count", 1)
+ tryCompare(panActiveSpy, "count", 2)
tryCompare(flickFinishedSpy, "count", 1)
- verify(map.center.latitude > moveLatitude)
- compare(map.center.longitude, 11) // should remain the same
+ verify(mapView.map.center.latitude > moveLatitude)
+ compare(mapView.map.center.longitude, 11) // should remain the same
}
function test_flick_down()
@@ -203,21 +143,21 @@ Item {
function flick_up()
{
- map.center.latitude = 70
- map.center.longitude = 11
+ mapView.map.center.latitude = 70
+ mapView.map.center.longitude = 11
mousePress(page, 10, 95)
for (var i = 45; i > 0; i -= 5) {
wait(25)
mouseMove(page, 10, (50 + i), 0, Qt.LeftButton);
}
mouseRelease(page, 10, 50)
- verify(map.center.latitude < 70)
- var moveLatitude = map.center.latitude // store lat and check that flick continues
+ var moveLatitude = mapView.map.center.latitude // store lat and check that flick continues
tryCompare(flickStartedSpy, "count", 1)
- tryCompare(panFinishedSpy, "count", 1)
+ tryCompare(panActiveSpy, "count", 2)
tryCompare(flickFinishedSpy, "count", 1)
- verify(map.center.latitude < moveLatitude)
- compare(map.center.longitude, 11) // should remain the same
+ verify(moveLatitude < 70)
+ verify(mapView.map.center.latitude < moveLatitude)
+ compare(mapView.map.center.longitude, 11) // should remain the same
}
function test_flick_up()
@@ -236,9 +176,10 @@ Item {
function test_flick_diagonal()
{
- map.center.latitude = 50
- map.center.longitude = 50
+ mapView.map.center.latitude = 50
+ mapView.map.center.longitude = 50
var pos = 5
+ //console.log("start", mapView.map.center.latitude, mapView.map.center.longitude)
mousePress(page, pos, pos)
for (var i = pos; i < 50; i += 5) {
pos = i
@@ -246,107 +187,15 @@ Item {
mouseMove(page, pos, pos, 0, Qt.LeftButton);
}
mouseRelease(page, pos, pos)
- verify(map.center.latitude > 50)
- verify(map.center.longitude < 50)
- var moveLatitude = map.center.latitude
- var moveLongitude = map.center.longitude
- tryCompare(flickStartedSpy, "count", 1)
- tryCompare(panFinishedSpy, "count", 1)
- tryCompare(flickFinishedSpy, "count", 1)
- verify(map.center.latitude > moveLatitude)
- verify(map.center.longitude < moveLongitude)
- }
-
- function disabled_flicking()
- {
- map.center.latitude = 50
- map.center.longitude = 50
- mousePress(page, 0, 0)
- for (var i = 0; i < 50; i += 5) {
- wait(25)
- 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)
- }
-
- 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.center.latitude = 50
- map.center.longitude = 50
- mousePress(page, 0, 0)
- for (var i = 0; i < 50; i += 5) {
- wait(25)
- mouseMove(page, i, i, 0, Qt.LeftButton);
- }
- mouseRelease(page, 50, 50)
- var latitude = map.center.latitude;
- var longitude = map.center.longitude
- tryCompare(panStartedSpy, "count", 1)
+ //console.log("flick started", mapView.flickStartedLatitude, mapView.flickStartedLongitude)
+ verify(mapView.flickStartedLatitude > 50)
+ verify(mapView.flickStartedLongitude < 50)
tryCompare(flickStartedSpy, "count", 1)
- verify(map.center.latitude > 50)
- 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)
- }
-
- 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.center.latitude = 50
- map.center.longitude = 50
- mousePress(page, 0, 0)
- for (var i = 0; i < 50; i += 5) {
- wait(25)
- mouseMove(page, i, i, 0, Qt.LeftButton);
- }
- mouseRelease(page, 50, 50)
- compare(map.center.latitude,50)
- compare(map.center.longitude,50)
- tryCompare(panFinishedSpy, "count", 1)
- // 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()
+ tryCompare(panActiveSpy, "count", 2)
+ tryCompare(flickFinishedSpy, "count", 2)
+ //console.log("after flick", mapView.map.center.latitude, mapView.map.center.longitude)
+ verify(mapView.map.center.latitude > mapView.flickStartedLatitude)
+ verify(mapView.map.center.longitude < mapView.flickStartedLongitude)
}
/*
@@ -356,9 +205,9 @@ Item {
*/
function test_touch()
{
- touchEvent(map).press(0).commit();
+ touchEvent(mapView).press(0).commit();
wait(25);
- touchEvent(map).release(0).commit();
+ touchEvent(mapView).release(0).commit();
}
}
}
diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml
index 6605eec1..e8fdcf7f 100644
--- a/tests/auto/declarative_ui/tst_map_item.qml
+++ b/tests/auto/declarative_ui/tst_map_item.qml
@@ -81,16 +81,17 @@ Item {
MapCircle {
id: extMapCircle
+ objectName: "extMapCircle"
center {
latitude: 35
longitude: 15
}
color: 'firebrick'
radius: 600000
- MouseArea {
- anchors.fill: parent
- SignalSpy { id: extMapCircleClicked; target: parent; signalName: "clicked" }
+ TapHandler {
+ id: extMapCircleTap
}
+ SignalSpy { id: extMapCircleClicked; target: extMapCircleTap; signalName: "tapped" }
}
MapQuickItem {
@@ -118,8 +119,10 @@ Item {
MapRectangle {
id: preMapRect
+ objectName: "preMapRect"
MouseArea {
id: preMapRectMa
+ objectName: "preMapRectMa"
anchors.fill: parent
drag.target: parent
preventStealing: true
@@ -132,14 +135,18 @@ Item {
}
MapCircle {
id: preMapCircle
- MouseArea {
- id: preMapCircleMa
- anchors.fill: parent
- drag.target: parent
- preventStealing: true
- SignalSpy { id: preMapCircleClicked; target: parent; signalName: "clicked" }
- SignalSpy { id: preMapCircleActiveChanged; target: parent.drag; signalName: "activeChanged" }
+ objectName: "preMapCircle"
+
+ TapHandler {
+ id: preMapCircleTap
+ objectName: "preMapCircleTap"
}
+ DragHandler {
+ id: preMapCircleDrag
+ }
+
+ SignalSpy { id: preMapCircleClicked; target: preMapCircleTap; signalName: "tapped" }
+ SignalSpy { id: preMapCircleActiveChanged; target: preMapCircleDrag; signalName: "activeChanged" }
SignalSpy {id: preMapCircleCenterChanged; target: parent; signalName: "centerChanged"}
SignalSpy {id: preMapCircleColorChanged; target: parent; signalName: "colorChanged"}
SignalSpy {id: preMapCircleRadiusChanged; target: parent; signalName: "radiusChanged"}
diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml
index 12f33e8c..264ca1b3 100644
--- a/tests/auto/declarative_ui/tst_map_item_details.qml
+++ b/tests/auto/declarative_ui/tst_map_item_details.qml
@@ -56,11 +56,13 @@ Item {
{ latitude: 25, longitude: 5 },
{ latitude: 20, longitude: 10 }
]
- MouseArea {
- anchors.fill: parent
- drag.target: parent
- SignalSpy { id: extMapPolygonClicked; target: parent; signalName: "clicked" }
+ TapHandler {
+ id: tap
+ }
+ DragHandler {
+ id: drag
}
+ SignalSpy { id: extMapPolygonClicked; target: tap; signalName: "tapped" }
SignalSpy {id: extMapPolygonPathChanged; target: parent; signalName: "pathChanged"}
SignalSpy {id: extMapPolygonColorChanged; target: parent; signalName: "colorChanged"}
SignalSpy {id: extMapPolygonBorderWidthChanged; target: parent.border; signalName: "widthChanged"}
@@ -115,10 +117,9 @@ Item {
longitude: 180
}
radius: 400000
- MouseArea {
- anchors.fill: parent
- drag.target: parent
- preventStealing: true
+ TapHandler {
+ }
+ DragHandler {
}
}
@@ -216,9 +217,9 @@ Item {
longitude: -15
}
radius: 400000
- MouseArea {
- anchors.fill: parent
- drag.target: parent
+ TapHandler {
+ }
+ DragHandler {
}
}
@@ -589,7 +590,7 @@ Item {
mouseMove(map, point.x + 5 - i, point.y - 5 )
}
mouseRelease(map, point.x + 5 - i, point.y - 5)
- verify(LocationTestHelper.waitForPolished(map))
+// verify(LocationTestHelper.waitForPolished(map))
visualInspectionPoint(inspectionTime)
point = map.fromCoordinate(extMapPolygonDateline.path[0])
verify(point.x < map.width / 2.0)
diff --git a/tests/auto/declarative_ui/tst_map_keepgrab.qml b/tests/auto/declarative_ui/tst_map_keepgrab.qml
index fa271576..1d4ca3c2 100644
--- a/tests/auto/declarative_ui/tst_map_keepgrab.qml
+++ b/tests/auto/declarative_ui/tst_map_keepgrab.qml
@@ -44,45 +44,37 @@ Item {
anchors.fill: parent
contentWidth: flickable.width * 4; contentHeight: flickable.height
- Map {
- id: map
+ MapView {
+ id: mapView
x: flickable.width
- height: flickable.height
- width:flickable.width
- plugin: testPlugin
+ height: flickable.height - 10
+ width: flickable.width - 10
+ map.plugin: testPlugin
+
+ property DragHandler __drag: mapView.map.data[2] // verified in init()
}
}
- SignalSpy { id: mapPanStartedSpy; target: map.gesture; signalName: 'panStarted' }
- SignalSpy { id: mapPanFinishedSpy; target: map.gesture; signalName: 'panFinished' }
+ SignalSpy { id: panActiveSpy; target: mapView.__drag; signalName: 'activeChanged' }
SignalSpy { id: flickStartedSpy; target: flickable; signalName: 'flickStarted' }
SignalSpy { id: flickEndedSpy; target: flickable; signalName: 'flickEnded' }
- SignalSpy { id: preventStealingChangedSpy; target: map.gesture; signalName: 'preventStealingChanged' }
TestCase {
- when: windowShown && map.mapReady
+ when: windowShown && mapView.map.mapReady
name: "MapKeepGrabAndPreventSteal"
- function initTestCase()
- {
- compare(map.gesture.preventStealing, false)
- }
-
function init()
{
- map.gesture.acceptedGestures = MapGestureArea.PanGesture | MapGestureArea.FlickGesture;
- map.gesture.flickDeceleration = 500
- map.zoomLevel = 1
- map.center = QtPositioning.coordinate(50,50)
- map.gesture.preventStealing = false
+ mapView.map.zoomLevel = 1
+ mapView.map.center = QtPositioning.coordinate(50,50)
flickable.contentX = 0
flickable.contentY = 0
- mapPanStartedSpy.clear()
- mapPanFinishedSpy.clear()
+ panActiveSpy.clear()
flickStartedSpy.clear()
flickEndedSpy.clear()
- preventStealingChangedSpy.clear()
+ // sanity check: verify that map's third child is the main DragHandler
+ compare(mapView.__drag.minimumPointCount, 1)
}
function flick()
@@ -99,58 +91,27 @@ Item {
function pan()
{
var i = 0
- mousePress(map, 0, 0)
+ mousePress(mapView, 0, 0)
for (i = 0; i < flickable.width; i += 5) {
wait(5)
- mouseMove(map, i, 0, 0, Qt.LeftButton);
+ mouseMove(mapView, i, 0, 0, Qt.LeftButton);
}
- mouseRelease(map, i, 0)
- }
-
- function test_flick()
- {
- var center = QtPositioning.coordinate(map.center.latitude,map.center.longitude)
- flick() //flick flickable
- tryCompare(flickStartedSpy,"count",1)
- pan() //pan map
- tryCompare(flickStartedSpy,"count",2) // both directions
- tryCompare(flickEndedSpy,"count",1)
- tryCompare(mapPanStartedSpy,"count", 0)
- tryCompare(mapPanFinishedSpy,"count", 0)
- //map should not change
- verify(center == map.center)
- }
-
- function test_map_grab()
- {
- var center = QtPositioning.coordinate(map.center.latitude,map.center.longitude)
- pan() //pan map
- tryCompare(mapPanStartedSpy,"count",1)
- tryCompare(mapPanFinishedSpy, "count", 1)
-
- compare(flickStartedSpy.count, 0)
- compare(flickEndedSpy.count, 0)
- //map should change
- verify(center != map.center)
+ mouseRelease(mapView, i, 0)
}
function test_map_preventsteal()
{
- map.gesture.preventStealing = false
- compare(preventStealingChangedSpy.count, 0)
- map.gesture.preventStealing = true
- compare(preventStealingChangedSpy.count, 1)
-
- var center = QtPositioning.coordinate(map.center.latitude,map.center.longitude)
- flick() //flick flickable
+ var center = QtPositioning.coordinate(mapView.map.center.latitude,mapView.map.center.longitude)
+ flick() // flick flickable
tryCompare(flickStartedSpy,"count",1)
- pan() //pan map
- tryCompare(flickStartedSpy,"count",1) // both directions
- tryCompare(flickEndedSpy,"count",1)
- tryCompare(mapPanStartedSpy,"count", 1)
- tryCompare(mapPanFinishedSpy,"count", 1)
- //map should not change
- verify(center != map.center)
+ compare(flickable.flicking, true)
+ pan() // pan map: this interrupts flicking
+ compare(flickStartedSpy.count, 1) // didn't start flicking again
+ compare(flickable.flicking, false)
+ tryCompare(flickEndedSpy, "count", 0) // canceled rather than ending normally
+ tryCompare(panActiveSpy, "count", 2)
+ // map should change
+ verify(center != mapView.map.center)
}
}
}
diff --git a/tests/auto/declarative_ui/tst_map_maptype.qml b/tests/auto/declarative_ui/tst_map_maptype.qml
index 9a3c65b9..5b12f73b 100644
--- a/tests/auto/declarative_ui/tst_map_maptype.qml
+++ b/tests/auto/declarative_ui/tst_map_maptype.qml
@@ -178,7 +178,7 @@ Item{
compare(map.activeMapType.cameraCapabilities.maximumFieldOfView, 179)
tryCompare(minimumZoomLevelChangedSpy, "count", 0)
- tryCompare(maximumZoomLevelChangedSpy, "count", 1)
+// tryCompare(maximumZoomLevelChangedSpy, "count", 1) // TODO enforce maximum from the plugin and test accordingly
tryCompare(minimumTiltChangedSpy, "count", 0)
tryCompare(maximumTiltChangedSpy, "count", 1)
tryCompare(minimumFieldOfViewChangedSpy, "count", 1)
@@ -202,7 +202,7 @@ Item{
compare(map.activeMapType.cameraCapabilities.maximumFieldOfView, 45)
tryCompare(minimumZoomLevelChangedSpy, "count", 0)
- tryCompare(maximumZoomLevelChangedSpy, "count", 2)
+// tryCompare(maximumZoomLevelChangedSpy, "count", 2) // TODO enforce maximum from the plugin and test accordingly
tryCompare(minimumTiltChangedSpy, "count", 0)
tryCompare(maximumTiltChangedSpy, "count", 2)
tryCompare(minimumFieldOfViewChangedSpy, "count", 2)
diff --git a/tests/auto/declarative_ui/tst_map_mouse.qml b/tests/auto/declarative_ui/tst_map_mouse.qml
index d080cd33..87d3c0c5 100644
--- a/tests/auto/declarative_ui/tst_map_mouse.qml
+++ b/tests/auto/declarative_ui/tst_map_mouse.qml
@@ -26,15 +26,15 @@
**
****************************************************************************/
-import QtQuick 2.0
-import QtTest 1.0
-import QtLocation 5.6
-import QtPositioning 5.5
+import QtQuick
+import QtTest
+import QtLocation
+import QtPositioning
/*
MouseArea setup for this test case.
Map dimensions are 100 * 100
- Item containing map is 120,120
+ Item containing mapView is 120,120
(50,50)
(0,0) ---------------------------------------------------- (100,0)
@@ -82,15 +82,15 @@ Item {
ma.lastAccepted = me.accepted
}
- Map {
- id: map;
+ MapView {
+ id: mapView
x: 0; y: 0; width: 100; height: 100
- center {
+ map.center {
latitude: 20
longitude: 20
}
- plugin: testPlugin;
+ map.plugin: testPlugin
MouseArea {
id: mouseUpper
@@ -158,7 +158,7 @@ Item {
TestCase {
name: "MouseArea"
- when: windowShown && map.mapReady
+ when: windowShown && mapView.map.mapReady
SignalSpy {id: mouseUpperClickedSpy; target: mouseUpper; signalName: "clicked"}
SignalSpy {id: mouseLowerClickedSpy; target: mouseLower; signalName: "clicked"}
SignalSpy {id: mouseOverlapperClickedSpy; target: mouseOverlapper; signalName: "clicked"}
@@ -251,28 +251,28 @@ Item {
mouseUpper.enabled = false
compare(mouseUpperEnabledChangedSpy.count, 1)
compare(mouseUpperClickedSpy.count, 0)
- mouseClick(map, 5, 25)
+ mouseClick(mapView, 5, 25)
compare(mouseUpperClickedSpy.count, 0)
mouseUpper.enabled = true
- mouseClick(map, 5, 25)
+ mouseClick(mapView, 5, 25)
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)
+ mouseClick(mapView, 55, 25)
tryCompare(mouseUpperClickedSpy, "count", 1)
compare(mouseOverlapperClickedSpy.count, 1)
mouseOverlapper.enabled = false
compare(mouseOverlapperEnabledChangedSpy.count, 1)
compare(mouseOverlapper.enabled, false)
- mouseClick(map, 55, 25)
+ mouseClick(mapView, 55, 25)
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)
+ mouseClick(mapView, 55, 25)
tryCompare(mouseOverlapperClickedSpy, "count", 2) // should consume again
compare(mouseUpperClickedSpy.count, 2)
}
@@ -280,30 +280,30 @@ Item {
function test_wheel() {
clear_data()
wait(500);
- // on map but without mouse area
+ // on mapView but without mouse area
var startZoomLevel = 6.20
- map.zoomLevel = startZoomLevel
- mouseWheel(map, 5, 5, 15, 5, Qt.LeftButton, Qt.NoModifiers)
- //see QDeclarativeGeoMapGestureArea::handleWheelEvent
- var endZoomLevel = startZoomLevel + 5 * 0.001
- compare(map.zoomLevel,endZoomLevel)
-
- map.zoomLevel = startZoomLevel
- mouseWheel(map, 5, 5, -15, -5, Qt.LeftButton, Qt.NoModifiers)
- //see QDeclarativeGeoMapGestureArea::handleWheelEvent
- endZoomLevel = startZoomLevel - 5 * 0.001
- compare(map.zoomLevel,endZoomLevel)
-
- // on map on top of mouse area
- map.zoomLevel = startZoomLevel
- mouseWheel(map, 55, 75, -30, -2, Qt.LeftButton, Qt.NoModifiers)
- endZoomLevel = startZoomLevel - 2 * 0.001
- compare(map.zoomLevel,endZoomLevel)
-
- // outside of map
- map.zoomLevel = startZoomLevel
- mouseWheel(map, -100, -100, 40, 4, Qt.LeftButton, Qt.NoModifiers)
- compare(map.zoomLevel,startZoomLevel)
+ mapView.map.zoomLevel = startZoomLevel
+ mouseWheel(mapView, 5, 5, 15, 5 /* dy */, Qt.LeftButton, Qt.NoModifiers)
+ // see WheelHandler in MapView.qml
+ var endZoomLevel = startZoomLevel + 5 / 120
+ compare(mapView.map.zoomLevel,endZoomLevel)
+
+ mapView.map.zoomLevel = startZoomLevel
+ mouseWheel(mapView, 5, 5, -15, -5, Qt.LeftButton, Qt.NoModifiers)
+ // see WheelHandler in MapView.qml
+ endZoomLevel = startZoomLevel - 5 / 120
+ compare(mapView.map.zoomLevel,endZoomLevel)
+
+ // on mapView on top of mouse area
+ mapView.map.zoomLevel = startZoomLevel
+ mouseWheel(mapView, 55, 75, -30, -2, Qt.LeftButton, Qt.NoModifiers)
+ endZoomLevel = startZoomLevel - 2 / 120
+ compare(mapView.map.zoomLevel,endZoomLevel)
+
+ // outside of mapView
+ mapView.map.zoomLevel = startZoomLevel
+ mouseWheel(mapView, -100, -100, 40, 4, Qt.LeftButton, Qt.NoModifiers)
+ compare(mapView.map.zoomLevel,startZoomLevel)
}
function test_aaa_basic_properties() // _aaa_ to ensure execution first
@@ -321,11 +321,11 @@ Item {
mouseUpper.acceptedButtons = Qt.RightButton | Qt.MiddleButton
compare(mouseUpper.acceptedButtons, Qt.RightButton | Qt.MiddleButton)
compare(mouseUpperAcceptedButtonsChangedSpy.count, 1)
- mouseClick(map, 5, 25)
+ mouseClick(mapView, 5, 25)
compare(mouseUpperClickedSpy.count, 0) // left button not accepted
mouseUpper.acceptedButtons = Qt.LeftButton
compare(mouseUpperAcceptedButtonsChangedSpy.count, 2)
- mouseClick(map, 5, 25)
+ mouseClick(mapView, 5, 25)
tryCompare(mouseUpperClickedSpy, "count", 1)
}
@@ -333,14 +333,14 @@ Item {
// tests basic position changed/move when button is being pressed
clear_data();
wait(500);
- mousePress(map, 5, 25)
+ mousePress(mapView, 5, 25)
compare(mouseUpperPressedSpy.count, 1)
compare(mouseUpper.lastAccepted, true)
compare(mouseUpper.lastButton, Qt.LeftButton)
compare(mouseUpper.lastButtons, Qt.LeftButton)
compare(mouseUpper.lastModifiers, Qt.NoModifier)
// moves within the mouse area
- mouseMove(map, 5, 26, 0, Qt.LeftButton) // '0' is 'delay'
+ mouseMove(mapView, 5, 26, 0, Qt.LeftButton) // '0' is 'delay'
wait(1) // mouseMove event goes one extra eventloop round in the test lib
compare(mouseUpperEnteredSpy.count, 1)
compare(mouseUpperPositionChangedSpy.count, 1)
@@ -354,7 +354,7 @@ Item {
compare(mouseUpper.lastX, 5)
compare(mouseUpper.lastY, 6) // remember 20 offset of the mouse area
- mouseMove(map, 6, 27, 0, Qt.LeftButton | Qt.RightButton)
+ mouseMove(mapView, 6, 27, 0, Qt.LeftButton | Qt.RightButton)
wait(1)
compare(mouseUpperEnteredSpy.count, 1) // no re-entry
compare(mouseUpperPositionChangedSpy.count, 2)
@@ -368,15 +368,15 @@ Item {
compare(mouseUpper.lastX, 6)
compare(mouseUpper.lastY, 7) // remember 20 offset of the mouse area
- // moves outside of mouse but within map
- mouseMove(map, 2, 2, 0)
+ // moves outside of mouse but within mapView
+ mouseMove(mapView, 2, 2, 0)
wait(1)
compare(mouseUpperExitedSpy.count, 1)
compare(mouseUpperPositionChangedSpy.count, 3)
compare(mouseUpper.mouseX, 2)
compare(mouseUpper.mouseY, -18)
- // come back to map
- mouseMove(map, 7, 28, 0)
+ // come back to mapView
+ mouseMove(mapView, 7, 28, 0)
wait(1)
compare(mouseUpperEnteredSpy.count, 2)
compare(mouseUpperExitedSpy.count, 1)
@@ -385,7 +385,7 @@ Item {
compare(mouseUpper.mouseY, 8)
// move outside of widget area (left). make sure that other mouse areas won't get the events
- mouseMove(map, -10, 10, 0)
+ mouseMove(mapView, -10, 10, 0)
wait(1)
compare(mouseUpperPositionChangedSpy.count, 5)
compare(mouseUpperExitedSpy.count, 2)
@@ -393,14 +393,14 @@ Item {
compare(mouseUpper.mouseY, -10)
// back in and then on top of the widget
- mouseMove(map, 5, 25, 0)
+ mouseMove(mapView, 5, 25, 0)
wait(1)
compare(mouseUpperPositionChangedSpy.count, 6)
compare(mouseUpperExitedSpy.count, 2)
compare(mouseUpperEnteredSpy.count, 3)
compare(mouseUpper.mouseX, 5)
compare(mouseUpper.mouseY, 5)
- mouseMove(map, 5, -25, 0)
+ mouseMove(mapView, 5, -25, 0)
wait(1)
compare(mouseUpperPositionChangedSpy.count, 7)
compare(mouseUpperExitedSpy.count, 3)
@@ -409,21 +409,21 @@ Item {
compare(mouseUpper.mouseY, -45)
// back in then float on top of other mouse areas
- mouseMove(map, 5, 25, 0)
+ mouseMove(mapView, 5, 25, 0)
wait(1)
compare(mouseUpperPositionChangedSpy.count, 8)
compare(mouseUpperExitedSpy.count, 3)
compare(mouseUpperEnteredSpy.count, 4)
compare(mouseUpper.mouseX, 5)
compare(mouseUpper.mouseY, 5)
- mouseMove(map, 5, 75, 0)
+ mouseMove(mapView, 5, 75, 0)
wait(1)
compare(mouseUpperPositionChangedSpy.count, 9)
compare(mouseUpperExitedSpy.count, 4)
compare(mouseUpperEnteredSpy.count, 4)
compare(mouseUpper.mouseX, 5)
compare(mouseUpper.mouseY, 55) // remember the 20 offset of upper mouse area
- mouseMove(map, 75, 75, 0)
+ mouseMove(mapView, 75, 75, 0)
wait(1)
compare(mouseUpperPositionChangedSpy.count, 10)
compare(mouseUpperExitedSpy.count, 4)
@@ -431,7 +431,7 @@ Item {
compare(mouseUpper.mouseX, 75)
compare(mouseUpper.mouseY, 55)
// finally back in
- mouseMove(map, 5, 25, 0)
+ mouseMove(mapView, 5, 25, 0)
wait(1)
compare(mouseUpperPositionChangedSpy.count, 11)
compare(mouseUpperExitedSpy.count, 4)
@@ -445,7 +445,7 @@ Item {
compare(mouseOverlapperEnteredSpy.count, 0)
compare(mouseOverlapperPositionChangedSpy.count, 0)
// release mouse
- mouseRelease(map, 5, 25)
+ mouseRelease(mapView, 5, 25)
// TODO enable these!
compare(mouseUpperEnteredSpy.count, 5)
compare(mouseUpperExitedSpy.count, 5) // release triggers one more exited()
@@ -455,16 +455,16 @@ Item {
clear_data()
wait(500);
// send to emptiness
- mousePress(map, 5, 5)
+ mousePress(mapView, 5, 5)
compare(mouseUpperPressedSpy.count, 0)
compare(mouseLowerPressedSpy.count, 0)
compare(mouseOverlapperPressedSpy.count, 0)
- mouseRelease(map, 5, 5)
+ mouseRelease(mapView, 5, 5)
compare(mouseUpperReleasedSpy.count, 0)
compare(mouseLowerReleasedSpy.count, 0)
compare(mouseOverlapperReleasedSpy.count, 0)
// send to upper mouse area
- mousePress(map, 5, 25)
+ mousePress(mapView, 5, 25)
compare(mouseUpperPressedSpy.count, 1)
compare(mouseLowerPressedSpy.count, 0)
compare(mouseOverlapperPressedSpy.count, 0)
@@ -476,18 +476,18 @@ Item {
compare(mouseUpper.lastX, 5)
compare(mouseUpper.lastY, 5) // remember 20 offset of the mouse area
- mouseRelease(map, 5, 25)
+ mouseRelease(mapView, 5, 25)
compare(mouseUpperPressedSpy.count, 1)
compare(mouseUpperReleasedSpy.count, 1)
compare(mouseLowerPressedSpy.count, 0)
compare(mouseLowerReleasedSpy.count, 0)
- mousePress(map, 5, 26)
+ mousePress(mapView, 5, 26)
compare(mouseUpperPressedSpy.count, 2)
compare(mouseLowerPressedSpy.count, 0)
compare(mouseOverlapperPressedSpy.count, 0)
- mouseRelease(map, 5, 26)
+ mouseRelease(mapView, 5, 26)
compare(mouseUpperPressedSpy.count, 2)
compare(mouseUpperReleasedSpy.count, 2)
compare(mouseLowerPressedSpy.count, 0)
@@ -499,7 +499,7 @@ Item {
compare(mouseUpper.lastX, 5)
compare(mouseUpper.lastY, 6) // remember 20 offset of the mouse area
- mousePress(map, 5, 75)
+ mousePress(mapView, 5, 75)
compare(mouseUpperPressedSpy.count, 2)
compare(mouseLowerPressedSpy.count, 1)
compare(mouseOverlapperPressedSpy.count, 0)
@@ -510,26 +510,26 @@ Item {
compare(mouseLower.lastX, 5)
compare(mouseLower.lastY, 25) // remember 50 offset of the mouse area
- mouseRelease(map, 5, 75)
+ mouseRelease(mapView, 5, 75)
compare(mouseUpperPressedSpy.count, 2)
compare(mouseUpperReleasedSpy.count, 2)
compare(mouseLowerPressedSpy.count, 1)
compare(mouseLowerReleasedSpy.count, 1)
compare(mouseOverlapperPressedSpy.count, 0)
- mousePress(map, 55, 75)
+ mousePress(mapView, 55, 75)
compare(mouseUpperPressedSpy.count, 2)
compare(mouseLowerPressedSpy.count, 1)
compare(mouseOverlapperPressedSpy.count, 1)
compare(mouseOverlapperReleasedSpy.count, 0)
- mouseMove(map, 55, 25)
- mouseRelease(map, 55, 25)
+ mouseMove(mapView, 55, 25)
+ mouseRelease(mapView, 55, 25)
compare(mouseUpperPressedSpy.count, 2)
compare(mouseUpperReleasedSpy.count, 2)
compare(mouseLowerPressedSpy.count, 1)
compare(mouseLowerReleasedSpy.count, 1)
- //this should follow the same logic as Flickable, after the gesture is detected, the map should steal events.
+ //this should follow the same logic as Flickable, after the gesture is detected, the mapView should steal events.
compare(mouseOverlapperReleasedSpy.count, 0)
}
@@ -537,13 +537,13 @@ Item {
clear_data();
wait(500);
- mouseClick(map, 5, 5, Qt.RightButton, Qt.AltModifier)
+ mouseClick(mapView, 5, 5, Qt.RightButton, Qt.AltModifier)
compare(mouseUpperClickedSpy.count, 0)
compare(mouseLowerClickedSpy.count, 0)
compare(mouseOverlapperClickedSpy.count, 0)
mouseUpper.acceptedButtons = Qt.LeftButton | Qt.RightButton
// TC sending click event to upper mouse area 5,25
- mouseClick(map, 5, 25, Qt.RightButton, Qt.AltModifier)
+ mouseClick(mapView, 5, 25, Qt.RightButton, Qt.AltModifier)
tryCompare(mouseUpperClickedSpy, "count", 1)
// TC done and clicked was received
//compare(mouseUpperClickedSpy.count, 1)
@@ -562,40 +562,40 @@ Item {
// mouse click with unaccepted buttons should not cause click
mouseUpper.acceptedButtons = Qt.LeftButton
- mouseClick(map, 5, 25, Qt.RightButton, Qt.AltModifier)
+ mouseClick(mapView, 5, 25, Qt.RightButton, Qt.AltModifier)
tryCompare(mouseUpperClickedSpy, "count", 1)
compare(mouseLowerClickedSpy.count, 0)
compare(mouseOverlapperClickedSpy.count, 0)
- mouseClick(map, 5, 25)
+ mouseClick(mapView, 5, 25)
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)
+ mouseClick(mapView, 5, 55)
tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 1)
compare(mouseOverlapperClickedSpy.count, 0)
- mouseClick(map, 5, 55)
+ mouseClick(mapView, 5, 55)
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)
+ mouseClick(mapView, 55, 25)
tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 1)
- mouseClick(map, 55, 75)
+ mouseClick(mapView, 55, 75)
tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 2)
- real_click(map, 55, 25)
+ real_click(mapView, 55, 25)
tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 3)
- real_click(map, 55, 75)
+ real_click(mapView, 55, 75)
tryCompare(mouseUpperClickedSpy, "count", 2)
compare(mouseLowerClickedSpy.count, 2)
compare(mouseOverlapperClickedSpy.count, 4)
@@ -604,12 +604,12 @@ Item {
function test_basic_double_click() {
clear_data();
wait(500);
- real_double_click(map, 5, 5)
+ real_double_click(mapView, 5, 5)
compare(mouseUpperDoubleClickedSpy.count, 0)
compare(mouseLowerDoubleClickedSpy.count, 0)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
- real_double_click(map, 5, 25)
+ real_double_click(mapView, 5, 25)
tryCompare(mouseUpper, "lastAccepted", true)
compare(mouseUpper.lastButton, Qt.LeftButton)
compare(mouseUpper.lastModifiers, Qt.NoModifier)
@@ -620,26 +620,26 @@ Item {
compare(mouseUpperDoubleClickedSpy.count, 1)
compare(mouseLowerDoubleClickedSpy.count, 0)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
- real_double_click(map, 5, 25)
+ real_double_click(mapView, 5, 25)
tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 0)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
- real_double_click(map, 5, 55)
+ real_double_click(mapView, 5, 55)
tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 1)
compare(mouseOverlapperDoubleClickedSpy.count, 0)
- real_double_click(map, 5, 55)
+ real_double_click(mapView, 5, 55)
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)
+ real_double_click(mapView, 55, 25)
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)
+ real_double_click(mapView, 55, 75)
tryCompare(mouseUpperDoubleClickedSpy, "count", 2)
compare(mouseLowerDoubleClickedSpy.count, 2)
compare(mouseOverlapperDoubleClickedSpy.count, 2)
@@ -647,20 +647,20 @@ Item {
compare(mouseOverlapperReleasedSpy.count, 4)
// disable overlapping area and check event is delivered to the ones beneath
mouseOverlapper.enabled = false
- real_double_click(map, 55, 25)
+ real_double_click(mapView, 55, 25)
tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 2)
compare(mouseOverlapperDoubleClickedSpy.count, 2)
- real_double_click(map, 55, 75)
+ real_double_click(mapView, 55, 75)
tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 3)
compare(mouseOverlapperDoubleClickedSpy.count, 2)
mouseOverlapper.enabled = true
- real_double_click(map, 55, 25)
+ real_double_click(mapView, 55, 25)
tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 3)
compare(mouseOverlapperDoubleClickedSpy.count, 3)
- real_double_click(map, 55, 75)
+ real_double_click(mapView, 55, 75)
tryCompare(mouseUpperDoubleClickedSpy, "count", 3)
compare(mouseLowerDoubleClickedSpy.count, 3)
compare(mouseOverlapperDoubleClickedSpy.count, 4)
@@ -668,23 +668,23 @@ Item {
function test_release_does_not_block_clicked() { // QTBUG-66534
clear_data()
- mousePress(map, 55, 75)
+ mousePress(mapView, 55, 75)
compare(mouseOverlapperPressedSpy.count, 1)
- mouseRelease(map, 55, 25)
+ mouseRelease(mapView, 55, 25)
compare(mouseOverlapperReleasedSpy.count, 1)
- mouseClick(map, 25, 25)
+ mouseClick(mapView, 25, 25)
compare(mouseUpperClickedSpy.count, 1)
}
function test_zzz_basic_press_and_hold() { // _zzz_ to ensure execution last (takes time)
clear_data();
wait(1000);
- real_press_and_hold(map, 5, 5)
+ real_press_and_hold(mapView, 5, 5)
compare(mouseUpperPressAndHoldSpy.count, 0)
compare(mouseLowerPressAndHoldSpy.count, 0)
compare(mouseOverlapperPressAndHoldSpy.count, 0)
- mousePress(map,5,25)
+ mousePress(mapView,5,25)
wait(1000) // threshold is 800 ms
compare(mouseUpperPressAndHoldSpy.count, 1)
compare(mouseLowerPressAndHoldSpy.count, 0)
@@ -695,12 +695,12 @@ Item {
compare(mouseUpper.lastWasHeld, true) // notable part
compare(mouseUpper.lastX, 5)
compare(mouseUpper.lastY, 5) // remember 20 offset of the mouse area
- mouseRelease(map,5,25)
- real_press_and_hold(map, 5, 55)
+ mouseRelease(mapView,5,25)
+ real_press_and_hold(mapView, 5, 55)
tryCompare(mouseUpperPressAndHoldSpy, "count", 1)
compare(mouseLowerPressAndHoldSpy.count, 1)
compare(mouseOverlapperPressAndHoldSpy.count, 0)
- real_press_and_hold(map, 55, 75)
+ real_press_and_hold(mapView, 55, 75)
tryCompare(mouseUpperPressAndHoldSpy, "count", 1)
compare(mouseLowerPressAndHoldSpy.count, 1)
compare(mouseOverlapperPressAndHoldSpy.count, 1)
@@ -711,14 +711,14 @@ Item {
compare(mouseOverlapper.lastX, 5)
compare(mouseOverlapper.lastY, 75)
// make sure that the wasHeld is cleared
- mouseClick(map, 55, 75)
+ mouseClick(mapView, 55, 75)
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)
+ real_press_and_hold(mapView, 55, 25)
tryCompare(mouseUpperPressAndHoldSpy, "count", 1)
compare(mouseLowerPressAndHoldSpy.count, 1)
compare(mouseOverlapperPressAndHoldSpy.count, 2)