From 999321fecb9223bcadc702674ca83d8f84bd3886 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 18 Dec 2014 10:20:03 +0100 Subject: Android: Stabilize QPauseAnimation test This will arbitrarily fail at certain points. Adjusting the timeouts helps, but it's very unpredictable, so it's better to do what we do on Windows and just expect-fail the results that we get. Change-Id: Ie6033c73539c2dd69115b06096919e173f097367 Reviewed-by: Friedemann Kleint Reviewed-by: BogDan Vatra --- .../qpauseanimation/tst_qpauseanimation.cpp | 72 ++++++++++++---------- 1 file changed, 38 insertions(+), 34 deletions(-) (limited to 'tests/auto/corelib/animation/qpauseanimation') diff --git a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp index a966f557f5..1b7f28bbfa 100644 --- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp @@ -39,8 +39,12 @@ #include -#ifdef Q_OS_WIN -static const char winTimerError[] = "On windows, consistent timing is not working properly due to bad timer resolution"; +#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID) +# define BAD_TIMER_RESOLUTION +#endif + +#ifdef BAD_TIMER_RESOLUTION +static const char timerError[] = "On this platform, consistent timing is not working properly due to bad timer resolution"; #endif class TestablePauseAnimation : public QPauseAnimation @@ -140,17 +144,17 @@ void tst_QPauseAnimation::noTimerUpdates() animation.start(); QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); const int expectedLoopCount = 1 + loopCount; -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount != expectedLoopCount) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation.m_updateCurrentTimeCount, expectedLoopCount); } @@ -169,41 +173,41 @@ void tst_QPauseAnimation::multiplePauseAnimations() animation2.start(); QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.state() != QAbstractAnimation::Running) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation2.state() == QAbstractAnimation::Running); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount != 2) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation.m_updateCurrentTimeCount, 2); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.m_updateCurrentTimeCount != 2) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation2.m_updateCurrentTimeCount, 2); QTest::qWait(550); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation2.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation2.m_updateCurrentTimeCount != 3) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(animation2.m_updateCurrentTimeCount, 3); } @@ -232,9 +236,9 @@ void tst_QPauseAnimation::pauseAndPropertyAnimations() QTest::qWait(animation.totalDuration() + 100); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(animation.state() == QAbstractAnimation::Stopped); QVERIFY(pause.state() == QAbstractAnimation::Stopped); @@ -253,9 +257,9 @@ void tst_QPauseAnimation::pauseResume() animation.start(); QTRY_COMPARE(animation.state(), QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (animation.m_updateCurrentTimeCount < 3) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY2(animation.m_updateCurrentTimeCount >= 3, qPrintable( QString::fromLatin1("animation.m_updateCurrentTimeCount = %1").arg(animation.m_updateCurrentTimeCount))); @@ -408,39 +412,39 @@ void tst_QPauseAnimation::multipleSequentialGroups() // measure... QTest::qWait(group.totalDuration() + 500); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (group.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(group.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup1.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup1.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup2.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup2.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup3.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup3.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (subgroup4.state() != QAbstractAnimation::Stopped) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QVERIFY(subgroup4.state() == QAbstractAnimation::Stopped); -#ifdef Q_OS_WIN +#ifdef BAD_TIMER_RESOLUTION if (pause5.m_updateCurrentTimeCount != 4) - QEXPECT_FAIL("", winTimerError, Abort); + QEXPECT_FAIL("", timerError, Abort); #endif QCOMPARE(pause5.m_updateCurrentTimeCount, 4); } -- cgit v1.2.3