diff options
author | Michael Brasser <mbrasser@ford.com> | 2017-09-20 15:15:06 -0500 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2017-11-07 16:29:16 +0000 |
commit | 7bedd55551fbe95355b0db11f9d576924e829f9d (patch) | |
tree | fdef6c4ec81b46161162abacefe350c87a373830 /tests | |
parent | a10f154e3b46cc004ab6f7d5319f550c450987d4 (diff) |
Add new PathAngleArc type
This type allows working with arcs in different ways (based
on angles rather than start/end positions) that can be more
intuitive for certain use cases (such as a circular
progress indicator).
[ChangeLog][QtQuick][Path] Add new PathAngleArc type
Change-Id: Icbe5fc0450edd9a4d92f9a8d03438842b72a312d
Task-number: QTBUG-62684
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickpath/data/anglearc.qml | 12 | ||||
-rw-r--r-- | tests/auto/quick/qquickpath/tst_qquickpath.cpp | 40 |
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickpath/data/anglearc.qml b/tests/auto/quick/qquickpath/data/anglearc.qml new file mode 100644 index 0000000000..cbe41c1ac8 --- /dev/null +++ b/tests/auto/quick/qquickpath/data/anglearc.qml @@ -0,0 +1,12 @@ +import QtQuick 2.11 + +Path { + PathAngleArc { + centerX: 100 + centerY: 100 + radiusX: 50 + radiusY: 50 + startAngle: 45 + sweepAngle: 90 + } +} diff --git a/tests/auto/quick/qquickpath/tst_qquickpath.cpp b/tests/auto/quick/qquickpath/tst_qquickpath.cpp index 2ec95840e1..106d7afd85 100644 --- a/tests/auto/quick/qquickpath/tst_qquickpath.cpp +++ b/tests/auto/quick/qquickpath/tst_qquickpath.cpp @@ -41,6 +41,7 @@ public: private slots: void arc(); + void angleArc(); void catmullromCurve(); void closedCatmullromCurve(); void svg(); @@ -82,6 +83,45 @@ void tst_QuickPath::arc() QCOMPARE(pos, QPointF(100,100)); } +void tst_QuickPath::angleArc() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("anglearc.qml")); + QQuickPath *obj = qobject_cast<QQuickPath*>(c.create()); + QVERIFY(obj != 0); + + QQmlListReference list(obj, "pathElements"); + QCOMPARE(list.count(), 1); + + QQuickPathAngleArc* arc = qobject_cast<QQuickPathAngleArc*>(list.at(0)); + QVERIFY(arc != 0); + QCOMPARE(arc->centerX(), 100.); + QCOMPARE(arc->centerY(), 100.); + QCOMPARE(arc->radiusX(), 50.); + QCOMPARE(arc->radiusY(), 50.); + QCOMPARE(arc->startAngle(), 45.); + QCOMPARE(arc->sweepAngle(), 90.); + QCOMPARE(arc->moveToStart(), true); + + QPainterPath path = obj->path(); + QVERIFY(path != QPainterPath()); + + // using QPoint to do fuzzy compare + QPointF pos = obj->pointAt(0); + QCOMPARE(pos.toPoint(), QPoint(135,135)); + pos = obj->pointAt(.25); + QCOMPARE(pos.toPoint(), QPoint(119,146)); + pos = obj->pointAt(.75); + QCOMPARE(pos.toPoint(), QPoint(81,146)); + pos = obj->pointAt(1); + QCOMPARE(pos.toPoint(), QPoint(65,135)); + + // if moveToStart is false, we should have a line starting from startX/Y + arc->setMoveToStart(false); + pos = obj->pointAt(0); + QCOMPARE(pos, QPointF(0,0)); +} + void tst_QuickPath::catmullromCurve() { QQmlEngine engine; |