summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-11-06 16:21:58 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-11-30 16:20:12 +0000
commit74e0f7b414432688858ce9d82a05384b4f883688 (patch)
tree8829ceb8bca000db8383f991240832e5c1e72835 /tests
parent3e107c6d2933b4b924100d1aab18f52f7ca40edc (diff)
downloadqtlocation-74e0f7b414432688858ce9d82a05384b4f883688.tar.gz
Introduce Waypoint
This patch replaces QGeoCoordinate with Waypoint as mean to specify waypoints in a RouteQuery. This patch also adds a new invokable to RouteQuery, waypointObjects, to return QDeclarativeGeoWaypoints instead of QGeoCooordinates. NOTE: If, by 5.11, support to perform implicit conversions in method invocations based on converters registered in the metatype system will be added, this method could/should be removed, and QDeclarativeGeoWaypoint objects should be return as QVariants from the waypoints() getter, as they could be used in place of QGeoCoordinate when passing them as arguments. Task-number: QTBUG-64066 Change-Id: I77747f53cdcbabe6430580b60fa59d4afe8c650a Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_core/tst_routing.qml73
-rw-r--r--tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h10
2 files changed, 78 insertions, 5 deletions
diff --git a/tests/auto/declarative_core/tst_routing.qml b/tests/auto/declarative_core/tst_routing.qml
index e68f1fea..6884cdc0 100644
--- a/tests/auto/declarative_core/tst_routing.qml
+++ b/tests/auto/declarative_core/tst_routing.qml
@@ -28,7 +28,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtLocation 5.3
+import QtLocation 5.10
import QtPositioning 5.2
Item {
@@ -502,7 +502,7 @@ Item {
}
Plugin {
- id: bacicRoutingPlugin_slacker;
+ id: basicRoutingPlugin_slacker;
name: "qmlgeo.test.plugin"
allowExperimental: true
parameters: [
@@ -527,6 +527,24 @@ Item {
property variant f2coordinate2: QtPositioning.coordinate(61, 62)
property variant f2coordinate3: QtPositioning.coordinate(63, 64)
+ Waypoint {
+ id: waypoint1
+ coordinate: QtPositioning.coordinate(70, 70)
+ bearing: 42
+ }
+
+ Waypoint {
+ id: waypoint2
+ coordinate: QtPositioning.coordinate(71, 71)
+ bearing: 43
+
+ MapParameter {
+ id: param1
+ type: "user_distance"
+ property real distance: 10
+ }
+ }
+
RouteQuery {id: routeQuery}
RouteQuery {
id: filledRouteQuery
@@ -564,7 +582,7 @@ Item {
SignalSpy {id: testErrorSpy; target: routeModel; signalName: "errorChanged"}
SignalSpy {id: testWaypointsSpy; target: routeQuery; signalName: "waypointsChanged"}
- RouteModel {id: routeModelSlack; plugin: bacicRoutingPlugin_slacker; query: routeQuery }
+ RouteModel {id: routeModelSlack; plugin: basicRoutingPlugin_slacker; query: routeQuery }
SignalSpy {id: testRoutesSlackSpy; target: routeModelSlack; signalName: "routesChanged"}
SignalSpy {id: testCountSlackSpy; target: routeModelSlack; signalName: "countChanged" }
SignalSpy {id: testStatusSlackSpy; target: routeModelSlack; signalName: "statusChanged"}
@@ -796,10 +814,55 @@ Item {
tryCompare (automaticRoutesSpy, "count", 9)
compare(routeModelAutomatic.get(0).travelTime, 0)
+ /* Test waypoints */
+ // Verify that bearing is NaN for coordinates
+ verify(isNaN(filledRouteQuery.waypointObjects()[0].bearing))
+ var numWaypoints = filledRouteQuery.waypoints.length
+ // Add a waypoint with bearing
+ filledRouteQuery.addWaypoint(waypoint1)
+ tryCompare (automaticRoutesSpy, "count", 10)
+ compare(filledRouteQuery.waypointObjects()[numWaypoints].bearing, 42)
+ // testing Waypoint to coordinate conversion
+ compare(filledRouteQuery.waypoints[numWaypoints], filledRouteQuery.waypointObjects()[numWaypoints].coordinate)
+ waypoint1.latitude += 0.1
+ compare(routeModelAutomatic.get(0).distance, 0)
+ tryCompare (automaticRoutesSpy, "count", 11)
+ numWaypoints++;
+ filledRouteQuery.addWaypoint(waypoint2)
+ numWaypoints++;
+ tryCompare (automaticRoutesSpy, "count", 12)
+ compare(filledRouteQuery.waypointObjects()[numWaypoints-1].bearing, 43)
+ compare(routeModelAutomatic.get(0).distance, 10)
+ waypoint1.latitude += 0.1
+ tryCompare (automaticRoutesSpy, "count", 13)
+ waypoint2.latitude += 0.1
+ tryCompare (automaticRoutesSpy, "count", 14)
+ filledRouteQuery.removeWaypoint(waypoint1)
+ tryCompare (automaticRoutesSpy, "count", 15)
+ waypoint2.latitude += 0.1
+ tryCompare (automaticRoutesSpy, "count", 16)
+ waypoint1.latitude += 0.1
+ tryCompare (automaticRoutesSpy, "count", 16) // No effect, now disconnected
+ // test with other props
+ waypoint2.longitude += 0.1
+ tryCompare (automaticRoutesSpy, "count", 17)
+ waypoint2.altitude = 42
+ tryCompare (automaticRoutesSpy, "count", 18)
+ waypoint2.bearing += 1
+ tryCompare (automaticRoutesSpy, "count", 19)
+ compare(waypoint2.longitude, 71.1)
+ compare(waypoint2.altitude, 42)
+ compare(waypoint2.bearing, 44)
+ // test with map parameters
+ param1.distance = 42
+ tryCompare (automaticRoutesSpy, "count", 20)
+ compare(routeModelAutomatic.get(0).distance, 42)
+
+
// Change query
routeModelAutomatic.query = filledRouteQuery2
filledRouteQuery2.numberAlternativeRoutes = 3
- tryCompare (automaticRoutesSpy, "count", 10)
+ tryCompare (automaticRoutesSpy, "count", 21)
compare (routeModelAutomatic.get(0).path.length, 3)
// Verify that the old query is disconnected internally ie. does not trigger update
@@ -811,7 +874,7 @@ Item {
{ latitude: 67, longitude: 68 }
];
wait(800) // wait to hope no further updates comes through
- compare (automaticRoutesSpy.count, 10)
+ compare (automaticRoutesSpy.count, 21)
compare(routeModelAutomatic.get(0).path.length, 3);
}
diff --git a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
index f4067857..2fc2b952 100644
--- a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
@@ -142,6 +142,16 @@ public:
QGeoRoute route;
route.setPath(request.waypoints());
route.setTravelTime(travelTime);
+
+ const QList<QVariantMap> metadata = request.waypointsMetadata();
+ for (const auto &meta: metadata) {
+ if (meta.contains("extra")) {
+ QVariantMap extra = meta.value("extra").toMap();
+ if (extra.contains("user_distance"))
+ route.setDistance(meta.value("extra").toMap().value("user_distance").toMap().value("distance").toDouble());
+ }
+ }
+
routes.append(route);
}
reply->callSetRoutes(routes);