summaryrefslogtreecommitdiff
path: root/tests/auto/geotestplugin
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-07-25 17:11:32 +0200
committerBogDan Vatra <bogdan@kdab.com>2017-08-24 12:16:32 +0000
commit8ac6377e62af803b567449cdf30c669b92114cc4 (patch)
tree0a8d9d797df2dbc32524f28510712f2ceacde764 /tests/auto/geotestplugin
parent2dc1acb63777c983cfc4cbdbd2176a8dab112209 (diff)
downloadqtlocation-8ac6377e62af803b567449cdf30c669b92114cc4.tar.gz
Make QGeoRoute extensible
This change makes it possible to subclass QGeoRoute, QGeoRouteSegment or QGeoRouteManeuver, with custom private implementations. It also attempts to minimize the cost that creating a QDeclarativeGeoRoute currently has, by deferring the initialization of QDeclarativeGeoRoute::segments_ to the first access, and also populating the list only to the requested point. Change-Id: I4c87391bcc380ddca6523c748ebb97d2a44ed9d2 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'tests/auto/geotestplugin')
-rw-r--r--tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
index 0a1e7ce6..c77cb0a5 100644
--- a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
@@ -34,6 +34,7 @@
#include <QLocale>
#include <qgeoaddress.h>
#include <qgeoroutereply.h>
+#include <QtLocation/private/qgeoroute_p.h>
#include <QDebug>
#include <QTimer>
@@ -42,6 +43,24 @@
QT_USE_NAMESPACE
+class QGeoRoutePrivateDefaultAlt : public QGeoRoutePrivateDefault
+{
+public:
+ QGeoRoutePrivateDefaultAlt() {}
+ QGeoRoutePrivateDefaultAlt(const QGeoRoutePrivateDefaultAlt &other)
+ : QGeoRoutePrivateDefault(other) {}
+ ~QGeoRoutePrivateDefaultAlt() {}
+};
+
+class QGeoRouteAlt : public QGeoRoute
+{
+public:
+ QGeoRouteAlt()
+ : QGeoRoute(QExplicitlySharedDataPointer<QGeoRoutePrivate>(new QGeoRoutePrivateDefaultAlt()))
+ {
+ }
+};
+
class RouteReplyTest :public QGeoRouteReply
{
Q_OBJECT
@@ -62,6 +81,7 @@ class QGeoRoutingManagerEngineTest: public QGeoRoutingManagerEngine
int timerId_;
QGeoRouteReply::Error errorCode_;
QString errorString_;
+ bool alternateGeoRouteImplementation_;
public:
QGeoRoutingManagerEngineTest(const QVariantMap &parameters,
@@ -70,7 +90,8 @@ public:
routeReply_(0),
finishRequestImmediately_(true),
timerId_(0),
- errorCode_(QGeoRouteReply::NoError)
+ errorCode_(QGeoRouteReply::NoError),
+ alternateGeoRouteImplementation_(false)
{
Q_UNUSED(error)
Q_UNUSED(errorString)
@@ -79,6 +100,10 @@ public:
finishRequestImmediately_ = qvariant_cast<bool>(parameters.value("gc_finishRequestImmediately"));
}
+ if (parameters.contains("gc_alternateGeoRoute")) {
+ alternateGeoRouteImplementation_ = qvariant_cast<bool>(parameters.value("gc_alternateGeoRoute"));
+ }
+
setLocale(QLocale (QLocale::German, QLocale::Germany));
setSupportedFeatureTypes (
QGeoRouteRequest::NoFeature | QGeoRouteRequest::TollFeature |
@@ -136,6 +161,8 @@ public:
QList<QGeoRoute> routes;
for (int i = 0; i < request.numberAlternativeRoutes(); ++i) {
QGeoRoute route;
+ if (alternateGeoRouteImplementation_)
+ route = QGeoRouteAlt();
route.setPath(request.waypoints());
routes.append(route);
}