summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorDavid Sansome <me@davidsansome.com>2012-03-22 11:28:29 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-10 08:45:22 +0200
commitc3ffcbd9a2697f1799ba4afbdf14ca1210ac2bbd (patch)
treedb32fd4c8acfc30fb2d7e6e77cdc3ef3a545e227 /tests/auto/gui
parent3d52d67096b0b3a427c085e5d84bcf13d16c1086 (diff)
Scale icons returned by QIcon::fromTheme.
The icon engine behind icons that are loaded from QIcon::fromTheme does not scale any pixmaps that it returns. When using an icon theme with an incomplete set of icons (for example, only a "128x128" folder), QIcon::pixmap will always return 128x128 pixmaps even if you ask for one of size 22x22. This is contrary to the QIcon::pixmap documentation that says "The pixmap might be smaller than requested, but never larger." This patch uses the same code that is in the main QIcon class in the PixmapEntry QIconLoaderEngineEntry to scale pixmaps if they are too big. Change-Id: Ic25a3628ac82cfb899574245f658490a2dd49d54 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/image/qicon/tst_qicon.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp
index 3ada9b9a80..acbb50d8f3 100644
--- a/tests/auto/gui/image/qicon/tst_qicon.cpp
+++ b/tests/auto/gui/image/qicon/tst_qicon.cpp
@@ -591,6 +591,12 @@ void tst_QIcon::fromTheme()
noIcon = QIcon::fromTheme("svg-icon", abIcon);
QVERIFY(!noIcon.availableSizes().isEmpty());
+ // Pixmaps should be no larger than the requested size (QTBUG-17953)
+ QCOMPARE(appointmentIcon.pixmap(22).size(), QSize(22, 22)); // exact
+ QCOMPARE(appointmentIcon.pixmap(32).size(), QSize(32, 32)); // exact
+ QCOMPARE(appointmentIcon.pixmap(48).size(), QSize(32, 32)); // smaller
+ QCOMPARE(appointmentIcon.pixmap(8).size(), QSize(8, 8)); // scaled down
+
QByteArray ba;
// write to QByteArray
{