summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2017-03-27 18:44:04 +0100
committerDavid Edmundson <davidedmundson@kde.org>2017-04-04 12:05:06 +0000
commit4a9470e55ce08752501868c60762268fdf2c44af (patch)
tree549725be91de52b0496802cec03fa23825de718f /tests
parent1aec05432bc596ececf78570b6ef035cfda1e5cf (diff)
downloadqtsvg-4a9470e55ce08752501868c60762268fdf2c44af.tar.gz
Implement QIcon::isNull support for QtSVG Icons
This was via a virtual hook in QIconEngine in Qt 5.7 This is especially useful for the SVG icon loader which returns no availableSizes which means we currently have no way to tell if an icon was loaded or not. Change-Id: Ic14971f94213fb2309f29bd0daa0a1c387d4da3c Reviewed-by: Kai Uwe Broulik <kde@privat.broulik.de> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qicon_svg/tst_qicon_svg.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qicon_svg/tst_qicon_svg.cpp b/tests/auto/qicon_svg/tst_qicon_svg.cpp
index 2271f21..170ec37 100644
--- a/tests/auto/qicon_svg/tst_qicon_svg.cpp
+++ b/tests/auto/qicon_svg/tst_qicon_svg.cpp
@@ -43,6 +43,8 @@ private slots:
void svgActualSize();
void svg();
void availableSizes();
+ void isNull();
+
private:
QString prefix;
@@ -139,5 +141,26 @@ void tst_QIcon_Svg::availableSizes()
}
}
+void tst_QIcon_Svg::isNull()
+{
+ {
+ //checks that an invalid file results in the icon being null
+ QIcon icon(prefix + "nonExistentFile.svg");
+ QVERIFY(icon.isNull());
+ }
+ {
+ //valid svg, we're not null
+ QIcon icon(prefix + "heart.svg");
+ QVERIFY(!icon.isNull());
+ }
+ {
+ //invalid svg, but a pixmap added means we're not null
+ QIcon icon(prefix + "nonExistentFile.svg");
+ icon.addFile(prefix + "image.png", QSize(32,32));
+ QVERIFY(!icon.isNull());
+ }
+
+}
+
QTEST_MAIN(tst_QIcon_Svg)
#include "tst_qicon_svg.moc"