From 1a66404fd0312a835da03a940894737c1bf77310 Mon Sep 17 00:00:00 2001 From: Lars Schmertmann Date: Sun, 25 Nov 2018 19:58:55 +0100 Subject: Consider relative path in image tags Task-number: QTBUG-16198 Change-Id: I26bf48cbac39af0fae490ed21579e8de326cd1a3 Reviewed-by: Eirik Aavitsland --- tests/auto/qsvgplugin/tst_qsvgplugin.cpp | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests/auto/qsvgplugin/tst_qsvgplugin.cpp') 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" -- cgit v1.2.1