aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2012-01-06 09:37:03 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-06 01:08:22 +0100
commitc13098fa6e0dcaca1022f1c50ced6cba4d5f7168 (patch)
treee08b3029c89396c6786fdde525601ecb9768b837 /tests
parent29d2d20be058f5b10dee4dd2d04b864aa155d48e (diff)
Smooth join point for closed Paths starting and ending with PathCurve.
Change-Id: I6d416e7d794271c10c9eb19de9678b0fe45b083d Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml9
-rw-r--r--tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp51
2 files changed, 52 insertions, 8 deletions
diff --git a/tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml b/tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml
new file mode 100644
index 0000000000..bb4a715e28
--- /dev/null
+++ b/tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+
+Path {
+ startX: 50; startY: 50
+
+ PathCurve { x: 100; y: 100 }
+ PathCurve { x: 50; y: 150 }
+ PathCurve { x: 50; y: 50 }
+}
diff --git a/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp b/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp
index 0b0000dd42..c2682358b3 100644
--- a/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp
+++ b/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp
@@ -55,6 +55,7 @@ public:
private slots:
void arc();
void catmullromCurve();
+ void closedCatmullromCurve();
void svg();
};
@@ -106,14 +107,15 @@ void tst_QDeclarativePath::catmullromCurve()
QDeclarativeListReference list(obj, "pathElements");
QCOMPARE(list.count(), 3);
- QDeclarativePathCatmullRomCurve* arc = qobject_cast<QDeclarativePathCatmullRomCurve*>(list.at(0));
-// QVERIFY(arc != 0);
-// QCOMPARE(arc->x(), 100.);
-// QCOMPARE(arc->y(), 100.);
-// QCOMPARE(arc->radiusX(), 100.);
-// QCOMPARE(arc->radiusY(), 100.);
-// QCOMPARE(arc->useLargeArc(), false);
-// QCOMPARE(arc->direction(), QDeclarativePathArc::Clockwise);
+ QDeclarativePathCatmullRomCurve* curve = qobject_cast<QDeclarativePathCatmullRomCurve*>(list.at(0));
+ QVERIFY(curve != 0);
+ QCOMPARE(curve->x(), 100.);
+ QCOMPARE(curve->y(), 50.);
+
+ curve = qobject_cast<QDeclarativePathCatmullRomCurve*>(list.at(2));
+ QVERIFY(curve != 0);
+ QCOMPARE(curve->x(), 100.);
+ QCOMPARE(curve->y(), 150.);
QPainterPath path = obj->path();
QVERIFY(path != QPainterPath());
@@ -128,6 +130,39 @@ void tst_QDeclarativePath::catmullromCurve()
QCOMPARE(pos, QPointF(100,150));
}
+void tst_QDeclarativePath::closedCatmullromCurve()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, testFileUrl("closedcurve.qml"));
+ QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 50.);
+ QCOMPARE(obj->startY(), 50.);
+
+ QDeclarativeListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 3);
+
+ QDeclarativePathCatmullRomCurve* curve = qobject_cast<QDeclarativePathCatmullRomCurve*>(list.at(2));
+ QVERIFY(curve != 0);
+ QCOMPARE(curve->x(), 50.);
+ QCOMPARE(curve->y(), 50.);
+
+ QVERIFY(obj->isClosed());
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(50,50));
+ pos = obj->pointAt(.1);
+ QCOMPARE(pos.toPoint(), QPoint(67,56)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(44,116)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(50,50));
+}
+
void tst_QDeclarativePath::svg()
{
QDeclarativeEngine engine;