diff options
-rw-r--r-- | src/corelib/tools/qtimeline.cpp | 3 | ||||
-rw-r--r-- | tests/auto/qtimeline/tst_qtimeline.cpp | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp index 1cfbe43..7d4dd90 100644 --- a/src/corelib/tools/qtimeline.cpp +++ b/src/corelib/tools/qtimeline.cpp @@ -748,7 +748,10 @@ void QTimeLine::setPaused(bool paused) d->timerId = 0; d->setState(Paused); } else if (!paused && d->state == Paused) { + // Same as resume() d->timerId = startTimer(d->updateInterval); + d->startTime = d->currentTime; + d->timer.start(); d->setState(Running); } } diff --git a/tests/auto/qtimeline/tst_qtimeline.cpp b/tests/auto/qtimeline/tst_qtimeline.cpp index ab83e9d..21c548e 100644 --- a/tests/auto/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/qtimeline/tst_qtimeline.cpp @@ -82,6 +82,7 @@ private slots: void stateInFinishedSignal(); void resume(); void restart(); + void setPaused(); protected slots: void finishedSlot(); @@ -725,6 +726,28 @@ void tst_QTimeLine::restart() QCOMPARE(timeLine.currentTime(), 0); } +void tst_QTimeLine::setPaused() +{ + QTimeLine timeLine(1000); + { + QCOMPARE(timeLine.currentTime(), 0); + timeLine.start(); + QTest::qWait(250); + timeLine.setPaused(true); + int oldCurrentTime = timeLine.currentTime(); + QVERIFY(oldCurrentTime > 0); + QVERIFY(oldCurrentTime < 1000); + QTest::qWait(1000); + timeLine.setPaused(false); + QTest::qWait(250); + int currentTime = timeLine.currentTime(); + QVERIFY(currentTime > 0); + QVERIFY(currentTime > oldCurrentTime); + QVERIFY(currentTime < 1000); + timeLine.stop(); + } +} + QTEST_MAIN(tst_QTimeLine) #include "tst_qtimeline.moc" |