summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-12-14 10:29:34 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-14 02:16:40 +0100
commita9ad8886fe25276ea6e81e191392d4c90d207759 (patch)
treedb6e10a7403a48e655e1c4846e9b327cb67c07a0 /tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp
parent3ed0a233231a94cd8adb2fe8dfa212caece0085b (diff)
Fix possible jump in animation timer.
When starting new animations with existing animations running, ensure we force an update to the timer first, so that the new animations can't mistakenly start with a very large delta. This fixes tst_qdeclarativeanimations::alwaysRunToEndRestartBug failure on slow machines. Change-Id: Ida4e5dcf0ff792e6bfe0d244b6e969d04d0b20fa Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp')
-rw-r--r--tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp b/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp
index 083324bdd8..28118aa203 100644
--- a/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp
+++ b/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp
@@ -60,6 +60,7 @@ private slots:
void totalDuration();
void avoidJumpAtStart();
void avoidJumpAtStartWithStop();
+ void avoidJumpAtStartWithRunning();
};
class TestableQAbstractAnimation : public QAbstractAnimation
@@ -180,6 +181,9 @@ void tst_QAbstractAnimation::avoidJumpAtStartWithStop()
TestableQAbstractAnimation anim2;
anim2.setDuration(1000);
+ TestableQAbstractAnimation anim3;
+ anim3.setDuration(1000);
+
anim.start();
QTest::qWait(300);
anim.stop();
@@ -190,10 +194,39 @@ void tst_QAbstractAnimation::avoidJumpAtStartWithStop()
*/
anim2.start();
QTest::qSleep(300);
+ anim3.start();
+ QCoreApplication::processEvents();
+ QVERIFY(anim2.currentTime() < 50);
+ QVERIFY(anim3.currentTime() < 50);
+}
+
+void tst_QAbstractAnimation::avoidJumpAtStartWithRunning()
+{
+ TestableQAbstractAnimation anim;
+ anim.setDuration(2000);
+
+ TestableQAbstractAnimation anim2;
+ anim2.setDuration(1000);
+
+ TestableQAbstractAnimation anim3;
+ anim3.setDuration(1000);
+
+ anim.start();
+ QTest::qWait(300); //make sure timer has started
+
+ /*
+ same test as avoidJumpAtStart, but with an
+ existing running animation
+ */
+ anim2.start();
+ QTest::qSleep(300); //force large delta for next tick
+ anim3.start();
QCoreApplication::processEvents();
QVERIFY(anim2.currentTime() < 50);
+ QVERIFY(anim3.currentTime() < 50);
}
+
QTEST_MAIN(tst_QAbstractAnimation)
#include "tst_qabstractanimation.moc"