diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative_core/tst_routing.qml | 36 | ||||
-rw-r--r-- | tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h | 5 |
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); |