summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChih-Hsuan Yen <yen@chyen.cc>2019-01-23 16:41:35 +0800
committerChih-Hsuan Yen <yan12125@gmail.com>2019-01-29 07:59:52 +0000
commitdcc4e2c4d96a6ad1447b9fb679afca21bb381218 (patch)
treed01af5d3b71b9e822f40963369820a2c7e0e73db /tests
parentac797c4e17376b5497e0c37f15b9da48d622d18f (diff)
downloadqtsvg-dcc4e2c4d96a6ad1447b9fb679afca21bb381218.tar.gz
Allow <style> without type attribute
According to https://www.w3.org/TR/SVG/styling.html#StyleElement, `type` can be omitted. > If the attribute is not specified, then the style sheet language is assumed to be CSS. Original-Author: Christoph Feck Fixes: QTBUG-58326 Fixes: QTBUG-69378 Change-Id: Ic3d0e8db99da8c81e5a01c0dda33fb38428e38d5 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
index 5e13bee..553838e 100644
--- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
@@ -76,6 +76,7 @@ private slots:
void testStopOffsetOpacity();
void testUseElement();
void smallFont();
+ void styleSheet();
#ifndef QT_NO_COMPRESS
void testGzLoading();
@@ -1437,5 +1438,26 @@ void tst_QSvgRenderer::smallFont()
QVERIFY(images[0] != images[1]);
}
+void tst_QSvgRenderer::styleSheet()
+{
+ static const char *svgs[] = { "<svg><style type=\"text/css\">.cls {fill:#ff0000;}</style><rect class=\"cls\" x = \"10\" y = \"10\" width = \"30\" height = \"30\"/></svg>",
+ "<svg><style>.cls {fill:#ff0000;}</style><rect class=\"cls\" x = \"10\" y = \"10\" width = \"30\" height = \"30\"/></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);
+ images[i] = QImage(50, 50, QImage::Format_ARGB32_Premultiplied);
+ images[i].fill(-1);
+ p.begin(&images[i]);
+ renderer.render(&p);
+ p.end();
+ }
+ QCOMPARE(images[0], images[1]);
+}
+
QTEST_MAIN(tst_QSvgRenderer)
#include "tst_qsvgrenderer.moc"