diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-04-21 08:29:00 (GMT) |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-04-21 08:43:19 (GMT) |
commit | a5248cd47a6d210c8faec20a8d962c88bbeb7846 (patch) | |
tree | 4f40b03f0bd6a714769dc9d7e99c2bce1800a33f /tests/auto/qanimationgroup | |
parent | 965a0d60fe28666471e9ffb99a7e97097254a4cc (diff) | |
download | Qt-a5248cd47a6d210c8faec20a8d962c88bbeb7846.zip Qt-a5248cd47a6d210c8faec20a8d962c88bbeb7846.tar.gz Qt-a5248cd47a6d210c8faec20a8d962c88bbeb7846.tar.bz2 |
Fixes bug when adding the same child animation twice to the same group
The child animation was removed twice from the group because in
QAnimationGroup::insertAnimationAt the insertion in the list was done
before removing the animation.
Reviewed-by: Jan-Arve
Diffstat (limited to 'tests/auto/qanimationgroup')
-rw-r--r-- | tests/auto/qanimationgroup/tst_qanimationgroup.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp index a7d616a..3cf5631 100644 --- a/tests/auto/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/qanimationgroup/tst_qanimationgroup.cpp @@ -68,6 +68,7 @@ private slots: void statesAndSignals(); void setParentAutoAdd(); void beginNestedGroup(); + void addChildTwice(); }; tst_QAnimationGroup::tst_QAnimationGroup() @@ -343,5 +344,38 @@ void tst_QAnimationGroup::beginNestedGroup() } } +void tst_QAnimationGroup::addChildTwice() +{ + QPropertyAnimation *subGroup; + QPropertyAnimation *subGroup2; + QAnimationGroup *parent = new QSequentialAnimationGroup(); + + subGroup = new QPropertyAnimation(); + subGroup->setParent(parent); + parent->addAnimation(subGroup); + QCOMPARE(parent->animationCount(), 1); + + parent->clearAnimations(); + + QCOMPARE(parent->animationCount(), 0); + + // adding the same item twice to a group will remove the item from its current position + // and append it to the end + subGroup = new QPropertyAnimation(parent); + subGroup2 = new QPropertyAnimation(parent); + + QCOMPARE(parent->animationCount(), 2); + QCOMPARE(parent->animationAt(0), subGroup); + QCOMPARE(parent->animationAt(1), subGroup2); + + parent->addAnimation(subGroup); + + QCOMPARE(parent->animationCount(), 2); + QCOMPARE(parent->animationAt(0), subGroup2); + QCOMPARE(parent->animationAt(1), subGroup); + + delete parent; +} + QTEST_MAIN(tst_QAnimationGroup) #include "tst_qanimationgroup.moc" |