From 4a9470e55ce08752501868c60762268fdf2c44af Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Mon, 27 Mar 2017 18:44:04 +0100 Subject: 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 Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/qicon_svg/tst_qicon_svg.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') 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" -- cgit v1.2.1