File indexing completed on 2024-03-24 17:10:37

0001 /*  This file is part of the KDE libraries
0002     SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 #include "../src/platformtheme/khintssettings.h"
0007 #include <KSharedConfig>
0008 #include <QDialogButtonBox>
0009 #include <QTest>
0010 #include <config-platformtheme.h>
0011 
0012 class KHintsSettingsTest : public QObject
0013 {
0014     Q_OBJECT
0015 private Q_SLOTS:
0016     void testDefaults();
0017 };
0018 
0019 void KHintsSettingsTest::testDefaults()
0020 {
0021     // this test verifies that default are correctly loaded if there is no config yet
0022     KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
0023     KHintsSettings hints(config);
0024 
0025     QCOMPARE(hints.hint(QPlatformTheme::CursorFlashTime).toInt(), 1000);
0026     QCOMPARE(hints.hint(QPlatformTheme::MouseDoubleClickInterval).toInt(), 400);
0027     QCOMPARE(hints.hint(QPlatformTheme::StartDragDistance).toInt(), 10);
0028     QCOMPARE(hints.hint(QPlatformTheme::StartDragTime).toInt(), 500);
0029 
0030     QCOMPARE(hints.hint(QPlatformTheme::ToolButtonStyle).toInt(), int(Qt::ToolButtonTextBesideIcon));
0031 
0032     QCOMPARE(hints.hint(QPlatformTheme::ToolBarIconSize).toInt(), 22);
0033     QCOMPARE(hints.hint(QPlatformTheme::ItemViewActivateItemOnSingleClick).toBool(), true);
0034 
0035     QCOMPARE(hints.hint(QPlatformTheme::SystemIconThemeName).toString(), QStringLiteral("breeze"));
0036     QCOMPARE(hints.hint(QPlatformTheme::SystemIconFallbackThemeName).toString(), QStringLiteral("hicolor"));
0037     QCOMPARE(hints.hint(QPlatformTheme::IconThemeSearchPaths).toStringList(), hints.xdgIconThemePaths());
0038 
0039     const QStringList expectedStyles =
0040         QStringList{QStringLiteral(BREEZE_STYLE_NAME), QStringLiteral("oxygen"), QStringLiteral("fusion"), QStringLiteral("windows")};
0041     QCOMPARE(hints.hint(QPlatformTheme::StyleNames).toStringList(), expectedStyles);
0042 
0043     QCOMPARE(hints.hint(QPlatformTheme::DialogButtonBoxLayout).toInt(), int(QDialogButtonBox::KdeLayout));
0044     QCOMPARE(hints.hint(QPlatformTheme::DialogButtonBoxButtonsHaveIcons).toBool(), true);
0045     QCOMPARE(hints.hint(QPlatformTheme::UseFullScreenForPopupMenu).toBool(), true);
0046     QCOMPARE(hints.hint(QPlatformTheme::KeyboardScheme).toInt(), int(QPlatformTheme::KdeKeyboardScheme));
0047     QCOMPARE(hints.hint(QPlatformTheme::UiEffects).toInt(), QPlatformTheme::HoverEffect);
0048     QCOMPARE(hints.hint(QPlatformTheme::IconPixmapSizes).value<QList<int>>(), QList<int>({512, 256, 128, 64, 32, 22, 16, 8}));
0049     QCOMPARE(hints.hint(QPlatformTheme::WheelScrollLines).toInt(), 3);
0050 }
0051 
0052 QTEST_GUILESS_MAIN(KHintsSettingsTest)
0053 
0054 #include "khintssettings_unittest.moc"