summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpropertyanimation
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-08-25 13:36:37 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-08-25 13:36:37 (GMT)
commit48489988521b818bda8d76e60cb272508e91b490 (patch)
treec27861bf42049a62dda5e13b91fa2a5c11a8e6bd /tests/auto/qpropertyanimation
parent1cc4ed833f75bc363507bcb7db235bff16785d88 (diff)
downloadQt-48489988521b818bda8d76e60cb272508e91b490.zip
Qt-48489988521b818bda8d76e60cb272508e91b490.tar.gz
Qt-48489988521b818bda8d76e60cb272508e91b490.tar.bz2
animations: make sure setCurrentTime is called on all animations
The problem was we were iterating over the list of running animations. And when calling setCurrentTime(<duration>) on one of them they just unregister themselves from the timer and we would miss some of them. Reviewed-by: leo
Diffstat (limited to 'tests/auto/qpropertyanimation')
-rw-r--r--tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
index 3ff177a..04cfe1a 100644
--- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
+++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp
@@ -114,6 +114,7 @@ private slots:
void updateOnSetKeyValues();
void restart();
void valueChanged();
+ void twoAnimations();
};
tst_QPropertyAnimation::tst_QPropertyAnimation()
@@ -1079,6 +1080,55 @@ void tst_QPropertyAnimation::valueChanged()
}
}
+//this class will help us make sure that 2 animations started
+//at the same time also end at the same time
+class MySyncObject : public MyErrorObject
+{
+ Q_OBJECT
+public:
+ MySyncObject() : anim(this, "ole")
+ {
+ anim.setEndValue(1000);
+ }
+public slots:
+ void checkAnimationFinished()
+ {
+ QCOMPARE(anim.state(), QAbstractAnimation::Stopped);
+ QCOMPARE(ole(), 1000);
+ }
+
+public:
+ QPropertyAnimation anim;
+};
+
+void tst_QPropertyAnimation::twoAnimations()
+{
+ MySyncObject o1, o2;
+ o1.setOle(0);
+ o2.setOle(0);
+
+ //when the animation in o1 is finished
+ //the animation in o2 should stop around the same time
+ //We use a queued connection to check just after the tick from the common timer
+ //the other way is true too
+ QObject::connect(&o1.anim, SIGNAL(finished()),
+ &o2, SLOT(checkAnimationFinished()), Qt::QueuedConnection);
+ QObject::connect(&o2.anim, SIGNAL(finished()),
+ &o1, SLOT(checkAnimationFinished()), Qt::QueuedConnection);
+
+ o1.anim.start();
+ o2.anim.start();
+
+ QTest::qWait(o1.anim.duration() + 50);
+ QCOMPARE(o1.anim.state(), QAbstractAnimation::Stopped);
+ QCOMPARE(o2.anim.state(), QAbstractAnimation::Stopped);
+
+ QCOMPARE(o1.ole(), 1000);
+ QCOMPARE(o2.ole(), 1000);
+
+}
+
+
QTEST_MAIN(tst_QPropertyAnimation)