summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtimeline
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2009-08-10 07:37:18 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-10 07:44:55 (GMT)
commit2be387f3e94f84cf0167cdc3871de0d0af85c62d (patch)
treedb0fed1caee646d360dbaaaf7a43173b7be9ab11 /tests/auto/qtimeline
parent4942e2834c1da00bfceec6430ce351888efc1976 (diff)
downloadQt-2be387f3e94f84cf0167cdc3871de0d0af85c62d.zip
Qt-2be387f3e94f84cf0167cdc3871de0d0af85c62d.tar.gz
Qt-2be387f3e94f84cf0167cdc3871de0d0af85c62d.tar.bz2
Make QTimeLine::start() restart from the beginning as the documentation says.
The documentation implies that start restarts. Which it did, but only if the timeline was finished _and_ the duration hadn't been changed meanwhile. So after a setDuration(), start() would do nothing, which was unexpected. Merge-request: 1145 Reviewed-by: Olivier Goffart <ogoffart@trolltech.com>
Diffstat (limited to 'tests/auto/qtimeline')
-rw-r--r--tests/auto/qtimeline/tst_qtimeline.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/tests/auto/qtimeline/tst_qtimeline.cpp b/tests/auto/qtimeline/tst_qtimeline.cpp
index e6e75ff..4ce1f4b 100644
--- a/tests/auto/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/qtimeline/tst_qtimeline.cpp
@@ -81,6 +81,7 @@ private slots:
void outOfRange();
void stateInFinishedSignal();
void resume();
+ void restart();
protected slots:
void finishedSlot();
@@ -177,7 +178,7 @@ void tst_QTimeLine::currentTime()
QCOMPARE(spy.count(), 1);
spy.clear();
QCOMPARE(timeLine.currentTime(), timeLine.duration()/2);
- timeLine.start();
+ timeLine.resume();
// Let it update on its own
QTest::qWait(timeLine.duration()/4);
QCOMPARE(timeLine.state(), QTimeLine::Running);
@@ -699,5 +700,43 @@ void tst_QTimeLine::resume()
}
}
+void tst_QTimeLine::restart()
+{
+ QTimeLine timeLine(100);
+ timeLine.setFrameRange(0,9);
+
+ timeLine.start();
+ QTest::qWait(timeLine.duration()*2);
+ QCOMPARE(timeLine.currentFrame(), timeLine.endFrame());
+ QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
+
+ // A restart with the same duration
+ timeLine.start();
+ QCOMPARE(timeLine.state(), QTimeLine::Running);
+ QCOMPARE(timeLine.currentFrame(), timeLine.startFrame());
+ QCOMPARE(timeLine.currentTime(), 0);
+ QTest::qWait(250);
+ QCOMPARE(timeLine.currentFrame(), timeLine.endFrame());
+ QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
+
+ // Set a smaller duration and restart
+ timeLine.setDuration(50);
+ timeLine.start();
+ QCOMPARE(timeLine.state(), QTimeLine::Running);
+ QCOMPARE(timeLine.currentFrame(), timeLine.startFrame());
+ QCOMPARE(timeLine.currentTime(), 0);
+ QTest::qWait(250);
+ QCOMPARE(timeLine.currentFrame(), timeLine.endFrame());
+ QCOMPARE(timeLine.state(), QTimeLine::NotRunning);
+
+ // Set a longer duration and restart
+ timeLine.setDuration(150);
+ timeLine.start();
+ QCOMPARE(timeLine.state(), QTimeLine::Running);
+ QCOMPARE(timeLine.currentFrame(), timeLine.startFrame());
+ QCOMPARE(timeLine.currentTime(), 0);
+}
+
QTEST_MAIN(tst_QTimeLine)
+
#include "tst_qtimeline.moc"