diff options
author | Alex Wilson <alex.wilson@nokia.com> | 2012-02-28 13:05:02 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-05 04:22:24 +0100 |
commit | 0287bfee05840511c12100f06f9142e3e2b8f7d5 (patch) | |
tree | f5386e27a4b012877d37ab0b99dfc1d5a08705c5 /tests | |
parent | c1d56bdae90f79d466769aa7a357d78a4f2ca6c7 (diff) | |
download | qtlocation-0287bfee05840511c12100f06f9142e3e2b8f7d5.tar.gz |
New plugin API changes, centralized geoservice feature detection
This change adapts geoservice plugins to use the new Qt5 plugin API,
performing boolean feature detection all through the JSON blobs
rather than methods on factories or managers.
As a result of this centralisation, it was also necessary to rework
the QML API for the Plugin element a little. Some additional changes
were made to the declarative places plugin to prevent it crashing
due to plugins becoming available later than they did previously.
Task-number: QTBUG-24331
Change-Id: I26149987344b67091480449103ab1712c869b2a5
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'tests')
28 files changed, 167 insertions, 184 deletions
diff --git a/tests/auto/declarative_core/tst_plugin.qml b/tests/auto/declarative_core/tst_plugin.qml index 683a028d..32ba7e1c 100644 --- a/tests/auto/declarative_core/tst_plugin.qml +++ b/tests/auto/declarative_core/tst_plugin.qml @@ -45,6 +45,7 @@ import QtLocation 5.0 Item { + Plugin { id: unattachedPlugin } Plugin { id: nokiaPlugin; name: "nokia"} Plugin { id: invalidPlugin; name: "invalid"} Plugin { id: testPlugin; @@ -56,9 +57,15 @@ Item { PluginParameter { name: "validateWellKnownValues"; value: true} ] } - Plugin { id: requiredPlugin; required: Plugin.MappingFeature | Plugin.GeocodingFeature } - SignalSpy {id: invalidFeaturesSpy; target: invalidPlugin; signalName: "supportedFeaturesChanged"} - SignalSpy {id: invalidSupportedPlacesFeaturesSpy; target: invalidPlugin; signalName: "supportedPlacesFeaturesChanged"} + SignalSpy {id: invalidAttachedSpy; target: invalidPlugin; signalName: "attached"} + + Plugin { id: requiredPlugin; + required { + mapping: Plugin.OfflineMappingFeature; + geocoding: Plugin.OfflineGeocodingFeature; + places: Plugin.AnyPlacesFeatures; + } + } TestCase { name: "Plugin properties" @@ -67,68 +74,65 @@ Item { verify (invalidPlugin.availableServiceProviders.indexOf('qmlgeo.test.plugin') > -1) // at least test plugin must be present // invalid plugins should have no features - compare(invalidPlugin.supported, Plugin.NoFeatures) + verify(invalidPlugin.isAttached) + verify(!(invalidPlugin.supportsMapping())) + verify(!(invalidPlugin.supportsGeocoding())) + verify(!(invalidPlugin.supportsRouting())) + verify(!(invalidPlugin.supportsPlaces())) if (invalidPlugin.availableServiceProviders.indexOf('qmlgeo.test.plugin') > -1) { - var nokiaFeatures = (Plugin.GeocodingFeature | - Plugin.ReverseGeocodingFeature | - Plugin.RoutingFeature | - Plugin.MappingFeature | - Plugin.AnyPlacesFeature) - compare(nokiaPlugin.supported & nokiaFeatures, nokiaFeatures) + verify(testPlugin.isAttached) + verify(testPlugin.supportsMapping()) + verify(testPlugin.supportsGeocoding()) + verify(testPlugin.supportsPlaces()) + verify(testPlugin.supportsRouting()) } - var testFeatures = (Plugin.GeocodingFeature | - Plugin.ReverseGeocodingFeature | - Plugin.RoutingFeature | - Plugin.MappingFeature | - Plugin.AnyPlacesFeature) - compare(testPlugin.supported & testFeatures, testFeatures) + if (invalidPlugin.availableServiceProviders.indexOf('nokia')) { + verify(nokiaPlugin.isAttached) + verify(nokiaPlugin.supportsMapping(Plugin.OnlineMappingFeature)) + verify(nokiaPlugin.supportsGeocoding(Plugin.OnlineGeocodingFeature)) + verify(nokiaPlugin.supportsRouting(Plugin.OnlineRoutingFeature)) + } + + verify(!unattachedPlugin.isAttached) // test changing name of plugin - invalidFeaturesSpy.clear() - compare(invalidFeaturesSpy.count, 0) + invalidAttachedSpy.clear() + compare(invalidAttachedSpy.count, 0) invalidPlugin.name = 'qmlgeo.test.plugin' - compare(invalidFeaturesSpy.count, 1) - compare(invalidPlugin.supported & testFeatures, testFeatures) + tryCompare(invalidAttachedSpy, 'count', 1) + verify(invalidPlugin.isAttached) + + verify(invalidPlugin.supportsMapping()) + verify(invalidPlugin.supportsGeocoding()) + verify(invalidPlugin.supportsRouting()) + verify(invalidPlugin.supportsPlaces()) invalidPlugin.name = '' - compare(invalidFeaturesSpy.count, 2) + compare(invalidAttachedSpy.count, 2) - compare(invalidPlugin.supported, Plugin.NoFeatures) + verify(!invalidPlugin.supportsMapping()) + verify(!invalidPlugin.supportsGeocoding()) + verify(!invalidPlugin.supportsRouting()) + verify(!invalidPlugin.supportsPlaces()) } function test_required() { // the required plugin should either get nokia or qmlgeo.test.plugin // either way the name will be non-empty and it'll meet the spec verify(requiredPlugin.name !== "") - verify((requiredPlugin.supported & requiredPlugin.required) === requiredPlugin.required) + verify(requiredPlugin.supportsMapping(requiredPlugin.required.mapping)) + verify(requiredPlugin.supportsGeocoding(requiredPlugin.required.geocoding)) + verify(requiredPlugin.supportsPlaces(requiredPlugin.required.places)) } function test_placesFeatures() { - verify((testPlugin.supportedPlacesFeatures & Plugin.SavePlaceFeature) === Plugin.SavePlaceFeature); - verify((testPlugin.supportedPlacesFeatures & Plugin.SaveCategoryFeature) === Plugin.SaveCategoryFeature); - verify((testPlugin.supportedPlacesFeatures & Plugin.SearchSuggestionsFeature) === Plugin.SearchSuggestionsFeature); - verify((testPlugin.supportedPlacesFeatures & Plugin.CorrectionsFeature) === 0); - verify((testPlugin.supportedPlacesFeatures & Plugin.RemovePlaceFeature) === 0); - - verify((nokiaPlugin.supportedPlacesFeatures & Plugin.SavePlaceFeature) === 0); - verify((nokiaPlugin.supportedPlacesFeatures & Plugin.RemovePlaceFeature) === 0); - verify((nokiaPlugin.supportedPlacesFeatures & Plugin.SaveCategoryFeature) === 0); - verify((nokiaPlugin.supportedPlacesFeatures & Plugin.RemoveCategoryFeature) === 0); - verify((nokiaPlugin.supportedPlacesFeatures & Plugin.RecommendationsFeature) === Plugin.RecommendationsFeature); - verify((nokiaPlugin.supportedPlacesFeatures & Plugin.SearchSuggestionsFeature) === Plugin.SearchSuggestionsFeature); - verify((nokiaPlugin.supportedPlacesFeatures & Plugin.CorrectionsFeature) === Plugin.CorrectionsFeature); - verify((nokiaPlugin.supportedPlacesFeatures & Plugin.LocaleFeature) === Plugin.LocaleFeature); - - invalidSupportedPlacesFeaturesSpy.clear(); - invalidPlugin.name = 'qmlgeo.test.plugin'; - compare(invalidSupportedPlacesFeaturesSpy.count, 1); - invalidPlugin.name = ''; - compare(invalidSupportedPlacesFeaturesSpy.count, 2); - - invalidFeaturesSpy.clear(); - invalidSupportedPlacesFeaturesSpy.clear(); + verify(testPlugin.supportsPlaces(Plugin.SavePlaceFeature)) + verify(testPlugin.supportsPlaces(Plugin.SaveCategoryFeature)) + verify(testPlugin.supportsPlaces(Plugin.SearchSuggestionsFeature)) + verify(!testPlugin.supportsPlaces(Plugin.CorrectionsFeature)) + verify(!testPlugin.supportsPlaces(Plugin.RemovePlaceFeature)) } function test_locale() { diff --git a/tests/auto/geotestplugin/geotestplugin.json b/tests/auto/geotestplugin/geotestplugin.json new file mode 100644 index 00000000..a43e43c7 --- /dev/null +++ b/tests/auto/geotestplugin/geotestplugin.json @@ -0,0 +1,19 @@ +{ + "Keys": ["qmlgeo.test.plugin"], + "Provider": "qmlgeo.test.plugin", + "Version": 100, + "Experimental": false, + "Features": [ + "OfflineMappingFeature", + "OfflineRoutingFeature", + "AlternativeRoutesFeature", + "ExcludeAreasRoutingFeature", + "RouteUpdatesFeature", + "OfflineGeocodingFeature", + "ReverseGeocodingFeature", + "OfflinePlacesFeature", + "SavePlaceFeature", + "SaveCategoryFeature", + "SearchSuggestionsFeature" + ] +} diff --git a/tests/auto/geotestplugin/geotestplugin.pro b/tests/auto/geotestplugin/geotestplugin.pro index d12454fc..bfed371b 100644 --- a/tests/auto/geotestplugin/geotestplugin.pro +++ b/tests/auto/geotestplugin/geotestplugin.pro @@ -17,3 +17,6 @@ SOURCES += qgeoserviceproviderplugin_test.cpp target.path += $$[QT_INSTALL_PLUGINS]/geoservices INSTALLS += target + +OTHER_FILES += \ + geotestplugin.json diff --git a/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h b/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h index 51fe3dd0..78914c61 100644 --- a/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h +++ b/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h @@ -100,8 +100,6 @@ public: if (parameters.contains("validateWellKnownValues")) validateWellKnownValues_ = qvariant_cast<bool>(parameters.value("validateWellKnownValues")); - setSupportsGeocoding(supported_); - setSupportsReverseGeocoding(supported_); setLocale(QLocale (QLocale::German, QLocale::Germany)); } diff --git a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h index e672782a..9cf3b847 100644 --- a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h +++ b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h @@ -120,9 +120,6 @@ public: QGeoRouteRequest::CarTravel | QGeoRouteRequest::PedestrianTravel | QGeoRouteRequest::BicycleTravel | QGeoRouteRequest::PublicTransitTravel | QGeoRouteRequest::TruckTravel ); - setSupportsAlternativeRoutes ( true ); - setSupportsExcludeAreas ( true ); - setSupportsRouteUpdates ( true ); } virtual QGeoRouteReply* calculateRoute(const QGeoRouteRequest& request) diff --git a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp index dc79e90c..5b5b095a 100644 --- a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp +++ b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp @@ -55,21 +55,6 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest() { } -QString QGeoServiceProviderFactoryTest::providerName() const -{ - return "qmlgeo.test.plugin"; -} - -QStringList QGeoServiceProviderFactoryTest::keys() const -{ - return QStringList() << QLatin1String("qmlgeo.test.plugin"); -} - -int QGeoServiceProviderFactoryTest::providerVersion() const -{ - return 3; -} - QGeoRoutingManagerEngine* QGeoServiceProviderFactoryTest::createRoutingManagerEngine ( const QMap<QString, QVariant> & parameters, QGeoServiceProvider::Error * error, QString * errorString ) const @@ -100,5 +85,3 @@ QPlaceManagerEngine* QGeoServiceProviderFactoryTest::createPlaceManagerEngine( Q_UNUSED(errorString); return new QPlaceManagerEngineTest(parameters); } - -Q_EXPORT_PLUGIN2(qtgeoservices_qmltestplugin, QGeoServiceProviderFactoryTest) diff --git a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h index d81137b8..7508e6d0 100644 --- a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h +++ b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h @@ -50,16 +50,14 @@ QT_USE_NAMESPACE class QGeoServiceProviderFactoryTest: public QObject, public QGeoServiceProviderFactory { Q_OBJECT - Q_INTERFACES(QGeoServiceProviderFactory:QFactoryInterface) + Q_INTERFACES(QGeoServiceProviderFactory) + Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0" + FILE "geotestplugin.json") + public: QGeoServiceProviderFactoryTest(); ~QGeoServiceProviderFactoryTest(); - QString providerName() const; - int providerVersion() const; - QStringList keys() const; - - QGeoMappingManagerEngine* createMappingManagerEngine ( const QMap<QString, QVariant> & parameters, QGeoServiceProvider::Error * error, QString * errorString ) const; diff --git a/tests/auto/geotestplugin/qplacemanagerengine_test.h b/tests/auto/geotestplugin/qplacemanagerengine_test.h index 9149e4c5..c04035e4 100644 --- a/tests/auto/geotestplugin/qplacemanagerengine_test.h +++ b/tests/auto/geotestplugin/qplacemanagerengine_test.h @@ -394,12 +394,6 @@ public: } } - QPlaceManager::ManagerFeatures supportedFeatures() const { - return QPlaceManager::SavePlaceFeature - | QPlaceManager::SaveCategoryFeature - | QPlaceManager::SearchSuggestionsFeature; - } - QPlace compatiblePlace(const QPlace &original) const { QPlace place; place.setName(original.name()); diff --git a/tests/auto/placesplugin_unsupported/placesplugin.json b/tests/auto/placesplugin_unsupported/placesplugin.json new file mode 100644 index 00000000..6749962a --- /dev/null +++ b/tests/auto/placesplugin_unsupported/placesplugin.json @@ -0,0 +1,8 @@ +{ + "Keys": ["test.places.unsupported"], + "Provider": "test.places.unsupported", + "Version": 1, + "Experimental": true, + "Features": [ + ] +} diff --git a/tests/auto/placesplugin_unsupported/placesplugin_unsupported.pro b/tests/auto/placesplugin_unsupported/placesplugin_unsupported.pro index 126e673e..5bbf6bc7 100644 --- a/tests/auto/placesplugin_unsupported/placesplugin_unsupported.pro +++ b/tests/auto/placesplugin_unsupported/placesplugin_unsupported.pro @@ -11,3 +11,6 @@ SOURCES += qgeoserviceproviderplugin_test.cpp target.path += $$[QT_INSTALL_PLUGINS]/geoservices INSTALLS += target + +OTHER_FILES += \ + placesplugin.json diff --git a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp index be33c6e9..ba4b6832 100644 --- a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp +++ b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp @@ -52,21 +52,6 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest() { } -QString QGeoServiceProviderFactoryTest::providerName() const -{ - return "test.places.unsupported"; -} - -QStringList QGeoServiceProviderFactoryTest::keys() const -{ - return QStringList() << QLatin1String("test.places.unsupported"); -} - -int QGeoServiceProviderFactoryTest::providerVersion() const -{ - return 1; -} - QPlaceManagerEngine *QGeoServiceProviderFactoryTest::createPlaceManagerEngine( const QMap<QString, QVariant> ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const @@ -76,5 +61,3 @@ QPlaceManagerEngine *QGeoServiceProviderFactoryTest::createPlaceManagerEngine( return new QPlaceManagerEngine(parameters); } - -Q_EXPORT_PLUGIN2(qtgeoservices_placesplugin_unsupported, QGeoServiceProviderFactoryTest) diff --git a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h index fb90fed5..6e7b0962 100644 --- a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h +++ b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h @@ -49,16 +49,14 @@ QT_USE_NAMESPACE class QGeoServiceProviderFactoryTest : public QObject, public QGeoServiceProviderFactory { Q_OBJECT - Q_INTERFACES(QGeoServiceProviderFactory:QFactoryInterface) + Q_INTERFACES(QGeoServiceProviderFactory) + Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0" + FILE "placesplugin.json") public: QGeoServiceProviderFactoryTest(); ~QGeoServiceProviderFactoryTest(); - QString providerName() const; - int providerVersion() const; - QStringList keys() const; - QPlaceManagerEngine *createPlaceManagerEngine(const QMap<QString, QVariant> ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; diff --git a/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp index 7a292bec..8e72064c 100644 --- a/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp +++ b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp @@ -76,22 +76,22 @@ void tst_QGeocodingManager::cleanup() void tst_QGeocodingManager::loadGeocodingManager() { QStringList providers = QGeoServiceProvider::availableServiceProviders(); - QVERIFY(providers.contains("static.geocode.test.plugin")); + QVERIFY(providers.contains("geocode.test.plugin")); - qgeoserviceprovider = new QGeoServiceProvider("static.geocode.test.plugin"); + qgeoserviceprovider = new QGeoServiceProvider("geocode.test.plugin"); QVERIFY(qgeoserviceprovider); + QCOMPARE(qgeoserviceprovider->error(), QGeoServiceProvider::NotSupportedError); + + qgeoserviceprovider->setAllowExperimental(true); QCOMPARE(qgeoserviceprovider->error(), QGeoServiceProvider::NoError); + QCOMPARE(qgeoserviceprovider->geocodingFeatures(), + QGeoServiceProvider::OfflineGeocodingFeature + | QGeoServiceProvider::ReverseGeocodingFeature); qgeocodingmanager = qgeoserviceprovider->geocodingManager(); QVERIFY(qgeocodingmanager); } -void tst_QGeocodingManager::supports() -{ - QVERIFY(qgeocodingmanager->supportsGeocoding()); - QVERIFY(qgeocodingmanager->supportsReverseGeocoding()); -} - void tst_QGeocodingManager::locale() { QLocale *german = new QLocale (QLocale::German, QLocale::Germany); @@ -112,13 +112,13 @@ void tst_QGeocodingManager::locale() void tst_QGeocodingManager::name() { - QString name = "static.geocode.test.plugin"; + QString name = "geocode.test.plugin"; QCOMPARE(qgeocodingmanager->managerName(),name); } void tst_QGeocodingManager::version() { - int version=3; + int version=100; QCOMPARE(qgeocodingmanager->managerVersion(),version); } diff --git a/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h index 70156dc3..e006d7c9 100644 --- a/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h +++ b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h @@ -67,7 +67,6 @@ private Q_SLOTS: void cleanupTestCase(); void init(); void cleanup(); - void supports(); void locale(); void name(); void version(); diff --git a/tests/auto/qgeocodingmanagerplugins/geocoding_plugin.json b/tests/auto/qgeocodingmanagerplugins/geocoding_plugin.json new file mode 100644 index 00000000..9ac93536 --- /dev/null +++ b/tests/auto/qgeocodingmanagerplugins/geocoding_plugin.json @@ -0,0 +1,10 @@ +{ + "Keys": ["geocode.test.plugin"], + "Provider": "geocode.test.plugin", + "Version": 100, + "Experimental": true, + "Features": [ + "OfflineGeocodingFeature", + "ReverseGeocodingFeature" + ] +} diff --git a/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h b/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h index 4c1a2e66..c502010f 100644 --- a/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h +++ b/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h @@ -80,8 +80,6 @@ public: { Q_UNUSED(error) Q_UNUSED(errorString) - setSupportsGeocoding(true); - setSupportsReverseGeocoding(true); setLocale(QLocale(QLocale::German, QLocale::Germany)); } diff --git a/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerplugins.pro b/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerplugins.pro index 3c41a645..936eb2f2 100644 --- a/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerplugins.pro +++ b/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerplugins.pro @@ -12,3 +12,6 @@ SOURCES += qgeoserviceproviderplugin_test.cpp target.path += $$[QT_INSTALL_PLUGINS]/geoservices INSTALLS += target + +OTHER_FILES += \ + geocoding_plugin.json diff --git a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp index 8c787804..32c27ce4 100644 --- a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp +++ b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp @@ -52,25 +52,8 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest() { } -QString QGeoServiceProviderFactoryTest::providerName() const -{ - return "static.geocode.test.plugin"; -} - -QStringList QGeoServiceProviderFactoryTest::keys() const -{ - return QStringList() << QLatin1String("static.geocode.test.plugin"); -} - -int QGeoServiceProviderFactoryTest::providerVersion() const -{ - return 3; -} - QGeocodingManagerEngine* QGeoServiceProviderFactoryTest::createGeocodingManagerEngine(const QMap< QString, QVariant> ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const { return new QGeocodingManagerEngineTest(parameters, error, errorString); } - -Q_EXPORT_PLUGIN2(qtgeoservices_staticgeocodingplugin, QGeoServiceProviderFactoryTest) diff --git a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h index 713af50c..8c8d6b23 100644 --- a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h +++ b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h @@ -50,15 +50,14 @@ QT_USE_NAMESPACE class QGeoServiceProviderFactoryTest: public QObject, public QGeoServiceProviderFactory { Q_OBJECT - Q_INTERFACES(QGeoServiceProviderFactory:QFactoryInterface) + Q_INTERFACES(QGeoServiceProviderFactory) + Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0" + FILE "geocoding_plugin.json") + public: QGeoServiceProviderFactoryTest(); ~QGeoServiceProviderFactoryTest(); - QString providerName() const; - int providerVersion() const; - QStringList keys() const; - QGeocodingManagerEngine* createGeocodingManagerEngine(const QMap<QString, QVariant> ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; }; diff --git a/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp b/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp index 5c08cf49..7044f7b5 100644 --- a/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp +++ b/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp @@ -68,10 +68,18 @@ void tst_QGeoRoutingManager::cleanup() void tst_QGeoRoutingManager::loadRoutingManager() { QStringList providers = QGeoServiceProvider::availableServiceProviders(); - QVERIFY(providers.contains("static.georoute.test.plugin")); + QVERIFY(providers.contains("georoute.test.plugin")); - qgeoserviceprovider = new QGeoServiceProvider("static.georoute.test.plugin"); + qgeoserviceprovider = new QGeoServiceProvider("georoute.test.plugin"); QVERIFY(qgeoserviceprovider); + QCOMPARE(qgeoserviceprovider->error(), QGeoServiceProvider::NotSupportedError); + qgeoserviceprovider->setAllowExperimental(true); + + QCOMPARE(qgeoserviceprovider->routingFeatures(), + QGeoServiceProvider::OfflineRoutingFeature + | QGeoServiceProvider::AlternativeRoutesFeature + | QGeoServiceProvider::RouteUpdatesFeature + | QGeoServiceProvider::ExcludeAreasRoutingFeature); QCOMPARE(qgeoserviceprovider->error(), QGeoServiceProvider::NoError); qgeoroutingmanager = qgeoserviceprovider->routingManager(); @@ -81,9 +89,6 @@ void tst_QGeoRoutingManager::loadRoutingManager() void tst_QGeoRoutingManager::supports() { - QVERIFY(qgeoroutingmanager->supportsAlternativeRoutes()); - QVERIFY(qgeoroutingmanager->supportsRouteUpdates()); - QVERIFY(qgeoroutingmanager->supportsExcludeAreas()); QCOMPARE(qgeoroutingmanager->supportedTravelModes(),QGeoRouteRequest::PedestrianTravel); QCOMPARE(qgeoroutingmanager->supportedFeatureTypes(),QGeoRouteRequest::TollFeature); QCOMPARE(qgeoroutingmanager->supportedFeatureWeights(),QGeoRouteRequest::PreferFeatureWeight); @@ -109,13 +114,13 @@ void tst_QGeoRoutingManager::locale() void tst_QGeoRoutingManager::name() { - QString name = "static.georoute.test.plugin"; + QString name = "georoute.test.plugin"; QCOMPARE(qgeoroutingmanager->managerName(), name); } void tst_QGeoRoutingManager::version() { - QCOMPARE(qgeoroutingmanager->managerVersion(), 2); + QCOMPARE(qgeoroutingmanager->managerVersion(), 100); } void tst_QGeoRoutingManager::calculate() diff --git a/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h b/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h index 0736e3d1..6fd61132 100644 --- a/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h +++ b/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h @@ -61,9 +61,6 @@ public: { Q_UNUSED(error) Q_UNUSED(errorString) - setSupportsRouteUpdates(true); - setSupportsAlternativeRoutes(true); - setSupportsExcludeAreas(true); setSupportedTravelModes(QGeoRouteRequest::PedestrianTravel); setSupportedFeatureTypes(QGeoRouteRequest::TollFeature); setSupportedFeatureWeights(QGeoRouteRequest::PreferFeatureWeight); diff --git a/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerplugins.pro b/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerplugins.pro index c5a39d3e..e2a3f6c4 100644 --- a/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerplugins.pro +++ b/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerplugins.pro @@ -12,3 +12,6 @@ SOURCES += qgeoserviceproviderplugin_test.cpp target.path += $$[QT_INSTALL_PLUGINS]/geoservices INSTALLS += target + +OTHER_FILES += \ + routing_plugin.json diff --git a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp index 01549e30..177a4e5d 100644 --- a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp +++ b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp @@ -52,25 +52,8 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest() { } -QString QGeoServiceProviderFactoryTest::providerName() const -{ - return "static.georoute.test.plugin"; -} - -QStringList QGeoServiceProviderFactoryTest::keys() const -{ - return QStringList() << QLatin1String("static.georoute.test.plugin"); -} - -int QGeoServiceProviderFactoryTest::providerVersion() const -{ - return 2; -} - QGeoRoutingManagerEngine* QGeoServiceProviderFactoryTest::createRoutingManagerEngine(const QMap< QString, QVariant> ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const { return new QGeoRoutingManagerEngineTest(parameters, error, errorString); } - -Q_EXPORT_PLUGIN2(qtgeoservices_staticroutingplugin, QGeoServiceProviderFactoryTest) diff --git a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h index 611ff702..e1c100ad 100644 --- a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h +++ b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h @@ -50,15 +50,14 @@ QT_USE_NAMESPACE class QGeoServiceProviderFactoryTest: public QObject, public QGeoServiceProviderFactory { Q_OBJECT - Q_INTERFACES(QGeoServiceProviderFactory:QFactoryInterface) + Q_INTERFACES(QGeoServiceProviderFactory) + Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0" + FILE "routing_plugin.json") + public: QGeoServiceProviderFactoryTest(); ~QGeoServiceProviderFactoryTest(); - QString providerName() const; - int providerVersion() const; - QStringList keys() const; - QGeoRoutingManagerEngine* createRoutingManagerEngine(const QMap<QString, QVariant> ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; diff --git a/tests/auto/qgeoroutingmanagerplugins/routing_plugin.json b/tests/auto/qgeoroutingmanagerplugins/routing_plugin.json new file mode 100644 index 00000000..25905f60 --- /dev/null +++ b/tests/auto/qgeoroutingmanagerplugins/routing_plugin.json @@ -0,0 +1,12 @@ +{ + "Keys": ["georoute.test.plugin"], + "Provider": "georoute.test.plugin", + "Version": 100, + "Experimental": true, + "Features": [ + "OfflineRoutingFeature", + "RouteUpdatesFeature", + "AlternativeRoutesFeature", + "ExcludeAreasRoutingFeature" + ] +} diff --git a/tests/auto/qplacemanager/tst_qplacemanager.cpp b/tests/auto/qplacemanager/tst_qplacemanager.cpp index abc62aa6..2f9b471b 100644 --- a/tests/auto/qplacemanager/tst_qplacemanager.cpp +++ b/tests/auto/qplacemanager/tst_qplacemanager.cpp @@ -91,6 +91,8 @@ void tst_QPlaceManager::initTestCase() QVERIFY(providers.contains("qmlgeo.test.plugin")); provider = new QGeoServiceProvider("qmlgeo.test.plugin"); + QCOMPARE(provider->placesFeatures() & QGeoServiceProvider::OfflinePlacesFeature, + QGeoServiceProvider::OfflinePlacesFeature); placeManager = provider->placeManager(); QVERIFY(placeManager); } @@ -98,7 +100,7 @@ void tst_QPlaceManager::initTestCase() void tst_QPlaceManager::testMetadata() { QCOMPARE(placeManager->managerName(), QLatin1String("qmlgeo.test.plugin")); - QCOMPARE(placeManager->managerVersion(), 3); + QCOMPARE(placeManager->managerVersion(), 100); } void tst_QPlaceManager::testLocales() diff --git a/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp b/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp index 62a44e64..8763a4dd 100644 --- a/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp +++ b/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp @@ -1695,19 +1695,16 @@ void tst_QPlaceManagerJsonDb::unsupportedFunctions() void tst_QPlaceManagerJsonDb::supportedFeatures() { - QCOMPARE((placeManager->supportedFeatures() & QPlaceManager::SavePlaceFeature), - QPlaceManager::SavePlaceFeature); - QCOMPARE((placeManager->supportedFeatures() & QPlaceManager::RemovePlaceFeature), - QPlaceManager::RemovePlaceFeature); - QCOMPARE((placeManager->supportedFeatures() & QPlaceManager::SaveCategoryFeature), - QPlaceManager::SaveCategoryFeature); - QCOMPARE((placeManager->supportedFeatures() & QPlaceManager::RemoveCategoryFeature), - QPlaceManager::RemoveCategoryFeature); - - QVERIFY((placeManager->supportedFeatures() & QPlaceManager::RecommendationsFeature) == 0); - QVERIFY((placeManager->supportedFeatures() & QPlaceManager::SearchSuggestionsFeature) == 0); - QVERIFY((placeManager->supportedFeatures() & QPlaceManager::CorrectionsFeature) == 0); - QVERIFY((placeManager->supportedFeatures() & QPlaceManager::LocaleFeature) == 0); + QGeoServiceProvider::PlacesFeatures f = QGeoServiceProvider::NoPlacesFeatures; + + f |= QGeoServiceProvider::OfflinePlacesFeature; + f |= QGeoServiceProvider::SavePlaceFeature; + f |= QGeoServiceProvider::RemovePlaceFeature; + f |= QGeoServiceProvider::SaveCategoryFeature; + f |= QGeoServiceProvider::RemoveCategoryFeature; + f |= QGeoServiceProvider::PlaceMatchingFeature; + + QCOMPARE(provider->placesFeatures(), f); } void tst_QPlaceManagerJsonDb::categoryFunctions() diff --git a/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp b/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp index c7b12ad8..67cc30c0 100644 --- a/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp +++ b/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp @@ -96,6 +96,11 @@ void tst_QPlaceManagerUnsupported::initTestCase() QVERIFY(providers.contains("test.places.unsupported")); m_provider = new QGeoServiceProvider("test.places.unsupported"); + QVERIFY(m_provider); + QCOMPARE(m_provider->error(), QGeoServiceProvider::NotSupportedError); + m_provider->setAllowExperimental(true); + QCOMPARE(m_provider->error(), QGeoServiceProvider::NoError); + m_manager = m_provider->placeManager(); QVERIFY(m_manager); } @@ -109,7 +114,7 @@ void tst_QPlaceManagerUnsupported::testMetadata() { QCOMPARE(m_manager->managerName(), QLatin1String("test.places.unsupported")); QCOMPARE(m_manager->managerVersion(), 1); - QCOMPARE(m_manager->supportedFeatures(), QPlaceManager::NoFeatures); + QCOMPARE(m_provider->placesFeatures(), QGeoServiceProvider::NoPlacesFeatures); } void tst_QPlaceManagerUnsupported::testLocales() |