summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-10-09 14:57:00 (GMT)
committerLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-10-09 15:40:16 (GMT)
commitd98012baf3315fad975d0c0acbab13a54ea15caa (patch)
treec8b109b32e676511152b2b8520b305a985ac1fd2
parent9b70924fe2ff5b4bc7246c46a9e3af764bb8bbc8 (diff)
downloadQt-d98012baf3315fad975d0c0acbab13a54ea15caa.zip
Qt-d98012baf3315fad975d0c0acbab13a54ea15caa.tar.gz
Qt-d98012baf3315fad975d0c0acbab13a54ea15caa.tar.bz2
Fixes QPauseAnimation autotests for unreliable timer intervals on Windows
The timer interval used currently on Windows is 16 ms, but we get ticks at every 32 ms on average, so the consistent timing is not reliable on windows. We should use the multimedia timer instead (use 15 ms for QTimer), once qt is able to handle events while native event loops are running. When this is done, the ifdefs introduced in this commit should be removed. Reviewed-by: thierry
-rw-r--r--tests/auto/qpauseanimation/tst_qpauseanimation.cpp43
1 files changed, 30 insertions, 13 deletions
diff --git a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp
index 0c742af..62b43c4 100644
--- a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp
+++ b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp
@@ -70,6 +70,21 @@ protected:
}
};
+class EnableConsistentTiming
+{
+public:
+ EnableConsistentTiming()
+ {
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setConsistentTiming(true);
+ }
+ ~EnableConsistentTiming()
+ {
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setConsistentTiming(false);
+ }
+};
+
class tst_QPauseAnimation : public QObject
{
Q_OBJECT
@@ -187,8 +202,7 @@ void tst_QPauseAnimation::mulitplePauseAnimations()
void tst_QPauseAnimation::pauseAndPropertyAnimations()
{
- QUnifiedTimer *timer = QUnifiedTimer::instance();
- timer->setConsistentTiming(true);
+ EnableConsistentTiming enabled;
TestablePauseAnimation pause;
pause.setDuration(200);
@@ -210,11 +224,13 @@ void tst_QPauseAnimation::pauseAndPropertyAnimations()
QTest::qWait(animation.totalDuration() + 100);
+#ifdef Q_OS_WIN
+ if (animation.state() != QAbstractAnimation::Stopped)
+ QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort);
+#endif
QVERIFY(animation.state() == QAbstractAnimation::Stopped);
QVERIFY(pause.state() == QAbstractAnimation::Stopped);
QVERIFY(pause.m_updateCurrentTimeCount > 3);
-
- timer->setConsistentTiming(false);
}
void tst_QPauseAnimation::pauseResume()
@@ -250,7 +266,7 @@ void tst_QPauseAnimation::sequentialPauseGroup()
QVERIFY(animation2.state() == QAbstractAnimation::Stopped);
QVERIFY(animation3.state() == QAbstractAnimation::Stopped);
- QTest::qWait(250);
+ group.setCurrentTime(250);
QVERIFY(group.state() == QAbstractAnimation::Running);
QVERIFY(animation1.state() == QAbstractAnimation::Stopped);
@@ -258,7 +274,7 @@ void tst_QPauseAnimation::sequentialPauseGroup()
QVERIFY(animation2.state() == QAbstractAnimation::Running);
QVERIFY(animation3.state() == QAbstractAnimation::Stopped);
- QTest::qWait(250);
+ group.setCurrentTime(500);
QVERIFY(group.state() == QAbstractAnimation::Running);
QVERIFY(animation1.state() == QAbstractAnimation::Stopped);
@@ -266,7 +282,7 @@ void tst_QPauseAnimation::sequentialPauseGroup()
QCOMPARE(&animation3, group.currentAnimation());
QVERIFY(animation3.state() == QAbstractAnimation::Running);
- QTest::qWait(250);
+ group.setCurrentTime(750);
QVERIFY(group.state() == QAbstractAnimation::Stopped);
QVERIFY(animation1.state() == QAbstractAnimation::Stopped);
@@ -296,14 +312,14 @@ void tst_QPauseAnimation::sequentialGroupWithPause()
QVERIFY(animation.state() == QAbstractAnimation::Running);
QVERIFY(pause.state() == QAbstractAnimation::Stopped);
- QTest::qWait(300);
+ group.setCurrentTime(300);
QVERIFY(group.state() == QAbstractAnimation::Running);
QVERIFY(animation.state() == QAbstractAnimation::Stopped);
QCOMPARE(&pause, group.currentAnimation());
QVERIFY(pause.state() == QAbstractAnimation::Running);
- QTest::qWait(300);
+ group.setCurrentTime(600);
QVERIFY(group.state() == QAbstractAnimation::Stopped);
QVERIFY(animation.state() == QAbstractAnimation::Stopped);
@@ -314,8 +330,7 @@ void tst_QPauseAnimation::sequentialGroupWithPause()
void tst_QPauseAnimation::multipleSequentialGroups()
{
- QUnifiedTimer *timer = QUnifiedTimer::instance();
- timer->setConsistentTiming(true);
+ EnableConsistentTiming enabled;
QParallelAnimationGroup group;
group.setLoopCount(2);
@@ -368,6 +383,10 @@ void tst_QPauseAnimation::multipleSequentialGroups()
QTest::qWait(group.totalDuration() + 100);
+#ifdef Q_OS_WIN
+ if (group.state() != QAbstractAnimation::Stopped)
+ QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort);
+#endif
QVERIFY(group.state() == QAbstractAnimation::Stopped);
QVERIFY(subgroup1.state() == QAbstractAnimation::Stopped);
QVERIFY(subgroup2.state() == QAbstractAnimation::Stopped);
@@ -375,8 +394,6 @@ void tst_QPauseAnimation::multipleSequentialGroups()
QVERIFY(subgroup4.state() == QAbstractAnimation::Stopped);
QCOMPARE(pause5.m_updateCurrentTimeCount, 4);
-
- timer->setConsistentTiming(false);
}
void tst_QPauseAnimation::zeroDuration()