diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-03-08 15:15:44 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2010-03-08 16:15:53 (GMT) |
commit | ea9f2aeba6f18d19d6a82b3a829373ec032af14f (patch) | |
tree | a90af7f1061a3d7623c2969bdf1f628d99045e0a /tests/auto | |
parent | 7b500ed543bb86429ef6fdb82b103784d6cc6a0c (diff) | |
download | Qt-ea9f2aeba6f18d19d6a82b3a829373ec032af14f.zip Qt-ea9f2aeba6f18d19d6a82b3a829373ec032af14f.tar.gz Qt-ea9f2aeba6f18d19d6a82b3a829373ec032af14f.tar.bz2 |
Fixed bounds calculation in QtSvg.
This commit fixes an auto-test failure after fixing QTBUG-8733.
The calculated element bounds should now be much tighter and
respect the width of non-cosmetic pens.
Task-number: QTBUG-8733
Reviewed-by: Trond
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp index 16dd2b4..106fd8c 100644 --- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp +++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp @@ -74,6 +74,7 @@ private slots: void nestedQXmlStreamReader() const; void stylePropagation() const; void matrixForElement() const; + void boundsOnElement() const; void gradientStops() const; void gradientRefs(); void fillRule(); @@ -470,6 +471,36 @@ void tst_QSvgRenderer::matrixForElement() const compareTransforms(QTransform(painter.worldMatrix()), QTransform(renderer.matrixForElement(QLatin1String("firkant")))); } +void tst_QSvgRenderer::boundsOnElement() const +{ + QByteArray data("<svg>" + "<g id=\"prim\" transform=\"translate(-3,1)\">" + "<g id=\"sjokade\" stroke=\"none\" stroke-width=\"10\">" + "<rect id=\"kaviar\" transform=\"rotate(45)\" x=\"-10\" y=\"-10\" width=\"20\" height=\"20\"/>" + "</g>" + "<g id=\"nugatti\" stroke=\"black\" stroke-width=\"2\">" + "<use x=\"0\" y=\"0\" transform=\"rotate(45)\" xlink:href=\"#kaviar\"/>" + "</g>" + "<g id=\"nutella\" stroke=\"none\" stroke-width=\"10\">" + "<path id=\"baconost\" transform=\"rotate(45)\" d=\"M-10 -10 L10 -10 L10 10 L-10 10 Z\"/>" + "</g>" + "<g id=\"hapaa\" transform=\"translate(-2,2)\" stroke=\"black\" stroke-width=\"2\">" + "<use x=\"0\" y=\"0\" transform=\"rotate(45)\" xlink:href=\"#baconost\"/>" + "</g>" + "</g>" + "</svg>"); + + qreal sqrt2 = qSqrt(2); + QSvgRenderer renderer(data); + QCOMPARE(renderer.boundsOnElement(QLatin1String("sjokade")), QRectF(-10 * sqrt2, -10 * sqrt2, 20 * sqrt2, 20 * sqrt2)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("kaviar")), QRectF(-10 * sqrt2, -10 * sqrt2, 20 * sqrt2, 20 * sqrt2)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("nugatti")), QRectF(-11, -11, 22, 22)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("nutella")), QRectF(-10 * sqrt2, -10 * sqrt2, 20 * sqrt2, 20 * sqrt2)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("baconost")), QRectF(-10 * sqrt2, -10 * sqrt2, 20 * sqrt2, 20 * sqrt2)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("hapaa")), QRectF(-13, -9, 22, 22)); + QCOMPARE(renderer.boundsOnElement(QLatin1String("prim")), QRectF(-10 * sqrt2 - 3, -10 * sqrt2 + 1, 20 * sqrt2, 20 * sqrt2)); +} + void tst_QSvgRenderer::gradientStops() const { { |