diff options
Diffstat (limited to 'tests')
14 files changed, 213 insertions, 9 deletions
diff --git a/tests/auto/declarative/animations/animations.pro b/tests/auto/declarative/animations/animations.pro new file mode 100644 index 0000000..419da4e --- /dev/null +++ b/tests/auto/declarative/animations/animations.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_animations.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/animations/data/badtype1.qml b/tests/auto/declarative/animations/data/badtype1.qml new file mode 100644 index 0000000..691d2b3 --- /dev/null +++ b/tests/auto/declarative/animations/data/badtype1.qml @@ -0,0 +1,10 @@ +Rect { + width: 240 + height: 320 + Rect { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: PropertyAnimation { from: "blue"; to: "green"; running: true; } + } +} diff --git a/tests/auto/declarative/animations/data/badtype2.qml b/tests/auto/declarative/animations/data/badtype2.qml new file mode 100644 index 0000000..aa248a6 --- /dev/null +++ b/tests/auto/declarative/animations/data/badtype2.qml @@ -0,0 +1,10 @@ +Rect { + width: 240 + height: 320 + Rect { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { from: "blue"; to: "green"; running: true; } + } +} diff --git a/tests/auto/declarative/animations/data/badtype3.qml b/tests/auto/declarative/animations/data/badtype3.qml new file mode 100644 index 0000000..f1a89b6 --- /dev/null +++ b/tests/auto/declarative/animations/data/badtype3.qml @@ -0,0 +1,10 @@ +Rect { + width: 240 + height: 320 + Rect { + color: "red" + color: ColorAnimation { from: 10; to: 15; running: true; } + width: 50; height: 50 + x: 100; y: 100 + } +} diff --git a/tests/auto/declarative/animations/data/badtype4.qml b/tests/auto/declarative/animations/data/badtype4.qml new file mode 100644 index 0000000..fa4eebe --- /dev/null +++ b/tests/auto/declarative/animations/data/badtype4.qml @@ -0,0 +1,23 @@ +Rect { + id: Wrapper + width: 240 + height: 320 + Rect { + id: MyRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + } + } + states: State { + name: "state1" + SetProperties { target: MyRect; x: 200; color: "blue" } + } + transitions: Transition { + ColorAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + //NumberAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + } +} diff --git a/tests/auto/declarative/animations/data/color.qml b/tests/auto/declarative/animations/data/color.qml new file mode 100644 index 0000000..051e0e1 --- /dev/null +++ b/tests/auto/declarative/animations/data/color.qml @@ -0,0 +1,10 @@ +Rect { + width: 240 + height: 320 + Rect { + color: "red" + color: PropertyAnimation { to: "green"; running: true } + width: 50; height: 50 + x: 100; y: 100 + } +} diff --git a/tests/auto/declarative/animations/data/mixedtype1.qml b/tests/auto/declarative/animations/data/mixedtype1.qml new file mode 100644 index 0000000..415bbfb --- /dev/null +++ b/tests/auto/declarative/animations/data/mixedtype1.qml @@ -0,0 +1,22 @@ +Rect { + id: Wrapper + width: 240 + height: 320 + Rect { + id: MyRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + } + } + states: State { + name: "state1" + SetProperties { target: MyRect; x: 200; width: 40 } + } + transitions: Transition { + PropertyAnimation { properties: "x,width"; duration: 1000 } //x is real, width is int + } +} diff --git a/tests/auto/declarative/animations/data/mixedtype2.qml b/tests/auto/declarative/animations/data/mixedtype2.qml new file mode 100644 index 0000000..0e9fb8d --- /dev/null +++ b/tests/auto/declarative/animations/data/mixedtype2.qml @@ -0,0 +1,22 @@ +Rect { + id: Wrapper + width: 240 + height: 320 + Rect { + id: MyRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + } + } + states: State { + name: "state1" + SetProperties { target: MyRect; x: 200; color: "blue" } + } + transitions: Transition { + PropertyAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + } +} diff --git a/tests/auto/declarative/animations/data/number.qml b/tests/auto/declarative/animations/data/number.qml new file mode 100644 index 0000000..feb551b --- /dev/null +++ b/tests/auto/declarative/animations/data/number.qml @@ -0,0 +1,10 @@ +Rect { + width: 240 + height: 320 + Rect { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: PropertyAnimation { from: 0; to: 200; duration: 1000; running: true } + } +} diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp new file mode 100644 index 0000000..1895cef2 --- /dev/null +++ b/tests/auto/declarative/animations/tst_animations.cpp @@ -0,0 +1,82 @@ +#include <qtest.h> +#include <QtDeclarative/qmlengine.h> +#include <QtDeclarative/qmlcomponent.h> +#include <QtDeclarative/qfxview.h> +#include <QtDeclarative/qfxrect.h> + +class tst_animations : public QObject +{ + Q_OBJECT +public: + tst_animations() {} + +private slots: + void badTypes(); + //void mixedTypes(); +}; + +void tst_animations::badTypes() +{ + //don't crash + { + QFxView *view = new QFxView; + view->setUrl(QUrl("file://" SRCDIR "/data/badtype1.qml")); + + view->execute(); + qApp->processEvents(); + + delete view; + } + + //make sure we get a compiler error + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/badtype2.qml")); + QTest::ignoreMessage(QtWarningMsg, "QmlComponent: Component is not ready"); + c.create(); + + QVERIFY(c.errors().count() == 1); + QCOMPARE(c.errors().at(0).description(), QLatin1String("Cannot convert value \"blue\" to double number")); + } + + //make sure we get a compiler error + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/badtype3.qml")); + QTest::ignoreMessage(QtWarningMsg, "QmlComponent: Component is not ready"); + c.create(); + + QVERIFY(c.errors().count() == 1); + QCOMPARE(c.errors().at(0).description(), QLatin1String("Cannot convert value \"10\" to color")); + } +} + +/*//test animating mixed types with property animation + //for example, int + real; color + real; etc +void tst_animations::mixedTypes() +{ + //### this one isn't real robust because width will likely change to real as well + { + QFxView *view = new QFxView; + view->setUrl(QUrl("file://" SRCDIR "/data/mixedtype1.qml")); + + view->execute(); + qApp->processEvents(); + + delete view; + } + + { + QFxView *view = new QFxView; + view->setUrl(QUrl("file://" SRCDIR "/data/mixedtype2.qml")); + + view->execute(); + qApp->processEvents(); + + delete view; + } +}*/ + +QTEST_MAIN(tst_animations) + +#include "tst_animations.moc" diff --git a/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml b/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml index 9cb2509..69c5d81 100644 --- a/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml +++ b/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml @@ -25,7 +25,7 @@ Rect { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { properties: "x" } } diff --git a/tests/auto/declarative/visual/easing/easing.qml b/tests/auto/declarative/visual/easing/easing.qml index 14622c9..7a58276 100644 --- a/tests/auto/declarative/visual/easing/easing.qml +++ b/tests/auto/declarative/visual/easing/easing.qml @@ -167,7 +167,7 @@ Rect { fromState: "*" toState: "to" reversible: true - NumericAnimation { + NumberAnimation { properties: "x" easing: type } diff --git a/tests/auto/declarative/visual/flipable/flipable.xml b/tests/auto/declarative/visual/flipable/flipable.xml index d769e55..9288acc 100644 --- a/tests/auto/declarative/visual/flipable/flipable.xml +++ b/tests/auto/declarative/visual/flipable/flipable.xml @@ -104,17 +104,17 @@ </states> <transitions> <Transition fromState="*" toState="*"> - <NumericAnimation property="r" duration="500" /> + <NumberAnimation property="r" duration="500" /> <SerialAnimation> <SetPropertyAction target="{MeRect}" property="moveToParent" value="{Bounce}" /> <ParallelAnimation> - <NumericAnimation target="{MeRect}" properties="x" to="0" duration="250" /> - <NumericAnimation target="{MeRect}" properties="y" to="0" easing="easeInQuad" duration="250"/> + <NumberAnimation target="{MeRect}" properties="x" to="0" duration="250" /> + <NumberAnimation target="{MeRect}" properties="y" to="0" easing="easeInQuad" duration="250"/> </ParallelAnimation> <SetPropertyAction target="{MeRect}" property="moveToParent" /> <ParallelAnimation> - <NumericAnimation target="{MeRect}" properties="x" to="0" duration="250"/> - <NumericAnimation target="{MeRect}" properties="y" to="0" easing="easeOutQuad" duration="250"/> + <NumberAnimation target="{MeRect}" properties="x" to="0" duration="250"/> + <NumberAnimation target="{MeRect}" properties="y" to="0" easing="easeOutQuad" duration="250"/> </ParallelAnimation> </SerialAnimation> </Transition> diff --git a/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml b/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml index 5c00f58..e0880f0 100644 --- a/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml +++ b/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml @@ -11,11 +11,11 @@ Rect { y: SequentialAnimation { running: true repeat: true - NumericAnimation { + NumberAnimation { to: 0; duration: 500 easing: "easeInOutQuad" } - NumericAnimation { + NumberAnimation { to: 200-img.height easing: "easeOutBounce" duration: 2000 |