diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-09-09 13:55:31 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-09-09 21:57:24 +0000 |
commit | f6a48c06d3090e553867db327665b3cc44d9b21a (patch) | |
tree | 4c074df93a40fe6784c10d4da0912aa06a67e05f | |
parent | 84ee5b304d1ab87bc2addb21fb684cc2b9a68d00 (diff) | |
download | qtlocation-f6a48c06d3090e553867db327665b3cc44d9b21a.tar.gz |
Skip loading real plugins in tests
Introduce a new plugin metadata field "Testable" that can be used to
indicate that using the plugin in question in test runs (e.g. in a CI
environment) is dangerous. We can then check for QT_QTESTLIB_RUNNING
and skip the plugin in question.
Change-Id: Iabe9f1600d7274e0e9224dc49d02aa2e5d3cabd6
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rw-r--r-- | src/plugins/position/android/src/plugin.json | 3 | ||||
-rw-r--r-- | src/plugins/position/corelocation/plugin.json | 3 | ||||
-rw-r--r-- | src/plugins/position/geoclue/plugin-satellite.json | 3 | ||||
-rw-r--r-- | src/plugins/position/geoclue/plugin.json | 3 | ||||
-rw-r--r-- | src/plugins/position/gypsy/plugin.json | 3 | ||||
-rw-r--r-- | src/plugins/position/positionpoll/plugin.json | 3 | ||||
-rw-r--r-- | src/plugins/position/simulator/plugin.json | 3 | ||||
-rw-r--r-- | src/plugins/position/winrt/plugin.json | 3 | ||||
-rw-r--r-- | src/positioning/qgeopositioninfosource.cpp | 6 | ||||
-rw-r--r-- | src/positioning/qgeosatelliteinfosource.cpp | 6 | ||||
-rw-r--r-- | tests/auto/positionplugin/plugin.json | 3 |
11 files changed, 30 insertions, 9 deletions
diff --git a/src/plugins/position/android/src/plugin.json b/src/plugins/position/android/src/plugin.json index b84fafea..4fd87892 100644 --- a/src/plugins/position/android/src/plugin.json +++ b/src/plugins/position/android/src/plugin.json @@ -4,5 +4,6 @@ "Position": true, "Satellite": true, "Monitor": false, - "Priority": 1000 + "Priority": 1000, + "Testable": false } diff --git a/src/plugins/position/corelocation/plugin.json b/src/plugins/position/corelocation/plugin.json index 96e5cbf1..58e3acd0 100644 --- a/src/plugins/position/corelocation/plugin.json +++ b/src/plugins/position/corelocation/plugin.json @@ -4,5 +4,6 @@ "Position": true, "Satellite": false, "Monitor" : false, - "Priority": 1000 + "Priority": 1000, + "Testable": false } diff --git a/src/plugins/position/geoclue/plugin-satellite.json b/src/plugins/position/geoclue/plugin-satellite.json index 59e190f1..cf03d6ed 100644 --- a/src/plugins/position/geoclue/plugin-satellite.json +++ b/src/plugins/position/geoclue/plugin-satellite.json @@ -3,5 +3,6 @@ "Provider": "geoclue", "Position": true, "Satellite": true, - "Priority": 1000 + "Priority": 1000, + "Testable": false } diff --git a/src/plugins/position/geoclue/plugin.json b/src/plugins/position/geoclue/plugin.json index cac7345b..f11d27cb 100644 --- a/src/plugins/position/geoclue/plugin.json +++ b/src/plugins/position/geoclue/plugin.json @@ -4,5 +4,6 @@ "Position": true, "Satellite": false, "Monitor": false, - "Priority": 1000 + "Priority": 1000, + "Testable": false } diff --git a/src/plugins/position/gypsy/plugin.json b/src/plugins/position/gypsy/plugin.json index b3ecc0f7..9cef03f8 100644 --- a/src/plugins/position/gypsy/plugin.json +++ b/src/plugins/position/gypsy/plugin.json @@ -4,5 +4,6 @@ "Position": false, "Satellite": true, "Monitor" : false, - "Priority": 1000 + "Priority": 1000, + "Testable": false } diff --git a/src/plugins/position/positionpoll/plugin.json b/src/plugins/position/positionpoll/plugin.json index a5b2f602..df1f47de 100644 --- a/src/plugins/position/positionpoll/plugin.json +++ b/src/plugins/position/positionpoll/plugin.json @@ -4,5 +4,6 @@ "Position": false, "Satellite": false, "Monitor": true, - "Priority": 1000 + "Priority": 1000, + "Testable": true } diff --git a/src/plugins/position/simulator/plugin.json b/src/plugins/position/simulator/plugin.json index 8aa5e79f..0935f4dc 100644 --- a/src/plugins/position/simulator/plugin.json +++ b/src/plugins/position/simulator/plugin.json @@ -4,5 +4,6 @@ "Position": true, "Satellite": true, "Monitor" : false, - "Priority": 1000 + "Priority": 1000, + "Testable": true } diff --git a/src/plugins/position/winrt/plugin.json b/src/plugins/position/winrt/plugin.json index 5bb21702..0696cb0a 100644 --- a/src/plugins/position/winrt/plugin.json +++ b/src/plugins/position/winrt/plugin.json @@ -4,5 +4,6 @@ "Position": true, "Satellite": false, "Monitor" : false, - "Priority": 1000 + "Priority": 1000, + "Testable": false } diff --git a/src/positioning/qgeopositioninfosource.cpp b/src/positioning/qgeopositioninfosource.cpp index 1cdd4116..0cec8eaa 100644 --- a/src/positioning/qgeopositioninfosource.cpp +++ b/src/positioning/qgeopositioninfosource.cpp @@ -158,6 +158,12 @@ void QGeoPositionInfoSourcePrivate::loadPluginMetadata(QHash<QString, QJsonObjec QList<QJsonObject> meta = l->metaData(); for (int i = 0; i < meta.size(); ++i) { QJsonObject obj = meta.at(i).value(QStringLiteral("MetaData")).toObject(); + const QString testableKey = QStringLiteral("Testable"); + if (obj.contains(testableKey) && !obj.value(testableKey).toBool()) { + static bool inTest = qEnvironmentVariableIsSet("QT_QTESTLIB_RUNNING"); + if (inTest) + continue; + } obj.insert(QStringLiteral("index"), i); plugins.insertMulti(obj.value(QStringLiteral("Provider")).toString(), obj); } diff --git a/src/positioning/qgeosatelliteinfosource.cpp b/src/positioning/qgeosatelliteinfosource.cpp index 06d6771d..da6eb8a0 100644 --- a/src/positioning/qgeosatelliteinfosource.cpp +++ b/src/positioning/qgeosatelliteinfosource.cpp @@ -167,6 +167,12 @@ QGeoSatelliteInfoSource *QGeoSatelliteInfoSource::createDefaultSource(QObject *p if (obj.value(QStringLiteral("Satellite")).isBool() && obj.value(QStringLiteral("Satellite")).toBool()) { + const QString testableKey = QStringLiteral("Testable"); + if (obj.contains(testableKey) && !obj.value(testableKey).toBool()) { + static bool inTest = qEnvironmentVariableIsSet("QT_QTESTLIB_RUNNING"); + if (inTest) + continue; + } QGeoPositionInfoSourcePrivate d; d.metaData = obj; d.loadPlugin(); diff --git a/tests/auto/positionplugin/plugin.json b/tests/auto/positionplugin/plugin.json index c16b7a8d..68acaded 100644 --- a/tests/auto/positionplugin/plugin.json +++ b/tests/auto/positionplugin/plugin.json @@ -4,5 +4,6 @@ "Position": true, "Satellite": false, "Monitor": false, - "Priority": 0 + "Priority": 0, + "Testable": true } |