/**************************************************************************** ** ** 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$ ** ****************************************************************************/ //TESTED_COMPONENT=src/location #include #include #include #include #include #include #include QT_USE_NAMESPACE Q_DECLARE_METATYPE(QGeoSatelliteInfo) Q_DECLARE_METATYPE(QGeoSatelliteInfo::Attribute) QByteArray tst_qgeosatelliteinfo_debug; void tst_qgeosatelliteinfo_messageHandler(QtMsgType type, const QMessageLogContext &, const QString &msg) { switch (type) { case QtDebugMsg : tst_qgeosatelliteinfo_debug = msg.toLocal8Bit(); break; default: break; } } QList tst_qgeosatelliteinfo_qrealTestValues() { QList values; if (qreal(DBL_MIN) == DBL_MIN) values << DBL_MIN; values << FLT_MIN; values << -1.0 << 0.0 << 1.0; values << FLT_MAX; if (qreal(DBL_MAX) == DBL_MAX) values << DBL_MAX; return values; } QList tst_qgeosatelliteinfo_intTestValues() { QList values; values << INT_MIN << -100 << 0 << 100 << INT_MAX; return values; } QList tst_qgeosatelliteinfo_getAttributes() { QList attributes; attributes << QGeoSatelliteInfo::Elevation << QGeoSatelliteInfo::Azimuth; return attributes; } class tst_QGeoSatelliteInfo : public QObject { Q_OBJECT private: QGeoSatelliteInfo updateWithAttribute(QGeoSatelliteInfo::Attribute attribute, qreal value) { QGeoSatelliteInfo info; info.setAttribute(attribute, value); return info; } void addTestData_update() { QTest::addColumn("info"); QList intValues = tst_qgeosatelliteinfo_intTestValues(); for (int i=0; i attributes = tst_qgeosatelliteinfo_getAttributes(); QList qrealValues = tst_qgeosatelliteinfo_qrealTestValues(); for (int i=0; i attributes = tst_qgeosatelliteinfo_getAttributes(); for (int i=0; i("signal"); QList intValues = tst_qgeosatelliteinfo_intTestValues(); for (int i=0; i("satId"); QList intValues = tst_qgeosatelliteinfo_intTestValues(); for (int i=0; i(system)); QCOMPARE(info.satelliteSystem(), static_cast(system)); } void setSatelliteSystem_data() { QTest::addColumn("system"); QTest::newRow("Sat system undefined") << int(QGeoSatelliteInfo::Undefined); QTest::newRow("Sat system GPS") << int(QGeoSatelliteInfo::GPS); QTest::newRow("Sat system GLONASS") << int(QGeoSatelliteInfo::GLONASS); } void attribute() { QFETCH(QGeoSatelliteInfo::Attribute, attribute); QFETCH(qreal, value); QGeoSatelliteInfo u; QCOMPARE(u.attribute(attribute), qreal(-1.0)); u.setAttribute(attribute, value); QCOMPARE(u.attribute(attribute), value); u.removeAttribute(attribute); QCOMPARE(u.attribute(attribute), qreal(-1.0)); } void attribute_data() { QTest::addColumn("attribute"); QTest::addColumn("value"); QList props; props << QGeoSatelliteInfo::Elevation << QGeoSatelliteInfo::Azimuth; for (int i=0; i> inInfo; QCOMPARE(inInfo, info); } void datastream_data() { addTestData_update(); } void debug() { QFETCH(QGeoSatelliteInfo, info); QFETCH(int, nextValue); QFETCH(QByteArray, debugString); qInstallMessageHandler(tst_qgeosatelliteinfo_messageHandler); qDebug() << info << nextValue; qInstallMessageHandler(0); QCOMPARE(QString(tst_qgeosatelliteinfo_debug), QString(debugString)); } void debug_data() { QTest::addColumn("info"); QTest::addColumn("nextValue"); QTest::addColumn("debugString"); QGeoSatelliteInfo info; 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 << 60 << QByteArray("QGeoSatelliteInfo(system=0, satId=-1, signal-strength=1) 60"); info = QGeoSatelliteInfo(); info.setSatelliteIdentifier(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 << 1 << QByteArray("QGeoSatelliteInfo(system=1, satId=-1, signal-strength=-1) 1"); info = QGeoSatelliteInfo(); info.setSatelliteSystem(QGeoSatelliteInfo::GLONASS); 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 << 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 << 45 << QByteArray("QGeoSatelliteInfo(system=0, satId=-1, signal-strength=-1, Azimuth=1.1) 45"); } }; QTEST_APPLESS_MAIN(tst_QGeoSatelliteInfo) #include "tst_qgeosatelliteinfo.moc"