summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/rotation.qml48
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp58
2 files changed, 106 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeanimations/data/rotation.qml b/tests/auto/declarative/qdeclarativeanimations/data/rotation.qml
new file mode 100644
index 0000000..e9c57d4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimations/data/rotation.qml
@@ -0,0 +1,48 @@
+import Qt 4.6
+
+Rectangle {
+ width: 600; height: 200
+
+ Row {
+ spacing: 5
+ Rectangle {
+ id: rr
+ objectName: "rr"
+ color: "red"
+ width: 100; height: 100
+ }
+ Rectangle {
+ id: rr2
+ objectName: "rr2"
+ color: "red"
+ width: 100; height: 100
+ }
+ Rectangle {
+ id: rr3
+ objectName: "rr3"
+ color: "red"
+ width: 100; height: 100
+ }
+ Rectangle {
+ id: rr4
+ objectName: "rr4"
+ color: "red"
+ width: 100; height: 100
+ }
+ }
+
+ states: State {
+ name: "state1"
+ PropertyChanges { target: rr; rotation: 370 }
+ PropertyChanges { target: rr2; rotation: 370 }
+ PropertyChanges { target: rr3; rotation: 370 }
+ PropertyChanges { target: rr4; rotation: 370 }
+ }
+
+ transitions: Transition {
+ RotationAnimation { target: rr; direction: RotationAnimation.Numerical; duration: 1000 }
+ RotationAnimation { target: rr2; direction: RotationAnimation.Clockwise; duration: 1000 }
+ RotationAnimation { target: rr3; direction: RotationAnimation.Counterclockwise; duration: 1000 }
+ RotationAnimation { target: rr4; direction: RotationAnimation.Shortest; duration: 1000 }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
index f5e15fb..076afea 100644
--- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -59,6 +59,7 @@ private slots:
void simpleProperty();
void simpleNumber();
void simpleColor();
+ void simpleRotation();
void alwaysRunToEnd();
void complete();
void resume();
@@ -73,6 +74,7 @@ private slots:
void propertyValueSourceDefaultStart();
void dontStart();
void easingProperties();
+ void rotation();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -168,6 +170,32 @@ void tst_qdeclarativeanimations::simpleColor()
QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
}
+void tst_qdeclarativeanimations::simpleRotation()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativeRotationAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("rotation");
+ animation.setTo(270);
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "rotation");
+ QVERIFY(animation.to() == 270);
+ QVERIFY(animation.direction() == QDeclarativeRotationAnimation::Shortest);
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.rotation(), qreal(270));
+
+ rect.setRotation(0);
+ animation.start();
+ animation.pause();
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.rotation(), qreal(-45));
+}
+
void tst_qdeclarativeanimations::alwaysRunToEnd()
{
QDeclarativeRectangle rect;
@@ -667,6 +695,36 @@ void tst_qdeclarativeanimations::easingProperties()
}
}
+void tst_qdeclarativeanimations::rotation()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/rotation.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *rr = rect->findChild<QDeclarativeRectangle*>("rr");
+ QDeclarativeRectangle *rr2 = rect->findChild<QDeclarativeRectangle*>("rr2");
+ QDeclarativeRectangle *rr3 = rect->findChild<QDeclarativeRectangle*>("rr3");
+ QDeclarativeRectangle *rr4 = rect->findChild<QDeclarativeRectangle*>("rr4");
+
+ rect->setState("state1");
+ QTest::qWait(800);
+ qreal r1 = rr->rotation();
+ qreal r2 = rr2->rotation();
+ qreal r3 = rr3->rotation();
+ qreal r4 = rr4->rotation();
+
+ QVERIFY(r1 > qreal(0) && r1 < qreal(370));
+ QVERIFY(r2 > qreal(0) && r2 < qreal(370));
+ QVERIFY(r3 < qreal(0) && r3 > qreal(-350));
+ QVERIFY(r4 > qreal(0) && r4 < qreal(10));
+ QCOMPARE(r1,r2);
+ QVERIFY(r4 < r2);
+
+ QTest::qWait(800);
+ QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4));
+}
+
QTEST_MAIN(tst_qdeclarativeanimations)
#include "tst_qdeclarativeanimations.moc"