summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp')
-rw-r--r--tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp142
1 files changed, 72 insertions, 70 deletions
diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
index 6d73725cff..c47ce53364 100644
--- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QVariantAnimation>
@@ -7,6 +7,7 @@
#include <QSignalSpy>
#include <QtCore/qparallelanimationgroup.h>
+#include <QtCore/qscopeguard.h>
Q_DECLARE_METATYPE(QAbstractAnimation::State)
@@ -234,38 +235,38 @@ void tst_QParallelAnimationGroup::stateChanged()
//first; let's start forward
group.start();
//all the animations should be started
- QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running);
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running);
- QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy3.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
- QCOMPARE(spy4.count(), 1);
+ QCOMPARE(spy4.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running);
group.setCurrentTime(1500); //anim1 should be finished
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy1.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy2.count(), 1); //no change
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
+ QCOMPARE(spy2.size(), 1); //no change
+ QCOMPARE(spy3.size(), 1); //no change
+ QCOMPARE(spy4.size(), 1); //no change
group.setCurrentTime(2500); //anim2 should be finished
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(spy1.count(), 2); //no change
- QCOMPARE(spy2.count(), 2);
+ QCOMPARE(spy1.size(), 2); //no change
+ QCOMPARE(spy2.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
+ QCOMPARE(spy3.size(), 1); //no change
+ QCOMPARE(spy4.size(), 1); //no change
group.setCurrentTime(3500); //everything should be finished
QCOMPARE(group.state(), QAnimationGroup::Stopped);
- QCOMPARE(spy1.count(), 2); //no change
- QCOMPARE(spy2.count(), 2); //no change
- QCOMPARE(spy3.count(), 2);
+ QCOMPARE(spy1.size(), 2); //no change
+ QCOMPARE(spy2.size(), 2); //no change
+ QCOMPARE(spy3.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy4.count(), 2);
+ QCOMPARE(spy4.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped);
//cleanup
@@ -280,38 +281,38 @@ void tst_QParallelAnimationGroup::stateChanged()
//only anim3 and anim4 should be started
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(spy1.count(), 0);
- QCOMPARE(spy2.count(), 0);
- QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy1.size(), 0);
+ QCOMPARE(spy2.size(), 0);
+ QCOMPARE(spy3.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running);
- QCOMPARE(spy4.count(), 1);
+ QCOMPARE(spy4.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running);
group.setCurrentTime(1500); //anim2 should be started
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(spy1.count(), 0); //no change
- QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy1.size(), 0); //no change
+ QCOMPARE(spy2.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running);
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
+ QCOMPARE(spy3.size(), 1); //no change
+ QCOMPARE(spy4.size(), 1); //no change
group.setCurrentTime(500); //anim1 is finally also started
QCOMPARE(group.state(), QAnimationGroup::Running);
- QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running);
- QCOMPARE(spy2.count(), 1); //no change
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
+ QCOMPARE(spy2.size(), 1); //no change
+ QCOMPARE(spy3.size(), 1); //no change
+ QCOMPARE(spy4.size(), 1); //no change
group.setCurrentTime(0); //everything should be stopped
QCOMPARE(group.state(), QAnimationGroup::Stopped);
- QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy1.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy2.count(), 2);
+ QCOMPARE(spy2.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy3.count(), 2);
+ QCOMPARE(spy3.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped);
- QCOMPARE(spy4.count(), 2);
+ QCOMPARE(spy4.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped);
}
@@ -405,8 +406,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
QVERIFY(groupStateChangedSpy.isValid());
QVERIFY(childStateChangedSpy.isValid());
- QCOMPARE(groupStateChangedSpy.count(), 0);
- QCOMPARE(childStateChangedSpy.count(), 0);
+ QCOMPARE(groupStateChangedSpy.size(), 0);
+ QCOMPARE(childStateChangedSpy.size(), 0);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
QCOMPARE(anim.state(), QAnimationGroup::Stopped);
@@ -417,8 +418,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(anim.state(), QAnimationGroup::Running);
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
+ QCOMPARE(groupStateChangedSpy.size(), 1);
+ QCOMPARE(childStateChangedSpy.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()),
QAnimationGroup::Running);
@@ -428,8 +429,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup()
// starting directly a running child will not have any effect
anim.start();
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
+ QCOMPARE(groupStateChangedSpy.size(), 1);
+ QCOMPARE(childStateChangedSpy.size(), 1);
anim.pause();
@@ -572,8 +573,8 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild()
QVERIFY(stateChangedSpy1.isValid());
QVERIFY(stateChangedSpy2.isValid());
- QCOMPARE(stateChangedSpy1.count(), 0);
- QCOMPARE(stateChangedSpy2.count(), 0);
+ QCOMPARE(stateChangedSpy1.size(), 0);
+ QCOMPARE(stateChangedSpy2.size(), 0);
QCOMPARE(group.state(), QAnimationGroup::Stopped);
QCOMPARE(anim1.state(), QAnimationGroup::Stopped);
QCOMPARE(anim2.state(), QAnimationGroup::Stopped);
@@ -598,13 +599,13 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild()
group.start();
- QCOMPARE(stateChangedSpy1.count(), 3);
+ QCOMPARE(stateChangedSpy1.size(), 3);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
QAnimationGroup::Stopped);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(2).first()),
QAnimationGroup::Running);
- QCOMPARE(stateChangedSpy2.count(), 4);
+ QCOMPARE(stateChangedSpy2.size(), 4);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()),
QAnimationGroup::Stopped);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()),
@@ -655,22 +656,22 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation()
group.addAnimation(&anim1);
group.addAnimation(&anim2);
group.addAnimation(&anim3);
- QCOMPARE(stateChangedSpy1.count(), 0);
+ QCOMPARE(stateChangedSpy1.size(), 0);
group.start();
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(finishedSpy1.count(), 1);
+ QCOMPARE(stateChangedSpy1.size(), 2);
+ QCOMPARE(finishedSpy1.size(), 1);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()),
QAnimationGroup::Stopped);
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(finishedSpy2.count(), 0);
+ QCOMPARE(stateChangedSpy2.size(), 1);
+ QCOMPARE(finishedSpy2.size(), 0);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()),
QAnimationGroup::Running);
- QCOMPARE(stateChangedSpy3.count(), 1);
- QCOMPARE(finishedSpy3.count(), 0);
+ QCOMPARE(stateChangedSpy3.size(), 1);
+ QCOMPARE(finishedSpy3.size(), 0);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy3.at(0).first()),
QAnimationGroup::Running);
@@ -688,21 +689,21 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation()
stateChangedSpy3.clear();
group.start();
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(stateChangedSpy3.count(), 1);
+ QCOMPARE(stateChangedSpy1.size(), 2);
+ QCOMPARE(stateChangedSpy2.size(), 1);
+ QCOMPARE(stateChangedSpy3.size(), 1);
group.setCurrentTime(50);
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(stateChangedSpy3.count(), 2);
+ QCOMPARE(stateChangedSpy1.size(), 2);
+ QCOMPARE(stateChangedSpy2.size(), 1);
+ QCOMPARE(stateChangedSpy3.size(), 2);
group.setCurrentTime(150);
- QCOMPARE(stateChangedSpy1.count(), 4);
- QCOMPARE(stateChangedSpy2.count(), 3);
- QCOMPARE(stateChangedSpy3.count(), 4);
+ QCOMPARE(stateChangedSpy1.size(), 4);
+ QCOMPARE(stateChangedSpy2.size(), 3);
+ QCOMPARE(stateChangedSpy3.size(), 4);
group.setCurrentTime(50);
- QCOMPARE(stateChangedSpy1.count(), 6);
- QCOMPARE(stateChangedSpy2.count(), 5);
- QCOMPARE(stateChangedSpy3.count(), 6);
+ QCOMPARE(stateChangedSpy1.size(), 6);
+ QCOMPARE(stateChangedSpy2.size(), 5);
+ QCOMPARE(stateChangedSpy3.size(), 6);
}
@@ -734,7 +735,7 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations()
group.start();
- QCOMPARE(stateChangedSpy.count(), 2);
+ QCOMPARE(stateChangedSpy.size(), 2);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(0).first()),
QAnimationGroup::Running);
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(1).first()),
@@ -928,6 +929,7 @@ void tst_QParallelAnimationGroup::autoAdd()
test = static_cast<TestAnimation2*>(group.animationAt(0));
test->setParent(0); // remove the last one (with duration = 250)
+ const auto deleteParentlessObject = qScopeGuard([test] { delete test; });
QCOMPARE(test->group(), static_cast<QAnimationGroup*>(0));
QCOMPARE(group.duration(), 0);
}
@@ -943,7 +945,7 @@ void tst_QParallelAnimationGroup::pauseResume()
QTest::qWait(100);
QCOMPARE(group.state(), QAnimationGroup::Running);
QCOMPARE(anim->state(), QAnimationGroup::Running);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
const int currentTime = group.currentLoopTime();
QCOMPARE(anim->currentLoopTime(), currentTime);
@@ -953,7 +955,7 @@ void tst_QParallelAnimationGroup::pauseResume()
QCOMPARE(group.currentLoopTime(), currentTime);
QCOMPARE(anim->state(), QAnimationGroup::Paused);
QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
group.resume();
@@ -961,21 +963,21 @@ void tst_QParallelAnimationGroup::pauseResume()
QCOMPARE(group.currentLoopTime(), currentTime);
QCOMPARE(anim->state(), QAnimationGroup::Running);
QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
group.stop();
spy.clear();
new TestAnimation2(500, &group);
group.start();
- QCOMPARE(spy.count(), 1); //the animation should have been started
+ QCOMPARE(spy.size(), 1); //the animation should have been started
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Running);
group.setCurrentTime(250); //end of first animation
- QCOMPARE(spy.count(), 2); //the animation should have been stopped
+ QCOMPARE(spy.size(), 2); //the animation should have been stopped
QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Stopped);
group.pause();
- QCOMPARE(spy.count(), 2); //this shouldn't have changed
+ QCOMPARE(spy.size(), 2); //this shouldn't have changed
group.resume();
- QCOMPARE(spy.count(), 2); //this shouldn't have changed
+ QCOMPARE(spy.size(), 2); //this shouldn't have changed
}
// This is a regression test for QTBUG-8910, where a crash occurred when the