diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 21:06:47 +0200 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 21:06:47 +0200 |
commit | 42e4ae042a4c86e58bcb8b6d2d59ba4a988285b4 (patch) | |
tree | a7f25b1d335a834a7c3ae104cee913ef3a4dd4fb /tests/auto/corelib/animation | |
parent | 4ee4fc18b4067b90efa46ca9baba74f53b54d9ec (diff) | |
parent | 168ff3419f256fdb35b586275d293fc0cd773fe1 (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.9' into tqtc/lts-5.15-opensourcev5.15.9-lts-lgpl
Change-Id: Iaff6b55275e50d19973e1020853d8622587069f9
Diffstat (limited to 'tests/auto/corelib/animation')
-rw-r--r-- | tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp | 6 | ||||
-rw-r--r-- | tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp | 27 |
2 files changed, 19 insertions, 14 deletions
diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp index 2b7de50971..d72370d182 100644 --- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp @@ -286,7 +286,8 @@ void tst_QAnimationGroup::setParentAutoAdd() void tst_QAnimationGroup::beginNestedGroup() { - QAnimationGroup *parent = new QParallelAnimationGroup(); + QParallelAnimationGroup group; + QAnimationGroup *parent = &group; for (int i = 0; i < 10; ++i) { if (i & 1) { @@ -343,7 +344,8 @@ void tst_QAnimationGroup::addChildTwice() void tst_QAnimationGroup::loopWithoutStartValue() { - QAnimationGroup *parent = new QSequentialAnimationGroup(); + QSequentialAnimationGroup group; + QAnimationGroup *parent = &group; QObject o; o.setProperty("ole", 0); QCOMPARE(o.property("ole").toInt(), 0); diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index 41a051a719..b3f72e3b49 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -286,16 +286,16 @@ void tst_QPropertyAnimation::statesAndSignals_data() void tst_QPropertyAnimation::statesAndSignals() { QFETCH(bool, uncontrolled); - QPropertyAnimation *anim; + std::unique_ptr<QPropertyAnimation> anim; if (uncontrolled) - anim = new UncontrolledAnimation; + anim.reset(new UncontrolledAnimation); else - anim = new DummyPropertyAnimation; + anim.reset(new DummyPropertyAnimation); anim->setDuration(100); - QSignalSpy finishedSpy(anim, &QPropertyAnimation::finished); - QSignalSpy runningSpy(anim, &QPropertyAnimation::stateChanged); - QSignalSpy currentLoopSpy(anim, &QPropertyAnimation::currentLoopChanged); + QSignalSpy finishedSpy(anim.get(), &QPropertyAnimation::finished); + QSignalSpy runningSpy(anim.get(), &QPropertyAnimation::stateChanged); + QSignalSpy currentLoopSpy(anim.get(), &QPropertyAnimation::currentLoopChanged); QVERIFY(finishedSpy.isValid()); QVERIFY(runningSpy.isValid()); @@ -366,8 +366,6 @@ void tst_QPropertyAnimation::statesAndSignals() QCOMPARE(runningSpy.count(), 1); // anim has stopped QCOMPARE(finishedSpy.count(), 2); QCOMPARE(anim->currentLoopTime(), 100); - - delete anim; } } @@ -416,9 +414,10 @@ void tst_QPropertyAnimation::deletion1() void tst_QPropertyAnimation::deletion2() { TestAnimationDriver timeDriver; - //test that the animation get deleted if the object is deleted + // test that the animation does not get deleted if the object is deleted QObject *object = new QWidget; QPointer<QPropertyAnimation> anim = new QPropertyAnimation(object,"minimumWidth"); + QVERIFY(anim->parent() != object); anim->setStartValue(10); anim->setEndValue(20); anim->setDuration(200); @@ -445,14 +444,18 @@ void tst_QPropertyAnimation::deletion2() QTimer::singleShot(0, object, SLOT(deleteLater())); timeDriver.wait(50); + QVERIFY(anim); QVERIFY(!anim->targetObject()); + + delete anim; } void tst_QPropertyAnimation::deletion3() { //test that the stopped signal is emit when the animation is destroyed TestAnimationDriver timeDriver; - QObject *object = new QWidget; + QWidget w; + QObject *object = &w; QPropertyAnimation *anim = new QPropertyAnimation(object,"minimumWidth"); anim->setStartValue(10); anim->setEndValue(20); @@ -1327,8 +1330,8 @@ void tst_QPropertyAnimation::totalDuration() void tst_QPropertyAnimation::zeroLoopCount() { - DummyPropertyAnimation* anim; - anim = new DummyPropertyAnimation; + DummyPropertyAnimation animation; + auto *anim = &animation; anim->setStartValue(0); anim->setDuration(20); anim->setLoopCount(0); |