summaryrefslogtreecommitdiffstats
path: root/tests/auto/qsvgrenderer
diff options
context:
space:
mode:
authorSuneel BS <suneel.b-s@nokia.com>2009-07-07 09:27:02 (GMT)
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-07-09 11:10:18 (GMT)
commit1c6edd28d528dbb946fcf2a9e0d4349075ca6f9b (patch)
treee9222ab8448a7427e133f116bf92ddcb9f5efcbe /tests/auto/qsvgrenderer
parent6574240d8ea657d02c3d5bf5567da7d28f42d69b (diff)
downloadQt-1c6edd28d528dbb946fcf2a9e0d4349075ca6f9b.zip
Qt-1c6edd28d528dbb946fcf2a9e0d4349075ca6f9b.tar.gz
Qt-1c6edd28d528dbb946fcf2a9e0d4349075ca6f9b.tar.bz2
Fixed inheritence of SVG fill attributes.
Fixed inheritence of fill-opacity, fill-rule and fill. Autotest included. Reviewed-by: Kim
Diffstat (limited to 'tests/auto/qsvgrenderer')
-rw-r--r--tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
index 3f658ec..68539ef 100644
--- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
@@ -81,6 +81,7 @@ private slots:
void paths();
void displayMode();
void strokeInherit();
+ void testFillInheritance();
#ifndef QT_NO_COMPRESS
void testGzLoading();
@@ -1053,5 +1054,72 @@ void tst_QSvgRenderer::strokeInherit()
}
}
+void tst_QSvgRenderer::testFillInheritance()
+{
+ static const char *svgs[] = {
+ //reference
+ "<svg viewBox = \"0 0 200 200\">"
+ " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" fill= \"red\" stroke = \"blue\" fill-opacity = \"0.5\" fill-rule = \"evenodd\"/>"
+ "</svg>",
+ "<svg viewBox = \"0 0 200 200\">"
+ " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" fill= \"red\" stroke = \"blue\" fill-opacity = \"0.5\" fill-rule = \"evenodd\"/>"
+ " <rect x = \"40\" y = \"40\" width = \"70\" height =\"20\" fill = \"green\" fill-opacity = \"0\"/>"
+ "</svg>",
+ "<svg viewBox = \"0 0 200 200\">"
+ " <g fill = \"red\" fill-opacity = \"0.5\" fill-rule = \"evenodd\">"
+ " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" stroke = \"blue\"/>"
+ " </g>"
+ " <rect x = \"40\" y = \"40\" width = \"70\" height =\"20\" fill = \"green\" fill-opacity = \"0\"/>"
+ "</svg>",
+ "<svg viewBox = \"0 0 200 200\">"
+ " <g fill = \"green\" fill-rule = \"nonzero\">"
+ " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" stroke = \"blue\" fill = \"red\" fill-opacity = \"0.5\" fill-rule = \"evenodd\"/>"
+ " </g>"
+ " <g fill-opacity = \"0.8\" fill = \"red\">"
+ " <rect x = \"40\" y = \"40\" width = \"70\" height =\"20\" fill = \"green\" fill-opacity = \"0\"/>"
+ " </g>"
+ "</svg>",
+ "<svg viewBox = \"0 0 200 200\">"
+ " <g fill = \"red\" >"
+ " <g fill-opacity = \"0.5\">"
+ " <g fill-rule = \"evenodd\">"
+ " <g>"
+ " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" stroke = \"blue\"/>"
+ " </g>"
+ " </g>"
+ " </g>"
+ " </g>"
+ " <g fill-opacity = \"0.8\" >"
+ " <rect x = \"40\" y = \"40\" width = \"70\" height =\"20\" fill = \"none\"/>"
+ " </g>"
+ "</svg>",
+ "<svg viewBox = \"0 0 200 200\">"
+ " <g fill = \"none\" fill-opacity = \"0\">"
+ " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" stroke = \"blue\" fill = \"red\" fill-opacity = \"0.5\" fill-rule = \"evenodd\"/>"
+ " </g>"
+ " <g fill-opacity = \"0\" >"
+ " <rect x = \"40\" y = \"40\" width = \"70\" height =\"20\" fill = \"green\"/>"
+ " </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, 200, 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"