From fdf2a161b59de9e0a6fd059b1d6ba6407f768a25 Mon Sep 17 00:00:00 2001 From: Suneel BS Date: Mon, 20 Jul 2009 16:14:19 +0530 Subject: Added autotest for SVG 'use' elements. Reviewed-by: Kim --- tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp | 102 +++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp index 73955fd..3d0d0c3 100644 --- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp +++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp @@ -83,6 +83,7 @@ private slots: void strokeInherit(); void testFillInheritance(); void testStopOffsetOpacity(); + void testUseElement(); #ifndef QT_NO_COMPRESS void testGzLoading(); @@ -1205,5 +1206,106 @@ void tst_QSvgRenderer::testStopOffsetOpacity() QCOMPARE(images[0], images[3]); } +void tst_QSvgRenderer::testUseElement() +{ + static const char *svgs[] = { + //Use refering to non group node (1) + "" + " " + " " + "", + "" + " " + " " + "", + "" + " " + " " + "" + "" + "", + "" + " " + " " + " " + " " + "", + //Use refering to non group node (2) + "" + " " + " " + "", + "" + " " + " " + " " + " " + " " + " " + "", + "" + " " + " " + " " + " " + " " + " " + "", + //Use refering to group node + "" + " " + " " + " " + " " + " " + "", + "" + " " + " " + " " + " " + " " + " " + " " + " " + "", + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + "" + }; + + 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(200, 200, QImage::Format_ARGB32_Premultiplied); + images[i].fill(-1); + p.begin(&images[i]); + renderer.render(&p); + p.end(); + if (i < 4 && i != 0) { + QCOMPARE(images[0], images[i]); + } else if (i > 4 && i < 7) { + QCOMPARE(images[4], images[i]); + } else if (i > 7) { + QCOMPARE(images[8], images[i]); + } + } +} + QTEST_MAIN(tst_QSvgRenderer) #include "tst_qsvgrenderer.moc" -- cgit v0.12