summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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()