summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSuneel BS <suneel.b-s@nokia.com>2009-05-08 05:39:45 (GMT)
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-07-01 13:19:03 (GMT)
commit7ab895f576b8ef8380838778958fae651a550f79 (patch)
tree633f3f37bc97e8d18f222f4b0a48ce781d11501a /tests
parent1d32cdf73843ba98104fdbc6d5d0a296dbb689b0 (diff)
downloadQt-7ab895f576b8ef8380838778958fae651a550f79.zip
Qt-7ab895f576b8ef8380838778958fae651a550f79.tar.gz
Qt-7ab895f576b8ef8380838778958fae651a550f79.tar.bz2
Fixed inheritance of some attributes in SVG.
Fixed inheritance of stroke attributes, the font-size and text-anchor attribute. Autotest added by Kim. Reviewed-by: Kim
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp124
1 files changed, 124 insertions, 0 deletions
diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
index f11aff9..7b62eae 100644
--- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
@@ -80,6 +80,7 @@ private slots:
void opacity();
void paths();
void displayMode();
+ void strokeInherit();
#ifndef QT_NO_COMPRESS
void testGzLoading();
@@ -925,5 +926,128 @@ void tst_QSvgRenderer::displayMode()
}
}
+void tst_QSvgRenderer::strokeInherit()
+{
+ static const char *svgs[] = {
+ // Reference.
+ "<svg viewBox=\"0 0 200 30\">"
+ " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\""
+ " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\""
+ " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">"
+ " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\"/>"
+ " </g>"
+ " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">"
+ " <polyline fill=\"none\" points=\"10 25 80 25\"/>"
+ " </g>"
+ "</svg>",
+ // stroke
+ "<svg viewBox=\"0 0 200 30\">"
+ " <g stroke=\"none\" stroke-width=\"20\" stroke-linecap=\"butt\""
+ " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\""
+ " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">"
+ " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke=\"blue\"/>"
+ " </g>"
+ " <g stroke=\"yellow\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">"
+ " <polyline fill=\"none\" points=\"10 25 80 25\" stroke=\"green\"/>"
+ " </g>"
+ "</svg>",
+ // stroke-width
+ "<svg viewBox=\"0 0 200 30\">"
+ " <g stroke=\"blue\" stroke-width=\"0\" stroke-linecap=\"butt\""
+ " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\""
+ " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">"
+ " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-width=\"20\"/>"
+ " </g>"
+ " <g stroke=\"green\" stroke-width=\"10\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">"
+ " <polyline fill=\"none\" points=\"10 25 80 25\" stroke-width=\"0\"/>"
+ " </g>"
+ "</svg>",
+ // stroke-linecap
+ "<svg viewBox=\"0 0 200 30\">"
+ " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"round\""
+ " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\""
+ " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">"
+ " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-linecap=\"butt\"/>"
+ " </g>"
+ " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">"
+ " <polyline fill=\"none\" points=\"10 25 80 25\"/>"
+ " </g>"
+ "</svg>",
+ // stroke-linejoin
+ "<svg viewBox=\"0 0 200 30\">"
+ " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\""
+ " stroke-linejoin=\"round\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\""
+ " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">"
+ " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-linejoin=\"miter\"/>"
+ " </g>"
+ " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">"
+ " <polyline fill=\"none\" points=\"10 25 80 25\"/>"
+ " </g>"
+ "</svg>",
+ // stroke-miterlimit
+ "<svg viewBox=\"0 0 200 30\">"
+ " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\""
+ " stroke-linejoin=\"miter\" stroke-miterlimit=\"2\" stroke-dasharray=\"20,10\""
+ " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">"
+ " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-miterlimit=\"1\"/>"
+ " </g>"
+ " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">"
+ " <polyline fill=\"none\" points=\"10 25 80 25\"/>"
+ " </g>"
+ "</svg>",
+ // stroke-dasharray
+ "<svg viewBox=\"0 0 200 30\">"
+ " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\""
+ " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"1,1,1,1,1,1,3,1,3,1,3,1,1,1,1,1,1,3\""
+ " stroke-dashoffset=\"10\" stroke-opacity=\"0.5\">"
+ " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-dasharray=\"20,10\"/>"
+ " </g>"
+ " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"none\" stroke-dashoffset=\"4.5\">"
+ " <polyline fill=\"none\" points=\"10 25 80 25\" stroke-dasharray=\"3,3,1\"/>"
+ " </g>"
+ "</svg>",
+ // stroke-dashoffset
+ "<svg viewBox=\"0 0 200 30\">"
+ " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\""
+ " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\""
+ " stroke-dashoffset=\"0\" stroke-opacity=\"0.5\">"
+ " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-dashoffset=\"10\"/>"
+ " </g>"
+ " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"0\">"
+ " <polyline fill=\"none\" points=\"10 25 80 25\" stroke-dashoffset=\"4.5\"/>"
+ " </g>"
+ "</svg>",
+ // stroke-opacity
+ "<svg viewBox=\"0 0 200 30\">"
+ " <g stroke=\"blue\" stroke-width=\"20\" stroke-linecap=\"butt\""
+ " stroke-linejoin=\"miter\" stroke-miterlimit=\"1\" stroke-dasharray=\"20,10\""
+ " stroke-dashoffset=\"10\" stroke-opacity=\"0\">"
+ " <polyline fill=\"none\" points=\"10 10 100 10 100 20 190 20\" stroke-opacity=\"0.5\"/>"
+ " </g>"
+ " <g stroke=\"green\" stroke-width=\"0\" stroke-dasharray=\"3,3,1\" stroke-dashoffset=\"4.5\">"
+ " <polyline fill=\"none\" points=\"10 25 80 25\"/>"
+ " </g>"
+ "</svg>"
+ };
+
+ const int COUNT = sizeof(svgs) / sizeof(svgs[0]);
+ QImage images[COUNT];
+ QPainter p;
+
+ for (int i = 0; i < COUNT; ++i) {
+ QByteArray data(svgs[i]);
+ QSvgRenderer renderer(data);
+ QVERIFY(renderer.isValid());
+ images[i] = QImage(200, 30, QImage::Format_ARGB32_Premultiplied);
+ images[i].fill(-1);
+ p.begin(&images[i]);
+ renderer.render(&p);
+ p.end();
+ if (i != 0) {
+ QCOMPARE(images[0], images[i]);
+ }
+ }
+}
+
QTEST_MAIN(tst_QSvgRenderer)
#include "tst_qsvgrenderer.moc"