diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-07-11 13:25:42 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-07-13 09:30:56 +0000 |
commit | cf0b965aaab0ea7e777c1f8e8d35de3a73d7d08e (patch) | |
tree | d8b9d19e10b77d186abf95c410749068765a6407 /tests/auto/quick/qquickanimations/tst_qquickanimations.cpp | |
parent | f4cbe6498bb070e658547dbed1beb0d8383981cf (diff) |
[Quick] Make sure an transition instance is stopped when destroyed
When a running transition does not finish of natural causes (reached
the end state due to e.g. the timer finishing), it can happen that it
will never be marked as finished. Specifically, when an transition is
running (e.g. an add animation for a ListView), and that transition is
replaced by another transition (a displace transition, because another
item got added to the ListView before the add transition was finished),
the first animation was never marked as stopped. The effect was that
the running property would stay "true" for forever.
Task-number: QTBUG-38099
Change-Id: Id7d7053cb2fc1912127d9f5e71f27eb984ba7435
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickanimations/tst_qquickanimations.cpp')
-rw-r--r-- | tests/auto/quick/qquickanimations/tst_qquickanimations.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp index de86bb16db..de8e30407b 100644 --- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp +++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp @@ -29,6 +29,8 @@ #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <QtQuick/qquickview.h> +#include <QtQml/private/qqmltimer_p.h> +#include <QtQml/private/qqmllistmodel_p.h> #include <QtQml/private/qanimationgroupjob_p.h> #include <QtQuick/private/qquickrectangle_p.h> #include <QtQuick/private/qquickitemanimation_p.h> @@ -105,6 +107,7 @@ private slots: void pathSvgAnimation(); void pathLineUnspecifiedXYBug(); void unsetAnimatorProxyJobWindow(); + void replacingTransitions(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -1612,6 +1615,40 @@ void tst_qquickanimations::unsetAnimatorProxyJobWindow() QCOMPARE(proxy.job().data(), job); } +void tst_qquickanimations::replacingTransitions() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("replacingTransitions.qml")); + QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create())); + if (!c.errors().isEmpty()) + qDebug() << c.errorString(); + QVERIFY(rect); + + QQmlTimer *addTimer = rect->property("addTimer").value<QQmlTimer*>(); + QVERIFY(addTimer); + QCOMPARE(addTimer->isRunning(), false); + + QQuickTransition *addTrans = rect->property("addTransition").value<QQuickTransition*>(); + QVERIFY(addTrans); + QCOMPARE(addTrans->running(), false); + + QQuickTransition *displaceTrans = rect->property("displaceTransition").value<QQuickTransition*>(); + QVERIFY(displaceTrans); + QCOMPARE(displaceTrans->running(), false); + + QQmlListModel *model = rect->property("model").value<QQmlListModel *>(); + QVERIFY(model); + QCOMPARE(model->count(), 0); + + addTimer->start(); + QTest::qWait(1000 + 1000 + 10000); + + QTRY_COMPARE(addTimer->isRunning(), false); + QTRY_COMPARE(addTrans->running(), false); + QTRY_COMPARE(displaceTrans->running(), false); + QCOMPARE(model->count(), 3); +} + QTEST_MAIN(tst_qquickanimations) #include "tst_qquickanimations.moc" |