aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp')
-rw-r--r--tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp58
1 files changed, 35 insertions, 23 deletions
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 <qtest.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativesmoothedanimation_p.h>
+#include <QtQuick/private/qdeclarativesmoothedanimation_p.h>
#include <QtQuick/private/qquickrectangle_p.h>
#include <private/qdeclarativevaluetype_p.h>
#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<QQuickRectangle*>("rect");
+ QVERIFY(rect);
+
+ QDeclarativeSmoothedAnimation *animation = obj->findChild<QDeclarativeSmoothedAnimation*>("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()