summaryrefslogtreecommitdiff
path: root/tests/auto/positionplugin/plugin.cpp
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-10-21 17:27:08 +0200
committerIvan Solovev <ivan.solovev@qt.io>2021-11-02 09:46:33 +0200
commit6db775f6d9d72cf8ee9d66333b8424e74be1e352 (patch)
tree0a293756b61619a91970d9368a0449b7bf922728 /tests/auto/positionplugin/plugin.cpp
parent5a1f44c3d41febca8480c077bd4c34e5a3332cdc (diff)
downloadqtlocation-6.2.tar.gz
Remove QtPositioning module from qtlocation.git6.2.46.2.36.2.26.2
Turns out that our CI does not support repos without any tests. This is treated like an error and leads to integration failure. This patch fixes it by disabling tests in coin/module_config.yaml. This config should be fixed when QtLocation tests are enabled Task-number: QTBUG-97084 Change-Id: Ib06e865fe2836806bbbee34345f06b471dd48660 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 23f32792ad53e23bbafbff6d7667f0bb0f69fc53)
Diffstat (limited to 'tests/auto/positionplugin/plugin.cpp')
-rw-r--r--tests/auto/positionplugin/plugin.cpp248
1 files changed, 0 insertions, 248 deletions
diff --git a/tests/auto/positionplugin/plugin.cpp b/tests/auto/positionplugin/plugin.cpp
deleted file mode 100644
index 32dc3dee..00000000
--- a/tests/auto/positionplugin/plugin.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/****************************************************************************
-**
-** 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 DummySourcePrivate;
-class DummySource : public QGeoPositionInfoSource
-{
- Q_OBJECT
-
-public:
- DummySource(const QVariantMap &parameters, QObject *parent=0);
- ~DummySource();
-
- void startUpdates() override;
- void stopUpdates() override;
- void requestUpdate(int timeout = 5000) override;
-
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const override;
- PositioningMethods supportedPositioningMethods() const override;
-
- void setUpdateInterval(int msec) override;
- int minimumUpdateInterval() const override;
- Error error() const override;
-
- bool setBackendProperty(const QString &name, const QVariant &value) override;
- QVariant backendProperty(const QString &name) const override;
-
-private:
- QTimer *timer;
- QTimer *timeoutTimer;
- QTimer *singleTimer;
- QGeoPositionInfo lastPosition;
- QDateTime lastUpdateTime;
- Error lastError = QGeoPositionInfoSource::NoError;
- qreal altitude = 0.0;
-
-private slots:
- void updatePosition();
- void doTimeout();
-};
-
-DummySource::DummySource(const QVariantMap &parameters, QObject *parent) :
- QGeoPositionInfoSource(parent),
- timer(new QTimer(this)),
- timeoutTimer(new QTimer(this)),
- singleTimer(new QTimer(this)),
- lastPosition(QGeoCoordinate(0,0), QDateTime::currentDateTime())
-{
- if (parameters.contains(QStringLiteral("test.source.altitude"))) {
- const qreal alti = parameters.value(QStringLiteral("test.source.altitude")).toReal();
- altitude = alti;
- QGeoCoordinate crd = lastPosition.coordinate();
- crd.setAltitude(alti);
- lastPosition.setCoordinate(crd);
- }
- timer->setInterval(200);
- 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 lastError;
-}
-
-bool DummySource::setBackendProperty(const QString &name, const QVariant &value)
-{
- if (name == QStringLiteral("altitude")) {
- altitude = value.toReal();
- return true;
- }
- return false;
-}
-
-QVariant DummySource::backendProperty(const QString &name) const
-{
- if (name == QStringLiteral("altitude"))
- return altitude;
- return QVariant();
-}
-
-
-void DummySource::setUpdateInterval(int msec)
-{
- const int minInterval = minimumUpdateInterval();
- if (msec == 0) {
- timer->setInterval(minInterval);
- } else if (msec < minInterval) {
- msec = minInterval;
- timer->setInterval(msec);
- } else {
- timer->setInterval(msec);
- }
-
- QGeoPositionInfoSource::setUpdateInterval(msec);
-}
-
-int DummySource::minimumUpdateInterval() const
-{
- return 200;
-}
-
-QGeoPositionInfo DummySource::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
-{
- Q_UNUSED(fromSatellitePositioningMethodsOnly);
- return lastPosition;
-}
-
-QGeoPositionInfoSource::PositioningMethods DummySource::supportedPositioningMethods() const
-{
- return QGeoPositionInfoSource::AllPositioningMethods;
-}
-
-void DummySource::startUpdates()
-{
- lastError = QGeoPositionInfoSource::NoError;
- timer->start();
-}
-
-void DummySource::stopUpdates()
-{
- timer->stop();
-}
-
-void DummySource::requestUpdate(int timeout)
-{
- lastError = QGeoPositionInfoSource::NoError;
- if (timeout == 0)
- timeout = 5000;
- if (timeout < 0)
- timeout = 0;
-
- timeoutTimer->setInterval(timeout);
- timeoutTimer->start();
-
- if (timer->isActive()) {
- timer->stop();
- timer->start();
- }
-
- singleTimer->setInterval(minimumUpdateInterval());
- 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,
- altitude);
-
- 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();
- lastError = QGeoPositionInfoSource::UpdateTimeoutError;
- emit QGeoPositionInfoSource::errorOccurred(lastError);
-}
-
-
-class QGeoPositionInfoSourceFactoryTest : public QObject, public QGeoPositionInfoSourceFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
- FILE "plugin.json")
- Q_INTERFACES(QGeoPositionInfoSourceFactory)
-
-public:
- QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
- QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
-};
-
-QGeoPositionInfoSource *QGeoPositionInfoSourceFactoryTest::positionInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- return new DummySource(parameters, parent);
-}
-
-QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactoryTest::satelliteInfoSource(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent);
- Q_UNUSED(parameters);
- return nullptr;
-}
-
-QGeoAreaMonitorSource *QGeoPositionInfoSourceFactoryTest::areaMonitor(QObject *parent, const QVariantMap &parameters)
-{
- Q_UNUSED(parent);
- Q_UNUSED(parameters);
- return nullptr;
-}
-
-#include "plugin.moc"