summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_core/tst_routing.qml135
-rw-r--r--tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h15
-rw-r--r--tests/auto/qgeorouterequest/tst_qgeorouterequest.cpp26
-rw-r--r--tests/auto/qgeorouterequest/tst_qgeorouterequest.h2
-rw-r--r--tests/auto/qgeoserviceprovider/tst_qgeoserviceprovider.cpp9
5 files changed, 161 insertions, 26 deletions
diff --git a/tests/auto/declarative_core/tst_routing.qml b/tests/auto/declarative_core/tst_routing.qml
index fdbfe7b6..d46184b4 100644
--- a/tests/auto/declarative_core/tst_routing.qml
+++ b/tests/auto/declarative_core/tst_routing.qml
@@ -28,10 +28,17 @@
import QtQuick 2.0
import QtTest 1.0
-import QtLocation 5.3
+import QtLocation 5.11
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: [
@@ -169,8 +176,7 @@ Item {
compare (emptyQuery.maneuverDetail, RouteQuery.BasicManeuvers)
compare (emptyQuery.waypoints.length, 0, "Waypoints")
compare (emptyQuery.excludedAreas.length, 0, "excluded areas")
- // Bug in QtQml. Todo, enable when QList<int> support is done
- //compare (emptyQuery.featureTypes.length, 0, "Feature types")
+ compare (emptyQuery.featureTypes.length, 0, "Feature types")
}
SignalSpy {id: autoUpdateSpy; target: emptyModel; signalName: "autoUpdateChanged"}
@@ -323,8 +329,7 @@ Item {
// Feature types and weights
queryDetailsChangedSpy.clear()
- // Bug in QtQml. Todo, enable when QList<int> support is done
- //compare(emptyQuery.featureTypes.length, 0)
+ compare(emptyQuery.featureTypes.length, 0)
compare(featureTypesSpy.count, 0)
emptyQuery.setFeatureWeight(RouteQuery.TollFeature, RouteQuery.AvoidFeatureWeight);
compare(featureTypesSpy.count, 1)
@@ -332,10 +337,9 @@ Item {
emptyQuery.setFeatureWeight(RouteQuery.HighwayFeature, RouteQuery.PreferFeatureWeight);
compare(featureTypesSpy.count, 2)
compare(queryDetailsChangedSpy.count, 2)
- // Bug in QtQml. Todo, enable when QList<int> support is done
- //compare(emptyQuery.featureTypes.length, 2)
- //compare(emptyQuery.featureTypes[0], RouteQuery.TollFeature)
- //compare(emptyQuery.featureTypes[1], RouteQuery.HighwayFeature)
+ compare(emptyQuery.featureTypes.length, 2)
+ compare(emptyQuery.featureTypes[0], RouteQuery.TollFeature)
+ compare(emptyQuery.featureTypes[1], RouteQuery.HighwayFeature)
// Verify feature weights are as set
compare(emptyQuery.featureWeight(RouteQuery.TollFeature), RouteQuery.AvoidFeatureWeight);
compare(emptyQuery.featureWeight(RouteQuery.HighwayFeature), RouteQuery.PreferFeatureWeight);
@@ -343,30 +347,25 @@ Item {
emptyQuery.setFeatureWeight(RouteQuery.TollFeature, RouteQuery.NeutralFeatureWeight);
compare(featureTypesSpy.count, 3)
compare(queryDetailsChangedSpy.count, 3)
- // Bug in QtQml. Todo, enable when QList<int> support is done
- //compare(emptyQuery.featureTypes.length, 1)
+ compare(emptyQuery.featureTypes.length, 1)
compare(emptyQuery.featureWeight(RouteQuery.TollFeature), RouteQuery.NeutralFeatureWeight);
compare(emptyQuery.featureWeight(RouteQuery.HighwayFeature), RouteQuery.PreferFeatureWeight);
- // Bug in QtQml. Todo, enable when QList<int> support is done
- //compare(emptyQuery.featureTypes[0], RouteQuery.HighwayFeature)
- //compare(emptyQuery.featureWeight(emptyQuery.featureTypes[0]), RouteQuery.PreferFeatureWeight)
+ compare(emptyQuery.featureTypes[0], RouteQuery.HighwayFeature)
+ compare(emptyQuery.featureWeight(emptyQuery.featureTypes[0]), RouteQuery.PreferFeatureWeight)
compare(featureTypesSpy.count, 3)
compare(queryDetailsChangedSpy.count, 3)
- // Bug in QtQml. Todo, enable when QList<int> support is done
- //compare(emptyQuery.featureTypes.length, 1)
+ compare(emptyQuery.featureTypes.length, 1)
// Put some feature weights and then reset them with NoFeature
emptyQuery.setFeatureWeight(RouteQuery.FerryFeature, RouteQuery.RequireFeatureWeight);
emptyQuery.setFeatureWeight(RouteQuery.MotorPoolLaneFeature, RouteQuery.DisallowFeatureWeight);
compare(featureTypesSpy.count, 5)
compare(queryDetailsChangedSpy.count, 5)
- // Bug in QtQml. Todo, enable when QList<int> support is done
- //compare(emptyQuery.featureTypes.length, 3)
+ compare(emptyQuery.featureTypes.length, 3)
emptyQuery.setFeatureWeight(RouteQuery.NoFeature, RouteQuery.NeutralFeatureWeight)
compare(featureTypesSpy.count, 6)
compare(queryDetailsChangedSpy.count, 6)
- // Bug in QtQml. Todo, enable when QList<int> support is done
- //compare(emptyQuery.featureTypes.length, 0)
+ compare(emptyQuery.featureTypes.length, 0)
// Segment details
queryDetailsChangedSpy.clear()
@@ -503,7 +502,7 @@ Item {
}
Plugin {
- id: bacicRoutingPlugin_slacker;
+ id: basicRoutingPlugin_slacker;
name: "qmlgeo.test.plugin"
allowExperimental: true
parameters: [
@@ -528,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
@@ -565,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"}
@@ -772,10 +789,80 @@ 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)
+
+ /* 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", 5)
+ tryCompare (automaticRoutesSpy, "count", 21)
compare (routeModelAutomatic.get(0).path.length, 3)
// Verify that the old query is disconnected internally ie. does not trigger update
@@ -787,7 +874,7 @@ Item {
{ latitude: 67, longitude: 68 }
];
wait(800) // wait to hope no further updates comes through
- compare (automaticRoutesSpy.count, 5)
+ 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 0a1e7ce6..2fc2b952 100644
--- a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
@@ -134,9 +134,24 @@ 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);
+
+ 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);
diff --git a/tests/auto/qgeorouterequest/tst_qgeorouterequest.cpp b/tests/auto/qgeorouterequest/tst_qgeorouterequest.cpp
index 5c43de65..508571c3 100644
--- a/tests/auto/qgeorouterequest/tst_qgeorouterequest.cpp
+++ b/tests/auto/qgeorouterequest/tst_qgeorouterequest.cpp
@@ -319,5 +319,31 @@ void tst_QGeoRouteRequest::featureWeight()
QVERIFY(qgeorouterequest->featureTypes().contains(type));
}
+void tst_QGeoRouteRequest::extraParameters_data()
+{
+ QTest::addColumn<QMap<QString, QVariantMap>>("extraParameters");
+
+ QMap<QString, QVariantMap> params;
+ QTest::newRow("Empty") << params;
+
+ params["param1"] = {{"property1", QVariant(42)} , {"property2", QVariant("42")} , {"property3", QVariant("42.0")}};
+
+ QTest::newRow("One param") << params;
+
+ params["param2"] = {{"property1", QVariant(43)} , {"property2", QVariant("43")} , {"property3", QVariant("43.0")}};
+
+ QTest::newRow("Two params") << params;
+}
+
+void tst_QGeoRouteRequest::extraParameters()
+{
+ typedef QMap<QString, QVariantMap> ParameterType;
+ QFETCH(ParameterType , extraParameters);
+ QMap<QString, QVariantMap> emptyParams;
+ qgeorouterequest->setExtraParameters(extraParameters);
+ QCOMPARE(qgeorouterequest->extraParameters(), extraParameters);
+ qgeorouterequest->setExtraParameters(emptyParams);
+ QCOMPARE(qgeorouterequest->extraParameters(), emptyParams);
+}
QTEST_APPLESS_MAIN(tst_QGeoRouteRequest);
diff --git a/tests/auto/qgeorouterequest/tst_qgeorouterequest.h b/tests/auto/qgeorouterequest/tst_qgeorouterequest.h
index 736510ff..12506cf6 100644
--- a/tests/auto/qgeorouterequest/tst_qgeorouterequest.h
+++ b/tests/auto/qgeorouterequest/tst_qgeorouterequest.h
@@ -72,6 +72,8 @@ private Q_SLOTS:
void maneuverDetail_data();
void featureWeight();
void featureWeight_data();
+ void extraParameters();
+ void extraParameters_data();
//End Unit Test for QGeoRouteRequest
private:
diff --git a/tests/auto/qgeoserviceprovider/tst_qgeoserviceprovider.cpp b/tests/auto/qgeoserviceprovider/tst_qgeoserviceprovider.cpp
index 6efa2f92..c21608b3 100644
--- a/tests/auto/qgeoserviceprovider/tst_qgeoserviceprovider.cpp
+++ b/tests/auto/qgeoserviceprovider/tst_qgeoserviceprovider.cpp
@@ -104,9 +104,14 @@ void tst_QGeoServiceProvider::tst_features_data()
QTest::newRow("mapbox") << QString("mapbox")
<< QGeoServiceProvider::MappingFeatures(QGeoServiceProvider::OnlineMappingFeature)
- << QGeoServiceProvider::GeocodingFeatures(QGeoServiceProvider::NoGeocodingFeatures)
+ << QGeoServiceProvider::GeocodingFeatures(QGeoServiceProvider::OnlineGeocodingFeature
+ | QGeoServiceProvider::ReverseGeocodingFeature
+ | QGeoServiceProvider::LocalizedGeocodingFeature)
<< QGeoServiceProvider::RoutingFeatures(QGeoServiceProvider::OnlineRoutingFeature)
- << QGeoServiceProvider::PlacesFeatures(QGeoServiceProvider::NoPlacesFeatures);
+ << QGeoServiceProvider::PlacesFeatures(QGeoServiceProvider::OnlinePlacesFeature
+ | QGeoServiceProvider::PlaceRecommendationsFeature
+ | QGeoServiceProvider::SearchSuggestionsFeature
+ | QGeoServiceProvider::LocalizedPlacesFeature);
QTest::newRow("here") << QString("here")
<< QGeoServiceProvider::MappingFeatures(QGeoServiceProvider::OnlineMappingFeature)