diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2011-02-21 06:11:50 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2011-02-22 01:12:22 (GMT) |
commit | 5fa90e4bc83541dc23db150166157e2a3f04a668 (patch) | |
tree | 3a82d613dbd1a7c80e5fa1c30c488022c49ee31a /tests/auto/declarative/qdeclarativeanimations | |
parent | 0c24787a2f35a7b0585c9dfb3bf0a8cb34ce867f (diff) | |
download | Qt-5fa90e4bc83541dc23db150166157e2a3f04a668.zip Qt-5fa90e4bc83541dc23db150166157e2a3f04a668.tar.gz Qt-5fa90e4bc83541dc23db150166157e2a3f04a668.tar.bz2 |
Prevent an animation from being registered to run twice.
This could cause animations to start running that could not later be
stopped.
Change-Id: I320f50121f3566619f08181664d049b02e2848e5
Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto/declarative/qdeclarativeanimations')
3 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeanimations/data/Double.qml b/tests/auto/declarative/qdeclarativeanimations/data/Double.qml new file mode 100644 index 0000000..b247fce --- /dev/null +++ b/tests/auto/declarative/qdeclarativeanimations/data/Double.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 + +Rectangle { + id: container + property bool on: false + border.color: "#ffffff" + color: "green" + width: 50 + height: 50 + NumberAnimation on x { + objectName: "animation" + running: container.on; from: 0; to: 600; loops: Animation.Infinite; duration: 2000 + } +} diff --git a/tests/auto/declarative/qdeclarativeanimations/data/doubleRegistrationBug.qml b/tests/auto/declarative/qdeclarativeanimations/data/doubleRegistrationBug.qml new file mode 100644 index 0000000..f0fdf9c --- /dev/null +++ b/tests/auto/declarative/qdeclarativeanimations/data/doubleRegistrationBug.qml @@ -0,0 +1,8 @@ +import QtQuick 1.0 + +Rectangle { + width: 400; height: 400 + + Double { id: dub; on: parent.width < 800 } + Component.onCompleted: dub.on = false +} diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index d1b7c1b..f7fee3b 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -86,6 +86,7 @@ private slots: void runningTrueBug(); void nonTransitionBug(); void registrationBug(); + void doubleRegistrationBug(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -805,6 +806,19 @@ void tst_qdeclarativeanimations::registrationBug() QTRY_COMPARE(rect->property("value"), QVariant(int(100))); } +void tst_qdeclarativeanimations::doubleRegistrationBug() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/doubleRegistrationBug.qml"); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); + QVERIFY(rect != 0); + + QDeclarativeAbstractAnimation *anim = rect->findChild<QDeclarativeAbstractAnimation*>("animation"); + QVERIFY(anim != 0); + QTRY_COMPARE(anim->qtAnimation()->state(), QAbstractAnimation::Stopped); +} + QTEST_MAIN(tst_qdeclarativeanimations) #include "tst_qdeclarativeanimations.moc" |