diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-04 11:58:35 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-15 14:40:23 +0200 |
commit | a6c48812eff4e1aa9b05ea4b811de357242c5588 (patch) | |
tree | a0524fa87eb6c77b3b0f0d9cb47b88e0655a8e97 /tests | |
parent | 366a6379fb80e8c223ae57b2fd791ffdfeacdbf3 (diff) | |
download | qtlocation-a6c48812eff4e1aa9b05ea4b811de357242c5588.tar.gz |
Change QJSValue properties to QList<QGeoCoordinate/Rectangle>
The QML engine is able to operate on lists of gadgets, there is no need
for using private APIs to operate on QJSValue.
For the time being, this breaks a QML construct like
path[0].longitude = 0
This no longer changes the value of path[0].latitude in place. Instead,
use
var path0 = path[0]
path0.longitude = ...
path[0] = path0
This is consistent with other properties that have type list<gadget>, as
QML operates on copies of values, not on references. Adapt the test case
accordingly.
Since support for value-initializing properties of type list<gadget>
requires plumbing in the QML engine, and registration of conversion
routines from QVariantMap to QGeoCoordinate, augment the test.
Remove the now unnecessary toList/fromList conversion functions, and
the dependency to private QtQml libraries.
Fixes: QTBUG-105241
Change-Id: I8f248c457a6de27a3b2680bdc948c5683ebc7fa0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative_location_core/tst_routing.qml | 26 | ||||
-rw-r--r-- | tests/auto/declarative_ui/tst_map_item_details.qml | 19 |
2 files changed, 40 insertions, 5 deletions
diff --git a/tests/auto/declarative_location_core/tst_routing.qml b/tests/auto/declarative_location_core/tst_routing.qml index fe3a2dbd..6fc92f8a 100644 --- a/tests/auto/declarative_location_core/tst_routing.qml +++ b/tests/auto/declarative_location_core/tst_routing.qml @@ -180,6 +180,32 @@ Item { compare (emptyQuery.featureTypes.length, 0, "Feature types") } + RouteQuery { + id: withExcludedAreas + excludedAreas: [ + { + bottomLeft: { latitude: 22.5, longitude: 22.5}, + topRight: { latitude: 23.5, longitude: 23.5} + }, + { + topLeft: { latitude: 23.5, longitude: 22.5}, + bottomRight: { latitude: 22.5, longitude: 23.5}, + }, + { + center: { latitude: 0.0, longitude: 0.0}, + width: 1.0, + height: 1.0 + } + ] + } + function test_initialized_model() { + compare(withExcludedAreas.excludedAreas.length, 3) + compare(withExcludedAreas.excludedAreas[0].width, 1.0) + compare(withExcludedAreas.excludedAreas[1], withExcludedAreas.excludedAreas[0]) + let topLeft = QtPositioning.coordinate(0.5, -0.5) + compare(withExcludedAreas.excludedAreas[2].topLeft, topLeft) + } + SignalSpy {id: autoUpdateSpy; target: emptyModel; signalName: "autoUpdateChanged"} SignalSpy {id: pluginSpy; target: emptyModel ; signalName: "pluginChanged"} diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml index b3409be1..1a44f0a5 100644 --- a/tests/auto/declarative_ui/tst_map_item_details.qml +++ b/tests/auto/declarative_ui/tst_map_item_details.qml @@ -568,12 +568,16 @@ Item { point = map.fromCoordinate(extMapPolygonDateline.path[2]) verify(point.x > map.width / 2.0) var path = extMapPolygonDateline.path; - path[0].longitude = datelineCoordinate.longitude; + var path0 = path[0] + path0.longitude = datelineCoordinate.longitude; + path[0] = path0; extMapPolygonDateline.path = path; point = map.fromCoordinate(extMapPolygonDateline.path[0]) compare(point.x, map.width / 2.0) path = extMapPolygonDateline.path; - path[3].longitude = datelineCoordinate.longitude; + var path3 = path[3] + path3.longitude = datelineCoordinate.longitude; + path[3] = path3 extMapPolygonDateline.path = path; point = map.fromCoordinate(extMapPolygonDateline.path[3]) compare(point.x, map.width / 2.0) @@ -606,11 +610,16 @@ Item { verify(point.x < map.width / 2.0) point = map.fromCoordinate(extMapPolylineDateline.path[1]) verify(point.x > map.width / 2.0) - extMapPolylineDateline.path[1].longitude = datelineCoordinateRight.longitude + var path = extMapPolylineDateline.path; + var path1 = path[1] + path1.longitude = datelineCoordinateRight.longitude + path[1] = path1 + extMapPolylineDateline.path = path point = map.fromCoordinate(extMapPolylineDateline.path[1]) verify(point.x > map.width / 2.0) - var path = extMapPolygonDateline.path; - path[0].longitude = datelineCoordinate.longitude; + path0 = path[0] + path0.longitude = datelineCoordinate.longitude; + path[0] = path0 extMapPolylineDateline.path = path; point = map.fromCoordinate(extMapPolylineDateline.path[0]) compare(point.x, map.width / 2.0) |