diff options
-rw-r--r-- | tests/auto/qdatastream/tst_qdatastream.cpp | 69 | ||||
-rw-r--r-- | tests/auto/qeasingcurve/tst_qeasingcurve.cpp | 54 |
2 files changed, 69 insertions, 54 deletions
diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp index c94ea7b..31e12fe 100644 --- a/tests/auto/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/qdatastream/tst_qdatastream.cpp @@ -162,6 +162,9 @@ private slots: void stream_QIcon_data(); void stream_QIcon(); + void stream_QEasingCurve_data(); + void stream_QEasingCurve(); + void stream_atEnd_data(); void stream_atEnd(); @@ -243,6 +246,7 @@ private: void writeqint64(QDataStream *s); void writeQWMatrix(QDataStream *s); void writeQIcon(QDataStream *s); + void writeQEasingCurve(QDataStream *s); void readbool(QDataStream *s); void readQBool(QDataStream *s); @@ -272,6 +276,7 @@ private: void readqint64(QDataStream *s); void readQWMatrix(QDataStream *s); void readQIcon(QDataStream *s); + void readQEasingCurve(QDataStream *s); private: QString svgFile; @@ -687,6 +692,70 @@ void tst_QDataStream::readHash(QDataStream *s) // ************************************ +static QEasingCurve QEasingCurveData(int index) +{ + QEasingCurve easing; + + switch (index) { + case 0: + default: + break; + case 1: + easing.setType(QEasingCurve::Linear); + break; + case 2: + easing.setType(QEasingCurve::OutCubic); + break; + case 3: + easing.setType(QEasingCurve::InOutSine); + break; + case 4: + easing.setType(QEasingCurve::InOutElastic); + easing.setPeriod(1.5); + easing.setAmplitude(2.0); + break; + case 5: + easing.setType(QEasingCurve::OutInBack); + break; + case 6: + easing.setType(QEasingCurve::OutCurve); + break; + case 7: + easing.setType(QEasingCurve::InOutBack); + easing.setOvershoot(0.5); + break; + } + return easing; +} +#define MAX_EASING_DATA 8 + +void tst_QDataStream::stream_QEasingCurve_data() +{ + stream_data(MAX_EASING_DATA); +} + +void tst_QDataStream::stream_QEasingCurve() +{ + STREAM_IMPL(QEasingCurve); +} + +void tst_QDataStream::writeQEasingCurve(QDataStream* s) +{ + QEasingCurve test(QEasingCurveData(dataIndex(QTest::currentDataTag()))); + *s << test; +} + +void tst_QDataStream::readQEasingCurve(QDataStream *s) +{ + QEasingCurve S; + QEasingCurve expected(QEasingCurveData(dataIndex(QTest::currentDataTag()))); + + *s >> S; + QCOMPARE(S, expected); +} + +// ************************************ + // contains some quint64 testing as well #define MAX_qint64_DATA 4 diff --git a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp index abb4014..124f900 100644 --- a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp @@ -69,8 +69,6 @@ private slots: void valueForProgress(); void setCustomType(); void operators(); - void dataStreamOperators_data(); - void dataStreamOperators(); void properties(); void metaTypes(); @@ -509,58 +507,6 @@ void tst_QEasingCurve::operators() QVERIFY(curve2 == curve); } -void tst_QEasingCurve::dataStreamOperators_data() -{ - QTest::addColumn<int>("type"); - QTest::addColumn<qreal>("amplitude"); - QTest::addColumn<qreal>("overshoot"); - QTest::addColumn<qreal>("period"); - QTest::addColumn<QEasingCurve>("easingCurve"); - QTest::newRow("Linear") << int(QEasingCurve::Linear) << -1.0 << -1.0 << -1.0 << QEasingCurve(QEasingCurve::Linear); - QTest::newRow("OutCubic") << int(QEasingCurve::OutCubic) << -1.0 << -1.0 << -1.0 << QEasingCurve(QEasingCurve::OutCubic); - QTest::newRow("InOutSine") << int(QEasingCurve::InOutSine) << -1.0 << -1.0 << -1.0 << QEasingCurve(QEasingCurve::InOutSine); - QEasingCurve inOutElastic(QEasingCurve::InOutElastic); - inOutElastic.setPeriod(1.5); - inOutElastic.setAmplitude(2.0); - QTest::newRow("InOutElastic") << int(QEasingCurve::InOutElastic) << 2.0 << -1.0 << 1.5 << inOutElastic; - QTest::newRow("OutInBack") << int(QEasingCurve::OutInBack) << -1.0 << -1.0 << -1.0 << QEasingCurve(QEasingCurve::OutInBack); - QTest::newRow("OutCurve") << int(QEasingCurve::OutCurve) << -1.0 << -1.0 << -1.0 << QEasingCurve(QEasingCurve::OutCurve); - QEasingCurve inOutBack(QEasingCurve::InOutBack); - inOutBack.setOvershoot(0.5); - QTest::newRow("InOutBack") << int(QEasingCurve::InOutBack) << -1.0 << 0.5 << -1.0 << inOutBack; -} - -void tst_QEasingCurve::dataStreamOperators() -{ - QFETCH(int, type); - QFETCH(qreal, amplitude); - QFETCH(qreal, overshoot); - QFETCH(qreal, period); - QFETCH(QEasingCurve, easingCurve); - - // operator << - QEasingCurve curve; - curve.setType(QEasingCurve::Type(type)); - if (amplitude != -1.0) - curve.setAmplitude(amplitude); - if (overshoot != -1.0) - curve.setOvershoot(overshoot); - if (period != -1.0) - curve.setPeriod(period); - - QVERIFY(easingCurve == curve); - - QByteArray array; - QDataStream out(&array, QIODevice::WriteOnly); - out << curve; - - QDataStream in(array); - QEasingCurve curve2; - in >> curve2; - - QVERIFY(curve2 == curve); -} - class tst_QEasingProperties : public QObject { Q_OBJECT |