aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickanimations
diff options
context:
space:
mode:
authorOleg Yadrov <oleg.yadrov@qt.io>2016-12-19 12:08:20 -0800
committerOleg Yadrov <oleg.yadrov@qt.io>2017-01-20 00:13:24 +0000
commit7ee15ecdd960cde6d0202e9675f7f6bd31bbb927 (patch)
tree4d543697b552eada54971b7d0684e0495507e308 /tests/auto/quick/qquickanimations
parentedffdcf9b45641708fb242449b77e8e53ee05d87 (diff)
PathAnimation: fix bug when PathSvg or PathLine is the last item in Path
Both QQuickPathLine and QQuickPathSvg inherit QQuickCurve class which has “x” and “y” properties that return qreal type, but internally they are stored as QQmlNullableValue<qreal>. At the same time, if any of them is not specified explicitly, its getter returns 0. QQuickPath processes QQuickPath%Type% objects and produces a QPainterPath which later used by QQuickPathAnimation. QQuickPathAnimation only created a QAbstractAnimationJob if QQuickPath::hasEnd returned true, and hasEnd returned true only if both “x” and “y” were specified explicitly. All that in conjunction led to the situation when if you had either - a PathLine with unspecified “x” or “y”; or - a PathSvg which was the last (or the only) path element in your Path, PathAnimation would not start. This patch removes hasEnd check, it should be safe to do because QPainterPath is always valid anyway due to the fact QQuickCurve::x() and QQuickCurve::y() return 0 if they have not been not explicitly set. Task-number: QTBUG-57666 Change-Id: Id320aaeb5aff0964d6493b7b80d5d9a7d36acce8 Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'tests/auto/quick/qquickanimations')
-rw-r--r--tests/auto/quick/qquickanimations/data/pathLineUnspecifiedXYBug.qml28
-rw-r--r--tests/auto/quick/qquickanimations/data/pathSvgAnimation.qml25
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp44
3 files changed, 97 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickanimations/data/pathLineUnspecifiedXYBug.qml b/tests/auto/quick/qquickanimations/data/pathLineUnspecifiedXYBug.qml
new file mode 100644
index 0000000000..426360bbcc
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/data/pathLineUnspecifiedXYBug.qml
@@ -0,0 +1,28 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 400
+
+ Rectangle {
+ id: redRect
+ color: "red"
+ width: 100; height: 100
+ x: 50; y: 50
+ }
+
+ PathAnimation {
+ target: redRect
+ duration: 1000
+ path: Path {
+ startX: 100; startY: 100
+
+ PathLine {
+ x: 200
+ y: 200
+ }
+
+ PathLine {}
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickanimations/data/pathSvgAnimation.qml b/tests/auto/quick/qquickanimations/data/pathSvgAnimation.qml
new file mode 100644
index 0000000000..e409bb031f
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/data/pathSvgAnimation.qml
@@ -0,0 +1,25 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 400
+ height: 400
+
+ Rectangle {
+ id: redRect
+ color: "red"
+ width: 100; height: 100
+ x: 50; y: 50
+ }
+
+ PathAnimation {
+ target: redRect
+ duration: 1000;
+ path: Path {
+ startX: 100; startY: 100
+
+ PathSvg {
+ path: "M 200 200"
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index 6e265503a1..fbd6c9c97e 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -101,6 +101,8 @@ private slots:
void scriptActionCrash();
void animatorInvalidTargetCrash();
void defaultPropertyWarning();
+ void pathSvgAnimation();
+ void pathLineUnspecifiedXYBug();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -1523,6 +1525,48 @@ void tst_qquickanimations::defaultPropertyWarning()
QVERIFY(warnings.isEmpty());
}
+// QTBUG-57666
+void tst_qquickanimations::pathSvgAnimation()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("pathSvgAnimation.qml"));
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(component.create()));
+ QVERIFY(rect);
+
+ QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(redRect);
+ QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
+ QVERIFY(pathAnim);
+
+ QCOMPARE(redRect->x(), qreal(50));
+ QCOMPARE(redRect->y(), qreal(50));
+
+ pathAnim->start();
+ QTRY_COMPARE(redRect->x(), qreal(200));
+ QCOMPARE(redRect->y(), qreal(200));
+}
+
+// QTBUG-57666
+void tst_qquickanimations::pathLineUnspecifiedXYBug()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("pathLineUnspecifiedXYBug.qml"));
+ QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(component.create()));
+ QVERIFY(rect);
+
+ QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(redRect);
+ QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
+ QVERIFY(pathAnim);
+
+ QCOMPARE(redRect->x(), qreal(50));
+ QCOMPARE(redRect->y(), qreal(50));
+
+ pathAnim->start();
+ QTRY_COMPARE(redRect->x(), qreal(0));
+ QCOMPARE(redRect->y(), qreal(0));
+}
+
QTEST_MAIN(tst_qquickanimations)
#include "tst_qquickanimations.moc"