From ce3dee765c858a0b573d468ef8fee6b838e576d1 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 3 Feb 2012 12:26:37 +1000 Subject: Add and use new animation backend. The new backend improves performance, and allows us to create multiple running animation jobs from a single Transition. It is based off of the existing Qt animation framework. Change-Id: Id1d0162f6e5c65bf31267f3f9f2042c354375d57 Reviewed-by: Yunqiao Yin --- .../tst_qdeclarativesmoothedanimation.cpp | 58 +++++++++++++--------- 1 file changed, 35 insertions(+), 23 deletions(-) (limited to 'tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp') diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp b/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp index 5ab3e96e06..f60955c58e 100644 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp +++ b/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include "../../shared/util.h" @@ -120,28 +120,40 @@ void tst_qdeclarativesmoothedanimation::disabled() void tst_qdeclarativesmoothedanimation::simpleAnimation() { - QQuickRectangle rect; - QDeclarativeSmoothedAnimation animation; - animation.setTarget(&rect); - animation.setProperty("x"); - animation.setTo(200); - animation.setDuration(250); - QVERIFY(animation.target() == &rect); - QVERIFY(animation.property() == "x"); - QVERIFY(animation.to() == 200); - animation.start(); - QVERIFY(animation.isRunning()); - QTest::qWait(animation.duration()); - QTRY_COMPARE(rect.x(), qreal(200)); - - rect.setX(0); - animation.start(); - animation.pause(); - QVERIFY(animation.isRunning()); - QVERIFY(animation.isPaused()); - animation.setCurrentTime(125); - QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.x(), qreal(100)); + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, testFileUrl("simpleanimation.qml")); + QObject *obj = c.create(); + QVERIFY(obj); + + QQuickRectangle *rect = obj->findChild("rect"); + QVERIFY(rect); + + QDeclarativeSmoothedAnimation *animation = obj->findChild("anim"); + QVERIFY(animation); + + animation->setTarget(rect); + animation->setProperty("x"); + animation->setTo(200); + animation->setDuration(250); + QVERIFY(animation->target() == rect); + QVERIFY(animation->property() == "x"); + QVERIFY(animation->to() == 200); + animation->start(); + QVERIFY(animation->isRunning()); + QTest::qWait(animation->duration()); + QTRY_COMPARE(rect->x(), qreal(200)); + QTest::qWait(100); //smoothed animation doesn't report stopped until delayed timer fires + + QVERIFY(!animation->isRunning()); + rect->setX(0); + animation->start(); + QVERIFY(animation->isRunning()); + animation->pause(); + QVERIFY(animation->isRunning()); + QVERIFY(animation->isPaused()); + animation->setCurrentTime(125); + QVERIFY(animation->currentTime() == 125); + QCOMPARE(rect->x(), qreal(100)); } void tst_qdeclarativesmoothedanimation::valueSource() -- cgit v1.2.3