summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpropertyanimation
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-07-01 14:38:37 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-07-01 15:16:11 (GMT)
commit0ee90990c24bf965317918074a5af683e94bdd40 (patch)
tree8a6232e1bc8206a825e490290e9cccb1444eb885 /tests/auto/qpropertyanimation
parent5077f0be81128ee81e8c7875eb9d1e9423868808 (diff)
downloadQt-0ee90990c24bf965317918074a5af683e94bdd40.zip
Qt-0ee90990c24bf965317918074a5af683e94bdd40.tar.gz
Qt-0ee90990c24bf965317918074a5af683e94bdd40.tar.bz2
Animations: adding an autotest for jumping values when restarting
The problem is that when restarting, the time is at the end. So the current value changes to the end value instead of the initial value.
Diffstat (limited to 'tests/auto/qpropertyanimation')
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index a30e9f9..09e12c3 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -111,6 +111,7 @@ private slots:
void operationsInStates();
void oneKeyValue();
void updateOnSetKeyValues();
+ void restart();
};
tst_QPropertyAnimation::tst_QPropertyAnimation()
@@ -559,6 +560,9 @@ void tst_QPropertyAnimation::startWithoutStartValue()
QTest::qWait(200);
QCOMPARE(anim.state(), QVariantAnimation::Stopped);
+ current = anim.currentValue().toInt();
+ QCOMPARE(current, 100);
+ QCOMPARE(o.property("ole").toInt(), current);
anim.setEndValue(110);
anim.start();
@@ -954,5 +958,53 @@ void tst_QPropertyAnimation::updateOnSetKeyValues()
QCOMPARE(animation2.currentValue().toInt(), animation.currentValue().toInt());
}
+
+//this class will 'throw' an error in the test lib
+// if the property ole is set to ErrorValue
+class MyErrorObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int ole READ ole WRITE setOle)
+public:
+
+ static const int ErrorValue = 10000;
+
+ MyErrorObject() : m_ole(0) { }
+ int ole() const { return m_ole; }
+ void setOle(int o)
+ {
+ QVERIFY(o != ErrorValue);
+ m_ole = o;
+ }
+
+private:
+ int m_ole;
+
+
+};
+
+void tst_QPropertyAnimation::restart()
+{
+ //here we check that be restarting an animation
+ //it doesn't get an bogus intermediate value (end value)
+ //because the time is not yet reset to 0
+ MyErrorObject o;
+ o.setOle(100);
+ QCOMPARE(o.property("ole").toInt(), 100);
+
+ QPropertyAnimation anim(&o, "ole");
+ anim.setEndValue(200);
+ anim.start();
+ anim.setCurrentTime(anim.duration());
+ QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
+ QCOMPARE(o.property("ole").toInt(), 200);
+
+ //we'll check that the animation never gets a wrong value when starting it
+ //after having changed the end value
+ anim.setEndValue(MyErrorObject::ErrorValue);
+ anim.start();
+}
+
+
QTEST_MAIN(tst_QPropertyAnimation)
#include "tst_qpropertyanimation.moc"