Improve tst_qtimeline::currentFrame

The test run faster and it less vulnerable to an inaccurate time.

Change-Id: I19475095395dcf1e6d47fdbba5eeffabab1fc7b9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
Jędrzej Nowacki 2015-12-14 12:35:47 +01:00
parent 70e290411a
commit 266511401f

View File

@ -236,22 +236,19 @@ void tst_QTimeLine::currentFrame()
QSignalSpy spy(&timeLine, &QTimeLine::frameChanged);
QVERIFY(spy.isValid());
timeLine.start();
QTest::qWait(timeLine.duration()/3);
QVERIFY(timeLine.currentFrame() > 10);
QTest::qWait(timeLine.duration());
QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
QTRY_VERIFY(timeLine.currentFrame() > 10);
QTRY_COMPARE(timeLine.state(), QTimeLine::NotRunning);
QCOMPARE(timeLine.currentFrame(), 20);
// Reverse should decrease the value
timeLine.setCurrentTime(timeLine.duration()/2);
timeLine.start();
// Let it update on its own
QTest::qWait(timeLine.duration()/4);
QCOMPARE(timeLine.state(), QTimeLine::Running);
QTRY_VERIFY(timeLine.currentTime() > timeLine.duration()/2); // wait for continuation
int value = timeLine.currentFrame();
timeLine.setDirection(QTimeLine::Backward);
QTest::qWait(timeLine.duration()/2);
QVERIFY(timeLine.currentFrame() < value);
QTRY_VERIFY(timeLine.currentFrame() < value);
timeLine.stop();
}