From 1549d59e448550f05c5bd1ea6a9da5d1e78c7f26 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 27 Jul 2012 12:58:48 +1000 Subject: Convert Coordinate into a QML coordinate value type. This replaces the Coordinate QML element with a value type. A value type is a better fit for a coordinate. It is very similar to a vector3d except it has an explicit coordinate system and some utility functions. Declare QGeoCoordinate as a movable type. Update documentation. Change-Id: I758fa9dfd7154a4d60fb791fe553b9fee3164c2c Reviewed-by: abcd --- tests/auto/declarative_core/tst_coordinate.qml | 46 +++--- tests/auto/declarative_core/tst_geoshape.qml | 35 ++--- tests/auto/declarative_core/tst_map_routing.qml | 170 +++++++++++++-------- tests/auto/declarative_core/tst_place.qml | 6 +- .../auto/declarative_core/tst_placesearchmodel.qml | 2 +- .../tst_placesearchsuggestionmodel.qml | 2 +- tests/auto/declarative_ui/tst_map.qml | 58 ++----- tests/auto/declarative_ui/tst_map_geocoding.qml | 22 ++- tests/auto/declarative_ui/tst_map_item.qml | 63 +++++--- tests/auto/declarative_ui/tst_map_item_details.qml | 106 ++++++++----- .../declarative_ui/tst_map_item_fit_viewport.qml | 112 ++++++-------- tests/auto/declarative_ui/tst_map_itemview.qml | 58 ++++--- tests/auto/declarative_ui/tst_map_maptype.qml | 3 +- tests/auto/declarative_ui/tst_map_mouse.qml | 7 +- .../declarative_ui/tst_map_pinch_and_flick.qml | 11 +- tests/auto/qmlinterface/data/TestCoordinate.qml | 48 ------ tests/auto/qmlinterface/data/TestGeoCircle.qml | 6 +- tests/auto/qmlinterface/data/TestGeoRectangle.qml | 6 +- tests/auto/qmlinterface/data/TestLocation.qml | 6 +- tests/auto/qmlinterface/qmlinterface.pro | 1 - tests/auto/qmlinterface/tst_qmlinterface.cpp | 21 --- 21 files changed, 387 insertions(+), 402 deletions(-) delete mode 100644 tests/auto/qmlinterface/data/TestCoordinate.qml (limited to 'tests/auto') diff --git a/tests/auto/declarative_core/tst_coordinate.qml b/tests/auto/declarative_core/tst_coordinate.qml index f79570af..72c3dce8 100644 --- a/tests/auto/declarative_core/tst_coordinate.qml +++ b/tests/auto/declarative_core/tst_coordinate.qml @@ -44,44 +44,44 @@ import QtTest 1.0 import QtLocation 5.0 Item { - Coordinate { id: empty } - Coordinate { id: base; longitude: 1.0; latitude: 1.0; altitude: 5.0 } - Coordinate { id: zero; longitude: 0; latitude: 0 } - Coordinate { id: plusone; longitude: 1; latitude: 0 } - Coordinate { id: minusone; longitude: -1; latitude: 0 } - Coordinate { id: north; longitude: 0; latitude: 3 } - - SignalSpy { id: validitySpy; target: empty; signalName: "validityChanged" } - SignalSpy { id: longSpy; target: base; signalName: "longitudeChanged" } - SignalSpy { id: latSpy; target: base; signalName: "latitudeChanged" } - SignalSpy { id: coordSpy; target: base; signalName: "coordinateChanged" } - SignalSpy { id: altSpy; target: base; signalName: "altitudeChanged" } + id: item + + property variant empty: QtLocation.coordinate() + property variant base: QtLocation.coordinate(1.0, 1.0, 5.0) + property variant zero: QtLocation.coordinate(0, 0) + property variant plusone: QtLocation.coordinate(0, 1) + property variant minusone: QtLocation.coordinate(0, -1) + property variant north: QtLocation.coordinate(3, 0) + + SignalSpy { id: coordSpy; target: item; signalName: "baseChanged" } TestCase { name: "Coordinate" function test_validity() { compare(empty.isValid, false) - empty.longitude = 0.0 - empty.latitude = 0.0 + + empty.longitude = 0.0; + empty.latitude = 0.0; + compare(empty.isValid, true) - compare(validitySpy.count, 1) } function test_accessors() { compare(base.longitude, 1.0) compare(base.latitude, 1.0) compare(base.altitude, 5.0) - base.longitude = 2.0 - base.latitude = 3.0 - base.altitude = 5.0 + + coordSpy.clear(); + + base.longitude = 2.0; + base.latitude = 3.0; + base.altitude = 6.0; + compare(base.longitude, 2.0) compare(base.latitude, 3.0) - compare(base.altitude, 5.0) - compare(longSpy.count, 1) - compare(latSpy.count, 1) - compare(altSpy.count, 0) - compare(coordSpy.count, 2) + compare(base.altitude, 6.0) + compare(coordSpy.count, 3) } function test_distance() { diff --git a/tests/auto/declarative_core/tst_geoshape.qml b/tests/auto/declarative_core/tst_geoshape.qml index e7701fe4..9cb06745 100644 --- a/tests/auto/declarative_core/tst_geoshape.qml +++ b/tests/auto/declarative_core/tst_geoshape.qml @@ -44,9 +44,9 @@ import QtTest 1.0 import QtLocation 5.0 Item { - Coordinate{ id: coordinate1; latitude: 1; longitude: 1} - Coordinate{ id: coordinate2; latitude: 2; longitude: 2} - Coordinate{ id: coordinate3; latitude: 80; longitude: 80} + property variant coordinate1: QtLocation.coordinate(1, 1) + property variant coordinate2: QtLocation.coordinate(2, 2) + property variant coordinate3: QtLocation.coordinate(80, 80) GeoCircle { id: emptyCircle } GeoCircle { id: circle1; center: coordinate1; radius: 200000 } @@ -82,32 +82,33 @@ Item { } // coordinate unit square - Coordinate{ id: bottomLeft; latitude: 0; longitude: 0} - Coordinate{ id: topLeft; latitude: 1; longitude: 0} - Coordinate{ id: topRight; latitude: 1; longitude: 1} - Coordinate{ id: bottomRight; latitude: 0; longitude: 1} - Coordinate{ id: newTopRight; latitude: 3; longitude: 3} + property variant bl: QtLocation.coordinate(0, 0) + property variant tl: QtLocation.coordinate(1, 0) + property variant tr: QtLocation.coordinate(1, 1) + property variant br: QtLocation.coordinate(0, 1) + property variant ntr: QtLocation.coordinate(3, 3) - Coordinate{ id: inside; latitude: 0.5; longitude: 0.5} - Coordinate{ id: outside; latitude: 2; longitude: 2} + property variant inside: QtLocation.coordinate(0.5, 0.5) + property variant outside: QtLocation.coordinate(2, 2) GeoRectangle { id: box; - bottomLeft: bottomLeft; - topLeft: topLeft; - topRight: topRight; - bottomRight: bottomRight} + bottomLeft: bl + topLeft: tl + topRight: tr + bottomRight: br + } // C++ auto test exists for basics of bounding box, testing here // only added functionality TestCase { name: "Bounding box" function test_box_defaults_and_setters() { - compare (box.bottomRight.longitude, bottomRight.longitude) // sanity - compare (box.contains(bottomLeft), true) + compare (box.bottomRight.longitude, br.longitude) // sanity + compare (box.contains(bl), true) compare (box.contains(inside), true) compare (box.contains(outside), false) - box.topRight = newTopRight + box.topRight = ntr compare (box.contains(outside), true) } } diff --git a/tests/auto/declarative_core/tst_map_routing.qml b/tests/auto/declarative_core/tst_map_routing.qml index 56ed6149..5ec1c8dc 100644 --- a/tests/auto/declarative_core/tst_map_routing.qml +++ b/tests/auto/declarative_core/tst_map_routing.qml @@ -46,22 +46,26 @@ import QtLocation 5.0 Item { Plugin { id: testPlugin; name: "qmlgeo.test.plugin"; allowExperimental: true } Plugin { id: invalidPlugin; name: "invalid"} - Coordinate{ id: coordinate1; latitude: 51; longitude: 0} - Coordinate{ id: coordinate2; latitude: 52; longitude: 0} + + property variant coordinate1: QtLocation.coordinate(51, 0) + property variant coordinate2: QtLocation.coordinate(52, 0) + GeoRectangle { id: boundingBox1; topLeft: coordinate2; bottomLeft: coordinate1; width: 1000 } GeoRectangle { id: boundingBox2; topLeft: coordinate2; bottomLeft: coordinate1; width: 1000 } - Coordinate{ id: bottomLeft; latitude: 0; longitude: 0} - Coordinate{ id: topLeft; latitude: 1; longitude: 0} - Coordinate{ id: topRight; latitude: 1; longitude: 1} - Coordinate{ id: bottomRight; latitude: 0; longitude: 1} - Coordinate{ id: newTopRight; latitude: 3; longitude: 3} + property variant bl: QtLocation.coordinate(0, 0) + property variant tl: QtLocation.coordinate(1, 0) + property variant tr: QtLocation.coordinate(1, 1) + property variant br: QtLocation.coordinate(0, 1) + property variant ntr: QtLocation.coordinate(3, 3) + GeoRectangle { id: unitBox; - bottomLeft: bottomLeft; - topLeft: topLeft; - topRight: topRight; - bottomRight: bottomRight} + bottomLeft: bl + topLeft: tl + topRight: tr + bottomRight: br + } Route {id: emptyRoute} TestCase { @@ -73,7 +77,8 @@ Item { //MapRoute {id: emptyMapRoute} GeoRectangle {id: emptyBox} - Coordinate {id: emptyCoordinate} + + property variant emptyCoordinate: QtLocation.coordinate() // TODO enable when we have map route /* @@ -245,38 +250,31 @@ Item { // Altering the waypoint contents should trigger signal emptyQuery.clearWaypoints() + queryDetailsChangedSpy.clear(); emptyQuery.addWaypoint(coordinate1) - queryDetailsChangedSpy.clear() - coordinate1.latitude = 41 - compare (queryDetailsChangedSpy.count, 1) - coordinate1.longitude = 1 - compare (queryDetailsChangedSpy.count, 2) - coordinate1.altitude = 1 - compare (queryDetailsChangedSpy.count, 3) + compare(queryDetailsChangedSpy.count, 1); + // verify coordinate is disconnected emptyQuery.removeWaypoint(coordinate1) - compare (queryDetailsChangedSpy.count, 4) - coordinate1.latitude = 46 - compare (queryDetailsChangedSpy.count, 4) - // verify that same coordinate instance only produces one set of changes + compare (queryDetailsChangedSpy.count, 2) + + // verify that the same coordinate can be added to the waypoints emptyQuery.addWaypoint(coordinate1) + compare(queryDetailsChangedSpy.count, 3); emptyQuery.addWaypoint(coordinate1) + compare(queryDetailsChangedSpy.count, 4); compare (emptyQuery.waypoints.length, 2) queryDetailsChangedSpy.clear() - coordinate1.latitude = 61 - compare (queryDetailsChangedSpy.count, 1) - // verify that removing duplicat coordinate leaves remaining ones correctly connected + + // verify that removing duplicate coordinate leaves remaining ones emptyQuery.removeWaypoint(coordinate1) - compare (queryDetailsChangedSpy.count, 2) + compare (queryDetailsChangedSpy.count, 1) compare (emptyQuery.waypoints.length, 1) - coordinate1.latitude = 69 - compare (queryDetailsChangedSpy.count, 3) + // verify that clearing works emptyQuery.clearWaypoints() - compare (queryDetailsChangedSpy.count, 4) + compare(queryDetailsChangedSpy.count, 2); compare (emptyQuery.waypoints.length, 0) - coordinate1.latitude = 62 - compare (queryDetailsChangedSpy.count, 4) // Excluded areas queryDetailsChangedSpy.clear() @@ -321,16 +319,18 @@ Item { queryDetailsChangedSpy.clear() compare (emptyQuery.excludedAreas.length, 1) unitBox.width = 200 - compare(queryDetailsChangedSpy.count, 1) + tryCompare(queryDetailsChangedSpy, "count", 1); unitBox.height = 200 - compare(queryDetailsChangedSpy.count, 2) - unitBox.topRight = newTopRight - compare(queryDetailsChangedSpy.count, 5) + tryCompare(queryDetailsChangedSpy , "count", 2); + unitBox.topRight = ntr + tryCompare(queryDetailsChangedSpy, "count", 3); + // verify box is disconnected emptyQuery.removeExcludedArea(unitBox) - compare (queryDetailsChangedSpy.count, 6) + compare(queryDetailsChangedSpy.count, 4); unitBox.height = 400 - compare (queryDetailsChangedSpy.count, 6) + tryCompare(queryDetailsChangedSpy, "count", 4); + // verify that same box instance only produces one set of changes compare (emptyQuery.excludedAreas.length, 0) emptyQuery.addExcludedArea(unitBox) @@ -338,16 +338,17 @@ Item { compare (emptyQuery.excludedAreas.length, 1) queryDetailsChangedSpy.clear() unitBox.width = 777 - compare (queryDetailsChangedSpy.count, 1) + tryCompare(queryDetailsChangedSpy, "count", 1); compare (emptyQuery.excludedAreas.length, 1) unitBox.width = 200 - compare (queryDetailsChangedSpy.count, 2) + tryCompare(queryDetailsChangedSpy, "count", 2); + // verify that clearing works emptyQuery.clearExcludedAreas() compare (queryDetailsChangedSpy.count, 3) compare (emptyQuery.excludedAreas.length, 0) unitBox.width = 717 - compare (queryDetailsChangedSpy.count, 3) + tryCompare(queryDetailsChangedSpy, "count", 3); // Feature types and weights queryDetailsChangedSpy.clear() @@ -511,28 +512,40 @@ Item { ] } - Coordinate {id: rcoordinate1; latitude: 50; longitude: 50} - Coordinate {id: rcoordinate2; latitude: 51; longitude: 52} - Coordinate {id: rcoordinate3; latitude: 53; longitude: 54} - Coordinate {id: rcoordinate4; latitude: 55; longitude: 56} - Coordinate {id: rcoordinate5; latitude: 57; longitude: 58} + property variant rcoordinate1: QtLocation.coordinate(50, 50) + property variant rcoordinate2: QtLocation.coordinate(51, 52) + property variant rcoordinate3: QtLocation.coordinate(53, 54) + property variant rcoordinate4: QtLocation.coordinate(55, 56) + property variant rcoordinate5: QtLocation.coordinate(57, 58) + + property variant fcoordinate1: QtLocation.coordinate(60, 60) + property variant fcoordinate2: QtLocation.coordinate(61, 62) + property variant fcoordinate3: QtLocation.coordinate(63, 64) + property variant fcoordinate4: QtLocation.coordinate(65, 66) + property variant fcoordinate5: QtLocation.coordinate(67, 68) + + property variant f2coordinate1: QtLocation.coordinate(60, 60) + property variant f2coordinate2: QtLocation.coordinate(61, 62) + property variant f2coordinate3: QtLocation.coordinate(63, 64) RouteQuery {id: routeQuery} - RouteQuery {id: filledRouteQuery; - numberAlternativeRoutes: 1 + RouteQuery { + id: filledRouteQuery + numberAlternativeRoutes: 0 waypoints: [ - Coordinate {id: fcoordinate1; latitude: 60; longitude: 60}, - Coordinate {id: fcoordinate2; latitude: 61; longitude: 62}, - Coordinate {id: fcoordinate3; latitude: 63; longitude: 64}, - Coordinate {id: fcoordinate4; latitude: 65; longitude: 66}, - Coordinate {id: fcoordinate5; latitude: 67; longitude: 68} + { latitude: 60, longitude: 60 }, + { latitude: 61, longitude: 62 }, + { latitude: 63, longitude: 64 }, + { latitude: 65, longitude: 66 }, + { latitude: 67, longitude: 68 } ] } - RouteQuery {id: filledRouteQuery2; + RouteQuery { + id: filledRouteQuery2 waypoints: [ - Coordinate {id: f2coordinate1; latitude: 60; longitude: 60}, - Coordinate {id: f2coordinate2; latitude: 61; longitude: 62}, - Coordinate {id: f2coordinate3; latitude: 63; longitude: 64} + f2coordinate1, + f2coordinate2, + f2coordinate3 ] } RouteModel { @@ -731,9 +744,10 @@ Item { compare(routeModelSlack.count, 1) // Autoupdate + automaticRoutesSpy.clear(); filledRouteQuery.numberAlternativeRoutes = 1 // 'altroutes - 70' is the echoed errorcode wait (300) - automaticRoutesSpy.clear() + compare(automaticRoutesSpy.count, 1); compare(routeModelAutomatic.count, 1) // There should be a route already compare (routeModelAutomatic.get(0).path.length, 5) compare (routeModelAutomatic.get(0).path[0].latitude, filledRouteQuery.waypoints[0].latitude) @@ -741,31 +755,53 @@ Item { // Remove a waypoint and check that autoupdate works filledRouteQuery.removeWaypoint(fcoordinate2) wait(300) + compare(automaticRoutesSpy.count, 2); compare (routeModelAutomatic.get(0).path.length, 4) compare (routeModelAutomatic.get(0).path[0].latitude, fcoordinate1.latitude) - compare (automaticRoutesSpy.count, 1) + + // Add a waypoint and check that autoupdate works + filledRouteQuery.addWaypoint(fcoordinate2); + wait(300); + compare(automaticRoutesSpy.count, 3); + compare(routeModelAutomatic.count, 1); + compare(routeModelAutomatic.get(0).path.length, 5); + compare(routeModelAutomatic.get(0).path[0].latitude, filledRouteQuery.waypoints[0].latitude); // Change contents of a coordinate and check that autoupdate works - fcoordinate1.latitude++ + filledRouteQuery.waypoints = [ + { latitude: fcoordinate1.latitude + 1, longitude: fcoordinate1.longitude }, + { latitude: 61, longitude: 62 }, + { latitude: 63, longitude: 64 }, + { latitude: 65, longitude: 66 }, + { latitude: 67, longitude: 68 } + ]; wait(300) - compare (routeModelAutomatic.get(0).path[0].latitude, fcoordinate1.latitude) // new value should be echoed - compare (automaticRoutesSpy.count, 2) + compare(automaticRoutesSpy.count, 4); + compare(routeModelAutomatic.get(0).path[0].latitude, fcoordinate1.latitude + 1) // new value should be echoed + // Change query routeModelAutomatic.query = filledRouteQuery2 filledRouteQuery2.numberAlternativeRoutes = 3 wait(300) + compare(automaticRoutesSpy.count, 5); compare (routeModelAutomatic.get(0).path.length, 3) - compare (automaticRoutesSpy.count, 3) + // Verify that the old query is disconnected internally ie. does not trigger update - fcoordinate1.latitude++ + filledRouteQuery.waypoints = [ + { latitude: fcoordinate1.latitude + 2, longitude: fcoordinate1.longitude }, + { latitude: 61, longitude: 62 }, + { latitude: 63, longitude: 64 }, + { latitude: 65, longitude: 66 }, + { latitude: 67, longitude: 68 } + ]; wait(300) - compare (automaticRoutesSpy.count, 3) + compare(automaticRoutesSpy.count, 5); + compare(routeModelAutomatic.get(0).path.length, 3); } function test_route_query_handles_destroyed_qml_objects() { - var coordinate = Qt.createQmlObject('import QtQuick 2.0; import QtLocation 5.0; Coordinate { latitude : 11; longitude : 52 }', this); + var coordinate = QtLocation.coordinate(11, 52); routeQuery.addWaypoint(coordinate); - coordinate.destroy(); wait(300); routeQuery.clearWaypoints(); } diff --git a/tests/auto/declarative_core/tst_place.qml b/tests/auto/declarative_core/tst_place.qml index 14d12b49..9b4ae991 100644 --- a/tests/auto/declarative_core/tst_place.qml +++ b/tests/auto/declarative_core/tst_place.qml @@ -85,14 +85,14 @@ TestCase { postalCode: "1234" } - coordinate: Coordinate { + coordinate { latitude: 10 longitude: 10 altitude: 100 } boundingBox: GeoRectangle { - center: Coordinate { + center { latitude: 10 longitude: 10 altitude: 100 @@ -436,7 +436,7 @@ TestCase { } function test_location() { - var location = Qt.createQmlObject('import QtLocation 5.0; Location { coordinate: Coordinate{ latitude:10.0 } }', testCase, "Location1"); + var location = Qt.createQmlObject('import QtLocation 5.0; Location { coordinate: QtLocation.coordinate(10.0, 20.0) }', testCase, "Location1"); var signalSpy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', testCase, "SignalSpy"); signalSpy.target = testPlace; diff --git a/tests/auto/declarative_core/tst_placesearchmodel.qml b/tests/auto/declarative_core/tst_placesearchmodel.qml index ee3e565c..8ec3c0a2 100644 --- a/tests/auto/declarative_core/tst_placesearchmodel.qml +++ b/tests/auto/declarative_core/tst_placesearchmodel.qml @@ -72,7 +72,7 @@ TestCase { GeoCircle { id: testSearchArea - center: Coordinate { + center { latitude: 10 longitude: 20 } diff --git a/tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml b/tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml index adb83179..b2c8b73e 100644 --- a/tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml +++ b/tests/auto/declarative_core/tst_placesearchsuggestionmodel.qml @@ -70,7 +70,7 @@ TestCase { GeoCircle { id: testSearchArea - center: Coordinate { + center { latitude: 10 longitude: 20 } diff --git a/tests/auto/declarative_ui/tst_map.qml b/tests/auto/declarative_ui/tst_map.qml index 72ce5861..ab20e673 100644 --- a/tests/auto/declarative_ui/tst_map.qml +++ b/tests/auto/declarative_ui/tst_map.qml @@ -61,19 +61,18 @@ Item { } ] } - Coordinate{ id: coordinate1; latitude: 10; longitude: 11} - Coordinate{ id: coordinate2; latitude: 12; longitude: 13} - Coordinate{ id: coordinate3; latitude: 50; longitude: 50; altitude: 0} - Coordinate{ id: coordinate4; latitude: 80; longitude: 80; altitude: 0} - Coordinate{ id: invalidCoordinate; altitude: 0} - Coordinate{ id: altitudelessCoordinate; latitude: 50; longitude: 50} + + property variant coordinate1: QtLocation.coordinate(10, 11) + property variant coordinate2: QtLocation.coordinate(12, 13) + property variant coordinate3: QtLocation.coordinate(50, 50, 0) + property variant coordinate4: QtLocation.coordinate(80, 80, 0) + property variant invalidCoordinate: QtLocation.coordinate() + property variant altitudelessCoordinate: QtLocation.coordinate(50, 50) + Map {id: map; plugin: testPlugin; center: coordinate1; width: 100; height: 100} Map {id: coordinateMap; plugin: nokiaPlugin; center: coordinate3; width: 1000; height: 1000; zoomLevel: 15} SignalSpy {id: mapCenterSpy; target: map; signalName: 'centerChanged'} - SignalSpy {id: coordinate2LatitudeSpy; target: coordinate2; signalName: 'latitudeChanged'} - SignalSpy {id: coordinate2LongitudeSpy; target: coordinate2; signalName: 'longitudeChanged'} - SignalSpy {id: coordinate2AltitudeSpy; target: coordinate2; signalName: 'altitudeChanged'} TestCase { when: windowShown @@ -87,15 +86,9 @@ Item { return false; } - function clear_data() { - mapCenterSpy.clear() - coordinate2AltitudeSpy.clear() - coordinate2LatitudeSpy.clear() - coordinate2LongitudeSpy.clear() - } - function test_map_center() { - clear_data() + mapCenterSpy.clear(); + // coordinate is set at map element declaration compare(map.center.latitude, 10) compare(map.center.longitude, 11) @@ -107,36 +100,17 @@ Item { compare(mapCenterSpy.count, 1) map.center = coordinate2 compare(mapCenterSpy.count, 1) - compare(coordinate2LatitudeSpy.count, 0) - compare(coordinate2LongitudeSpy.count, 0) - compare(coordinate2AltitudeSpy.count, 0) - coordinate2.latitude = 21 - compare(coordinate2LatitudeSpy.count, 1) - compare(mapCenterSpy.count, 2) - compare(coordinate2LongitudeSpy.count, 0) - compare(coordinate2AltitudeSpy.count, 0) - compare(map.center.latitude, 21) - coordinate2.longitude = 31 - compare(coordinate2LatitudeSpy.count, 1) - compare(mapCenterSpy.count, 3) - compare(coordinate2LongitudeSpy.count, 1) - compare(coordinate2AltitudeSpy.count, 0) - compare(map.center.longitude, 31) - coordinate2.altitude = 41 - compare(coordinate2LatitudeSpy.count, 1) - compare(mapCenterSpy.count, 4) - compare(coordinate2LongitudeSpy.count, 1) - compare(coordinate2AltitudeSpy.count, 1) - compare(map.center.altitude, 41) - compare(map.center.longitude, 31) - compare(map.center.latitude, 21) + + verify(isNaN(map.center.altitude)); + compare(map.center.longitude, 13) + compare(map.center.latitude, 12) } function test_pan() { map.center.latitude = 30 map.center.longitude = 60 map.zoomLevel = 4 - clear_data() + mapCenterSpy.clear(); // up left tryCompare(mapCenterSpy, "count", 0) @@ -216,7 +190,7 @@ Item { function test_coordinate_conversion() { wait(1000) - clear_data() + mapCenterSpy.clear(); compare(coordinateMap.center.latitude, 50) compare(coordinateMap.center.longitude, 50) // valid to screen position diff --git a/tests/auto/declarative_ui/tst_map_geocoding.qml b/tests/auto/declarative_ui/tst_map_geocoding.qml index c150421e..2d64fcd6 100644 --- a/tests/auto/declarative_ui/tst_map_geocoding.qml +++ b/tests/auto/declarative_ui/tst_map_geocoding.qml @@ -47,15 +47,16 @@ Item { Plugin { id: nokiaPlugin; name: "qmlgeo.test.plugin"} Plugin { id: invalidPlugin; name: "invalid"} - Coordinate{ id: coordinate1; latitude: 51; longitude: 41} - Coordinate{ id: coordinate2; latitude: 52; longitude: 42} + property variant coordinate1: QtLocation.coordinate(51, 41) + property variant coordinate2: QtLocation.coordinate(52, 42) + property variant emptyCoordinate: QtLocation.coordinate() + GeoRectangle { id: boundingBox1; topLeft: coordinate2; bottomLeft: coordinate1; width: 1000 } GeoRectangle { id: boundingBox2; topLeft: coordinate2; bottomLeft: coordinate1; width: 1000 } GeoCircle { id: boundingCircle1; center: coordinate1; radius: 100 } GeoCircle { id: boundingCircle2; center: coordinate2; radius: 100 } GeoRectangle {id: emptyBox} - Coordinate {id: emptyCoordinate} GeocodeModel {id: emptyModel} Address {id: emptyAddress} @@ -137,7 +138,7 @@ Item { emptyModel.bounds = boundingCircle2 compare(boundsSpy.count, 2) compare(emptyModel.bounds.center.latitude, coordinate2.latitude) - var dynamicCircle = Qt.createQmlObject("import QtQuick 2.0; import QtLocation 5.0; GeoCircle { id: dynCircle; center: Coordinate { id: dynCoord; latitude: 8; longitude: 9 } }", testCase1) + var dynamicCircle = Qt.createQmlObject("import QtQuick 2.0; import QtLocation 5.0; GeoCircle { id: dynCircle; center { latitude: 8; longitude: 9 } }", testCase1) emptyModel.bounds = dynamicCircle compare(boundsSpy.count, 3) compare(emptyModel.bounds.center.latitude, dynamicCircle.center.latitude) @@ -191,12 +192,13 @@ Item { } Address {id: address1; street: "wellknown street"; city: "expected city"; county: "2"} Address {id: errorAddress1; street: "error"; county: "2"} // street is the error reason - Coordinate{ id: rcoordinate1; latitude: 51; longitude: 2} - Coordinate{ id: errorCoordinate1; latitude: 73; longitude: 2} // (latiude mod 70) is the error code - Coordinate{ id: slackCoordinate1; latitude: 60; longitude: 3} + + property variant rcoordinate1: QtLocation.coordinate(51, 2) + property variant errorCoordinate1: QtLocation.coordinate(73, 2) // (latiude mod 70) is the error code + property variant slackCoordinate1: QtLocation.coordinate(60, 3) Address {id: slackAddress1; street: "Slacker st"; city: "Lazy town"; county: "4"} - Coordinate{ id: automaticCoordinate1; latitude: 60; longitude: 3} + property variant automaticCoordinate1: QtLocation.coordinate(60, 3) Address {id: automaticAddress1; street: "Auto st"; city: "Detroit"; county: "4"} Plugin { @@ -536,10 +538,6 @@ Item { wait (300) compare (automaticLocationsSpy.count, 4) compare (automaticModel.count, 3) - automaticCoordinate1.longitude = 7 - wait (300) - compare (automaticLocationsSpy.count, 5) - compare (automaticModel.count, 7) } function test_delayed_geocode() { diff --git a/tests/auto/declarative_ui/tst_map_item.qml b/tests/auto/declarative_ui/tst_map_item.qml index 57e06fdb..84394dc2 100644 --- a/tests/auto/declarative_ui/tst_map_item.qml +++ b/tests/auto/declarative_ui/tst_map_item.qml @@ -74,21 +74,26 @@ Item { width: 240 height: 240 Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true } - Coordinate{ id: mapDefaultCenter; latitude: 20; longitude: 20} - Coordinate{ id: someCoordinate1; latitude: 15; longitude: 15} - Coordinate{ id: someCoordinate2; latitude: 16; longitude: 16} + + property variant mapDefaultCenter: QtLocation.coordinate(20, 20) + property variant someCoordinate1: QtLocation.coordinate(15, 15) + property variant someCoordinate2: QtLocation.coordinate(16, 16) + Route { id: someRoute; path: [ - Coordinate { latitude: 22; longitude: 15}, - Coordinate { latitude: 21; longitude: 16}, - Coordinate { latitude: 23; longitude: 17} + { latitude: 22, longitude: 15 }, + { latitude: 21, longitude: 16 }, + { latitude: 23, longitude: 17 } ] } Item { id: someItem } MapCircle { id: extMapCircle - center: Coordinate { latitude: 35; longitude: 15} + center { + latitude: 35 + longitude: 15 + } color: 'firebrick' radius: 600000 MapMouseArea { @@ -104,7 +109,10 @@ Item { anchors.fill: parent SignalSpy { id: extMapQuickItemClicked; target: parent; signalName: "clicked" } } - coordinate: Coordinate { latitude: 35; longitude: 33} + coordinate { + latitude: 35 + longitude: 33 + } sourceItem: Rectangle { color: 'darkblue' width: 40 @@ -123,8 +131,14 @@ Item { id: preMapRect color: 'darkcyan' border.width: 0 - topLeft: Coordinate { latitude: 20; longitude: 20} - bottomRight: Coordinate { latitude: 10; longitude: 30} + topLeft { + latitude: 20 + longitude: 20 + } + bottomRight { + latitude: 10 + longitude: 30 + } MapMouseArea { id: preMapRectMa anchors.fill: parent @@ -140,7 +154,10 @@ Item { id: preMapCircle color: 'darkmagenta' border.width: 0 - center: Coordinate { latitude: 10; longitude: 30} + center { + latitude: 10 + longitude: 30 + } radius: 400000 MapMouseArea { id: preMapCircleMa @@ -163,7 +180,10 @@ Item { SignalSpy { id: preMapQuickItemClicked; target: parent; signalName: "clicked" } SignalSpy { id: preMapQuickItemActiveChanged; target: parent.drag; signalName: "activeChanged" } } - coordinate: Coordinate { latitude: 35; longitude: 3} + coordinate { + latitude: 35 + longitude: 3 + } sourceItem: Rectangle { color: 'darkgreen' width: 20 @@ -179,9 +199,9 @@ Item { color: 'darkgrey' border.width: 0 path: [ - Coordinate { latitude: 25; longitude: 5}, - Coordinate { latitude: 20; longitude: 10}, - Coordinate { latitude: 15; longitude: 6} + { latitude: 25, longitude: 5 }, + { latitude: 20, longitude: 10 }, + { latitude: 15, longitude: 6 } ] MapMouseArea { anchors.fill: parent @@ -197,9 +217,9 @@ Item { id: preMapPolyline line.color: 'darkred' path: [ - Coordinate { latitude: 25; longitude: 15}, - Coordinate { latitude: 20; longitude: 19}, - Coordinate { latitude: 15; longitude: 16} + { latitude: 25, longitude: 15 }, + { latitude: 20, longitude: 19 }, + { latitude: 15, longitude: 16 } ] SignalSpy {id: preMapPolylineColorChanged; target: parent.line; signalName: "colorChanged"} SignalSpy {id: preMapPolylineWidthChanged; target: parent.line; signalName: "widthChanged"} @@ -211,9 +231,9 @@ Item { // don't try this at home - route is not user instantiable route: Route { path: [ - Coordinate { latitude: 25; longitude: 14}, - Coordinate { latitude: 20; longitude: 18}, - Coordinate { latitude: 15; longitude: 15} + { latitude: 25, longitude: 14 }, + { latitude: 20, longitude: 18 }, + { latitude: 15, longitude: 15 } ] } SignalSpy {id: preMapRouteRouteChanged; target: parent; signalName: "routeChanged"} @@ -221,7 +241,6 @@ Item { SignalSpy {id: preMapRouteLineColorChanged; target: parent.line; signalName: "colorChanged"} } } - TestCase { name: "Map Items" when: windowShown diff --git a/tests/auto/declarative_ui/tst_map_item_details.qml b/tests/auto/declarative_ui/tst_map_item_details.qml index 43e0ec44..0ca5b098 100644 --- a/tests/auto/declarative_ui/tst_map_item_details.qml +++ b/tests/auto/declarative_ui/tst_map_item_details.qml @@ -50,18 +50,19 @@ Item { width: 240 height: 240 Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true } - Coordinate{ id: mapDefaultCenter; latitude: 20; longitude: 20} - Coordinate{ id: datelineCoordinate; latitude: 20; longitude: 180} - Coordinate{ id: datelineCoordinateLeft; latitude: 20; longitude: 170} - Coordinate{ id: datelineCoordinateRight; latitude: 20; longitude: -170} + property variant mapDefaultCenter: QtLocation.coordinate(20, 20) + + property variant datelineCoordinate: QtLocation.coordinate(20, 180) + property variant datelineCoordinateLeft: QtLocation.coordinate(20, 170) + property variant datelineCoordinateRight: QtLocation.coordinate(20, -170) MapPolygon { id: extMapPolygon color: 'darkgrey' path: [ - Coordinate { latitude: 25; longitude: 5}, - Coordinate { latitude: 20; longitude: 10} + { latitude: 25, longitude: 5 }, + { latitude: 20, longitude: 10 } ] MapMouseArea { anchors.fill: parent @@ -73,7 +74,8 @@ Item { SignalSpy {id: extMapPolygonBorderWidthChanged; target: parent.border; signalName: "widthChanged"} SignalSpy {id: extMapPolygonBorderColorChanged; target: parent.border; signalName: "colorChanged"} } - Coordinate { id: polyCoordinate; latitude: 15; longitude: 6} + + property variant polyCoordinate: QtLocation.coordinate(15, 6) MapPolygon { id: extMapPolygon0 @@ -87,8 +89,8 @@ Item { MapPolyline { id: extMapPolyline path: [ - Coordinate { latitude: 25; longitude: 5}, - Coordinate { latitude: 20; longitude: 10} + { latitude: 25, longitude: 5 }, + { latitude: 20, longitude: 10 } ] SignalSpy {id: extMapPolylineColorChanged; target: parent.line; signalName: "colorChanged"} SignalSpy {id: extMapPolylineWidthChanged; target: parent.line; signalName: "widthChanged"} @@ -98,8 +100,14 @@ Item { MapRectangle { id: extMapRectDateline color: 'darkcyan' - topLeft: Coordinate { latitude: 20; longitude: 175} - bottomRight: Coordinate { latitude: 10; longitude: -175} + topLeft { + latitude: 20 + longitude: 175 + } + bottomRight { + latitude: 10 + longitude: -175 + } MapMouseArea { anchors.fill: parent drag.target: parent @@ -109,7 +117,10 @@ Item { MapCircle { id: extMapCircleDateline color: 'darkmagenta' - center: Coordinate { latitude: 20; longitude: 180} + center { + latitude: 20 + longitude: 180 + } radius: 400000 MapMouseArea { anchors.fill: parent @@ -123,7 +134,10 @@ Item { anchors.fill: parent drag.target: parent } - coordinate: Coordinate { latitude: 20; longitude: 175} + coordinate { + latitude: 20 + longitude: 175 + } sourceItem: Rectangle { color: 'darkgreen' width: 20 @@ -135,10 +149,10 @@ Item { id: extMapPolygonDateline color: 'darkmagenta' path: [ - Coordinate { latitude: 20; longitude: 175}, - Coordinate { latitude: 20; longitude: -175}, - Coordinate { latitude: 10; longitude: -175}, - Coordinate { latitude: 10; longitude: 175} + { latitude: 20, longitude: 175 }, + { latitude: 20, longitude: -175 }, + { latitude: 10, longitude: -175 }, + { latitude: 10, longitude: 175 } ] MapMouseArea { anchors.fill: parent @@ -150,8 +164,8 @@ Item { id: extMapPolylineDateline line.width : 3 path: [ - Coordinate { latitude: 20; longitude: 175}, - Coordinate { latitude: 25; longitude: -175} + { latitude: 20, longitude: 175 }, + { latitude: 25, longitude: -175 } ] MapMouseArea { anchors.fill: parent @@ -164,8 +178,8 @@ Item { line.color: 'yellow' route: Route { path: [ - Coordinate { latitude: 25; longitude: 175}, - Coordinate { latitude: 20; longitude: -175} + { latitude: 25, longitude: 175 }, + { latitude: 20, longitude: -175 } ] } } @@ -173,8 +187,14 @@ Item { MapRectangle { id: extMapRectEdge color: 'darkcyan' - topLeft: Coordinate { latitude: 20; longitude: -15} - bottomRight: Coordinate { latitude: 10; longitude: -5} + topLeft { + latitude: 20 + longitude: -15 + } + bottomRight { + latitude: 10 + longitude: -5 + } MapMouseArea { anchors.fill: parent drag.target: parent @@ -184,7 +204,10 @@ Item { MapCircle { id: extMapCircleEdge color: 'darkmagenta' - center: Coordinate { latitude: 20; longitude: -15} + center { + latitude: 20 + longitude: -15 + } radius: 400000 MapMouseArea { anchors.fill: parent @@ -198,7 +221,10 @@ Item { anchors.fill: parent drag.target: parent } - coordinate: Coordinate { latitude: 20; longitude: -15} + coordinate { + latitude: 20 + longitude: -15 + } sourceItem: Rectangle { color: 'darkgreen' width: 20 @@ -210,10 +236,10 @@ Item { id: extMapPolygonEdge color: 'darkmagenta' path: [ - Coordinate { latitude: 20; longitude: -15}, - Coordinate { latitude: 20; longitude: -5}, - Coordinate { latitude: 10; longitude: -5}, - Coordinate { latitude: 10; longitude: -15} + { latitude: 20, longitude: -15 }, + { latitude: 20, longitude: -5 }, + { latitude: 10, longitude: -5 }, + { latitude: 10, longitude: -15 } ] MapMouseArea { anchors.fill: parent @@ -225,8 +251,8 @@ Item { id: extMapPolylineEdge line.width : 3 path: [ - Coordinate { latitude: 20; longitude: -15}, - Coordinate { latitude: 25; longitude: -5} + { latitude: 20, longitude: -15 }, + { latitude: 25, longitude: -5 } ] MapMouseArea { anchors.fill: parent @@ -239,8 +265,8 @@ Item { line.color: 'yellow' route: Route { path: [ - Coordinate { latitude: 25; longitude: -15}, - Coordinate { latitude: 20; longitude: -5} + { latitude: 25, longitude: -15 }, + { latitude: 20, longitude: -5 } ] } } @@ -475,14 +501,18 @@ Item { extMapPolygonDateline.path[2].longitude = datelineCoordinateRight.longitude point = map.toScreenPosition(extMapPolygonDateline.path[2]) verify(point.x > map.width / 2.0) - extMapPolygonDateline.path[0].longitude = datelineCoordinate.longitude + var path = extMapPolygonDateline.path; + path[0].longitude = datelineCoordinate.longitude; + extMapPolygonDateline.path = path; point = map.toScreenPosition(extMapPolygonDateline.path[0]) verify(point.x == map.width / 2.0) - extMapPolygonDateline.path[3].longitude = datelineCoordinate.longitude + path = extMapPolygonDateline.path; + path[3].longitude = datelineCoordinate.longitude; + extMapPolygonDateline.path = path; point = map.toScreenPosition(extMapPolygonDateline.path[3]) verify(point.x == map.width / 2.0) mousePress(map, point.x + 5, point.y - 5) - for (i=0; i < 20; i += 2) { + for (i=0; i < 16; i += 2) { wait(1) mouseMove(map, point.x + 5 - i, point.y - 5 ) } @@ -508,7 +538,9 @@ Item { extMapPolylineDateline.path[1].longitude = datelineCoordinateRight.longitude point = map.toScreenPosition(extMapPolylineDateline.path[1]) verify(point.x > map.width / 2.0) - extMapPolylineDateline.path[0].longitude = datelineCoordinate.longitude + var path = extMapPolygonDateline.path; + path[0].longitude = datelineCoordinate.longitude; + extMapPolylineDateline.path = path; point = map.toScreenPosition(extMapPolylineDateline.path[0]) verify(point.x == map.width / 2.0) map.removeMapItem(extMapPolylineDateline) 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 5560a832..8073e638 100644 --- a/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml +++ b/tests/auto/declarative_ui/tst_map_item_fit_viewport.qml @@ -74,49 +74,49 @@ Item { width: 240 height: 240 Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true } - Coordinate{ id: mapDefaultCenter; latitude: 20; longitude: 20} - Coordinate{ id: preMapRectangleDefaultTopLeft; latitude: 20; longitude: 20} - Coordinate{ id: preMapRectangleDefaultBottomRight; latitude: 10; longitude: 30} - Coordinate{ id: preMapCircleDefaultCenter; latitude: 10; longitude: 30} - Coordinate{ id: preMapQuickItemDefaultCoordinate; latitude: 35; longitude: 3} + property variant mapDefaultCenter: QtLocation.coordinate(20, 20) + property variant preMapRectangleDefaultTopLeft: QtLocation.coordinate(20, 20) + property variant preMapRectangleDefaultBottomRight: QtLocation.coordinate(10, 30) + property variant preMapCircleDefaultCenter: QtLocation.coordinate(10, 30) + property variant preMapQuickItemDefaultCoordinate: QtLocation.coordinate(35, 3) - property list preMapPolygonDefaultPath:[ - Coordinate { latitude: 25; longitude: 5}, - Coordinate { latitude: 20; longitude: 10}, - Coordinate { latitude: 15; longitude: 6} + property variant preMapPolygonDefaultPath: [ + { latitude: 25, longitude: 5 }, + { latitude: 20, longitude: 10 }, + { latitude: 15, longitude: 6 } ] - property list preMapPolylineDefaultPath:[ - Coordinate { latitude: 25; longitude: 15}, - Coordinate { latitude: 20; longitude: 19}, - Coordinate { latitude: 15; longitude: 16} + property variant preMapPolylineDefaultPath: [ + { latitude: 25, longitude: 15 }, + { latitude: 20, longitude: 19 }, + { latitude: 15, longitude: 16 } ] - property list preMapRouteDefaultPath:[ - Coordinate { latitude: 25; longitude: 14}, - Coordinate { latitude: 20; longitude: 18}, - Coordinate { latitude: 15; longitude: 15} + property variant preMapRouteDefaultPath: [ + { latitude: 25, longitude: 14 }, + { latitude: 20, longitude: 18 }, + { latitude: 15, longitude: 15 } ] - Coordinate{ id: mapCircleTopLeft; latitude: 0; longitude: 0} - Coordinate{ id: mapCircleBottomRight; latitude: 0; longitude: 0} - Coordinate{ id: mapQuickItemTopLeft; latitude: 0; longitude: 0} - Coordinate{ id: mapQuickItemBottomRight; latitude: 0; longitude: 0} - Coordinate{ id: mapPolygonTopLeft; latitude: 0; longitude: 0} - Coordinate{ id: mapPolygonBottomRight; latitude: 0; longitude: 0} - Coordinate{ id: mapPolylineTopLeft; latitude: 0; longitude: 0} - Coordinate{ id: mapPolylineBottomRight; latitude: 0; longitude: 0} - Coordinate{ id: mapRouteTopLeft; latitude: 0; longitude: 0} - Coordinate{ id: mapRouteBottomRight; latitude: 0; longitude: 0} + property variant mapCircleTopLeft: QtLocation.coordinate(0, 0) + property variant mapCircleBottomRight: QtLocation.coordinate(0, 0) + property variant mapQuickItemTopLeft: QtLocation.coordinate(0, 0) + property variant mapQuickItemBottomRight: QtLocation.coordinate(0, 0) + property variant mapPolygonTopLeft: QtLocation.coordinate(0, 0) + property variant mapPolygonBottomRight: QtLocation.coordinate(0, 0) + property variant mapPolylineTopLeft: QtLocation.coordinate(0, 0) + property variant mapPolylineBottomRight: QtLocation.coordinate(0, 0) + property variant mapRouteTopLeft: QtLocation.coordinate(0, 0) + property variant mapRouteBottomRight: QtLocation.coordinate(0, 0) GeoRectangle { id: boundingBox - topLeft: Coordinate { + topLeft { latitude: 0 longitude: 0 } - bottomRight: Coordinate { + bottomRight { latitude: 0 longitude: 0 } @@ -189,9 +189,9 @@ Item { color: 'darkgrey' border.width: 0 path: [ - Coordinate { latitude: 25; longitude: 5}, - Coordinate { latitude: 20; longitude: 10}, - Coordinate { latitude: 15; longitude: 6} + { latitude: 25, longitude: 5 }, + { latitude: 20, longitude: 10 }, + { latitude: 15, longitude: 6 } ] MapMouseArea { anchors.fill: parent @@ -207,9 +207,9 @@ Item { id: preMapPolyline line.color: 'darkred' path: [ - Coordinate { latitude: 25; longitude: 15}, - Coordinate { latitude: 20; longitude: 19}, - Coordinate { latitude: 15; longitude: 16} + { latitude: 25, longitude: 15 }, + { latitude: 20, longitude: 19 }, + { latitude: 15, longitude: 16 } ] SignalSpy {id: preMapPolylineColorChanged; target: parent.line; signalName: "colorChanged"} SignalSpy {id: preMapPolylineWidthChanged; target: parent.line; signalName: "widthChanged"} @@ -221,9 +221,9 @@ Item { // don't try this at home - route is not user instantiable route: Route { path: [ - Coordinate { latitude: 25; longitude: 14}, - Coordinate { latitude: 20; longitude: 18}, - Coordinate { latitude: 15; longitude: 15} + { latitude: 25, longitude: 14 }, + { latitude: 20, longitude: 18 }, + { latitude: 15, longitude: 15 } ] } SignalSpy {id: preMapRouteRouteChanged; target: parent; signalName: "routeChanged"} @@ -426,10 +426,8 @@ Item { var itemTopLeft = preMapCircle.center.atDistanceAndAzimuth(circleDiagonal,-45) var itemBottomRight = preMapCircle.center.atDistanceAndAzimuth(circleDiagonal,135) - mapCircleTopLeft.latitude = itemTopLeft.latitude - mapCircleTopLeft.longitude = itemTopLeft.longitude - mapCircleBottomRight.latitude = itemBottomRight.latitude - mapCircleBottomRight.longitude = itemBottomRight.longitude + mapCircleTopLeft = itemTopLeft; + mapCircleBottomRight = itemBottomRight; itemTopLeft = preMapQuickItem.coordinate var preMapQuickItemScreenPosition = map.toScreenPosition(preMapQuickItem.coordinate) @@ -437,28 +435,20 @@ Item { preMapQuickItemScreenPosition.y += preMapQuickItem.sourceItem.height itemBottomRight = map.toCoordinate(preMapQuickItemScreenPosition) - mapQuickItemTopLeft.latitude = itemTopLeft.latitude - mapQuickItemTopLeft.longitude = itemTopLeft.longitude - mapQuickItemBottomRight.latitude = itemBottomRight.latitude - mapQuickItemBottomRight.longitude = itemBottomRight.longitude + mapQuickItemTopLeft = itemTopLeft; + mapQuickItemBottomRight = itemBottomRight; var bounds = min_max_bounds_from_list(preMapPolygon.path) - mapPolygonTopLeft.latitude = bounds.topLeft.latitude - mapPolygonTopLeft.longitude = bounds.topLeft.longitude - mapPolygonBottomRight.latitude = bounds.bottomRight.latitude - mapPolygonBottomRight.longitude = bounds.bottomRight.longitude + mapPolygonTopLeft = bounds.topLeft; + mapPolygonBottomRight = bounds.bottomRight; bounds = min_max_bounds_from_list(preMapPolyline.path) - mapPolylineTopLeft.latitude = bounds.topLeft.latitude - mapPolylineTopLeft.longitude = bounds.topLeft.longitude - mapPolylineBottomRight.latitude = bounds.bottomRight.latitude - mapPolylineBottomRight.longitude = bounds.bottomRight.longitude + mapPolylineTopLeft = bounds.topLeft; + mapPolylineBottomRight = bounds.bottomRight; bounds = min_max_bounds_from_list(preMapRoute.route.path) - mapRouteTopLeft.latitude = bounds.topLeft.latitude - mapRouteTopLeft.longitude = bounds.topLeft.longitude - mapRouteBottomRight.latitude = bounds.bottomRight.latitude - mapRouteBottomRight.longitude = bounds.bottomRight.longitude + mapRouteTopLeft = bounds.topLeft; + mapRouteBottomRight = bounds.bottomRight; } function min_max_bounds_from_list(coorindates){ @@ -487,10 +477,8 @@ Item { point.y = maxY var itemBottomRight = map.toCoordinate(point) - boundingBox.topLeft.latitude = itemTopLeft.latitude - boundingBox.topLeft.longitude = itemTopLeft.longitude - boundingBox.bottomRight.latitude = itemBottomRight.latitude - boundingBox.bottomRight.longitude = itemBottomRight.longitude + boundingBox.topLeft = itemTopLeft; + boundingBox.bottomRight = itemBottomRight; return boundingBox } diff --git a/tests/auto/declarative_ui/tst_map_itemview.qml b/tests/auto/declarative_ui/tst_map_itemview.qml index 239b3856..d1566e81 100644 --- a/tests/auto/declarative_ui/tst_map_itemview.qml +++ b/tests/auto/declarative_ui/tst_map_itemview.qml @@ -50,7 +50,8 @@ Item { height: 350 // General-purpose elements for the test: Plugin { id: testPlugin; name : "qmlgeo.test.plugin"; allowExperimental: true } - Coordinate{ id: mapDefaultCenter; latitude: 10; longitude: 30} + + property variant mapDefaultCenter: QtLocation.coordinate(10, 30) Map { id: map @@ -82,9 +83,9 @@ Item { delegate: Component { MapCircle { radius: 1500000 - center: Coordinate { - latitude: modeldata.coordinate.latitude; - longitude: modeldata.coordinate.longitude; + center { + latitude: modeldata.coordinate.latitude + longitude: modeldata.coordinate.longitude } } } @@ -170,11 +171,11 @@ Item { } RouteQuery {id: routeQuery; waypoints: [ - Coordinate {id: fcoordinate1; latitude: 60; longitude: 60}, - Coordinate {id: fcoordinate2; latitude: 61; longitude: 62}, - Coordinate {id: fcoordinate3; latitude: 63; longitude: 64}, - Coordinate {id: fcoordinate4; latitude: 65; longitude: 66}, - Coordinate {id: fcoordinate5; latitude: 67; longitude: 68} + { latitude: 60, longitude: 60 }, + { latitude: 61, longitude: 62 }, + { latitude: 63, longitude: 64 }, + { latitude: 65, longitude: 66 }, + { latitude: 67, longitude: 68 } ] } @@ -199,9 +200,9 @@ Item { id: theItemViewsComponent MapCircle { radius: 1500000 - center: Coordinate { - latitude: modeldata.coordinate.latitude; - longitude: modeldata.coordinate.longitude; + center { + latitude: modeldata.coordinate.latitude + longitude: modeldata.coordinate.longitude } } } @@ -214,16 +215,9 @@ Item { plugin: testPlugin; anchors.fill: parent; zoomLevel: 2 - Coordinate { - id: firstItemCoord - latitude: 11 - longitude: 31 - } - Coordinate { - id: secondItemCoord - latitude: 12 - longitude: 32 - } + + property variant firstItemCoord: QtLocation.coordinate(11, 31) + property variant secondItemCoord: QtLocation.coordinate(12, 32) MapItemView { id: listModelItemView @@ -236,9 +230,9 @@ Item { delegate: Component { MapCircle { radius: 1500000 - center: Coordinate { - latitude: lat; - longitude: lon; + center { + latitude: lat + longitude: lon } } } @@ -344,7 +338,7 @@ Item { compare(dynamicMap2.mapItems.length, 0) // create and destroy a dynamic item that is in the map - var dynamicCircle = Qt.createQmlObject('import QtQuick 2.0; import QtLocation 5.0; MapCircle { objectName: \'dynamic circle 1\'; center: Coordinate { latitude: 5; longitude: 5 } radius: 15 } ', masterItem, "dynamicCreationErrors" ); + var dynamicCircle = Qt.createQmlObject('import QtQuick 2.0; import QtLocation 5.0; MapCircle { objectName: \'dynamic circle 1\'; center { latitude: 5; longitude: 5 } radius: 15 } ', masterItem, "dynamicCreationErrors" ); verify (dynamicCircle !== null) compare(map.mapItems.length, 0) map.addMapItem(dynamicCircle) @@ -403,12 +397,16 @@ Item { function test_listmodel() { compare(mapForTestingListModel.mapItems.length, 3); - compare(mapForTestingListModel.mapItems[0].center.longitude, firstItemCoord.longitude); - compare(mapForTestingListModel.mapItems[0].center.latitude, firstItemCoord.latitude); + compare(mapForTestingListModel.mapItems[0].center.longitude, + mapForTestingListModel.firstItemCoord.longitude); + compare(mapForTestingListModel.mapItems[0].center.latitude, + mapForTestingListModel.firstItemCoord.latitude); testingListModel.remove(0); compare(mapForTestingListModel.mapItems.length, 2); - compare(mapForTestingListModel.mapItems[0].center.longitude, secondItemCoord.longitude); - compare(mapForTestingListModel.mapItems[0].center.latitude, secondItemCoord.latitude); + compare(mapForTestingListModel.mapItems[0].center.longitude, + mapForTestingListModel.secondItemCoord.longitude); + compare(mapForTestingListModel.mapItems[0].center.latitude, + mapForTestingListModel.secondItemCoord.latitude); testingListModel.append({ lat: 1, lon: 1 }); compare(mapForTestingListModel.mapItems.length, 3); compare(mapForTestingListModel.mapItems[2].center.latitude, 1); diff --git a/tests/auto/declarative_ui/tst_map_maptype.qml b/tests/auto/declarative_ui/tst_map_maptype.qml index a73130e6..729f86f0 100644 --- a/tests/auto/declarative_ui/tst_map_maptype.qml +++ b/tests/auto/declarative_ui/tst_map_maptype.qml @@ -66,8 +66,7 @@ TestCase { Map { id: map; plugin: nokiaPlugin - center: Coordinate { - id: coordinate1 + center { latitude: 62.240501 longitude: 25.757014 } diff --git a/tests/auto/declarative_ui/tst_map_mouse.qml b/tests/auto/declarative_ui/tst_map_mouse.qml index eb715fb6..ce656f66 100644 --- a/tests/auto/declarative_ui/tst_map_mouse.qml +++ b/tests/auto/declarative_ui/tst_map_mouse.qml @@ -82,7 +82,6 @@ Item { height: 120 // General-purpose elements for the test: Plugin { id: testPlugin; name : "qmlgeo.test.plugin";} - Coordinate{ id: mapDefaultCenter; latitude: 20; longitude: 20} MapMouseEvent{ id: mapMouseEvent @@ -103,7 +102,11 @@ Item { Map { id: map; x: 0; y: 0; width: 100; height: 100 - center: mapDefaultCenter + center { + latitude: 20 + longitude: 20 + } + plugin: testPlugin; property real lastWheelAngleDeltaX: 0 diff --git a/tests/auto/declarative_ui/tst_map_pinch_and_flick.qml b/tests/auto/declarative_ui/tst_map_pinch_and_flick.qml index 08907047..970aa103 100644 --- a/tests/auto/declarative_ui/tst_map_pinch_and_flick.qml +++ b/tests/auto/declarative_ui/tst_map_pinch_and_flick.qml @@ -50,8 +50,9 @@ Item { width: 100 height: 100 Plugin { id: testPlugin; name: "qmlgeo.test.plugin"; allowExperimental: true } - Coordinate{ id: coordinate1; latitude: 10; longitude: 11} - Coordinate{ id: coordinate2; latitude: 12; longitude: 13} + + property variant coordinate1: QtLocation.coordinate(10, 11) + Map { id: map plugin: testPlugin @@ -90,9 +91,6 @@ Item { } } SignalSpy {id: centerSpy; target: map; signalName: 'centerChanged'} - SignalSpy {id: coordinate2LatitudeSpy; target: coordinate2; signalName: 'latitudeChanged'} - SignalSpy {id: coordinate2LongitudeSpy; target: coordinate2; signalName: 'longitudeChanged'} - SignalSpy {id: coordinate2AltitudeSpy; target: coordinate2; signalName: 'altitudeChanged'} SignalSpy {id: pinchStartedSpy; target: map.gesture; signalName: 'pinchStarted'} SignalSpy {id: pinchUpdatedSpy; target: map.gesture; signalName: 'pinchUpdated'} SignalSpy {id: pinchFinishedSpy; target: map.gesture; signalName: 'pinchFinished'} @@ -126,9 +124,6 @@ Item { function clear_data() { centerSpy.clear() - coordinate2AltitudeSpy.clear() - coordinate2LatitudeSpy.clear() - coordinate2LongitudeSpy.clear() pinchStartedSpy.clear() pinchUpdatedSpy.clear() pinchFinishedSpy.clear() diff --git a/tests/auto/qmlinterface/data/TestCoordinate.qml b/tests/auto/qmlinterface/data/TestCoordinate.qml deleted file mode 100644 index 0eee3066..00000000 --- a/tests/auto/qmlinterface/data/TestCoordinate.qml +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtLocation 5.0 - -Coordinate { - longitude: 10.0 - latitude: 20.0 - altitude: 30.0 -} diff --git a/tests/auto/qmlinterface/data/TestGeoCircle.qml b/tests/auto/qmlinterface/data/TestGeoCircle.qml index b505a365..d645cef2 100644 --- a/tests/auto/qmlinterface/data/TestGeoCircle.qml +++ b/tests/auto/qmlinterface/data/TestGeoCircle.qml @@ -42,6 +42,10 @@ import QtLocation 5.0 GeoCircle { - center: TestCoordinate { } + center { + longitude: 10.0 + latitude: 20.0 + altitude: 30.0 + } radius: 30.0 } diff --git a/tests/auto/qmlinterface/data/TestGeoRectangle.qml b/tests/auto/qmlinterface/data/TestGeoRectangle.qml index 14d785ce..00e0fea6 100644 --- a/tests/auto/qmlinterface/data/TestGeoRectangle.qml +++ b/tests/auto/qmlinterface/data/TestGeoRectangle.qml @@ -42,7 +42,11 @@ import QtLocation 5.0 GeoRectangle { - center: TestCoordinate { } + center { + longitude: 10.0 + latitude: 20.0 + altitude: 30.0 + } height: 30.0 width: 40.0 } diff --git a/tests/auto/qmlinterface/data/TestLocation.qml b/tests/auto/qmlinterface/data/TestLocation.qml index 046b7459..97c25e5a 100644 --- a/tests/auto/qmlinterface/data/TestLocation.qml +++ b/tests/auto/qmlinterface/data/TestLocation.qml @@ -44,5 +44,9 @@ import QtLocation 5.0 Location { address: TestAddress { } boundingBox: TestGeoRectangle { } - coordinate: TestCoordinate { } + coordinate { + longitude: 10.0 + latitude: 20.0 + altitude: 30.0 + } } diff --git a/tests/auto/qmlinterface/qmlinterface.pro b/tests/auto/qmlinterface/qmlinterface.pro index 54bfe4ae..6571fe90 100644 --- a/tests/auto/qmlinterface/qmlinterface.pro +++ b/tests/auto/qmlinterface/qmlinterface.pro @@ -20,7 +20,6 @@ DEFINES += SRCDIR=\\\"$$PWD/\\\" OTHER_FILES += \ data/TestCategory.qml \ - data/TestCoordinate.qml \ data/TestAddress.qml \ data/TestLocation.qml \ data/TestPlace.qml \ diff --git a/tests/auto/qmlinterface/tst_qmlinterface.cpp b/tests/auto/qmlinterface/tst_qmlinterface.cpp index ce3e800a..0b529e9e 100644 --- a/tests/auto/qmlinterface/tst_qmlinterface.cpp +++ b/tests/auto/qmlinterface/tst_qmlinterface.cpp @@ -65,7 +65,6 @@ public: tst_qmlinterface(); private Q_SLOTS: - void testCoordinate(); void testAddress(); void testGeoRectangle(); void testGeoCircle(); @@ -164,26 +163,6 @@ tst_qmlinterface::tst_qmlinterface() m_place.setVisibility(QtLocation::PrivateVisibility); } -void tst_qmlinterface::testCoordinate() -{ - QQmlEngine engine; - QQmlComponent component(&engine, SRCDIR "data/TestCoordinate.qml"); - QVERIFY(component.isReady()); - QObject *qmlObject = component.create(); - - QGeoCoordinate coordinate = qmlObject->property("coordinate").value(); - - QCOMPARE(coordinate, m_coordinate); - - qmlObject->setProperty("coordinate", QVariant::fromValue(QGeoCoordinate())); - - QVERIFY(qIsNaN(qmlObject->property("longitude").toDouble())); - QVERIFY(qIsNaN(qmlObject->property("latitude").toDouble())); - QVERIFY(qIsNaN(qmlObject->property("altitude").toDouble())); - - delete qmlObject; -} - void tst_qmlinterface::testAddress() { QQmlEngine engine; -- cgit v1.2.1