diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp | 60 | ||||
-rw-r--r-- | tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp | 21 | ||||
-rw-r--r-- | tests/auto/qgeopositioninfo/tst_qgeopositioninfo.cpp | 14 | ||||
-rw-r--r-- | tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp | 32 | ||||
-rw-r--r-- | tests/auto/qgeoshape/tst_qgeoshape.cpp | 46 |
5 files changed, 143 insertions, 30 deletions
diff --git a/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp b/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp index 456a8378..9ae6eac8 100644 --- a/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp +++ b/tests/auto/qgeoareamonitor/tst_qgeoareamonitor.cpp @@ -60,6 +60,21 @@ QT_USE_NAMESPACE Q_DECLARE_METATYPE(QGeoPositionInfo) Q_DECLARE_METATYPE(QGeoAreaMonitorInfo) +QString tst_qgeoareamonitorinfo_debug; + +void tst_qgeoareamonitorinfo_messageHandler(QtMsgType type, + const QMessageLogContext &, + const QString &msg) +{ + switch (type) { + case QtDebugMsg : + tst_qgeoareamonitorinfo_debug = msg; + break; + default: + break; + } +} + class tst_QGeoAreaMonitorSource : public QObject { Q_OBJECT @@ -693,6 +708,51 @@ private slots: //obj was deleted when setting new source delete obj2; } + + void debug_data() + { + QTest::addColumn<QGeoAreaMonitorInfo>("info"); + QTest::addColumn<int>("nextValue"); + QTest::addColumn<QString>("debugString"); + + QGeoAreaMonitorInfo info; + QTest::newRow("uninitialized") << info << 45 + << QString("QGeoAreaMonitorInfo(\"\", QGeoShape(Unknown), " + "persistent: false, expiry: QDateTime(\" Qt::LocalTime\") ) 45"); + + info.setArea(QGeoRectangle()); + info.setPersistent(true); + info.setName("RectangleAreaMonitor"); + QTest::newRow("Rectangle Test") << info << 45 + << QString("QGeoAreaMonitorInfo(\"RectangleAreaMonitor\", QGeoShape(Rectangle), " + "persistent: true, expiry: QDateTime(\" Qt::LocalTime\") ) 45"); + + info = QGeoAreaMonitorInfo(); + info.setArea(QGeoCircle()); + info.setPersistent(false); + info.setName("CircleAreaMonitor"); + QVariantMap map; + map.insert(QString("foobarKey"), QVariant(45)); //should be ignored + info.setNotificationParameters(map); + QTest::newRow("Circle Test") << info << 45 + << QString("QGeoAreaMonitorInfo(\"CircleAreaMonitor\", QGeoShape(Circle), " + "persistent: false, expiry: QDateTime(\" Qt::LocalTime\") ) 45"); + + // we ignore any further QDateTime related changes to avoid depending on QDateTime related + // failures in case its QDebug string changes + } + + void debug() + { + QFETCH(QGeoAreaMonitorInfo, info); + QFETCH(int, nextValue); + QFETCH(QString, debugString); + + qInstallMessageHandler(tst_qgeoareamonitorinfo_messageHandler); + qDebug() << info << nextValue; + qInstallMessageHandler(0); + QCOMPARE(tst_qgeoareamonitorinfo_debug, debugString); + } }; diff --git a/tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp b/tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp index 0c960c21..1e069c9e 100644 --- a/tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp +++ b/tests/auto/qgeocoordinate/tst_qgeocoordinate.cpp @@ -879,10 +879,11 @@ private slots: void debug() { QFETCH(QGeoCoordinate, c); + QFETCH(int, nextValue); QFETCH(QByteArray, debugString); qInstallMessageHandler(tst_qgeocoordinate_messageHandler); - qDebug() << c; + qDebug() << c << nextValue; qInstallMessageHandler(0); QCOMPARE(tst_qgeocoordinate_debug, debugString); } @@ -890,17 +891,19 @@ private slots: void debug_data() { QTest::addColumn<QGeoCoordinate>("c"); + QTest::addColumn<int>("nextValue"); QTest::addColumn<QByteArray>("debugString"); - QTest::newRow("uninitialized") << QGeoCoordinate() - << QByteArray("QGeoCoordinate(?, ?)"); - QTest::newRow("initialized without altitude") << BRISBANE - << (QString("QGeoCoordinate(%1, %2)").arg(BRISBANE.latitude()) + + QTest::newRow("uninitialized") << QGeoCoordinate() << 45 + << QByteArray("QGeoCoordinate(?, ?) 45"); + QTest::newRow("initialized without altitude") << BRISBANE << 45 + << (QString("QGeoCoordinate(%1, %2) 45").arg(BRISBANE.latitude()) .arg(BRISBANE.longitude())).toLatin1(); - QTest::newRow("invalid initialization") << QGeoCoordinate(-100,-200) - << QByteArray("QGeoCoordinate(?, ?)"); - QTest::newRow("initialized with altitude") << QGeoCoordinate(1,2,3) - << QByteArray("QGeoCoordinate(1, 2, 3)"); + QTest::newRow("invalid initialization") << QGeoCoordinate(-100,-200) << 45 + << QByteArray("QGeoCoordinate(?, ?) 45"); + QTest::newRow("initialized with altitude") << QGeoCoordinate(1,2,3) << 45 + << QByteArray("QGeoCoordinate(1, 2, 3) 45"); } }; diff --git a/tests/auto/qgeopositioninfo/tst_qgeopositioninfo.cpp b/tests/auto/qgeopositioninfo/tst_qgeopositioninfo.cpp index 66917ed7..c0300713 100644 --- a/tests/auto/qgeopositioninfo/tst_qgeopositioninfo.cpp +++ b/tests/auto/qgeopositioninfo/tst_qgeopositioninfo.cpp @@ -347,10 +347,11 @@ private slots: void debug() { QFETCH(QGeoPositionInfo, info); + QFETCH(int, nextValue); QFETCH(QByteArray, debugStringEnd); qInstallMessageHandler(tst_qgeopositioninfo_messageHandler); - qDebug() << info; + qDebug() << info << nextValue; qInstallMessageHandler(0); // use endsWith() so we don't depend on QDateTime's debug() implementation @@ -363,14 +364,15 @@ private slots: void debug_data() { QTest::addColumn<QGeoPositionInfo>("info"); + QTest::addColumn<int>("nextValue"); QTest::addColumn<QByteArray>("debugStringEnd"); - QTest::newRow("no values") << QGeoPositionInfo() - << QString("QGeoCoordinate(?, ?))").toLatin1(); + QTest::newRow("no values") << QGeoPositionInfo() << 40 + << QString("QGeoCoordinate(?, ?)) 40").toLatin1(); QGeoCoordinate coord(1, 1); QTest::newRow("coord, time") << QGeoPositionInfo(coord, QDateTime::currentDateTime()) - << QByteArray("QGeoCoordinate(1, 1))"); + << 40 << QByteArray("QGeoCoordinate(1, 1)) 40"); QGeoPositionInfo info; info.setAttribute(QGeoPositionInfo::Direction, 1.1); @@ -379,8 +381,8 @@ private slots: info.setAttribute(QGeoPositionInfo::MagneticVariation, 4.1); info.setAttribute(QGeoPositionInfo::HorizontalAccuracy, 5.1); info.setAttribute(QGeoPositionInfo::VerticalAccuracy, 6.1); - QTest::newRow("all attributes") << info - << QByteArray("QGeoCoordinate(?, ?), Direction=1.1, GroundSpeed=2.1, VerticalSpeed=3.1, MagneticVariation=4.1, HorizontalAccuracy=5.1, VerticalAccuracy=6.1)"); + QTest::newRow("all attributes") << info << 40 + << QByteArray("QGeoCoordinate(?, ?), Direction=1.1, GroundSpeed=2.1, VerticalSpeed=3.1, MagneticVariation=4.1, HorizontalAccuracy=5.1, VerticalAccuracy=6.1) 40"); } }; diff --git a/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp b/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp index 07519713..8c55e0de 100644 --- a/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp +++ b/tests/auto/qgeosatelliteinfo/tst_qgeosatelliteinfo.cpp @@ -353,10 +353,11 @@ private slots: void debug() { QFETCH(QGeoSatelliteInfo, info); + QFETCH(int, nextValue); QFETCH(QByteArray, debugString); qInstallMessageHandler(tst_qgeosatelliteinfo_messageHandler); - qDebug() << info; + qDebug() << info << nextValue; qInstallMessageHandler(0); QCOMPARE(QString(tst_qgeosatelliteinfo_debug), QString(debugString)); } @@ -364,42 +365,43 @@ private slots: void debug_data() { QTest::addColumn<QGeoSatelliteInfo>("info"); + QTest::addColumn<int>("nextValue"); QTest::addColumn<QByteArray>("debugString"); QGeoSatelliteInfo info; - QTest::newRow("uninitialized") << info - << QByteArray("QGeoSatelliteInfo(system=0, satId=-1, signal-strength=-1)"); + QTest::newRow("uninitialized") << info << 45 + << QByteArray("QGeoSatelliteInfo(system=0, satId=-1, signal-strength=-1) 45"); info = QGeoSatelliteInfo(); info.setSignalStrength(1); - QTest::newRow("with SignalStrength") << info - << QByteArray("QGeoSatelliteInfo(system=0, satId=-1, signal-strength=1)"); + QTest::newRow("with SignalStrength") << info << 60 + << QByteArray("QGeoSatelliteInfo(system=0, satId=-1, signal-strength=1) 60"); info = QGeoSatelliteInfo(); info.setSatelliteIdentifier(1); - QTest::newRow("with SatelliteIdentifier") << info - << QByteArray("QGeoSatelliteInfo(system=0, satId=1, signal-strength=-1)"); + QTest::newRow("with SatelliteIdentifier") << info << -1 + << QByteArray("QGeoSatelliteInfo(system=0, satId=1, signal-strength=-1) -1"); info = QGeoSatelliteInfo(); info.setSatelliteSystem(QGeoSatelliteInfo::GPS); - QTest::newRow("with System GPS") << info - << QByteArray("QGeoSatelliteInfo(system=1, satId=-1, signal-strength=-1)"); + QTest::newRow("with System GPS") << info << 1 + << QByteArray("QGeoSatelliteInfo(system=1, satId=-1, signal-strength=-1) 1"); info = QGeoSatelliteInfo(); info.setSatelliteSystem(QGeoSatelliteInfo::GLONASS); - QTest::newRow("with System GLONASS") << info - << QByteArray("QGeoSatelliteInfo(system=2, satId=-1, signal-strength=-1)"); + QTest::newRow("with System GLONASS") << info << 56 + << QByteArray("QGeoSatelliteInfo(system=2, satId=-1, signal-strength=-1) 56"); info = QGeoSatelliteInfo(); info.setAttribute(QGeoSatelliteInfo::Elevation, 1.1); - QTest::newRow("with Elevation") << info - << QByteArray("QGeoSatelliteInfo(system=0, satId=-1, signal-strength=-1, Elevation=1.1)"); + QTest::newRow("with Elevation") << info << 0 + << QByteArray("QGeoSatelliteInfo(system=0, satId=-1, signal-strength=-1, Elevation=1.1) 0"); info = QGeoSatelliteInfo(); info.setAttribute(QGeoSatelliteInfo::Azimuth, 1.1); - QTest::newRow("with Azimuth") << info - << QByteArray("QGeoSatelliteInfo(system=0, satId=-1, signal-strength=-1, Azimuth=1.1)"); + QTest::newRow("with Azimuth") << info << 45 + << QByteArray("QGeoSatelliteInfo(system=0, satId=-1, signal-strength=-1, Azimuth=1.1) 45"); } }; diff --git a/tests/auto/qgeoshape/tst_qgeoshape.cpp b/tests/auto/qgeoshape/tst_qgeoshape.cpp index 02d334c2..6c2d5a0a 100644 --- a/tests/auto/qgeoshape/tst_qgeoshape.cpp +++ b/tests/auto/qgeoshape/tst_qgeoshape.cpp @@ -33,6 +33,23 @@ #include <QtTest/QtTest> #include <QtPositioning/QGeoShape> +#include <QtCore/QDebug> +#include <QtPositioning/QGeoRectangle> +#include <QtPositioning/QGeoCircle> + +QString tst_qgeoshape_debug; + +void tst_qgeoshape_messageHandler(QtMsgType type, const QMessageLogContext&, + const QString &msg) +{ + switch (type) { + case QtDebugMsg : + tst_qgeoshape_debug = msg; + break; + default: + break; + } +} class tst_qgeoshape : public QObject { @@ -40,6 +57,8 @@ class tst_qgeoshape : public QObject private slots: void testArea(); + void debug_data(); + void debug(); }; void tst_qgeoshape::testArea() @@ -65,5 +84,32 @@ void tst_qgeoshape::testArea() QCOMPARE(area2, area3); } +void tst_qgeoshape::debug_data() +{ + QTest::addColumn<QGeoShape>("shape"); + QTest::addColumn<int>("nextValue"); + QTest::addColumn<QString>("debugString"); + + QTest::newRow("uninitialized") << QGeoShape() << 45 + << QString("QGeoShape(Unknown) 45"); + QTest::newRow("uninitialized") << QGeoShape(QGeoRectangle()) << 45 + << QString("QGeoShape(Rectangle) 45"); + QTest::newRow("uninitialized") << QGeoShape(QGeoCircle()) << 45 + << QString("QGeoShape(Circle) 45"); +} + + +void tst_qgeoshape::debug() +{ + QFETCH(QGeoShape, shape); + QFETCH(int, nextValue); + QFETCH(QString, debugString); + + qInstallMessageHandler(tst_qgeoshape_messageHandler); + qDebug() << shape << nextValue; + qInstallMessageHandler(0); + QCOMPARE(tst_qgeoshape_debug, debugString); +} + QTEST_MAIN(tst_qgeoshape) #include "tst_qgeoshape.moc" |