File indexing completed on 2024-10-06 06:40:35
0001 /* 0002 SPDX-FileCopyrightText: 2016 Harald Sitter <sitter@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include <QStandardPaths> 0008 #include <QTest> 0009 0010 #include <kicontheme.h> 0011 0012 class KIconTheme_UnitTest : public QObject 0013 { 0014 Q_OBJECT 0015 0016 private Q_SLOTS: 0017 void initTestCase() 0018 { 0019 QStandardPaths::setTestModeEnabled(true); 0020 } 0021 0022 void init() 0023 { 0024 KIconTheme::forceThemeForTests(QString()); // Reset override. 0025 } 0026 0027 void testForceThemeForTests() 0028 { 0029 auto forcedName = QStringLiteral("kitten"); 0030 auto resolvedCurrent = KIconTheme::current(); 0031 QVERIFY2(KIconTheme::current() != forcedName, "current theme initially expected to not be mangled"); 0032 // Force a specific theme. 0033 KIconTheme::forceThemeForTests(forcedName); 0034 QCOMPARE(KIconTheme::current(), forcedName); 0035 // Reset override. 0036 KIconTheme::forceThemeForTests(QString()); 0037 QCOMPARE(KIconTheme::current(), resolvedCurrent); 0038 // And then override again to make sure we still can. 0039 KIconTheme::forceThemeForTests(forcedName); 0040 QCOMPARE(KIconTheme::current(), forcedName); 0041 } 0042 }; 0043 0044 QTEST_MAIN(KIconTheme_UnitTest) 0045 0046 #include "kicontheme_unittest.moc"