summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>2015-12-14 13:23:47 +0100
committerJędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>2015-12-21 08:52:49 +0000
commit4e012cb08390beb21620b5d3fbf86ad2216b2a6d (patch)
tree71e30df6cb19f5abd65e98897e3f7e90ddeb3e34 /tests
parent266511401f8d513aaeca1380248e5534e33bf55e (diff)
Improve tst_qtimeline::value
The test was improved by: - Use QCOMPARE instead of QVERIFY - Use QTRY_ macro instead arbitrary qWait - Use longer time line The test executes faster and it should be less vulnerable to an unreliable timer. Change-Id: I92675015a6251b47eaf20b0fc916f3a36b52d783 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
index 91e095f541..98e8ffded5 100644
--- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
@@ -198,31 +198,27 @@ void tst_QTimeLine::frameRate()
void tst_QTimeLine::value()
{
- QTimeLine timeLine(2000);
- QVERIFY(timeLine.currentValue() == 0.0);
+ QTimeLine timeLine(5000);
+ QCOMPARE(timeLine.currentValue(), 0.0);
// Default speed
QSignalSpy spy(&timeLine, &QTimeLine::valueChanged);
QVERIFY(spy.isValid());
timeLine.start();
- QTest::qWait(timeLine.duration()/3);
- QVERIFY(timeLine.currentValue() > 0);
- QTest::qWait(timeLine.duration());
- QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
- qreal currentValue = timeLine.currentValue();
- QVERIFY(currentValue == 1);
+ QTRY_VERIFY(timeLine.currentValue() > 0);
+ QTRY_COMPARE(timeLine.state(), QTimeLine::NotRunning);
+ QCOMPARE(timeLine.currentValue(), 1.0);
QVERIFY(spy.count() > 0);
// Reverse should decrease the value
timeLine.setCurrentTime(100);
timeLine.start();
// Let it update on its own
- QTest::qWait(500);
QCOMPARE(timeLine.state(), QTimeLine::Running);
+ QTRY_VERIFY(timeLine.currentValue());
qreal value = timeLine.currentValue();
timeLine.setDirection(QTimeLine::Backward);
- QTest::qWait(1000);
- QVERIFY(timeLine.currentValue() < value);
+ QTRY_VERIFY(timeLine.currentValue() < value);
timeLine.stop();
}