Fix the kdeplatformplugin_unittest, which fails on Jenkins.

The old code would attempt to cast a QVariant containing a QStringList
to a QString, and check it was empty.  This value was never meant to be
empty, but the test happened to succeed most of the time, because the
case fails for multiple-element stringlists (returning an empty string).
 This is not the case on Jenkins, however.

Attached patch does something a bit saner.

Alex
diff --git a/autotests/kdeplatformtheme_unittest.cpp b/autotests/kdeplatformtheme_unittest.cpp
index 6bba325..2f9943f 100644
--- a/autotests/kdeplatformtheme_unittest.cpp
+++ b/autotests/kdeplatformtheme_unittest.cpp
@@ -107,6 +107,14 @@ private Q_SLOTS:
                                               "notifyChange",  &m_loop, SLOT(quit()));
     }
 
+    void cleanupTestCase()
+    {
+        QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
+        configPath.append("/kdeglobals");
+
+        QFile::remove(configPath);
+    }
+
     void testPlatformHints()
     {
         QCOMPARE(m_qpa->themeHint(QPlatformTheme::CursorFlashTime).toInt(), 1042);
@@ -118,7 +126,15 @@ private Q_SLOTS:
         QCOMPARE(m_qpa->themeHint(QPlatformTheme::ItemViewActivateItemOnSingleClick).toBool(), false);
         QCOMPARE(m_qpa->themeHint(QPlatformTheme::SystemIconThemeName).toString(), QLatin1String("non-existent-icon-theme"));
         QCOMPARE(m_qpa->themeHint(QPlatformTheme::SystemIconFallbackThemeName).toString(), QLatin1String("hicolor"));
-        QVERIFY(m_qpa->themeHint(QPlatformTheme::IconThemeSearchPaths).toString().isEmpty());
+
+        QStringList iconThemeSearchPaths = m_qpa->themeHint(QPlatformTheme::IconThemeSearchPaths).toStringList();
+        foreach (const QString &iconPath, iconThemeSearchPaths) {
+            QVERIFY(iconPath.endsWith(QLatin1String("/icons")));
+            QVERIFY(QFile::exists(iconPath));
+        }
+        // there must be *some* icons in XDG_DATA_DIRS, right?
+        QVERIFY(!iconThemeSearchPaths.isEmpty());
+
         QStringList styles;
         styles << "non-existent-widget-style" << "oxygen" << "fusion" << "windows";
         QCOMPARE(m_qpa->themeHint(QPlatformTheme::StyleNames).toStringList(), styles);
_______________________________________________
Kde-frameworks-devel mailing list
Kde-frameworks-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-frameworks-devel

Reply via email to