diff options
author | Aaron McCarthy <mccarthy.aaron@gmail.com> | 2015-01-20 11:48:16 +1000 |
---|---|---|
committer | Aaron McCarthy <mccarthy.aaron@gmail.com> | 2015-09-10 07:46:11 +0000 |
commit | a3cb74a7ce3d4d138deb2e895288a36a1b3ce3ce (patch) | |
tree | ea69a2d563be4dee567be5bde8de0ddcadcf7074 /tests/auto | |
parent | f6a48c06d3090e553867db327665b3cc44d9b21a (diff) | |
download | qtlocation-a3cb74a7ce3d4d138deb2e895288a36a1b3ce3ce.tar.gz |
Remove dependency on libgeoclue.
Re-implement Geoclue plugin using only Qt DBus dropping both the
build-time and run-time dependency on libgeoclue. Allowing the Geoclue
plugin to be build on all platforms that support Qt DBus.
The priority of the Geoclue plugin has been lowered slightly so that
the native position plugin, if available, has precedence.
[ChangeLog][QtPositioning][Position] The Geoclue plugin has been
re-implemented using Qt DBus.
Task-number: QTBUG-40702
Change-Id: Ia06d089bfb46c10769ccffd765c044c361a9b484
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests/auto')
3 files changed, 105 insertions, 23 deletions
diff --git a/tests/auto/qgeosatelliteinfosource/qgeosatelliteinfosource.pro b/tests/auto/qgeosatelliteinfosource/qgeosatelliteinfosource.pro index 1fb72da7..7c0e7ee2 100644 --- a/tests/auto/qgeosatelliteinfosource/qgeosatelliteinfosource.pro +++ b/tests/auto/qgeosatelliteinfosource/qgeosatelliteinfosource.pro @@ -11,7 +11,4 @@ HEADERS += testqgeosatelliteinfosource_p.h \ QT += positioning testlib -# Define whether a satellite source is available. This must match the logic in -# src/location/location.pro or the test will fail on some platforms. -qtHaveModule(simulator):DEFINES += SATELLITE_SOURCE_AVAILABLE DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qgeosatelliteinfosource/testqgeosatelliteinfosource.cpp b/tests/auto/qgeosatelliteinfosource/testqgeosatelliteinfosource.cpp index c825cdad..d80385c8 100644 --- a/tests/auto/qgeosatelliteinfosource/testqgeosatelliteinfosource.cpp +++ b/tests/auto/qgeosatelliteinfosource/testqgeosatelliteinfosource.cpp @@ -46,6 +46,7 @@ #include "../utils/qlocationtestutils_p.h" Q_DECLARE_METATYPE(QList<QGeoSatelliteInfo>) +Q_DECLARE_METATYPE(QGeoSatelliteInfoSource::Error) #define MAX_WAITING_TIME 50000 @@ -90,6 +91,8 @@ protected: TestQGeoSatelliteInfoSource::TestQGeoSatelliteInfoSource(QObject *parent) : QObject(parent) { + qRegisterMetaType<QGeoSatelliteInfoSource::Error>(); + m_testingDefaultSource = false; } @@ -167,23 +170,26 @@ void TestQGeoSatelliteInfoSource::createDefaultSource() { QObject *parent = new QObject; QGeoSatelliteInfoSource *source = QGeoSatelliteInfoSource::createDefaultSource(parent); - // Satellite sources are available when SATELLITE_SOURCE_AVAILABLE is defined -#if defined(SATELLITE_SOURCE_AVAILABLE) - QVERIFY(source != 0); -#else - QVERIFY(source == 0); -#endif + + // Check that default satellite source is successfully created. + if (!QGeoSatelliteInfoSource::availableSources().isEmpty()) + QVERIFY(source); + else + QVERIFY(!source); + delete parent; } void TestQGeoSatelliteInfoSource::createDefaultSource_noParent() { QGeoSatelliteInfoSource *source = QGeoSatelliteInfoSource::createDefaultSource(0); -#if defined(SATELLITE_SOURCE_AVAILABLE) - QVERIFY(source != 0); -#else - QVERIFY(source == 0); -#endif + + // Check that default satellite source is successfully created. + if (!QGeoSatelliteInfoSource::availableSources().isEmpty()) + QVERIFY(source); + else + QVERIFY(!source); + delete source; } @@ -246,10 +252,16 @@ void TestQGeoSatelliteInfoSource::startUpdates_testIntervals() QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy timeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); + m_source->setUpdateInterval(7000); int interval = m_source->updateInterval(); m_source->startUpdates(); + + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + QTRY_VERIFY_WITH_TIMEOUT((spyView.count() == 1) && (spyUse.count() == 1), 9500); for (int i = 0; i < 6; i++) { QTRY_VERIFY_WITH_TIMEOUT((spyView.count() == 1) && (spyUse.count() == 1) && (timeout.count() == 0), (interval*2)); @@ -275,10 +287,15 @@ void TestQGeoSatelliteInfoSource::startUpdates_testIntervalChangesWhileRunning() QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy timeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); + m_source->setUpdateInterval(0); m_source->startUpdates(); m_source->setUpdateInterval(0); + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + QTRY_VERIFY_WITH_TIMEOUT((spyView.count() > 0) && (spyUse.count() > 0), 7000); QCOMPARE(timeout.count(), 0); spyView.clear(); @@ -330,7 +347,13 @@ void TestQGeoSatelliteInfoSource::startUpdates_testDefaultInterval() QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy timeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); + m_source->startUpdates(); + + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + for (int i = 0; i < 3; i++) { QTRY_VERIFY_WITH_TIMEOUT( (spyView.count() > 0 ) && (spyUse.count() > 0) && (timeout.count() == 0), 7000); spyView.clear(); @@ -347,9 +370,14 @@ void TestQGeoSatelliteInfoSource::startUpdates_testZeroInterval() QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy timeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); m_source->setUpdateInterval(0); m_source->startUpdates(); + + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + for (int i = 0; i < 3; i++) { QTRY_VERIFY_WITH_TIMEOUT( (spyView.count() > 0 ) && (spyUse.count() > 0) && (timeout.count() == 0), 7000); spyView.clear(); @@ -365,9 +393,14 @@ void TestQGeoSatelliteInfoSource::startUpdates_moreThanOnce() SIGNAL(satellitesInViewUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); + m_source->setUpdateInterval(0); m_source->startUpdates(); + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + m_source->startUpdates(); // check there is no crash QTRY_VERIFY_WITH_TIMEOUT((spyView.count() > 0) && (spyUse.count() > 0), MAX_WAITING_TIME); @@ -379,16 +412,20 @@ void TestQGeoSatelliteInfoSource::startUpdates_moreThanOnce() void TestQGeoSatelliteInfoSource::stopUpdates() { - CHECK_SOURCE_VALID; QSignalSpy spyView(m_source, SIGNAL(satellitesInViewUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); + m_source->setUpdateInterval(10000); m_source->startUpdates(); + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + for (int i = 0; i < 2; i++) { QTRY_VERIFY_WITH_TIMEOUT((spyView.count() == 1) && (spyUse.count() == 1), 12000); spyView.clear(); @@ -415,7 +452,13 @@ void TestQGeoSatelliteInfoSource::requestUpdate() QSignalSpy spy(m_source, SIGNAL(requestTimeout())); QSignalSpy spyView(m_source, SIGNAL(satellitesInViewUpdated(QList<QGeoSatelliteInfo>))); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); + m_source->requestUpdate(timeout); + + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + // Geoclue may deliver update instantly if there is a satellite fix QTRY_VERIFY_WITH_TIMEOUT(!spy.isEmpty() || !spyView.isEmpty(), 10); } @@ -436,9 +479,13 @@ void TestQGeoSatelliteInfoSource::requestUpdate_validTimeout() QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy spyTimeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); m_source->requestUpdate(7000); + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + QTRY_VERIFY_WITH_TIMEOUT( (spyView.count() == 1) && (spyUse.count() == 1 && (spyTimeout.count()) == 0), 7000); } @@ -452,9 +499,13 @@ void TestQGeoSatelliteInfoSource::requestUpdate_defaultTimeout() QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy spyTimeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); m_source->requestUpdate(0); + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + QTRY_VERIFY_WITH_TIMEOUT( (spyView.count() == 1) && (spyUse.count() == 1 && (spyTimeout.count()) == 0), MAX_WAITING_TIME); @@ -465,8 +516,13 @@ void TestQGeoSatelliteInfoSource::requestUpdate_timeoutLessThanMinimumInterval() CHECK_SOURCE_VALID; QSignalSpy spyTimeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); + m_source->requestUpdate(1); + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + QTRY_COMPARE_WITH_TIMEOUT(spyTimeout.count(), 1, 1000); } @@ -478,9 +534,13 @@ void TestQGeoSatelliteInfoSource::requestUpdate_repeatedCalls() SIGNAL(satellitesInViewUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); m_source->requestUpdate(7000); + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + QTRY_VERIFY_WITH_TIMEOUT((spyView.count() == 1) && (spyUse.count() == 1), 7000); spyView.clear(); spyUse.clear(); @@ -498,8 +558,13 @@ void TestQGeoSatelliteInfoSource::requestUpdate_overlappingCalls() SIGNAL(satellitesInViewUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); m_source->requestUpdate(7000); + + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + m_source->requestUpdate(7000); QTRY_VERIFY_WITH_TIMEOUT((spyView.count() == 1) && (spyUse.count() == 1), 7000); @@ -515,8 +580,13 @@ void TestQGeoSatelliteInfoSource::requestUpdate_overlappingCallsWithTimeout() SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy spyTimeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); m_source->requestUpdate(0); + + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + m_source->requestUpdate(1); QTRY_COMPARE_WITH_TIMEOUT(spyTimeout.count(), 0, 7000); @@ -533,10 +603,14 @@ void TestQGeoSatelliteInfoSource::requestUpdateAfterStartUpdates_ZeroInterval() QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy spyTimeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); m_source->setUpdateInterval(0); m_source->startUpdates(); + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + QTRY_VERIFY_WITH_TIMEOUT((spyView.count() == 1) && (spyUse.count() == 1), MAX_WAITING_TIME); spyView.clear(); spyUse.clear(); @@ -563,9 +637,14 @@ void TestQGeoSatelliteInfoSource::requestUpdateAfterStartUpdates_SmallInterval() QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy spyTimeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); + m_source->setUpdateInterval(10000); m_source->requestUpdate(7000); + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + m_source->startUpdates(); QTRY_VERIFY_WITH_TIMEOUT((spyView.count() > 0) && (spyUse.count() > 0) @@ -587,9 +666,13 @@ void TestQGeoSatelliteInfoSource::requestUpdateBeforeStartUpdates_ZeroInterval() QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy timeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); m_source->requestUpdate(7000); + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + m_source->setUpdateInterval(0); m_source->startUpdates(); @@ -612,9 +695,13 @@ void TestQGeoSatelliteInfoSource::requestUpdateBeforeStartUpdates_SmallInterval( QSignalSpy spyUse(m_source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>))); QSignalSpy timeout(m_source, SIGNAL(requestTimeout())); + QSignalSpy errorSpy(m_source, SIGNAL(error(QGeoSatelliteInfoSource::Error))); m_source->requestUpdate(7000); + if (!errorSpy.isEmpty()) + QSKIP("Error starting satellite updates."); + m_source->setUpdateInterval(10000); m_source->startUpdates(); @@ -657,6 +744,9 @@ void TestQGeoSatelliteInfoSource::removeSlotForSatellitesInUseUpdated() m_source->requestUpdate(7000); + if (m_source->error() != QGeoSatelliteInfoSource::NoError) + QSKIP("Error starting satellite updates."); + QTRY_VERIFY_WITH_TIMEOUT((m_testSlot2Called == true), 7000); } @@ -673,6 +763,9 @@ void TestQGeoSatelliteInfoSource::removeSlotForSatellitesInViewUpdated() m_source->requestUpdate(7000); + if (m_source->error() != QGeoSatelliteInfoSource::NoError) + QSKIP("Error starting satellite updates."); + QTRY_VERIFY_WITH_TIMEOUT((m_testSlot2Called == true), 7000); } diff --git a/tests/auto/qgeosatelliteinfosource/testqgeosatelliteinfosource_p.h b/tests/auto/qgeosatelliteinfosource/testqgeosatelliteinfosource_p.h index f62bc28c..9efb9dde 100644 --- a/tests/auto/qgeosatelliteinfosource/testqgeosatelliteinfosource_p.h +++ b/tests/auto/qgeosatelliteinfosource/testqgeosatelliteinfosource_p.h @@ -110,14 +110,6 @@ private slots: void removeSlotForSatellitesInUseUpdated(); void removeSlotForSatellitesInViewUpdated(); -#ifdef TST_GYPSYMOCK_ENABLED - // Cases only ran with mock backend - void updateValues(); - void initGoneBad(); - void badUpdates(); -#endif - - private: QGeoSatelliteInfoSource *m_source; bool m_testingDefaultSource; |