summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@jollamobile.com>2013-09-04 17:28:27 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-11 00:08:30 +0100
commit2e75e8c18617250c864d2305a1ad14391e0cf4d7 (patch)
tree0e7c946fa0e9086969adcdd9fb568f90b6dc7487 /tests/auto
parent7b07235bdc4799f1a87b1989fb84cdc3333892c7 (diff)
downloadqtlocation-2e75e8c18617250c864d2305a1ad14391e0cf4d7.tar.gz
Support position accuracy in QNmeaPositionInfoSource.
Extract the HDOP and VDOP from the NMEA stream and calculate the twice the distance root mean square (2DRMS) error based on the user provided User equivalent range error value. [ChangeLog][QtPositioning][QNmeaPositionInfoSource] Added support for reporting position accuracy. Change-Id: I59e5f8c32070fa96ae4d0bd02a18f38663920e05 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp61
-rw-r--r--tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.h2
-rw-r--r--tests/auto/utils/qlocationtestutils.cpp5
-rw-r--r--tests/auto/utils/qlocationtestutils_p.h1
4 files changed, 64 insertions, 5 deletions
diff --git a/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp b/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp
index 4b5f4ff6..c0a57535 100644
--- a/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp
+++ b/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.cpp
@@ -1,5 +1,7 @@
/****************************************************************************
**
+** Copyright (C) 2013 Jolla Ltd.
+** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
@@ -43,6 +45,8 @@
#include "tst_qnmeapositioninfosource.h"
+#include <QtCore/QtNumeric>
+
#ifdef Q_OS_WIN
// Windows seems to require longer timeouts and step length
@@ -103,6 +107,14 @@ void tst_QNmeaPositionInfoSource::minimumUpdateInterval()
QCOMPARE(source.minimumUpdateInterval(), 100);
}
+void tst_QNmeaPositionInfoSource::userEquivalentRangeError()
+{
+ QNmeaPositionInfoSource source(m_mode);
+ QVERIFY(qIsNaN(source.userEquivalentRangeError()));
+ source.setUserEquivalentRangeError(5.1);
+ QVERIFY(qFuzzyCompare(source.userEquivalentRangeError(), 5.1));
+}
+
void tst_QNmeaPositionInfoSource::setUpdateInterval_delayedUpdate()
{
// If an update interval is set, and an update is not available at a
@@ -348,8 +360,11 @@ void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime()
QFETCH(QByteArray, bytes);
QFETCH(QList<QDateTime>, dateTimes);
+ QFETCH(QList<bool>, expectHorizontalAccuracy);
+ QFETCH(QList<bool>, expectVerticalAccuracy);
QNmeaPositionInfoSource source(m_mode);
+ source.setUserEquivalentRangeError(5.1);
QNmeaPositionInfoSourceProxyFactory factory;
QNmeaPositionInfoSourceProxy *proxy = static_cast<QNmeaPositionInfoSourceProxy*>(factory.createProxy(&source));
@@ -359,14 +374,33 @@ void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime()
proxy->feedBytes(bytes);
QTRY_COMPARE(spy.count(), dateTimes.count());
- for (int i=0; i<spy.count(); i++)
- QCOMPARE(spy[i][0].value<QGeoPositionInfo>().timestamp(), dateTimes[i]);
+ for (int i=0; i<spy.count(); i++) {
+ QGeoPositionInfo pInfo = spy[i][0].value<QGeoPositionInfo>();
+
+ QCOMPARE(pInfo.timestamp(), dateTimes[i]);
+
+ // Generated GGA/GSA sentences have hard coded HDOP of 3.5, which corrisponds to a
+ // horizontal accuracy of 35.7, for the user equivalent range error of 5.1 set above.
+ QCOMPARE(pInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy),
+ expectHorizontalAccuracy[i]);
+ if (pInfo.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
+ QVERIFY(qFuzzyCompare(pInfo.attribute(QGeoPositionInfo::HorizontalAccuracy), 35.7));
+
+ // Generate GSA sentences have hard coded VDOP of 4.0, which corrisponds to a vertical
+ // accuracy of 40.8, for the user equivalent range error of 5.1 set above.
+ QCOMPARE(pInfo.hasAttribute(QGeoPositionInfo::VerticalAccuracy),
+ expectVerticalAccuracy[i]);
+ if (pInfo.hasAttribute(QGeoPositionInfo::VerticalAccuracy))
+ QVERIFY(qFuzzyCompare(pInfo.attribute(QGeoPositionInfo::VerticalAccuracy), 40.8));
+ }
}
void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime_data()
{
QTest::addColumn<QByteArray>("bytes");
QTest::addColumn<QList<QDateTime> >("dateTimes");
+ QTest::addColumn<QList<bool> >("expectHorizontalAccuracy");
+ QTest::addColumn<QList<bool> >("expectVerticalAccuracy");
QDateTime dt = QDateTime::currentDateTime().toUTC();
QByteArray bytes;
@@ -376,7 +410,9 @@ void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime_data()
bytes += QLocationTestUtils::createRmcSentence(dt.addSecs(2)).toLatin1();
bytes += QLocationTestUtils::createGgaSentence(dt.addSecs(3).time()).toLatin1();
QTest::newRow("Feed GGA,RMC,GGA; expect RMC, second GGA only")
- << bytes << (QList<QDateTime>() << dt.addSecs(2) << dt.addSecs(3));
+ << bytes << (QList<QDateTime>() << dt.addSecs(2) << dt.addSecs(3))
+ << (QList<bool>() << true << true)
+ << (QList<bool>() << false << false);
// should not receive ZDA (has no coordinates) but should get the GGA
// sentence after it since it got the date/time from ZDA
@@ -385,7 +421,20 @@ void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime_data()
bytes += QLocationTestUtils::createZdaSentence(dt.addSecs(2)).toLatin1();
bytes += QLocationTestUtils::createGgaSentence(dt.addSecs(3).time()).toLatin1();
QTest::newRow("Feed GGA,ZDA,GGA; expect second GGA only")
- << bytes << (QList<QDateTime>() << dt.addSecs(3));
+ << bytes << (QList<QDateTime>() << dt.addSecs(3))
+ << (QList<bool>() << true)
+ << (QList<bool>() << false);
+
+ // Feed ZDA,GGA,GSA,GGA; expect vertical accuracy from second GGA.
+ bytes.clear();
+ bytes += QLocationTestUtils::createZdaSentence(dt.addSecs(1)).toLatin1();
+ bytes += QLocationTestUtils::createGgaSentence(dt.addSecs(2).time()).toLatin1();
+ bytes += QLocationTestUtils::createGsaSentence().toLatin1();
+ bytes += QLocationTestUtils::createGgaSentence(dt.addSecs(3).time()).toLatin1();
+ QTest::newRow("Feed ZDA,GGA,GSA,GGA; expect vertical accuracy from second GGA")
+ << bytes << (QList<QDateTime>() << dt.addSecs(2) << dt.addSecs(3))
+ << (QList<bool>() << true << true)
+ << (QList<bool>() << false << true);
if (m_mode == QNmeaPositionInfoSource::SimulationMode) {
// In sim m_mode, should ignore sentence with a date/time before the known date/time
@@ -395,7 +444,9 @@ void tst_QNmeaPositionInfoSource::startUpdates_waitForValidDateTime_data()
bytes += QLocationTestUtils::createRmcSentence(dt.addSecs(-2)).toLatin1();
bytes += QLocationTestUtils::createRmcSentence(dt.addSecs(2)).toLatin1();
QTest::newRow("Feed good RMC, RMC with bad date/time, good RMC; expect first and third RMC only")
- << bytes << (QList<QDateTime>() << dt.addSecs(1) << dt.addSecs(2));
+ << bytes << (QList<QDateTime>() << dt.addSecs(1) << dt.addSecs(2))
+ << (QList<bool>() << false << false)
+ << (QList<bool>() << false << false);
}
}
diff --git a/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.h b/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.h
index d541465d..9d837933 100644
--- a/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.h
+++ b/tests/auto/qnmeapositioninfosource/tst_qnmeapositioninfosource.h
@@ -96,6 +96,8 @@ private slots:
void minimumUpdateInterval();
+ void userEquivalentRangeError();
+
void setUpdateInterval_delayedUpdate();
void lastKnownPosition();
diff --git a/tests/auto/utils/qlocationtestutils.cpp b/tests/auto/utils/qlocationtestutils.cpp
index 97e4f8d9..d5eed344 100644
--- a/tests/auto/utils/qlocationtestutils.cpp
+++ b/tests/auto/utils/qlocationtestutils.cpp
@@ -93,3 +93,8 @@ QString QLocationTestUtils::createZdaSentence(const QDateTime &dt)
.arg(time).arg(dt.toString("dd")).arg(dt.toString("MM")).arg(dt.toString("yyyy"));
return addNmeaChecksumAndBreaks(nmea);
}
+
+QString QLocationTestUtils::createGsaSentence()
+{
+ return addNmeaChecksumAndBreaks(QStringLiteral("$GPGSA,A,3,,,,,,,,,,,,,3.0,3.5,4.0*"));
+}
diff --git a/tests/auto/utils/qlocationtestutils_p.h b/tests/auto/utils/qlocationtestutils_p.h
index 2c827d41..6ed5de38 100644
--- a/tests/auto/utils/qlocationtestutils_p.h
+++ b/tests/auto/utils/qlocationtestutils_p.h
@@ -57,6 +57,7 @@ namespace QLocationTestUtils
QString createGgaSentence(const QTime &time);
QString createGgaSentence(int lat, int lng, const QTime &time);
QString createZdaSentence(const QDateTime &dt);
+ QString createGsaSentence();
//The purpose of compareEquality() is to test equality
//operators where it is expected that A == B.