summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsvgplugin/imageInclude.svg18
-rw-r--r--tests/auto/qsvgplugin/imageIncludeA.svg5
-rw-r--r--tests/auto/qsvgplugin/resources.qrc2
-rw-r--r--tests/auto/qsvgplugin/tst_qsvgplugin.cpp41
4 files changed, 66 insertions, 0 deletions
diff --git a/tests/auto/qsvgplugin/imageInclude.svg b/tests/auto/qsvgplugin/imageInclude.svg
new file mode 100644
index 0000000..c78d3fa
--- /dev/null
+++ b/tests/auto/qsvgplugin/imageInclude.svg
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100">
+ <circle cx="50" cy="50" r="25" fill="#00ff00" />
+
+ <image x="0" y="0" width="100" height="100" xlink:href="imageIncludeA.svg" />
+ <image x="0" y="0" width="100" height="100" xlink:href="./imageIncludeA.svg" />
+ <image x="0" y="0" width="100" height="100" xlink:href=":/imageIncludeA.svg" />
+
+ <image x="0" y="0" width="100" height="100" xlink:href="notExisting.svg" />
+ <image x="0" y="0" width="100" height="100" xlink:href="./notExisting.svg" />
+ <image x="0" y="0" width="100" height="100" xlink:href="../notExisting.svg" />
+ <image x="0" y="0" width="100" height="100" xlink:href="/notExisting.svg" />
+ <image x="0" y="0" width="100" height="100" xlink:href=":/notExisting.svg" />
+ <image x="0" y="0" width="100" height="100" xlink:href="qrc:///notExisting.svg" />
+ <image x="0" y="0" width="100" height="100" xlink:href="file:///notExisting.svg" />
+ <image x="0" y="0" width="100" height="100" xlink:href="http://qt.io/notExisting.svg" />
+</svg>
diff --git a/tests/auto/qsvgplugin/imageIncludeA.svg b/tests/auto/qsvgplugin/imageIncludeA.svg
new file mode 100644
index 0000000..5811505
--- /dev/null
+++ b/tests/auto/qsvgplugin/imageIncludeA.svg
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg version="1.0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
+ <circle cx="50" cy="50" r="25" fill="#00ff00" />
+</svg>
diff --git a/tests/auto/qsvgplugin/resources.qrc b/tests/auto/qsvgplugin/resources.qrc
index fcb311a..fd83b80 100644
--- a/tests/auto/qsvgplugin/resources.qrc
+++ b/tests/auto/qsvgplugin/resources.qrc
@@ -1,5 +1,7 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
+ <file>imageInclude.svg</file>
+ <file>imageIncludeA.svg</file>
<file>square.svg</file>
<file>square_size.svg</file>
<file>square_size_viewbox.svg</file>
diff --git a/tests/auto/qsvgplugin/tst_qsvgplugin.cpp b/tests/auto/qsvgplugin/tst_qsvgplugin.cpp
index 4ec1737..da49b75 100644
--- a/tests/auto/qsvgplugin/tst_qsvgplugin.cpp
+++ b/tests/auto/qsvgplugin/tst_qsvgplugin.cpp
@@ -39,6 +39,16 @@
#endif
+QStringList logMessages;
+
+static void messageHandler(QtMsgType pType, const QMessageLogContext& pContext, const QString& pMsg)
+{
+ Q_UNUSED(pType);
+ Q_UNUSED(pContext);
+ logMessages.append(pMsg);
+}
+
+
class tst_QSvgPlugin : public QObject
{
Q_OBJECT
@@ -50,6 +60,7 @@ public:
private slots:
void checkSize_data();
void checkSize();
+ void checkImageInclude();
};
@@ -103,6 +114,36 @@ void tst_QSvgPlugin::checkSize()
QCOMPARE(imageWidth, image.width());
}
+void tst_QSvgPlugin::checkImageInclude()
+{
+ const QString filename(SRCDIR "imageInclude.svg");
+
+ QFile file(filename);
+ file.open(QIODevice::ReadOnly);
+
+ QSvgIOHandler plugin;
+ plugin.setDevice(&file);
+
+ QImage image;
+ qInstallMessageHandler(messageHandler);
+ plugin.read(&image);
+ qInstallMessageHandler(nullptr);
+
+ file.close();
+
+ QCOMPARE(logMessages.size(), 8);
+ QCOMPARE(logMessages.at(0), QString("Could not create image from \"%1notExisting.svg\"").arg(SRCDIR));
+ QCOMPARE(logMessages.at(1), QString("Could not create image from \"%1./notExisting.svg\"").arg(SRCDIR));
+ QCOMPARE(logMessages.at(2), QString("Could not create image from \"%1../notExisting.svg\"").arg(SRCDIR));
+ QCOMPARE(logMessages.at(3), QString("Could not create image from \"%1notExisting.svg\"").arg(QDir::rootPath()));
+ QCOMPARE(logMessages.at(4), QLatin1String("Could not create image from \":/notExisting.svg\""));
+ QCOMPARE(logMessages.at(5), QLatin1String("Could not create image from \"qrc:///notExisting.svg\""));
+ QCOMPARE(logMessages.at(6), QLatin1String("Could not create image from \"file:///notExisting.svg\""));
+ QCOMPARE(logMessages.at(7), QLatin1String("Could not create image from \"http://qt.io/notExisting.svg\""));
+
+ logMessages.clear();
+}
+
QTEST_MAIN(tst_QSvgPlugin)
#include "tst_qsvgplugin.moc"