aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-09-30 09:04:11 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-30 10:37:05 +0200
commitf32a83bfcf5a667a81fdd2020f119cdeec79a9f1 (patch)
tree8fd1c7e520743db050ff2369c0fdab1bbcbf6786 /tests
parent3fff5e654e1b39844deae43cf5b211c2f196227f (diff)
Fix issue with interpolating more than one path segment backwards.
Change-Id: I463010ed63d41be80db96e8306aef8caa3863ccf Reviewed-on: http://codereview.qt-project.org/5821 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/pathInterpolatorBack.qml11
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp33
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeanimations/data/pathInterpolatorBack.qml b/tests/auto/declarative/qdeclarativeanimations/data/pathInterpolatorBack.qml
new file mode 100644
index 0000000000..41366ef798
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimations/data/pathInterpolatorBack.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.0
+
+PathInterpolator {
+ path: Path {
+ startX: 50; startY: 50
+ PathLine { x: 50; y: 100 }
+ PathLine { x: 100; y: 100 }
+ PathLine { x: 100; y: 50 }
+ PathLine { x: 200; y: 50 }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
index 303268eba6..652e357d5c 100644
--- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -75,6 +75,7 @@ private slots:
void simpleRotation();
void simplePath();
void pathInterpolator();
+ void pathInterpolatorBackwardJump();
void pathWithNoStart();
void alwaysRunToEnd();
void complete();
@@ -316,6 +317,38 @@ void tst_qdeclarativeanimations::pathInterpolator()
QCOMPARE(interpolator->angle(), qreal(0));
}
+void tst_qdeclarativeanimations::pathInterpolatorBackwardJump()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathInterpolatorBack.qml"));
+ QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
+ QVERIFY(interpolator);
+
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(50));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(270));
+
+ interpolator->setProgress(.5);
+ QCOMPARE(interpolator->progress(), qreal(.5));
+ QCOMPARE(interpolator->x(), qreal(100));
+ QCOMPARE(interpolator->y(), qreal(75));
+ QCOMPARE(interpolator->angle(), qreal(90));
+
+ interpolator->setProgress(1);
+ QCOMPARE(interpolator->progress(), qreal(1));
+ QCOMPARE(interpolator->x(), qreal(200));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(0));
+
+ //make sure we don't get caught in infinite loop here
+ interpolator->setProgress(0);
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(50));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(270));
+}
+
void tst_qdeclarativeanimations::pathWithNoStart()
{
QDeclarativeEngine engine;