tests/auto/qicon/tst_qicon.cpp
changeset 30 5dc02b23752f
parent 19 fcece45ef507
--- a/tests/auto/qicon/tst_qicon.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/tests/auto/qicon/tst_qicon.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -76,6 +76,7 @@
     void svg();
     void addFile();
     void availableSizes();
+    void name();
     void streamAvailableSizes_data();
     void streamAvailableSizes();
     void fromTheme();
@@ -550,6 +551,28 @@
     }
 }
 
+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");