diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-12 12:19:15 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-12 12:21:23 (GMT) |
commit | 657de489549bab1f9d2ba759739dd55f65a8532e (patch) | |
tree | ad1878a9bd11bfe0b7b7f03eddf44cfca5bf7dc7 /tests | |
parent | 4cf8deb5da96b00a3b89c5c328aab3d47e1dfbb3 (diff) | |
download | Qt-657de489549bab1f9d2ba759739dd55f65a8532e.zip Qt-657de489549bab1f9d2ba759739dd55f65a8532e.tar.gz Qt-657de489549bab1f9d2ba759739dd55f65a8532e.tar.bz2 |
Make QPropertyAnimation symetric wrt direction
It is now possible to set a start value and no end value and starting
the animation will pick the default end value from the current value
of the property that's being animated.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 6f49d8e..5af6f39 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -102,6 +102,7 @@ private slots: void easingcurve_data(); void easingcurve(); void startWithoutStartValue(); + void startBackwardWithoutEndValue(); void playForwardBackward(); void interpolated(); void setStartEndValues_data(); @@ -582,6 +583,47 @@ void tst_QPropertyAnimation::startWithoutStartValue() QVERIFY(current <= 110); } +void tst_QPropertyAnimation::startBackwardWithoutEndValue() +{ + QObject o; + o.setProperty("ole", 42); + QCOMPARE(o.property("ole").toInt(), 42); + + QPropertyAnimation anim(&o, "ole"); + anim.setStartValue(100); + anim.setDirection(QAbstractAnimation::Backward); + + //we start without an end value + anim.start(); + QCOMPARE(anim.state(), QAbstractAnimation::Running); + QCOMPARE(o.property("ole").toInt(), 42); //the initial value + + QTest::qWait(100); + int current = anim.currentValue().toInt(); + //it is somewhere in the animation + QVERIFY(current > 42); + QVERIFY(current < 100); + + QTest::qWait(200); + QCOMPARE(anim.state(), QVariantAnimation::Stopped); + current = anim.currentValue().toInt(); + QCOMPARE(current, 100); + QCOMPARE(o.property("ole").toInt(), current); + + anim.setStartValue(110); + anim.start(); + current = anim.currentValue().toInt(); + // the default start value will reevaluate the current property + // and set it to the end value of the last iteration + QCOMPARE(current, 100); + QTest::qWait(100); + current = anim.currentValue().toInt(); + //it is somewhere in the animation + QVERIFY(current >= 100); + QVERIFY(current <= 110); +} + + void tst_QPropertyAnimation::playForwardBackward() { QObject o; |