summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2010-03-08 15:15:44 (GMT)
committerSamuli Piippo <samuli.piippo@digia.com>2011-06-09 10:05:04 (GMT)
commita6ea47b0ced2b07cc1b2ec3562e23fa3153dffb4 (patch)
tree2c71d165639f73af741918b8f25f7a74775ebfe0 /tests
parent902071c2233145453f15bbbded446ad294c9c4a1 (diff)
downloadQt-a6ea47b0ced2b07cc1b2ec3562e23fa3153dffb4.zip
Qt-a6ea47b0ced2b07cc1b2ec3562e23fa3153dffb4.tar.gz
Qt-a6ea47b0ced2b07cc1b2ec3562e23fa3153dffb4.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 (cherry picked from commit ea9f2aeba6f18d19d6a82b3a829373ec032af14f)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
index af98aba..352e274 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
{
{