diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-05 17:22:10 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-05 17:22:10 (GMT) |
commit | d801a997abbea01eade4155f5e7a0d51437ba1d9 (patch) | |
tree | c22649a54741783cb4b74f32922e60ca657c34d1 /tests/auto/declarative/qdeclarativeanimations | |
parent | c6ac9fe2e8d219bb9694efaf5b25ec5108fb8fa6 (diff) | |
parent | 5de63109f548eee20df1fcf8b705b3471b005238 (diff) | |
download | Qt-d801a997abbea01eade4155f5e7a0d51437ba1d9.zip Qt-d801a997abbea01eade4155f5e7a0d51437ba1d9.tar.gz Qt-d801a997abbea01eade4155f5e7a0d51437ba1d9.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (25 commits)
optimize dynamic call-by-name away
Add support for QtScript connect/disconnect syntax in QML
Minor perf improvement when running QML script blocks
Fix qdeclarative{audio,video} tests.
Don't assume documents are in UTF-8.
Add basic support for explicit newParent in ParentAnimation.
Delete uninspiring example.
Fix compiler warning on RVCT
Use new enum syntax for value types.
Expect fail in currentIndex test for now.
Allow unquoted enum syntax for value types
More declarative examples cleanup.
Improve declarative tabs example.
Fix test leaks
Use _data() for some tests
Add missing NOTIFYs to timer, xmllistmodel, xmlrole
Document new ParentChange properties.
declarative examples cleanup
Fix test
Update QmlChanges.txt
...
Diffstat (limited to 'tests/auto/declarative/qdeclarativeanimations')
-rw-r--r-- | tests/auto/declarative/qdeclarativeanimations/data/rotation.qml | 48 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp | 58 |
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" |