aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-02-03 14:24:14 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-02-05 15:20:02 +0100
commit4938984f9a779192264757a06e6ca555fc8f5e91 (patch)
treed4d1684298c889a3775f5dd19added3a23e24371 /tests/auto/qml
parent680f28b08f65ad38c8d5498b5738231b2a2779a3 (diff)
Use a QDoubleEndedList for the children of animation group jobs
This way it's fundamentally impossible to add the same animation job to two different group jobs. The pointers are not exposed anymore and no one can re-order the jobs. Task-number: QTBUG-90401 Change-Id: Iebff4b64960c853915dd32714acd144fc5cdc00d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp17
-rw-r--r--tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp9
-rw-r--r--tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp15
3 files changed, 18 insertions, 23 deletions
diff --git a/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
index 6bd8c2a2e0..ceb8cc707f 100644
--- a/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
+++ b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
@@ -266,14 +266,15 @@ void tst_QAnimationGroupJob::addChildTwice()
subGroup = new QAbstractAnimationJob;
parent->appendAnimation(subGroup);
parent->appendAnimation(subGroup);
- QVERIFY(parent->firstChild());
- QVERIFY(!parent->firstChild()->nextSibling());
- QVERIFY(!parent->firstChild()->previousSibling());
+ QVERIFY(!parent->children()->isEmpty());
+ QCOMPARE(parent->children()->count(), 1);
+ QVERIFY(!parent->children()->next(parent->children()->first()));
+ QVERIFY(!parent->children()->prev(parent->children()->last()));
parent->clear();
QCOMPARE(parent->currentAnimation(), nullptr);
- QVERIFY(!parent->firstChild());
+ QVERIFY(parent->children()->isEmpty());
// adding the same item twice to a group will remove the item from its current position
// and append it to the end
@@ -282,13 +283,13 @@ void tst_QAnimationGroupJob::addChildTwice()
subGroup2 = new QAbstractAnimationJob;
parent->appendAnimation(subGroup2);
- QCOMPARE(parent->firstChild(), subGroup);
- QCOMPARE(parent->lastChild(), subGroup2);
+ QCOMPARE(parent->children()->first(), subGroup);
+ QCOMPARE(parent->children()->last(), subGroup2);
parent->appendAnimation(subGroup);
- QCOMPARE(parent->firstChild(), subGroup2);
- QCOMPARE(parent->lastChild(), subGroup);
+ QCOMPARE(parent->children()->first(), subGroup2);
+ QCOMPARE(parent->children()->last(), subGroup);
delete parent;
}
diff --git a/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
index 8c4c461813..a22c94e4c4 100644
--- a/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
+++ b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
@@ -321,14 +321,11 @@ void tst_QParallelAnimationGroupJob::clearGroup()
group.appendAnimation(new QParallelAnimationGroupJob);
}
- int count = 0;
- for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling())
- ++count;
- QCOMPARE(count, animationCount);
+ QCOMPARE(group.children()->count(), animationCount);
group.clear();
- QVERIFY(!group.firstChild() && !group.lastChild());
+ QVERIFY(group.children()->isEmpty());
QCOMPARE(group.currentLoopTime(), 0);
}
@@ -435,7 +432,7 @@ void tst_QParallelAnimationGroupJob::deleteChildrenWithRunningGroup()
QTRY_VERIFY(group.currentLoopTime() > 0);
delete anim1;
- QVERIFY(!group.firstChild());
+ QVERIFY(group.children()->isEmpty());
QCOMPARE(group.duration(), 0);
QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
index 2712ccde67..e8872ebc58 100644
--- a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
+++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
@@ -933,14 +933,11 @@ void tst_QSequentialAnimationGroupJob::clearGroup()
subGroup->appendAnimation(new QPauseAnimationJob(10));
}
- int count = 0;
- for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling())
- ++count;
- QCOMPARE(count, animationCount);
+ QCOMPARE(group.children()->count(), animationCount);
group.clear();
- QVERIFY(!group.firstChild() && !group.lastChild());
+ QVERIFY(group.children()->isEmpty());
QCOMPARE(group.currentLoopTime(), 0);
}
@@ -1131,7 +1128,7 @@ void tst_QSequentialAnimationGroupJob::deleteChildrenWithRunningGroup()
QTRY_VERIFY(group.currentLoopTime() > 0);
delete anim1;
- QVERIFY(!group.firstChild());
+ QVERIFY(group.children()->isEmpty());
QCOMPARE(group.duration(), 0);
QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
@@ -1568,12 +1565,12 @@ void tst_QSequentialAnimationGroupJob::clear()
TestAnimation *anim2 = new TestAnimation;
group.appendAnimation(anim2);
- QCOMPARE(group.firstChild(), anim1);
- QCOMPARE(group.lastChild(), anim2);
+ QCOMPARE(group.children()->first(), anim1);
+ QCOMPARE(group.children()->last(), anim2);
group.start();
QTest::qWait(anim1->duration() + 100);
- QTRY_VERIFY(!group.firstChild());
+ QTRY_VERIFY(group.children()->isEmpty());
QCOMPARE(group.state(), QAbstractAnimationJob::Stopped);
QCOMPARE(group.currentLoopTime(), 0);