diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-02-17 03:21:46 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-02-18 05:17:15 (GMT) |
commit | 05cbd2fe4b5d9cbdef3be52b6d14d2d20255641a (patch) | |
tree | decbeb2a21a1b022bf5f3d5773935a33691c9ca8 /tests | |
parent | 9fb06ea43e807f2bbb40de89e9af5f2cca02212f (diff) | |
download | Qt-05cbd2fe4b5d9cbdef3be52b6d14d2d20255641a.zip Qt-05cbd2fe4b5d9cbdef3be52b6d14d2d20255641a.tar.gz Qt-05cbd2fe4b5d9cbdef3be52b6d14d2d20255641a.tar.bz2 |
Fix bugs and add tests related to manual start/stop control of animations.
This better enforces the restriction on starting an animation that is
not top-level, or is part of a Transition or Behavior.
Diffstat (limited to 'tests')
5 files changed, 104 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlanimations/data/dontStart.qml b/tests/auto/declarative/qmlanimations/data/dontStart.qml new file mode 100644 index 0000000..36417db --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/dontStart.qml @@ -0,0 +1,19 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + x: SequentialAnimation { + running: false + NumberAnimation { objectName: "MyAnim"; running: true } + } + + } + +} diff --git a/tests/auto/declarative/qmlanimations/data/dontStart2.qml b/tests/auto/declarative/qmlanimations/data/dontStart2.qml new file mode 100644 index 0000000..1a6540f --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/dontStart2.qml @@ -0,0 +1,19 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + + transitions: Transition { + SequentialAnimation { + NumberAnimation { id: myAnim; objectName: "MyAnim"; running: true } + } + } + } +} diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp index b4759d4..54e6e27 100644 --- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -71,6 +71,7 @@ private slots: void invalidDuration(); void attached(); void propertyValueSourceDefaultStart(); + void dontStart(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -634,6 +635,38 @@ void tst_qmlanimations::propertyValueSourceDefaultStart() } } + +void tst_qmlanimations::dontStart() +{ + { + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); + + QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + } + + { + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml")); + + QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + } +} + QTEST_MAIN(tst_qmlanimations) #include "tst_qmlanimations.moc" diff --git a/tests/auto/declarative/qmlbehaviors/data/dontStart.qml b/tests/auto/declarative/qmlbehaviors/data/dontStart.qml new file mode 100644 index 0000000..ba7cc9c --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/dontStart.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + x: Behavior { + NumberAnimation { objectName: "MyAnim"; running: true } + } + + } + +} diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp index 47bd329..5f199ef 100644 --- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp +++ b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp @@ -67,6 +67,7 @@ private slots: void nonSelectingBehavior(); void reassignedAnimation(); void disabled(); + void dontStart(); }; void tst_qmlbehaviors::simpleBehavior() @@ -278,7 +279,21 @@ void tst_qmlbehaviors::disabled() rect->setState("moved"); qreal x = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately +} + +void tst_qmlbehaviors::dontStart() +{ + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); + + QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + QmlAbstractAnimation *myAnim = rect->findChild<QmlAbstractAnimation*>("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); } QTEST_MAIN(tst_qmlbehaviors) |