aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickpath
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-04-20 15:52:41 +1000
committerQt by Nokia <qt-info@nokia.com>2012-04-23 09:52:33 +0200
commitb50aa539e854f1a10c5f012a448ab6977c3fc9ac (patch)
treeb1a8526c6c621edd76d94870f2c4e6734c7ba71f /tests/auto/quick/qquickpath
parenta0adcc6480bce8ca4f91afc792176d313f92ecee (diff)
Reduce memory usage of QQuickPath for simple paths.
For a single segment line path we can get correct results by interpolating across just two points, so there no need to allocate the comparatively large point cache required for more complex paths. This also correct a normally small interpolation error caused by including the terminal point in the number of intervals. Change-Id: I564c3c012b6822831251276951603fca8544a356 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/quick/qquickpath')
-rw-r--r--tests/auto/quick/qquickpath/tst_qquickpath.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickpath/tst_qquickpath.cpp b/tests/auto/quick/qquickpath/tst_qquickpath.cpp
index 73e7e6ea38..af5b194bd9 100644
--- a/tests/auto/quick/qquickpath/tst_qquickpath.cpp
+++ b/tests/auto/quick/qquickpath/tst_qquickpath.cpp
@@ -57,6 +57,7 @@ private slots:
void catmullromCurve();
void closedCatmullromCurve();
void svg();
+ void line();
};
void tst_QuickPath::arc()
@@ -193,6 +194,43 @@ void tst_QuickPath::svg()
QCOMPARE(pos, QPointF(1000,300));
}
+void tst_QuickPath::line()
+{
+ QQmlEngine engine;
+ QQmlComponent c1(&engine);
+ c1.setData(
+ "import QtQuick 2.0\n"
+ "Path {\n"
+ "startX: 0; startY: 0\n"
+ "PathLine { x: 100; y: 100 }\n"
+ "}", QUrl());
+ QScopedPointer<QObject> o1(c1.create());
+ QQuickPath *path1 = qobject_cast<QQuickPath *>(o1.data());
+ QVERIFY(path1);
+
+ QQmlComponent c2(&engine);
+ c2.setData(
+ "import QtQuick 2.0\n"
+ "Path {\n"
+ "startX: 0; startY: 0\n"
+ "PathLine { x: 50; y: 50 }\n"
+ "PathLine { x: 100; y: 100 }\n"
+ "}", QUrl());
+ QScopedPointer<QObject> o2(c2.create());
+ QQuickPath *path2 = qobject_cast<QQuickPath *>(o2.data());
+ QVERIFY(path2);
+
+ for (int i = 0; i < 167; ++i) {
+ qreal t = i / 167.0;
+
+ QPointF p1 = path1->pointAt(t);
+ QCOMPARE(p1.x(), p1.y());
+
+ QPointF p2 = path2->pointAt(t);
+ QCOMPARE(p1, p2);
+ }
+}
+
QTEST_MAIN(tst_QuickPath)