diff options
Diffstat (limited to 'tests/auto/qgeomaneuver/tst_qgeomaneuver.cpp')
-rw-r--r-- | tests/auto/qgeomaneuver/tst_qgeomaneuver.cpp | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/tests/auto/qgeomaneuver/tst_qgeomaneuver.cpp b/tests/auto/qgeomaneuver/tst_qgeomaneuver.cpp index 25d5bf75..c35b57f6 100644 --- a/tests/auto/qgeomaneuver/tst_qgeomaneuver.cpp +++ b/tests/auto/qgeomaneuver/tst_qgeomaneuver.cpp @@ -27,7 +27,30 @@ ****************************************************************************/ #include "tst_qgeomaneuver.h" +#include <QtLocation/private/qgeomaneuver_p.h> +class QGeoManeuverPrivateDefaultAlt : public QGeoManeuverPrivateDefault +{ +public: + QGeoManeuverPrivateDefaultAlt() {} + QGeoManeuverPrivateDefaultAlt(const QGeoManeuverPrivateDefaultAlt &other) + : QGeoManeuverPrivateDefault(other) {} + ~QGeoManeuverPrivateDefaultAlt() {} + + QString text() const override + { + return QStringLiteral("QGeoManeuverPrivateDefaultAlt"); // To identify this is actually a QGeoManeuverPrivateDefaultAlt + } +}; + +class QGeoManeuverAlt : public QGeoManeuver +{ +public: + QGeoManeuverAlt() + : QGeoManeuver(QSharedDataPointer<QGeoManeuverPrivate>(new QGeoManeuverPrivateDefaultAlt())) + { + } +}; tst_QGeoManeuver::tst_QGeoManeuver() { @@ -241,9 +264,7 @@ void tst_QGeoManeuver::operators(){ qgeomaneuvercopy->setTimeToNextInstruction(70); qgeomaneuvercopy->setDistanceToNextInstruction(56065.45); -// Not passing QVERIFY(!(qgeomaneuver->operator ==(*qgeomaneuvercopy))); -// Not passing QVERIFY(qgeomaneuver->operator !=(*qgeomaneuvercopy)); *qgeomaneuvercopy = qgeomaneuvercopy->operator =(*qgeomaneuver); @@ -253,5 +274,28 @@ void tst_QGeoManeuver::operators(){ delete qgeomaneuvercopy; } +void tst_QGeoManeuver::alternateImplementation() +{ + QGeoManeuver qgeomaneuvercopy = *qgeomaneuver; + + QVERIFY(qgeomaneuvercopy == (*qgeomaneuver)); + + qgeomaneuvercopy.setDirection(QGeoManeuver::DirectionForward); + qgeomaneuvercopy.setInstructionText("Turn left in 80m"); + qgeomaneuvercopy.setTimeToNextInstruction(70); + qgeomaneuvercopy.setDistanceToNextInstruction(56065.45); + + QVERIFY(qgeomaneuvercopy != (*qgeomaneuver)); + + QGeoManeuverAlt mAlt; + QGeoManeuver m = mAlt; + + QCOMPARE(m.instructionText(), "QGeoManeuverPrivateDefaultAlt"); + m = qgeomaneuvercopy; + QCOMPARE(m.instructionText(), "Turn left in 80m"); + m = mAlt; + QCOMPARE(m.instructionText(), "QGeoManeuverPrivateDefaultAlt"); +} + QTEST_APPLESS_MAIN(tst_QGeoManeuver); |