Improve tst_qtimeline::setPaused resilience

The test should not depend on qWait explicitly

Change-Id: I13c01c47c9f7bae8b0c30afa2ac8550dc0fbf028
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
This commit is contained in:
Jędrzej Nowacki 2015-12-14 10:42:51 +01:00
parent 63ec10353d
commit 67509693bd

View File

@ -649,22 +649,21 @@ void tst_QTimeLine::restart()
void tst_QTimeLine::setPaused()
{
QTimeLine timeLine(1000);
const int EndTime = 10000;
QTimeLine timeLine(EndTime);
{
QCOMPARE(timeLine.currentTime(), 0);
timeLine.start();
QTest::qWait(250);
QTRY_VERIFY(timeLine.currentTime() != 0); // wait for start
timeLine.setPaused(true);
int oldCurrentTime = timeLine.currentTime();
QVERIFY(oldCurrentTime > 0);
QVERIFY(oldCurrentTime < 1000);
QVERIFY(oldCurrentTime < EndTime);
QTest::qWait(1000);
timeLine.setPaused(false);
QTest::qWait(250);
int currentTime = timeLine.currentTime();
QVERIFY(currentTime > 0);
QVERIFY(currentTime > oldCurrentTime);
QVERIFY(currentTime < 1000);
QTRY_VERIFY(timeLine.currentTime() > oldCurrentTime);
QVERIFY(timeLine.currentTime() > 0);
QVERIFY(timeLine.currentTime() < EndTime);
timeLine.stop();
}
}