diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-11-06 03:28:34 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-11-06 03:28:34 (GMT) |
commit | 9c984b6b421e7cc6c091623f63ed84ce700f1ee1 (patch) | |
tree | 7cda0f0f784a12de3352890f6d3362265476abf4 /tests/auto | |
parent | aff81e3fb3253d99cb42f68d08b2979d946153f4 (diff) | |
download | Qt-9c984b6b421e7cc6c091623f63ed84ce700f1ee1.zip Qt-9c984b6b421e7cc6c091623f63ed84ce700f1ee1.tar.gz Qt-9c984b6b421e7cc6c091623f63ed84ce700f1ee1.tar.bz2 |
Add autotest for target/property matchTargets/matchProperties semantics.
Diffstat (limited to 'tests/auto')
12 files changed, 383 insertions, 0 deletions
diff --git a/tests/auto/declarative/animations/data/properties.qml b/tests/auto/declarative/animations/data/properties.qml new file mode 100644 index 0000000..a8023b4 --- /dev/null +++ b/tests/auto/declarative/animations/data/properties.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { to: 200; running: true; } + } +} diff --git a/tests/auto/declarative/animations/data/properties2.qml b/tests/auto/declarative/animations/data/properties2.qml new file mode 100644 index 0000000..aab7661 --- /dev/null +++ b/tests/auto/declarative/animations/data/properties2.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { matchTargets: theRect; matchProperties: "x"; to: 200; running: true } + } +} diff --git a/tests/auto/declarative/animations/data/properties3.qml b/tests/auto/declarative/animations/data/properties3.qml new file mode 100644 index 0000000..fd21a85 --- /dev/null +++ b/tests/auto/declarative/animations/data/properties3.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { target: theRect; property: "x"; to: 300; running: true } + } +} diff --git a/tests/auto/declarative/animations/data/properties4.qml b/tests/auto/declarative/animations/data/properties4.qml new file mode 100644 index 0000000..e23651c --- /dev/null +++ b/tests/auto/declarative/animations/data/properties4.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { target: theRect; property: "y"; to: 200; running: true } + } +} diff --git a/tests/auto/declarative/animations/data/properties5.qml b/tests/auto/declarative/animations/data/properties5.qml new file mode 100644 index 0000000..25c9866 --- /dev/null +++ b/tests/auto/declarative/animations/data/properties5.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + x: NumberAnimation { matchTargets: theRect; matchProperties: "y"; to: 200; running: true } + } +} diff --git a/tests/auto/declarative/animations/data/propertiesTransition.qml b/tests/auto/declarative/animations/data/propertiesTransition.qml new file mode 100644 index 0000000..75603b9 --- /dev/null +++ b/tests/auto/declarative/animations/data/propertiesTransition.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { matchTargets: theRect; matchProperties: "x" } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/animations/data/propertiesTransition2.qml b/tests/auto/declarative/animations/data/propertiesTransition2.qml new file mode 100644 index 0000000..ae59157 --- /dev/null +++ b/tests/auto/declarative/animations/data/propertiesTransition2.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { target: theRect; property: "y"; to: 200 } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/animations/data/propertiesTransition3.qml b/tests/auto/declarative/animations/data/propertiesTransition3.qml new file mode 100644 index 0000000..eedba7b --- /dev/null +++ b/tests/auto/declarative/animations/data/propertiesTransition3.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { matchTargets: theRect; matchProperties: "y" } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/animations/data/propertiesTransition4.qml b/tests/auto/declarative/animations/data/propertiesTransition4.qml new file mode 100644 index 0000000..301f796 --- /dev/null +++ b/tests/auto/declarative/animations/data/propertiesTransition4.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { target: theRect; matchProperties: "x" } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/animations/data/propertiesTransition5.qml b/tests/auto/declarative/animations/data/propertiesTransition5.qml new file mode 100644 index 0000000..565c519 --- /dev/null +++ b/tests/auto/declarative/animations/data/propertiesTransition5.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { matchTargets: theRect; property: "x" } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/animations/data/propertiesTransition6.qml b/tests/auto/declarative/animations/data/propertiesTransition6.qml new file mode 100644 index 0000000..b541dab --- /dev/null +++ b/tests/auto/declarative/animations/data/propertiesTransition6.qml @@ -0,0 +1,29 @@ +import Qt 4.6 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { matchTargets: theItem; matchProperties: "x" } + } + + MouseRegion { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp index 418a3dc..a4402cb 100644 --- a/tests/auto/declarative/animations/tst_animations.cpp +++ b/tests/auto/declarative/animations/tst_animations.cpp @@ -59,6 +59,8 @@ private slots: void badTypes(); void badProperties(); void mixedTypes(); + void properties(); + void propertiesTransition(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -245,6 +247,143 @@ void tst_animations::mixedTypes() } } +void tst_animations::properties() +{ + const int waitDuration = 300; + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/properties.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/properties2.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/properties3.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(300)); + } + + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/properties4.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->y(),qreal(200)); + QTIMED_COMPARE(myRect->x(),qreal(100)); + } + + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/properties5.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(100)); + QTIMED_COMPARE(myRect->y(),qreal(100)); + } +} + +void tst_animations::propertiesTransition() +{ + const int waitDuration = 300; + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/propertiesTransition.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + rect->setState("moved"); + QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/propertiesTransition2.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); + QVERIFY(myRect); + rect->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + QCOMPARE(myRect->y(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->y(),qreal(200)); + } + + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/propertiesTransition3.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); + QVERIFY(myRect); + QTest::ignoreMessage(QtWarningMsg, "QML QmlNumberAnimation (file:///home/brasser/depot/kinetic-declarativeui/qt/tests/auto/declarative/animations/data/propertiesTransition4.qml:22:9) targets/properties/exclude and target/property are mutually exclusive."); + rect->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + } + + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/propertiesTransition4.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); + QVERIFY(myRect); + QTest::ignoreMessage(QtWarningMsg, "QML QmlNumberAnimation (file:///home/brasser/depot/kinetic-declarativeui/qt/tests/auto/declarative/animations/data/propertiesTransition5.qml:22:9) targets/properties/exclude and target/property are mutually exclusive."); + rect->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + } + + { + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/propertiesTransition5.qml")); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); + + //### should output warning at some point -- theItem doesn't exist + QmlGraphicsRectangle *myRect = rect->findChild<QmlGraphicsRectangle*>("TheRect"); + QVERIFY(myRect); + rect->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + } +} + QTEST_MAIN(tst_animations) #include "tst_animations.moc" |