summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/declarative_core/tst_plugin.qml2
-rw-r--r--tests/auto/declarative_core/tst_positionsource.qml133
-rw-r--r--tests/auto/declarative_ui/BLACKLIST20
-rw-r--r--tests/auto/geotestplugin/geotestplugin.json3
-rw-r--r--tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h4
-rw-r--r--tests/auto/geotestplugin/qplacemanagerengine_test.h27
-rw-r--r--tests/auto/nokia_services/places_semiauto/tst_places.cpp4
-rw-r--r--tests/auto/positionplugin/plugin.cpp74
-rw-r--r--tests/auto/positionplugin/plugin.json2
-rw-r--r--tests/auto/positionplugin/positionplugin.pro4
-rw-r--r--tests/auto/positionpluginV1/plugin.cpp212
-rw-r--r--tests/auto/positionpluginV1/plugin.json9
-rw-r--r--tests/auto/positionpluginV1/positionpluginV1.pro12
-rw-r--r--tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp7
-rw-r--r--tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp4
-rw-r--r--tests/auto/utils/qlocationtestutils.cpp3
17 files changed, 423 insertions, 98 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 745e264b..05559d12 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -86,6 +86,7 @@ SUBDIRS += \
!android: SUBDIRS += \
positionplugin \
+ positionpluginV1 \
positionplugintest \
qgeoareamonitor \
qgeopositioninfosource \
diff --git a/tests/auto/declarative_core/tst_plugin.qml b/tests/auto/declarative_core/tst_plugin.qml
index 7b880f1d..23c1ff9f 100644
--- a/tests/auto/declarative_core/tst_plugin.qml
+++ b/tests/auto/declarative_core/tst_plugin.qml
@@ -54,6 +54,7 @@ Item {
mapping: Plugin.OfflineMappingFeature;
geocoding: Plugin.OfflineGeocodingFeature;
places: Plugin.AnyPlacesFeatures;
+ navigation: Plugin.AnyNavigationFeatures;
}
}
@@ -120,6 +121,7 @@ Item {
verify(requiredPlugin.supportsMapping(requiredPlugin.required.mapping))
verify(requiredPlugin.supportsGeocoding(requiredPlugin.required.geocoding))
verify(requiredPlugin.supportsPlaces(requiredPlugin.required.places))
+ verify(requiredPlugin.supportsNavigation(requiredPlugin.required.navigation))
}
function test_placesFeatures() {
diff --git a/tests/auto/declarative_core/tst_positionsource.qml b/tests/auto/declarative_core/tst_positionsource.qml
index a663f3ab..7b787a0c 100644
--- a/tests/auto/declarative_core/tst_positionsource.qml
+++ b/tests/auto/declarative_core/tst_positionsource.qml
@@ -28,7 +28,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtPositioning 5.2
+import QtPositioning 5.14
TestCase {
id: testCase
@@ -106,6 +106,26 @@ TestCase {
SignalSpy { id: directionValidSpy; target: testingSource.position; signalName: "directionValidChanged" }
SignalSpy { id: directionSpy; target: testingSource.position; signalName: "directionChanged" }
+ PositionSource {
+ id: testingSourceWParams
+ name: "test.source"
+ updateInterval: 1000
+ PluginParameter {
+ id: altitudeParameter
+ name: "test.source.altitude"
+ value: 42.42
+ }
+ }
+
+ SignalSpy { id: updateSpyWParams; target: testingSourceWParams; signalName: "positionChanged" }
+ SignalSpy { id: directionValidSpyWParams; target: testingSourceWParams.position; signalName: "directionValidChanged" }
+ SignalSpy { id: directionSpyWParams; target: testingSourceWParams.position; signalName: "directionChanged" }
+
+ PositionSource { id: testingSourceV1; name: "test.source.v1"; updateInterval: 1000 }
+ SignalSpy { id: updateSpyV1; target: testingSourceV1; signalName: "positionChanged" }
+ SignalSpy { id: directionValidSpyV1; target: testingSourceV1.position; signalName: "directionValidChanged" }
+ SignalSpy { id: directionSpyV1; target: testingSourceV1.position; signalName: "directionChanged" }
+
function test_updateInterval() {
testingSource.updateInterval = 1000;
compare(testingSource.updateInterval, 1000);
@@ -125,40 +145,83 @@ TestCase {
}
function test_updates() {
- updateSpy.clear();
-
- compare(directionValidSpy.count, 0)
- compare(directionSpy.count, 0)
-
- testingSource.active = true;
-
- tryCompare(updateSpy, "count", 1, 1500);
- compare(testingSource.position.coordinate.longitude, 0.1);
- compare(testingSource.position.coordinate.latitude, 0.1);
- compare(directionValidSpy.count, 1)
- compare(directionSpy.count, 1)
- fuzzyCompare(testingSource.position.direction, 45, 0.1)
- verify(!testingSource.position.speedValid)
- verify(isNaN(testingSource.position.speed))
-
- tryCompare(updateSpy, "count", 2, 1500);
- compare(testingSource.position.coordinate.longitude, 0.2);
- compare(testingSource.position.coordinate.latitude, 0.2);
- compare(directionValidSpy.count, 1)
- compare(directionSpy.count, 2)
- fuzzyCompare(testingSource.position.direction, 45, 0.1)
- verify(testingSource.position.speedValid)
- verify(testingSource.position.speed > 10000)
-
- testingSource.active = false;
+ updateSpyV1.clear();
+
+ compare(directionValidSpyV1.count, 0)
+ compare(directionSpyV1.count, 0)
+
+ testingSourceV1.active = true;
+
+ tryCompare(updateSpyV1, "count", 1, 1500);
+ compare(testingSourceV1.position.coordinate.longitude, 0.1);
+ compare(testingSourceV1.position.coordinate.latitude, 0.1);
+ compare(directionValidSpyV1.count, 1)
+ compare(directionSpyV1.count, 1)
+ fuzzyCompare(testingSourceV1.position.direction, 45, 0.1)
+ verify(!testingSourceV1.position.speedValid)
+ verify(isNaN(testingSourceV1.position.speed))
+
+ tryCompare(updateSpyV1, "count", 2, 1500);
+ compare(testingSourceV1.position.coordinate.longitude, 0.2);
+ compare(testingSourceV1.position.coordinate.latitude, 0.2);
+ compare(directionValidSpyV1.count, 1)
+ compare(directionSpyV1.count, 2)
+ fuzzyCompare(testingSourceV1.position.direction, 45, 0.1)
+ verify(testingSourceV1.position.speedValid)
+ verify(testingSourceV1.position.speed > 10000)
+
+ testingSourceV1.active = false;
+ wait(2500);
+ compare(updateSpyV1.count, 2);
+ compare(testingSourceV1.position.coordinate.longitude, 0.2);
+ compare(testingSourceV1.position.coordinate.latitude, 0.2);
+ compare(directionValidSpyV1.count, 1)
+ compare(directionSpyV1.count, 2)
+ fuzzyCompare(testingSourceV1.position.direction, 45, 0.1)
+ verify(testingSourceV1.position.speedValid)
+ verify(testingSourceV1.position.speed > 10000)
+ }
+
+ function test_updates_w_params() {
+ updateSpyWParams.clear();
+
+ compare(directionValidSpyWParams.count, 0)
+ compare(directionSpyWParams.count, 0)
+ compare(testingSourceWParams.backendProperty("altitude"), altitudeParameter.value)
+ testingSourceWParams.active = true;
+
+ tryCompare(updateSpyWParams, "count", 1, 1500);
+ compare(testingSourceWParams.position.coordinate.longitude, 0.1);
+ compare(testingSourceWParams.position.coordinate.latitude, 0.1);
+ compare(testingSourceWParams.position.coordinate.altitude, altitudeParameter.value);
+ compare(directionValidSpyWParams.count, 1)
+ compare(directionSpyWParams.count, 1)
+ fuzzyCompare(testingSourceWParams.position.direction, 45, 0.1)
+ verify(!testingSourceWParams.position.speedValid)
+ verify(isNaN(testingSourceWParams.position.speed))
+ testingSourceWParams.setBackendProperty("altitude", 24.24)
+
+ tryCompare(updateSpyWParams, "count", 2, 1500);
+ compare(testingSourceWParams.position.coordinate.longitude, 0.2);
+ compare(testingSourceWParams.position.coordinate.latitude, 0.2);
+ compare(testingSourceWParams.position.coordinate.altitude, 24.24);
+ compare(directionValidSpyWParams.count, 1)
+ compare(directionSpyWParams.count, 2)
+ fuzzyCompare(testingSourceWParams.position.direction, 45, 0.1)
+ verify(testingSourceWParams.position.speedValid)
+ verify(testingSourceWParams.position.speed > 10000)
+ compare(testingSourceWParams.backendProperty("altitude"), 24.24)
+
+ testingSourceWParams.active = false;
wait(2500);
- compare(updateSpy.count, 2);
- compare(testingSource.position.coordinate.longitude, 0.2);
- compare(testingSource.position.coordinate.latitude, 0.2);
- compare(directionValidSpy.count, 1)
- compare(directionSpy.count, 2)
- fuzzyCompare(testingSource.position.direction, 45, 0.1)
- verify(testingSource.position.speedValid)
- verify(testingSource.position.speed > 10000)
+ compare(updateSpyWParams.count, 2);
+ compare(testingSourceWParams.position.coordinate.longitude, 0.2);
+ compare(testingSourceWParams.position.coordinate.latitude, 0.2);
+ compare(testingSourceWParams.position.coordinate.altitude, 24.24);
+ compare(directionValidSpyWParams.count, 1)
+ compare(directionSpyWParams.count, 2)
+ fuzzyCompare(testingSourceWParams.position.direction, 45, 0.1)
+ verify(testingSourceWParams.position.speedValid)
+ verify(testingSourceWParams.position.speed > 10000)
}
}
diff --git a/tests/auto/declarative_ui/BLACKLIST b/tests/auto/declarative_ui/BLACKLIST
deleted file mode 100644
index 4abe024c..00000000
--- a/tests/auto/declarative_ui/BLACKLIST
+++ /dev/null
@@ -1,20 +0,0 @@
-[MapFlick::test_disable_onFlickStarted_with_disabled]
-windows
-
-[MapFlick::test_flick_down]
-windows
-
-[MapFlick::test_flick_up]
-windows
-
-[MapFlick::test_flick_down_with_filtering]
-windows
-
-[MapFlick::test_disable_onFlickStarted_with_nogesture]
-windows
-
-[MapFlick::test_flick_diagonal]
-windows
-
-[MapFlick::test_flick_up_with_filtering]
-windows
diff --git a/tests/auto/geotestplugin/geotestplugin.json b/tests/auto/geotestplugin/geotestplugin.json
index 52721715..f6218b67 100644
--- a/tests/auto/geotestplugin/geotestplugin.json
+++ b/tests/auto/geotestplugin/geotestplugin.json
@@ -14,6 +14,7 @@
"OfflinePlacesFeature",
"SavePlaceFeature",
"SaveCategoryFeature",
- "SearchSuggestionsFeature"
+ "SearchSuggestionsFeature",
+ "OfflineNavigationFeature"
]
}
diff --git a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h
index c606fdb0..ac195d69 100644
--- a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h
+++ b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h
@@ -34,10 +34,10 @@
QT_USE_NAMESPACE
-class QGeoServiceProviderFactoryTest: public QObject, public QGeoServiceProviderFactory
+class QGeoServiceProviderFactoryTest: public QObject, public QGeoServiceProviderFactoryV2
{
Q_OBJECT
- Q_INTERFACES(QGeoServiceProviderFactory)
+ Q_INTERFACES(QGeoServiceProviderFactoryV2)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0"
FILE "geotestplugin.json")
diff --git a/tests/auto/geotestplugin/qplacemanagerengine_test.h b/tests/auto/geotestplugin/qplacemanagerengine_test.h
index 7245ccf1..0c707b65 100644
--- a/tests/auto/geotestplugin/qplacemanagerengine_test.h
+++ b/tests/auto/geotestplugin/qplacemanagerengine_test.h
@@ -474,9 +474,12 @@ public:
results.append(r);
}
} else if (!query.categories().isEmpty()) {
- QSet<QPlaceCategory> categories = query.categories().toSet();
- foreach (const QPlace &place, m_places) {
- if (place.categories().toSet().intersect(categories).isEmpty())
+ const auto &categoryList = query.categories();
+ const QSet<QPlaceCategory> categories(categoryList.cbegin(), categoryList.cend());
+ for (const QPlace &place : qAsConst(m_places)) {
+ const auto &placeCategoryList = place.categories();
+ const QSet<QPlaceCategory> placeCategories(placeCategoryList.cbegin(), placeCategoryList.cend());
+ if (!placeCategories.intersects(categories))
continue;
QPlaceResult r;
@@ -571,11 +574,8 @@ public:
m_categories.insert(category.categoryId(), category);
QStringList children = m_childCategories.value(parentId);
- QMutableHashIterator<QString, QStringList> i(m_childCategories);
- while (i.hasNext()) {
- i.next();
- i.value().removeAll(category.categoryId());
- }
+ for (QStringList &c : m_childCategories)
+ c.removeAll(category.categoryId());
if (!children.contains(category.categoryId())) {
children.append(category.categoryId());
@@ -611,11 +611,8 @@ public:
} else {
m_categories.remove(categoryId);
- QMutableHashIterator<QString, QStringList> i(m_childCategories);
- while (i.hasNext()) {
- i.next();
- i.value().removeAll(categoryId);
- }
+ for (auto &c : m_childCategories)
+ c.removeAll(categoryId);
}
QMetaObject::invokeMethod(reply, "emitFinished", Qt::QueuedConnection);
@@ -634,9 +631,7 @@ public:
QString parentCategoryId(const QString &categoryId) const override
{
- QHashIterator<QString, QStringList> i(m_childCategories);
- while (i.hasNext()) {
- i.next();
+ for (auto i = m_childCategories.cbegin(), end = m_childCategories.cend(); i != end; ++i) {
if (i.value().contains(categoryId))
return i.key();
}
diff --git a/tests/auto/nokia_services/places_semiauto/tst_places.cpp b/tests/auto/nokia_services/places_semiauto/tst_places.cpp
index 2f68ab44..c198c616 100644
--- a/tests/auto/nokia_services/places_semiauto/tst_places.cpp
+++ b/tests/auto/nokia_services/places_semiauto/tst_places.cpp
@@ -610,9 +610,7 @@ void tst_QPlaceManagerNokia::content()
QVERIFY(results.count() > 0);
- QMapIterator<int, QPlaceContent> iter(results);
- while (iter.hasNext()) {
- iter.next();
+ for (auto iter = results.cbegin(), end = results.cend(); iter != end; ++iter) {
switch (type) {
case (QPlaceContent::ImageType): {
QPlaceImage image = iter.value();
diff --git a/tests/auto/positionplugin/plugin.cpp b/tests/auto/positionplugin/plugin.cpp
index a15a89a5..9d5c7dd5 100644
--- a/tests/auto/positionplugin/plugin.cpp
+++ b/tests/auto/positionplugin/plugin.cpp
@@ -27,6 +27,7 @@
****************************************************************************/
#include <QtPositioning/qgeopositioninfosource.h>
+#include <QtPositioning/private/qgeopositioninfosource_p.h>
#include <QtPositioning/qgeopositioninfosourcefactory.h>
#include <QObject>
#include <QtPlugin>
@@ -39,7 +40,7 @@ class DummySource : public QGeoPositionInfoSource
Q_OBJECT
public:
- DummySource(QObject *parent=0);
+ DummySource(const QVariantMap &parameters, QObject *parent=0);
~DummySource();
void startUpdates();
@@ -65,13 +66,42 @@ private slots:
void doTimeout();
};
-DummySource::DummySource(QObject *parent) :
- QGeoPositionInfoSource(parent),
+class DummySourcePrivate : public QGeoPositionInfoSourcePrivate
+{
+public:
+ bool setBackendProperty(const QString &name, QVariant value) override
+ {
+ if (name == QStringLiteral("altitude")) {
+ m_altitude = value.toReal();
+ return true;
+ }
+ return false;
+ }
+ QVariant backendProperty(const QString &name) const override
+ {
+ if (name == QStringLiteral("altitude"))
+ return m_altitude;
+ return QVariant();
+ }
+
+ qreal m_altitude = 0.0;
+};
+
+DummySource::DummySource(const QVariantMap &parameters, QObject *parent) :
+ QGeoPositionInfoSource(*new DummySourcePrivate, parent),
timer(new QTimer(this)),
timeoutTimer(new QTimer(this)),
singleTimer(new QTimer(this)),
lastPosition(QGeoCoordinate(0,0), QDateTime::currentDateTime())
{
+ DummySourcePrivate *dd = static_cast<DummySourcePrivate *>(QGeoPositionInfoSourcePrivate::get(*this));
+ if (parameters.contains(QStringLiteral("test.source.altitude"))) {
+ const qreal alti = parameters.value(QStringLiteral("test.source.altitude")).toReal();
+ dd->m_altitude = alti;
+ QGeoCoordinate crd = lastPosition.coordinate();
+ crd.setAltitude(alti);
+ lastPosition.setCoordinate(crd);
+ }
timer->setInterval(1000);
connect(timer, SIGNAL(timeout()),
this, SLOT(updatePosition()));
@@ -151,13 +181,15 @@ DummySource::~DummySource()
void DummySource::updatePosition()
{
+ DummySourcePrivate *dd = static_cast<DummySourcePrivate *>(QGeoPositionInfoSourcePrivate::get(*this));
timeoutTimer->stop();
singleTimer->stop();
const QDateTime now = QDateTime::currentDateTime();
QGeoCoordinate coord(lastPosition.coordinate().latitude() + 0.1,
- lastPosition.coordinate().longitude() + 0.1);
+ lastPosition.coordinate().longitude() + 0.1,
+ dd->m_altitude);
QGeoPositionInfo info(coord, now);
info.setAttribute(QGeoPositionInfo::Direction, lastPosition.coordinate().azimuthTo(coord));
@@ -179,35 +211,55 @@ void DummySource::doTimeout()
}
-class QGeoPositionInfoSourceFactoryTest : public QObject, public QGeoPositionInfoSourceFactory
+class QGeoPositionInfoSourceFactoryTest : public QObject, public QGeoPositionInfoSourceFactoryV2
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/5.0"
FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
+ Q_INTERFACES(QGeoPositionInfoSourceFactoryV2)
public:
QGeoPositionInfoSource *positionInfoSource(QObject *parent);
QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent);
QGeoAreaMonitorSource *areaMonitor(QObject *parent);
+
+ QGeoPositionInfoSource *positionInfoSourceWithParameters(QObject *parent, const QVariantMap &parameters);
+ QGeoSatelliteInfoSource *satelliteInfoSourceWithParameters(QObject *parent, const QVariantMap &parameters);
+ QGeoAreaMonitorSource *areaMonitorWithParameters(QObject *parent, const QVariantMap &parameters);
};
QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryTest::positionInfoSource(QObject *parent)
{
- return new DummySource(parent);
+ return new DummySource(QVariantMap(), parent);
}
QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryTest::satelliteInfoSource(QObject *parent)
{
- Q_UNUSED(parent);
- // not implemented
- return 0;
+ return satelliteInfoSourceWithParameters(parent, QVariantMap());
}
QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryTest::areaMonitor(QObject* parent)
{
+ return areaMonitorWithParameters(parent, QVariantMap());
+}
+
+QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryTest::positionInfoSourceWithParameters(QObject *parent, const QVariantMap &parameters)
+{
+ return new DummySource(parameters, parent);
+}
+
+QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryTest::satelliteInfoSourceWithParameters(QObject *parent, const QVariantMap &parameters)
+{
+ Q_UNUSED(parent);
+ Q_UNUSED(parameters)
+ return nullptr;
+}
+
+QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryTest::areaMonitorWithParameters(QObject *parent, const QVariantMap &parameters)
+{
Q_UNUSED(parent);
- return 0;
+ Q_UNUSED(parameters)
+ return nullptr;
}
#include "plugin.moc"
diff --git a/tests/auto/positionplugin/plugin.json b/tests/auto/positionplugin/plugin.json
index 68acaded..a38d2a5a 100644
--- a/tests/auto/positionplugin/plugin.json
+++ b/tests/auto/positionplugin/plugin.json
@@ -4,6 +4,6 @@
"Position": true,
"Satellite": false,
"Monitor": false,
- "Priority": 0,
+ "Priority": 1,
"Testable": true
}
diff --git a/tests/auto/positionplugin/positionplugin.pro b/tests/auto/positionplugin/positionplugin.pro
index dd04e7fb..84d08ac0 100644
--- a/tests/auto/positionplugin/positionplugin.pro
+++ b/tests/auto/positionplugin/positionplugin.pro
@@ -1,8 +1,8 @@
TARGET = qtposition_testplugin
-QT += positioning
+QT += positioning-private
PLUGIN_TYPE = position
-PLUGIN_CLASS_NAME = TestPositionPlugin
+PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryTest
PLUGIN_EXTENDS = -
load(qt_plugin)
diff --git a/tests/auto/positionpluginV1/plugin.cpp b/tests/auto/positionpluginV1/plugin.cpp
new file mode 100644
index 00000000..bf8b8234
--- /dev/null
+++ b/tests/auto/positionpluginV1/plugin.cpp
@@ -0,0 +1,212 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtPositioning/qgeopositioninfosource.h>
+#include <QtPositioning/qgeopositioninfosourcefactory.h>
+#include <QObject>
+#include <QtPlugin>
+#include <QTimer>
+
+QT_USE_NAMESPACE
+
+class DummySource : public QGeoPositionInfoSource
+{
+ Q_OBJECT
+
+public:
+ DummySource(QObject *parent = nullptr);
+ ~DummySource();
+
+ void startUpdates();
+ void stopUpdates();
+ void requestUpdate(int timeout=5000);
+
+ QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const;
+ PositioningMethods supportedPositioningMethods() const;
+
+ void setUpdateInterval(int msec);
+ int minimumUpdateInterval() const;
+ Error error() const;
+
+private:
+ QTimer *timer;
+ QTimer *timeoutTimer;
+ QTimer *singleTimer;
+ QGeoPositionInfo lastPosition;
+ QDateTime lastUpdateTime;
+
+private slots:
+ void updatePosition();
+ void doTimeout();
+};
+
+DummySource::DummySource(QObject *parent) :
+ QGeoPositionInfoSource(parent),
+ timer(new QTimer(this)),
+ timeoutTimer(new QTimer(this)),
+ singleTimer(new QTimer(this)),
+ lastPosition(QGeoCoordinate(0,0), QDateTime::currentDateTime())
+{
+ timer->setInterval(1000);
+ connect(timer, SIGNAL(timeout()),
+ this, SLOT(updatePosition()));
+ connect(singleTimer, SIGNAL(timeout()),
+ this, SLOT(updatePosition()));
+ connect(timeoutTimer, SIGNAL(timeout()),
+ this, SLOT(doTimeout()));
+}
+
+QGeoPositionInfoSource::Error DummySource::error() const
+{
+ return QGeoPositionInfoSource::NoError;
+}
+
+
+void DummySource::setUpdateInterval(int msec)
+{
+ if (msec == 0) {
+ timer->setInterval(1000);
+ } else if (msec < 1000) {
+ msec = 1000;
+ timer->setInterval(msec);
+ } else {
+ timer->setInterval(msec);
+ }
+
+ QGeoPositionInfoSource::setUpdateInterval(msec);
+}
+
+int DummySource::minimumUpdateInterval() const
+{
+ return 1000;
+}
+
+QGeoPositionInfo DummySource::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
+{
+ Q_UNUSED(fromSatellitePositioningMethodsOnly);
+ return lastPosition;
+}
+
+QGeoPositionInfoSource::PositioningMethods DummySource::supportedPositioningMethods() const
+{
+ return QGeoPositionInfoSource::AllPositioningMethods;
+}
+
+void DummySource::startUpdates()
+{
+ timer->start();
+}
+
+void DummySource::stopUpdates()
+{
+ timer->stop();
+}
+
+void DummySource::requestUpdate(int timeout)
+{
+ if (timeout == 0)
+ timeout = 5000;
+ if (timeout < 0)
+ timeout = 0;
+
+ timeoutTimer->setInterval(timeout);
+ timeoutTimer->start();
+
+ if (timer->isActive()) {
+ timer->stop();
+ timer->start();
+ }
+
+ singleTimer->setInterval(1000);
+ singleTimer->start();
+}
+
+DummySource::~DummySource()
+{}
+
+void DummySource::updatePosition()
+{
+ timeoutTimer->stop();
+ singleTimer->stop();
+
+ const QDateTime now = QDateTime::currentDateTime();
+
+ QGeoCoordinate coord(lastPosition.coordinate().latitude() + 0.1,
+ lastPosition.coordinate().longitude() + 0.1);
+
+ QGeoPositionInfo info(coord, now);
+ info.setAttribute(QGeoPositionInfo::Direction, lastPosition.coordinate().azimuthTo(coord));
+ if (lastUpdateTime.isValid()) {
+ double speed = lastPosition.coordinate().distanceTo(coord) / lastUpdateTime.msecsTo(now);
+ info.setAttribute(QGeoPositionInfo::GroundSpeed, 1000 * speed);
+ }
+
+ lastUpdateTime = now;
+ lastPosition = info;
+ emit positionUpdated(info);
+}
+
+void DummySource::doTimeout()
+{
+ timeoutTimer->stop();
+ singleTimer->stop();
+ emit updateTimeout();
+}
+
+
+class QGeoPositionInfoSourceFactoryTestV1 : public QObject, public QGeoPositionInfoSourceFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/5.0"
+ FILE "plugin.json")
+ Q_INTERFACES(QGeoPositionInfoSourceFactory)
+
+public:
+ QGeoPositionInfoSource *positionInfoSource(QObject *parent);
+ QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent);
+ QGeoAreaMonitorSource *areaMonitor(QObject *parent);
+};
+
+QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryTestV1::positionInfoSource(QObject *parent)
+{
+ return new DummySource(parent);
+}
+
+QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryTestV1::satelliteInfoSource(QObject *parent)
+{
+ Q_UNUSED(parent);
+ return nullptr;
+}
+
+QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryTestV1::areaMonitor(QObject* parent)
+{
+ Q_UNUSED(parent);
+ return nullptr;
+}
+
+#include "plugin.moc"
diff --git a/tests/auto/positionpluginV1/plugin.json b/tests/auto/positionpluginV1/plugin.json
new file mode 100644
index 00000000..9acf27e7
--- /dev/null
+++ b/tests/auto/positionpluginV1/plugin.json
@@ -0,0 +1,9 @@
+{
+ "Keys": ["test.source.v1"],
+ "Provider": "test.source.v1",
+ "Position": true,
+ "Satellite": false,
+ "Monitor": false,
+ "Priority": 0,
+ "Testable": true
+}
diff --git a/tests/auto/positionpluginV1/positionpluginV1.pro b/tests/auto/positionpluginV1/positionpluginV1.pro
new file mode 100644
index 00000000..925a7e29
--- /dev/null
+++ b/tests/auto/positionpluginV1/positionpluginV1.pro
@@ -0,0 +1,12 @@
+TARGET = qtposition_testpluginv1
+QT += positioning
+
+PLUGIN_TYPE = position
+PLUGIN_CLASS_NAME = QGeoPositionInfoSourceFactoryTestV1
+PLUGIN_EXTENDS = -
+load(qt_plugin)
+
+SOURCES += plugin.cpp
+
+OTHER_FILES += \
+ plugin.json
diff --git a/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp b/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp
index 5da6b4d4..c7189278 100644
--- a/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp
+++ b/tests/auto/qgeotiledmap/tst_qgeotiledmap.cpp
@@ -145,7 +145,7 @@ void tst_QGeoTiledMap::fetchTiles()
m_tilesCounter->m_tiles.clear();
m_map->setCameraData(camera);
waitForFetch(visibleCount);
- QSet<QGeoTileSpec> visible = m_tilesCounter->m_tiles;
+ const QSet<QGeoTileSpec> visible = m_tilesCounter->m_tiles;
m_map->clearData();
m_tilesCounter->m_tiles.clear();
m_map->prefetchData();
@@ -164,9 +164,8 @@ void tst_QGeoTiledMap::fetchTiles()
QVERIFY2(visibleCount == visible.size(), "visible count incorrect");
QVERIFY2(prefetchCount == prefetched.size(), "prefetch count incorrect");
- QSetIterator<QGeoTileSpec> i(visible);
- while (i.hasNext())
- QVERIFY2(prefetched.contains(i.next()),"visible tile missing from prefetched tiles");
+ for (const QGeoTileSpec &tile : visible)
+ QVERIFY2(prefetched.contains(tile),"visible tile missing from prefetched tiles");
//for zoomLevels wihtout fractions more tiles are fetched for current zoomlevel due to ViewExpansion
if (qCeil(zoomLevel) != zoomLevel && style == QGeoTiledMap::PrefetchNeighbourLayer && nearestNeighbourLayer < zoomLevel)
diff --git a/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp b/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp
index 37fe7abc..51f996fb 100644
--- a/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp
+++ b/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp
@@ -32,6 +32,8 @@
#include "tst_qnmeapositioninfosource.h"
+#include <QtCore/QDateTime>
+#include <QtCore/QElapsedTimer>
#include <QtCore/QtNumeric>
#ifdef Q_OS_WIN
@@ -264,7 +266,7 @@ void tst_QNmeaPositionInfoSource::startUpdates_withTimeout()
proxy->feedBytes(QLocationTestUtils::createRmcSentence(dt.addMSecs(2200)).toLatin1());
proxy->feedBytes(QLocationTestUtils::createRmcSentence(dt.addSecs(9)).toLatin1());
- QTime t;
+ QElapsedTimer t;
t.start();
for (int j = 1; j < 4; ++j) {
diff --git a/tests/auto/utils/qlocationtestutils.cpp b/tests/auto/utils/qlocationtestutils.cpp
index d6e77855..df595daa 100644
--- a/tests/auto/utils/qlocationtestutils.cpp
+++ b/tests/auto/utils/qlocationtestutils.cpp
@@ -46,8 +46,7 @@ QString QLocationTestUtils::addNmeaChecksumAndBreaks(const QString &sentence)
int result = 0;
for (int i=1; i<sentence.length()-1; i++)
result ^= sentence[i].toLatin1();
- QString sum;
- sum.sprintf("%02x", result);
+ const QString sum = QString::asprintf("%02x", result);
return sentence + sum + "\r\n";
}