summaryrefslogtreecommitdiffstats
path: root/tests/auto/qicon
diff options
context:
space:
mode:
authorAurelien Gateau <agateau@kde.org>2010-04-20 11:49:14 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-04-20 11:50:53 (GMT)
commita057a48cbac8acbf54a121c63a795480d3f9a8c0 (patch)
tree6142bfdeb4e7185c76c64acc1a852a4fe88d0a93 /tests/auto/qicon
parent434d2312b63090cfd2ba7e0f3728b5b225bcaeec (diff)
downloadQt-a057a48cbac8acbf54a121c63a795480d3f9a8c0.zip
Qt-a057a48cbac8acbf54a121c63a795480d3f9a8c0.tar.gz
Qt-a057a48cbac8acbf54a121c63a795480d3f9a8c0.tar.bz2
Added QIcon::name()
This only works with icons loaded with QIcon::fromTheme() for now. Merge-request: 2367 Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com> Reviewed-by: jbache
Diffstat (limited to 'tests/auto/qicon')
-rw-r--r--tests/auto/qicon/tst_qicon.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp
index fae9cc0..e68664c 100644
--- a/tests/auto/qicon/tst_qicon.cpp
+++ b/tests/auto/qicon/tst_qicon.cpp
@@ -76,6 +76,7 @@ private slots:
void svg();
void addFile();
void availableSizes();
+ void name();
void streamAvailableSizes_data();
void streamAvailableSizes();
void fromTheme();
@@ -550,6 +551,28 @@ void tst_QIcon::availableSizes()
}
}
+void tst_QIcon::name()
+{
+ {
+ // No name if icon does not come from a theme
+ QIcon icon(":/image.png");
+ QString name = icon.name();
+ QVERIFY(name.isEmpty());
+ }
+
+ {
+ // Getting the name of an icon coming from a theme should work
+ QString searchPath = QLatin1String(":/icons");
+ QIcon::setThemeSearchPaths(QStringList() << searchPath);
+ QString themeName("testtheme");
+ QIcon::setThemeName(themeName);
+
+ QIcon icon = QIcon::fromTheme("appointment-new");
+ QString name = icon.name();
+ QCOMPARE(name, QLatin1String("appointment-new"));
+ }
+}
+
void tst_QIcon::streamAvailableSizes_data()
{
QTest::addColumn<QIcon>("icon");