aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/animation
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-09-20 15:26:03 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-26 17:32:40 +0200
commit57ae961bcf09efd98968b918332f8ff30562cd92 (patch)
tree84692bed8063ba3f520d0117ed11345d6eeb8dc9 /tests/auto/qml/animation
parent6d425ebab34030ff12572f9588eac589930f2659 (diff)
Support looping for "uncontrolled animations".
The render thread animations rely heavily on uncontrolled animations, meaning animations with duration=-1. We support this by adding a m_currentLoopStartTime and incrementally counting the finish time of each uncontrolled animation. Change-Id: I1f2ccea09aff4c51b1a7f98a2ddb58636af50557 Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'tests/auto/qml/animation')
-rw-r--r--tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp44
-rw-r--r--tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp45
2 files changed, 89 insertions, 0 deletions
diff --git a/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
index 3fed59ea20..149f034903 100644
--- a/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
+++ b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
@@ -64,6 +64,7 @@ private slots:
void startGroupWithRunningChild();
void zeroDurationAnimation();
void stopUncontrolledAnimations();
+ void uncontrolledWithLoops();
void loopCount_data();
void loopCount();
void addAndRemoveDuration();
@@ -779,6 +780,9 @@ void tst_QParallelAnimationGroupJob::loopCount_data()
}
+#undef Stopped
+#undef Running
+
void tst_QParallelAnimationGroupJob::loopCount()
{
QFETCH(bool, directionBackward);
@@ -926,6 +930,46 @@ void tst_QParallelAnimationGroupJob::crashWhenRemovingUncontrolledAnimation()
delete anim2;
}
+void tst_QParallelAnimationGroupJob::uncontrolledWithLoops()
+{
+ QParallelAnimationGroupJob group;
+
+ TestAnimation *plain = new TestAnimation(100);
+ TestAnimation *loopsForever = new TestAnimation();
+ UncontrolledAnimation *notTimeBased = new UncontrolledAnimation();
+
+ loopsForever->setLoopCount(-1);
+
+ group.appendAnimation(plain);
+ group.appendAnimation(loopsForever);
+ group.appendAnimation(notTimeBased);
+
+ StateChangeListener listener;
+ group.addAnimationChangeListener(&listener, QAbstractAnimationJob::CurrentLoop);
+ group.setLoopCount(2);
+
+ group.start();
+
+ QCOMPARE(group.currentLoop(), 0);
+ QCOMPARE(group.state(), QAbstractAnimationJob::Running);
+ QCOMPARE(plain->state(), QAbstractAnimationJob::Running);
+ QCOMPARE(loopsForever->state(), QAbstractAnimationJob::Running);
+ QCOMPARE(notTimeBased->state(), QAbstractAnimationJob::Running);
+
+ loopsForever->stop();
+ notTimeBased->stop();
+
+ QTRY_COMPARE(group.currentLoop(), 1);
+ QCOMPARE(group.state(), QAbstractAnimationJob::Running);
+ QCOMPARE(loopsForever->state(), QAbstractAnimationJob::Running);
+ QCOMPARE(notTimeBased->state(), QAbstractAnimationJob::Running);
+
+ loopsForever->stop();
+ notTimeBased->stop();
+
+ QTRY_COMPARE(group.state(), QAbstractAnimationJob::Stopped);
+}
+
QTEST_MAIN(tst_QParallelAnimationGroupJob)
#include "tst_qparallelanimationgroupjob.moc"
diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
index bb626293aa..591e8f2665 100644
--- a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
+++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
@@ -73,6 +73,7 @@ private slots:
void startGroupWithRunningChild();
void zeroDurationAnimation();
void stopUncontrolledAnimations();
+ void uncontrolledWithLoops();
void finishWithUncontrolledAnimation();
void addRemoveAnimation();
void currentAnimation();
@@ -1613,5 +1614,49 @@ void tst_QSequentialAnimationGroupJob::pauseResume()
anim->removeAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
}
+
+void tst_QSequentialAnimationGroupJob::uncontrolledWithLoops()
+{
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation *plain = new TestAnimation(100);
+ TestAnimation *loopsForever = new TestAnimation();
+ UncontrolledAnimation *notTimeBased = new UncontrolledAnimation();
+
+ loopsForever->setLoopCount(-1);
+
+ group.appendAnimation(plain);
+ group.appendAnimation(loopsForever);
+ group.appendAnimation(notTimeBased);
+
+ StateChangeListener listener;
+ group.addAnimationChangeListener(&listener, QAbstractAnimationJob::CurrentLoop);
+ group.setLoopCount(2);
+
+ group.start();
+
+ QCOMPARE(group.currentLoop(), 0);
+ QCOMPARE(group.state(), QAbstractAnimationJob::Running);
+ QTRY_COMPARE(plain->state(), QAbstractAnimationJob::Running);
+
+ QTRY_COMPARE(loopsForever->state(), QAbstractAnimationJob::Running);
+ loopsForever->stop();
+ QTRY_COMPARE(notTimeBased->state(), QAbstractAnimationJob::Running);
+ QTRY_COMPARE(notTimeBased->state(), QAbstractAnimationJob::Stopped); // Stops on its own after 250ms
+
+ QTRY_COMPARE(group.currentLoop(), 1);
+
+ QCOMPARE(group.state(), QAbstractAnimationJob::Running);
+ QTRY_COMPARE(plain->state(), QAbstractAnimationJob::Running);
+ QTRY_COMPARE(plain->state(), QAbstractAnimationJob::Stopped);
+ QTRY_COMPARE(loopsForever->state(), QAbstractAnimationJob::Running);
+ loopsForever->stop();
+ QTRY_COMPARE(notTimeBased->state(), QAbstractAnimationJob::Running);
+ QTRY_COMPARE(notTimeBased->state(), QAbstractAnimationJob::Stopped);
+
+ QTRY_COMPARE(group.state(), QAbstractAnimationJob::Stopped);
+}
+
+
QTEST_MAIN(tst_QSequentialAnimationGroupJob)
#include "tst_qsequentialanimationgroupjob.moc"