diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-06-02 15:12:05 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-06-07 08:33:33 +0000 |
commit | 5af4c9b237a23ce12ca7c56eb6c9ecda17743228 (patch) | |
tree | fe8f85d5c353216cddc18df3c996be0c50cf0c67 /tests | |
parent | 961da5273e17655e73ec0975c6de446b88d7f5ca (diff) |
Reduce objects: Make ShapePath inherit Path
Shape { ShapePath { Path { ... } } } simply becomes
Shape { ShapePath { ... } }
Change-Id: Ie57936cd7953c8a8d6c67e78b9d73bdbe2a05316
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickshape/data/pathitem3.qml | 10 | ||||
-rw-r--r-- | tests/auto/quick/qquickshape/data/pathitem4.qml | 50 | ||||
-rw-r--r-- | tests/auto/quick/qquickshape/tst_qquickshape.cpp | 16 | ||||
-rw-r--r-- | tests/manual/shapestest/shapestest.qml | 114 |
4 files changed, 80 insertions, 110 deletions
diff --git a/tests/auto/quick/qquickshape/data/pathitem3.qml b/tests/auto/quick/qquickshape/data/pathitem3.qml index 12bfa1bb5f..3b819991e6 100644 --- a/tests/auto/quick/qquickshape/data/pathitem3.qml +++ b/tests/auto/quick/qquickshape/data/pathitem3.qml @@ -24,12 +24,10 @@ Item { } strokeStyle: ShapePath.DashLine dashPattern: [ 1, 4 ] - Path { - startX: 20; startY: 20 - PathLine { x: 180; y: 130 } - PathLine { x: 20; y: 130 } - PathLine { x: 20; y: 20 } - } + startX: 20; startY: 20 + PathLine { x: 180; y: 130 } + PathLine { x: 20; y: 130 } + PathLine { x: 20; y: 20 } } } } diff --git a/tests/auto/quick/qquickshape/data/pathitem4.qml b/tests/auto/quick/qquickshape/data/pathitem4.qml index 7d9ed4b84e..26e7084b8d 100644 --- a/tests/auto/quick/qquickshape/data/pathitem4.qml +++ b/tests/auto/quick/qquickshape/data/pathitem4.qml @@ -13,22 +13,18 @@ Item { ShapePath { strokeColor: "red" fillColor: "green" - Path { - startX: 40; startY: 30 - PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } - PathLine { x: 150; y: 80 } - PathQuad { x: 160; y: 30; controlX: 200; controlY: 80 } - } + startX: 40; startY: 30 + PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } + PathLine { x: 150; y: 80 } + PathQuad { x: 160; y: 30; controlX: 200; controlY: 80 } } ShapePath { strokeWidth: 10 fillColor: "transparent" strokeColor: "blue" - Path { - startX: 40; startY: 30 - PathCubic { x: 50; y: 80; control1X: 0; control1Y: 80; control2X: 100; control2Y: 100 } - } + startX: 40; startY: 30 + PathCubic { x: 50; y: 80; control1X: 0; control1Y: 80; control2X: 100; control2Y: 100 } } ShapePath { @@ -38,24 +34,22 @@ Item { ShapeGradientStop { position: 1; color: "green" } } - Path { - startX: 10; startY: 100 - PathArc { - relativeX: 50; y: 100 - radiusX: 25; radiusY: 25 - } - PathArc { - relativeX: 50; y: 100 - radiusX: 25; radiusY: 35 - } - PathArc { - relativeX: 50; y: 100 - radiusX: 25; radiusY: 60 - } - PathArc { - relativeX: 50; y: 100 - radiusX: 50; radiusY: 120 - } + startX: 10; startY: 100 + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 25 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 35 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 60 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 50; radiusY: 120 } } } diff --git a/tests/auto/quick/qquickshape/tst_qquickshape.cpp b/tests/auto/quick/qquickshape/tst_qquickshape.cpp index 56d891d87e..fecac573b7 100644 --- a/tests/auto/quick/qquickshape/tst_qquickshape.cpp +++ b/tests/auto/quick/qquickshape/tst_qquickshape.cpp @@ -103,7 +103,8 @@ void tst_QQuickShape::vpInitValues() QQuickShapePath *vp = vps.at(&vps, 0); QVERIFY(vp != nullptr); - QVERIFY(!vp->path()); + QQmlListReference pathList(vp, "pathElements"); + QCOMPARE(pathList.count(), 0); QCOMPARE(vp->strokeColor(), QColor(Qt::white)); QCOMPARE(vp->strokeWidth(), 1.0f); QCOMPARE(vp->fillColor(), QColor(Qt::white)); @@ -134,7 +135,6 @@ void tst_QQuickShape::basicShape() QVERIFY(vp != nullptr); QCOMPARE(vp->strokeWidth(), 4.0f); QVERIFY(vp->fillGradient() != nullptr); - QVERIFY(vp->path() != nullptr); QCOMPARE(vp->strokeStyle(), QQuickShapePath::DashLine); vp->setStrokeWidth(5.0f); @@ -148,7 +148,7 @@ void tst_QQuickShape::basicShape() QCOMPARE(stopList.count(), 5); QVERIFY(stopList.at(2) != nullptr); - QQuickPath *path = vp->path(); + QQuickPath *path = vp; QCOMPARE(path->startX(), 20.0f); QQmlListReference pathList(path, "pathElements"); QCOMPARE(pathList.count(), 3); @@ -173,8 +173,8 @@ void tst_QQuickShape::changeSignals() QQuickShapePath *vp = qobject_cast<QQuickShapePath *>(list.at(0)); QVERIFY(vp != nullptr); - // Verify that VisualPath property changes emit changed(). - QSignalSpy vpChangeSpy(vp, SIGNAL(changed())); + // Verify that VisualPath property changes emit shapePathChanged(). + QSignalSpy vpChangeSpy(vp, SIGNAL(shapePathChanged())); QSignalSpy strokeColorPropSpy(vp, SIGNAL(strokeColorChanged())); vp->setStrokeColor(Qt::blue); vp->setStrokeWidth(1.0f); @@ -190,15 +190,15 @@ void tst_QQuickShape::changeSignals() QCOMPARE(strokeColorPropSpy.count(), 1); QCOMPARE(vpChangeSpy.count(), 10); - // Verify that property changes from Path and its elements bubble up and result in changed(). - QQuickPath *path = vp->path(); + // Verify that property changes from Path and its elements bubble up and result in shapePathChanged(). + QQuickPath *path = vp; path->setStartX(30); QCOMPARE(vpChangeSpy.count(), 11); QQmlListReference pathList(path, "pathElements"); qobject_cast<QQuickPathLine *>(pathList.at(1))->setY(200); QCOMPARE(vpChangeSpy.count(), 12); - // Verify that property changes from the gradient bubble up and result in changed(). + // Verify that property changes from the gradient bubble up and result in shapePathChanged(). vp->setFillGradient(g); QCOMPARE(vpChangeSpy.count(), 13); QQuickShapeLinearGradient *lgrad = qobject_cast<QQuickShapeLinearGradient *>(g); diff --git a/tests/manual/shapestest/shapestest.qml b/tests/manual/shapestest/shapestest.qml index 0971ea9da1..bf503c12d9 100644 --- a/tests/manual/shapestest/shapestest.qml +++ b/tests/manual/shapestest/shapestest.qml @@ -95,11 +95,9 @@ Rectangle { fillColor: "blue" // ignored with the gradient set strokeStyle: ShapePath.DashLine dashPattern: [ 1, 4 ] - Path { - PathLine { x: 200; y: 100 } - PathLine { x: 0; y: 100 } - PathLine { x: 0; y: 0 } - } + PathLine { x: 200; y: 100 } + PathLine { x: 0; y: 100 } + PathLine { x: 0; y: 0 } } transform: Rotation { origin.x: 100; origin.y: 50; axis { x: 0; y: 1; z: 0 } SequentialAnimation on angle { @@ -125,13 +123,11 @@ Rectangle { strokeColor: sc property color fc: "yellow" fillColor: fc - Path { - startX: 20; startY: 10 - PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } - PathLine { x: 150; y: 80 } - PathQuad { x: 180; y: 10; controlX: 200; controlY: 80 } - PathLine { x: 20; y: 10 } - } + startX: 20; startY: 10 + PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } + PathLine { x: 150; y: 80 } + PathQuad { x: 180; y: 10; controlX: 200; controlY: 80 } + PathLine { x: 20; y: 10 } // Dynamic changes via property bindings etc. all work but can // be computationally expense with the generic backend for properties // that need retriangulating on every change. Should be cheap with NVPR. @@ -168,12 +164,10 @@ Rectangle { anchors.fill: parent ShapePath { strokeColor: "black" - Path { - startX: 0; startY: 50 - PathLine { relativeX: 100; y: 50 } - PathMove { relativeX: 100; y: 50 } - PathLine { relativeX: 100; y: 50 } - } + startX: 0; startY: 50 + PathLine { relativeX: 100; y: 50 } + PathMove { relativeX: 100; y: 50 } + PathLine { relativeX: 100; y: 50 } } } } @@ -191,12 +185,10 @@ Rectangle { strokeWidth: 16 fillColor: "transparent" capStyle: ShapePath.RoundCap - Path { - startX: 30 - startY: 30 - PathLine { x: 100; y: 100 } - PathLine { x: 30; y: 100 } - } + startX: 30 + startY: 30 + PathLine { x: 100; y: 100 } + PathLine { x: 30; y: 100 } } } Timer { @@ -226,14 +218,12 @@ Rectangle { strokeColor: "blue" fillColor: "lightGray" strokeWidth: 2 - Path { - PathMove { x: 90; y: 50 } - PathLine { x: 50 + 40 * Math.cos(0.8 * 1 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 1 * Math.PI) } - PathLine { x: 50 + 40 * Math.cos(0.8 * 2 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 2 * Math.PI) } - PathLine { x: 50 + 40 * Math.cos(0.8 * 3 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 3 * Math.PI) } - PathLine { x: 50 + 40 * Math.cos(0.8 * 4 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 4 * Math.PI) } - PathLine { x: 90; y: 50 } - } + PathMove { x: 90; y: 50 } + PathLine { x: 50 + 40 * Math.cos(0.8 * 1 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 1 * Math.PI) } + PathLine { x: 50 + 40 * Math.cos(0.8 * 2 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 2 * Math.PI) } + PathLine { x: 50 + 40 * Math.cos(0.8 * 3 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 3 * Math.PI) } + PathLine { x: 50 + 40 * Math.cos(0.8 * 4 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 4 * Math.PI) } + PathLine { x: 90; y: 50 } } } Timer { @@ -255,14 +245,12 @@ Rectangle { strokeWidth: 4 strokeColor: "black" fillColor: "transparent" - Path { - startX: 20; startY: 10 - PathCubic { - id: cb - x: 180; y: 10 - control1X: -10; control1Y: 90; control2Y: 90 - NumberAnimation on control2X { from: 400; to: 0; duration: 5000; loops: Animation.Infinite } - } + startX: 20; startY: 10 + PathCubic { + id: cb + x: 180; y: 10 + control1X: -10; control1Y: 90; control2Y: 90 + NumberAnimation on control2X { from: 400; to: 0; duration: 5000; loops: Animation.Infinite } } } } @@ -283,13 +271,11 @@ Rectangle { fillColor: "transparent" strokeColor: "red" strokeWidth: 4 - Path { - startX: 10; startY: 40 - PathArc { - x: 10; y: 60 - radiusX: 40; radiusY: 40 - useLargeArc: true - } + startX: 10; startY: 40 + PathArc { + x: 10; y: 60 + radiusX: 40; radiusY: 40 + useLargeArc: true } } } @@ -320,12 +306,10 @@ Rectangle { fillColor: "blue" strokeColor: "red" strokeWidth: 4 - Path { - startX: 10; startY: 10 - PathLine { x: 140; y: 140 } - PathLine { x: 10; y: 140 } - PathLine { x: 10; y: 10 } - } + startX: 10; startY: 10 + PathLine { x: 140; y: 140 } + PathLine { x: 10; y: 140 } + PathLine { x: 10; y: 10 } } } } @@ -353,14 +337,12 @@ Rectangle { strokeColor: "blue" fillColor: "lightGray" strokeWidth: 2 - Path { - PathMove { x: 90; y: 50 } - PathLine { x: 50 + 40 * Math.cos(0.8 * 1 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 1 * Math.PI) } - PathLine { x: 50 + 40 * Math.cos(0.8 * 2 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 2 * Math.PI) } - PathLine { x: 50 + 40 * Math.cos(0.8 * 3 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 3 * Math.PI) } - PathLine { x: 50 + 40 * Math.cos(0.8 * 4 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 4 * Math.PI) } - PathLine { x: 90; y: 50 } - } + PathMove { x: 90; y: 50 } + PathLine { x: 50 + 40 * Math.cos(0.8 * 1 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 1 * Math.PI) } + PathLine { x: 50 + 40 * Math.cos(0.8 * 2 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 2 * Math.PI) } + PathLine { x: 50 + 40 * Math.cos(0.8 * 3 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 3 * Math.PI) } + PathLine { x: 50 + 40 * Math.cos(0.8 * 4 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 4 * Math.PI) } + PathLine { x: 90; y: 50 } } } Timer { @@ -381,16 +363,12 @@ Rectangle { anchors.fill: parent ShapePath { strokeColor: "red" - Path { - PathLine { x: 100; y: 100 } - } + PathLine { x: 100; y: 100 } } ShapePath { strokeColor: "blue" - Path { - startX: 100; startY: 0 - PathLine { x: 0; y: 100 } - } + startX: 100; startY: 0 + PathLine { x: 0; y: 100 } } } } |