summaryrefslogtreecommitdiffstats
path: root/tests/auto/qeasingcurve
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qeasingcurve')
-rw-r--r--tests/auto/qeasingcurve/tst_qeasingcurve.cpp115
1 files changed, 115 insertions, 0 deletions
diff --git a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
index 12ddff1..abb4014 100644
--- a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
+++ b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
@@ -69,6 +69,10 @@ private slots:
void valueForProgress();
void setCustomType();
void operators();
+ void dataStreamOperators_data();
+ void dataStreamOperators();
+ void properties();
+ void metaTypes();
protected:
};
@@ -505,6 +509,117 @@ 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
+ Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing)
+public:
+ tst_QEasingProperties(QObject *parent = 0) : QObject(parent) {}
+
+ QEasingCurve easing() const { return e; }
+ void setEasing(const QEasingCurve& value) { e = value; }
+
+private:
+ QEasingCurve e;
+};
+
+// Test getting and setting easing properties via the metaobject system.
+void tst_QEasingCurve::properties()
+{
+ tst_QEasingProperties obj;
+
+ QEasingCurve inOutBack(QEasingCurve::InOutBack);
+ qreal overshoot = 1.5f;
+ inOutBack.setOvershoot(overshoot);
+ qreal amplitude = inOutBack.amplitude();
+ qreal period = inOutBack.period();
+
+ obj.setEasing(inOutBack);
+
+ QEasingCurve easing = qVariantValue<QEasingCurve>(obj.property("easing"));
+ QCOMPARE(easing.type(), QEasingCurve::InOutBack);
+ QCOMPARE(easing.overshoot(), overshoot);
+ QCOMPARE(easing.amplitude(), amplitude);
+ QCOMPARE(easing.period(), period);
+
+ QEasingCurve linear(QEasingCurve::Linear);
+ overshoot = linear.overshoot();
+ amplitude = linear.amplitude();
+ period = linear.period();
+
+ obj.setProperty("easing",
+ qVariantFromValue(QEasingCurve(QEasingCurve::Linear)));
+
+ easing = qVariantValue<QEasingCurve>(obj.property("easing"));
+ QCOMPARE(easing.type(), QEasingCurve::Linear);
+ QCOMPARE(easing.overshoot(), overshoot);
+ QCOMPARE(easing.amplitude(), amplitude);
+ QCOMPARE(easing.period(), period);
+}
+
+void tst_QEasingCurve::metaTypes()
+{
+ QVERIFY(QMetaType::type("QEasingCurve") == QMetaType::QEasingCurve);
+
+ QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QEasingCurve)),
+ QByteArray("QEasingCurve"));
+
+ QVERIFY(QMetaType::isRegistered(QMetaType::QEasingCurve));
+
+ QVERIFY(qMetaTypeId<QEasingCurve>() == QMetaType::QEasingCurve);
+}
QTEST_MAIN(tst_QEasingCurve)
#include "tst_qeasingcurve.moc"