summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-11-06 14:02:36 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-11-29 23:02:35 +0000
commit3e107c6d2933b4b924100d1aab18f52f7ca40edc (patch)
tree20b87cef43353cad503f2cf294f21d4755130691 /tests
parentefcffce97117f571fcf4bf745426eb36ef784804 (diff)
Allow to specify extra parameters in RouteQuery using MapParameters
This patch works on top of the previous one, and passes the content of the map parameters as a QMap<QString, QVariantMap>, where the key is the parameter type and the value is a map<property name, property value> of all properties of the map parameter except for the property "type". To achieve this, a new list property, quickChildren, has been added to RouteQuery, to pick up Map Parameters declared inside the query Change-Id: I364f5438e8f4cfc42430bfe448d96519c407eb74 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_core/tst_routing.qml36
-rw-r--r--tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h5
2 files changed, 39 insertions, 2 deletions
diff --git a/tests/auto/declarative_core/tst_routing.qml b/tests/auto/declarative_core/tst_routing.qml
index c1aaea67..e68f1fea 100644
--- a/tests/auto/declarative_core/tst_routing.qml
+++ b/tests/auto/declarative_core/tst_routing.qml
@@ -32,6 +32,13 @@ import QtLocation 5.3
import QtPositioning 5.2
Item {
+ id: root
+ function cloneArray(a) {
+ var i = a.length
+ var arr = new Array(i)
+ while (i--) arr[i] = a[i];
+ return arr
+ }
Plugin { id: testPlugin; name: "qmlgeo.test.plugin"; allowExperimental: true }
Plugin { id: errorPlugin; name: "qmlgeo.test.plugin"; allowExperimental: true
parameters: [
@@ -764,10 +771,35 @@ Item {
tryCompare (automaticRoutesSpy, "count", 4)
compare(routeModelAutomatic.get(0).path[0].latitude, fcoordinate1.latitude + 1) // new value should be echoed
+ // Extra parameter
+ var param = Qt.createQmlObject ('import QtLocation 5.9; MapParameter { type : "test-traveltime"; property var requestedTime : 42}', root)
+ var initialParams = cloneArray(filledRouteQuery.quickChildren)
+ var modifiedParams = cloneArray(initialParams)
+ modifiedParams.push(param)
+
+ filledRouteQuery.quickChildren = modifiedParams
+ tryCompare (automaticRoutesSpy, "count", 5)
+ compare(routeModelAutomatic.get(0).travelTime, 42)
+ param.requestedTime = 43
+ tryCompare (automaticRoutesSpy, "count", 6)
+ compare(routeModelAutomatic.get(0).travelTime, 43)
+ filledRouteQuery.quickChildren = initialParams
+ tryCompare (automaticRoutesSpy, "count", 7)
+ compare(routeModelAutomatic.get(0).travelTime, 0)
+ var secondParam = Qt.createQmlObject ('import QtLocation 5.9; MapParameter { type : "foo"; property var bar : 42}', root)
+ modifiedParams.push(secondParam)
+ param.requestedTime = 44
+ filledRouteQuery.quickChildren = modifiedParams
+ tryCompare (automaticRoutesSpy, "count", 8)
+ compare(routeModelAutomatic.get(0).travelTime, 44)
+ filledRouteQuery.quickChildren = initialParams
+ tryCompare (automaticRoutesSpy, "count", 9)
+ compare(routeModelAutomatic.get(0).travelTime, 0)
+
// Change query
routeModelAutomatic.query = filledRouteQuery2
filledRouteQuery2.numberAlternativeRoutes = 3
- tryCompare (automaticRoutesSpy, "count", 5)
+ tryCompare (automaticRoutesSpy, "count", 10)
compare (routeModelAutomatic.get(0).path.length, 3)
// Verify that the old query is disconnected internally ie. does not trigger update
@@ -779,7 +811,7 @@ Item {
{ latitude: 67, longitude: 68 }
];
wait(800) // wait to hope no further updates comes through
- compare (automaticRoutesSpy.count, 5)
+ compare (automaticRoutesSpy.count, 10)
compare(routeModelAutomatic.get(0).path.length, 3);
}
diff --git a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
index 0a1e7ce6..f4067857 100644
--- a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
@@ -134,9 +134,14 @@ public:
void setRoutes(const QGeoRouteRequest& request, RouteReplyTest* reply)
{
QList<QGeoRoute> routes;
+ int travelTime = 0;
+ if (request.extraParameters().contains("test-traveltime"))
+ travelTime = request.extraParameters().value("test-traveltime").value("requestedTime").toInt();
+
for (int i = 0; i < request.numberAlternativeRoutes(); ++i) {
QGeoRoute route;
route.setPath(request.waypoints());
+ route.setTravelTime(travelTime);
routes.append(route);
}
reply->callSetRoutes(routes);