File indexing completed on 2024-10-06 06:40:35

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2015 Christoph Cullmann <cullmann@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #include <kiconloader.h>
0009 
0010 #include <QStandardPaths>
0011 #include <QTest>
0012 
0013 #include <KConfigGroup>
0014 #include <KSharedConfig>
0015 
0016 class KIconLoader_ResourceThemeTest : public QObject
0017 {
0018     Q_OBJECT
0019 
0020 private Q_SLOTS:
0021     void initTestCase()
0022     {
0023         QStandardPaths::setTestModeEnabled(true);
0024 
0025         // set our test theme only present in :/icons
0026         KConfigGroup cg(KSharedConfig::openConfig(), "Icons");
0027         cg.writeEntry("Theme", "themeinresource");
0028         cg.sync();
0029     }
0030 
0031     void testThemeFound()
0032     {
0033         // try to load icon that can only be found in resource theme and check we found it in the resource
0034         QString path;
0035         KIconLoader::global()->loadIcon(QStringLiteral("someiconintheme"), KIconLoader::Desktop, 22, KIconLoader::DefaultState, QStringList(), &path);
0036         QCOMPARE(path, QStringLiteral(":/icons/themeinresource/22x22/appsNoContext/someiconintheme.png"));
0037     }
0038 };
0039 
0040 QTEST_MAIN(KIconLoader_ResourceThemeTest)
0041 
0042 #include "kiconloader_resourcethemetest.moc"