aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickpath
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-02-16 14:43:03 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-24 04:51:31 +0100
commitb855240b782395f94315f43ea3e7e182299fac48 (patch)
treebc594c04449be8cd14cd0ab0bb72dafc2be0ffb2 /tests/auto/quick/qquickpath
parent6a42a6e0a9a1abdda0d07a5a20b4ac7e45348684 (diff)
Rename QDeclarative symbols to QQuick and QQml
Symbols beginning with QDeclarative are already exported by the quick1 module. Users can apply the bin/rename-qtdeclarative-symbols.sh script to modify client code using the previous names of the renamed symbols. Task-number: QTBUG-23737 Change-Id: Ifaa482663767634931e8711a8e9bf6e404859e66 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickpath')
-rw-r--r--tests/auto/quick/qquickpath/data/arc.qml11
-rw-r--r--tests/auto/quick/qquickpath/data/closedcurve.qml9
-rw-r--r--tests/auto/quick/qquickpath/data/curve.qml9
-rw-r--r--tests/auto/quick/qquickpath/data/svg.qml5
-rw-r--r--tests/auto/quick/qquickpath/qquickpath.pro15
-rw-r--r--tests/auto/quick/qquickpath/tst_qquickpath.cpp199
6 files changed, 248 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickpath/data/arc.qml b/tests/auto/quick/qquickpath/data/arc.qml
new file mode 100644
index 0000000000..000221c784
--- /dev/null
+++ b/tests/auto/quick/qquickpath/data/arc.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.0
+
+Path {
+ startX: 0; startY: 0
+
+ PathArc {
+ x: 100; y: 100
+ radiusX: 100; radiusY: 100
+ direction: PathArc.Clockwise
+ }
+}
diff --git a/tests/auto/quick/qquickpath/data/closedcurve.qml b/tests/auto/quick/qquickpath/data/closedcurve.qml
new file mode 100644
index 0000000000..bb4a715e28
--- /dev/null
+++ b/tests/auto/quick/qquickpath/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/quick/qquickpath/data/curve.qml b/tests/auto/quick/qquickpath/data/curve.qml
new file mode 100644
index 0000000000..c571186496
--- /dev/null
+++ b/tests/auto/quick/qquickpath/data/curve.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+
+Path {
+ startX: 0; startY: 0
+
+ PathCurve { x: 100; y: 50 }
+ PathCurve { x: 50; y: 100 }
+ PathCurve { x: 100; y: 150 }
+}
diff --git a/tests/auto/quick/qquickpath/data/svg.qml b/tests/auto/quick/qquickpath/data/svg.qml
new file mode 100644
index 0000000000..cec0f75061
--- /dev/null
+++ b/tests/auto/quick/qquickpath/data/svg.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+Path {
+ PathSvg { path: "M200,300 Q400,50 600,300 T1000,300" }
+}
diff --git a/tests/auto/quick/qquickpath/qquickpath.pro b/tests/auto/quick/qquickpath/qquickpath.pro
new file mode 100644
index 0000000000..e1f0f7b278
--- /dev/null
+++ b/tests/auto/quick/qquickpath/qquickpath.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickpath
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickpath.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickpath/tst_qquickpath.cpp b/tests/auto/quick/qquickpath/tst_qquickpath.cpp
new file mode 100644
index 0000000000..73e7e6ea38
--- /dev/null
+++ b/tests/auto/quick/qquickpath/tst_qquickpath.cpp
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquickpath_p.h>
+
+#include "../../shared/util.h"
+
+class tst_QuickPath : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QuickPath() {}
+
+private slots:
+ void arc();
+ void catmullromCurve();
+ void closedCatmullromCurve();
+ void svg();
+};
+
+void tst_QuickPath::arc()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("arc.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 0.);
+ QCOMPARE(obj->startY(), 0.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 1);
+
+ QQuickPathArc* arc = qobject_cast<QQuickPathArc*>(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(), QQuickPathArc::Clockwise);
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(0,0));
+ pos = obj->pointAt(.25);
+ QCOMPARE(pos.toPoint(), QPoint(39,8)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(92,61)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(100,100));
+}
+
+void tst_QuickPath::catmullromCurve()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("curve.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 0.);
+ QCOMPARE(obj->startY(), 0.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 3);
+
+ QQuickPathCatmullRomCurve* curve = qobject_cast<QQuickPathCatmullRomCurve*>(list.at(0));
+ QVERIFY(curve != 0);
+ QCOMPARE(curve->x(), 100.);
+ QCOMPARE(curve->y(), 50.);
+
+ curve = qobject_cast<QQuickPathCatmullRomCurve*>(list.at(2));
+ QVERIFY(curve != 0);
+ QCOMPARE(curve->x(), 100.);
+ QCOMPARE(curve->y(), 150.);
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(0,0));
+ pos = obj->pointAt(.25);
+ QCOMPARE(pos.toPoint(), QPoint(63,26)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(51,105)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(100,150));
+}
+
+void tst_QuickPath::closedCatmullromCurve()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("closedcurve.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 50.);
+ QCOMPARE(obj->startY(), 50.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 3);
+
+ QQuickPathCatmullRomCurve* curve = qobject_cast<QQuickPathCatmullRomCurve*>(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_QuickPath::svg()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("svg.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 0.);
+ QCOMPARE(obj->startY(), 0.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 1);
+
+ QQuickPathSvg* svg = qobject_cast<QQuickPathSvg*>(list.at(0));
+ QVERIFY(svg != 0);
+ QCOMPARE(svg->path(), QLatin1String("M200,300 Q400,50 600,300 T1000,300"));
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(200,300));
+ pos = obj->pointAt(.25);
+ QCOMPARE(pos.toPoint(), QPoint(400,175)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(800,425)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(1000,300));
+}
+
+
+QTEST_MAIN(tst_QuickPath)
+
+#include "tst_qquickpath.moc"