diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2012-04-16 23:47:19 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-17 10:15:44 +0200 |
commit | 1bbd9d8ee563c0741f5f0767b24413a863b63d95 (patch) | |
tree | 783a46e3cede17cc6a8ed4b7ba4df9e3a55f7896 /tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp | |
parent | 5192b06ccb3a015a224c8a5efb23d5c8029b1156 (diff) |
Make failures in QTimeLine autotest more stable.
QTimeLine appears to have very poor timing characteristics. Historical
CI logs show roughly one failure in every twenty-five test runs on
Windows, and less frequent failures on Mac and Linux.
The root of the problem seems to be that QTimeLine's currentTime
counter appears to run at a variable speed and the only guarantee is
that it is slower than wall time. The frameChanged() test
function waited for double the expected duration of the timeline and
still found that the timeline had failed to finish in about one in every
thirty test runs. The interpolation() test function also failed for the
same reason, though less often.
This commit makes the frameChanged test more strict so that the poor
timing will be demonstrated more often, waiting only 1.5 times the
duration instead of double the duration. It also makes the test fail
gracefully so that this known issue won't disrupt CI when the test is
made significant in a later commit.
Task-number: QTBUG-24796
Change-Id: If469d43abb662e24445a9da619052eea9cf7c581
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp index 4ac0e91755..b15de5c1df 100644 --- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp @@ -369,6 +369,8 @@ void tst_QTimeLine::interpolation() QCOMPARE(timeLine.state(), QTimeLine::Running); // Smooth accellerates slowly so in the beginning so it is farther behind + if (firstValue >= timeLine.currentFrame()) + QEXPECT_FAIL("", "QTBUG-24796: QTimeLine exhibits inconsistent timing behaviour", Abort); QVERIFY(firstValue < timeLine.currentFrame()); QTest::qWait(200); QVERIFY(endValue > timeLine.currentFrame()); @@ -457,24 +459,33 @@ void tst_QTimeLine::toggleDirection() void tst_QTimeLine::frameChanged() { QTimeLine timeLine; + timeLine.setCurveShape(QTimeLine::LinearCurve); timeLine.setFrameRange(0,9); - timeLine.setUpdateInterval(1000); + timeLine.setUpdateInterval(800); QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int))); QVERIFY(spy.isValid()); + + // Test what happens when duration expires before all frames are emitted. timeLine.start(); - QTest::qWait(timeLine.duration()*2); + QTest::qWait(timeLine.duration()/2); + QCOMPARE(timeLine.state(), QTimeLine::Running); + QCOMPARE(spy.count(), 0); + QTest::qWait(timeLine.duration()); + if (timeLine.state() != QTimeLine::NotRunning) + QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - // Probably 10 - QVERIFY(spy.count() <= 10 && spy.count() > 0); + if (spy.count() != 1) + QEXPECT_FAIL("", "QTBUG-24796: QTimeLine runs slower than it should", Abort); + QCOMPARE(spy.count(), 1); + // Test what happens when the frames are all emitted well before duration expires. timeLine.setUpdateInterval(5); spy.clear(); timeLine.setCurrentTime(0); timeLine.start(); QTest::qWait(timeLine.duration()*2); QCOMPARE(timeLine.state(), QTimeLine::NotRunning); - // Probably 1 - QVERIFY(spy.count() <= 10 && spy.count() > 0); + QCOMPARE(spy.count(), 10); } void tst_QTimeLine::stopped() |