summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp')
-rw-r--r--tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index f83594e32a..43a8593803 100644
--- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -71,6 +71,7 @@ private slots:
void insertAnimation();
void clear();
void pauseResume();
+ void bindings();
};
void tst_QSequentialAnimationGroup::initTestCase()
@@ -1667,5 +1668,48 @@ void tst_QSequentialAnimationGroup::pauseResume()
QCOMPARE(spy.count(), 1);
}
+void tst_QSequentialAnimationGroup::bindings()
+{
+ // create a group consisting of three animations
+ QSequentialAnimationGroup group;
+ QPointer<QAbstractAnimation> anim1 = new DummyPropertyAnimation(&group);
+ QCOMPARE(group.animationCount(), 1);
+ QPointer<QAbstractAnimation> anim2 = new DummyPropertyAnimation(&group);
+ QCOMPARE(group.animationCount(), 2);
+ QPointer<QAbstractAnimation> anim3 = new DummyPropertyAnimation(&group);
+ QCOMPARE(group.animationCount(), 3);
+
+ // bind a QProperty to group.currentAnimation
+ QProperty<QAbstractAnimation *> currentAnim;
+ currentAnim.setBinding([&]() { return group.currentAnimation(); });
+
+ // check that everything behaves as expected
+ QSignalSpy spy(&group, &QSequentialAnimationGroup::currentAnimationChanged);
+ QVERIFY(spy.isValid());
+
+ int totalDuration = group.duration();
+
+ group.setCurrentTime(int(totalDuration * 0.5 / 3));
+ QCOMPARE(currentAnim.value(), anim1.get());
+ QCOMPARE(spy.count(), 0);
+
+ group.setCurrentTime(int(totalDuration * 1.5 / 3));
+ QCOMPARE(currentAnim.value(), anim2.get());
+ QCOMPARE(spy.count(), 1);
+
+ // change to other style of formulating a binding to test both
+ currentAnim.setBinding(group.bindableCurrentAnimation().makeBinding());
+
+ group.setCurrentTime(int(totalDuration * 2.5 / 3));
+ QCOMPARE(currentAnim.value(), anim3.get());
+ QCOMPARE(spy.count(), 2);
+
+ // currentAnimation is read-only. Binding it to something should have no effect
+ QProperty<QAbstractAnimation *> leader;
+ group.bindableCurrentAnimation().setBinding([&]() { return leader.value(); });
+
+ QCOMPARE(group.currentAnimation(), anim3.get());
+}
+
QTEST_MAIN(tst_QSequentialAnimationGroup)
#include "tst_qsequentialanimationgroup.moc"