diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2009-11-16 05:46:49 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2009-11-16 05:46:49 (GMT) |
commit | 106aa2327cdd341b948b442ac3867bbab610ada7 (patch) | |
tree | 855d114bc86df55aeadf58608ed1107eb9bbe10b | |
parent | 341d12b9cbe7d516d32b8409def7193058aef33c (diff) | |
download | Qt-106aa2327cdd341b948b442ac3867bbab610ada7.zip Qt-106aa2327cdd341b948b442ac3867bbab610ada7.tar.gz Qt-106aa2327cdd341b948b442ac3867bbab610ada7.tar.bz2 |
Path autotests
-rw-r--r-- | tests/auto/declarative/qmlgraphicspathview/data/path.qml | 14 | ||||
-rw-r--r-- | tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp | 47 |
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/path.qml b/tests/auto/declarative/qmlgraphicspathview/data/path.qml new file mode 100644 index 0000000..7e82a48 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicspathview/data/path.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Path { + startX: 120; startY: 100 + + PathAttribute { name: "scale"; value: 1.0 } + PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } + PathPercent { value: 0.3 } + PathLine { x: 120; y: 100 } + PathCubic { + x: 180; y: 0; control1X: -10; control1Y: 90 + control2X: 210; control2Y: 90 + } +} diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp index c36b969..561392a 100644 --- a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp +++ b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include <private/qmlgraphicspathview_p.h> +#include <private/qmlgraphicspath_p.h> #include <qmlcontext.h> #include <qmlexpression.h> #include <qtest.h> @@ -57,6 +58,7 @@ private slots: void initValues(); void pathview2(); void pathview3(); + void path(); }; @@ -118,6 +120,51 @@ void tst_QmlGraphicsPathView::pathview3() QCOMPARE(obj->pathItemCount(), 4); } +void tst_QmlGraphicsPathView::path() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/path.qml")); + QmlGraphicsPath *obj = qobject_cast<QmlGraphicsPath*>(c.create()); + + QVERIFY(obj != 0); + QCOMPARE(obj->startX(), 120.); + QCOMPARE(obj->startY(), 100.); + QVERIFY(obj->path() != QPainterPath()); + + QList<QmlGraphicsPathElement*> *list = obj->pathElements(); + QCOMPARE(list->count(), 5); + + QmlGraphicsPathAttribute* attr = qobject_cast<QmlGraphicsPathAttribute*>(list->at(0)); + QVERIFY(attr != 0); + QCOMPARE(attr->name(), QString("scale")); + QCOMPARE(attr->value(), 1.0); + + QmlGraphicsPathQuad* quad = qobject_cast<QmlGraphicsPathQuad*>(list->at(1)); + QVERIFY(quad != 0); + QCOMPARE(quad->x(), 120.); + QCOMPARE(quad->y(), 25.); + QCOMPARE(quad->controlX(), 260.); + QCOMPARE(quad->controlY(), 75.); + + QmlGraphicsPathPercent* perc = qobject_cast<QmlGraphicsPathPercent*>(list->at(2)); + QVERIFY(perc != 0); + QCOMPARE(perc->value(), 0.3); + + QmlGraphicsPathLine* line = qobject_cast<QmlGraphicsPathLine*>(list->at(3)); + QVERIFY(line != 0); + QCOMPARE(line->x(), 120.); + QCOMPARE(line->y(), 100.); + + QmlGraphicsPathCubic* cubic = qobject_cast<QmlGraphicsPathCubic*>(list->at(4)); + QVERIFY(cubic != 0); + QCOMPARE(cubic->x(), 180.); + QCOMPARE(cubic->y(), 0.); + QCOMPARE(cubic->control1X(), -10.); + QCOMPARE(cubic->control1Y(), 90.); + QCOMPARE(cubic->control2X(), 210.); + QCOMPARE(cubic->control2Y(), 90.); +} + QTEST_MAIN(tst_QmlGraphicsPathView) #include "tst_qmlgraphicspathview.moc" |