1 /* This file is part of the KDE libraries
2 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #include "../src/platformtheme/khintssettings.h"
7 #include <KSharedConfig>
8 #include <QDialogButtonBox>
9 #include <QTest>
10 #include <config-platformtheme.h>
11
12 class KHintsSettingsTest : public QObject
13 {
14 Q_OBJECT
15 private Q_SLOTS:
16 void testDefaults();
17 };
18
testDefaults()19 void KHintsSettingsTest::testDefaults()
20 {
21 // this test verifies that default are correctly loaded if there is no config yet
22 KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
23 KHintsSettings hints(config);
24
25 QCOMPARE(hints.hint(QPlatformTheme::CursorFlashTime).toInt(), 1000);
26 QCOMPARE(hints.hint(QPlatformTheme::MouseDoubleClickInterval).toInt(), 400);
27 QCOMPARE(hints.hint(QPlatformTheme::StartDragDistance).toInt(), 10);
28 QCOMPARE(hints.hint(QPlatformTheme::StartDragTime).toInt(), 500);
29
30 QCOMPARE(hints.hint(QPlatformTheme::ToolButtonStyle).toInt(), int(Qt::ToolButtonTextBesideIcon));
31
32 QCOMPARE(hints.hint(QPlatformTheme::ToolBarIconSize).toInt(), 22);
33 QCOMPARE(hints.hint(QPlatformTheme::ItemViewActivateItemOnSingleClick).toBool(), true);
34
35 QCOMPARE(hints.hint(QPlatformTheme::SystemIconThemeName).toString(), QStringLiteral("breeze"));
36 QCOMPARE(hints.hint(QPlatformTheme::SystemIconFallbackThemeName).toString(), QStringLiteral("hicolor"));
37 QCOMPARE(hints.hint(QPlatformTheme::IconThemeSearchPaths).toStringList(), hints.xdgIconThemePaths());
38
39 const QStringList expectedStyles =
40 QStringList{QStringLiteral(BREEZE_STYLE_NAME), QStringLiteral("oxygen"), QStringLiteral("fusion"), QStringLiteral("windows")};
41 QCOMPARE(hints.hint(QPlatformTheme::StyleNames).toStringList(), expectedStyles);
42
43 QCOMPARE(hints.hint(QPlatformTheme::DialogButtonBoxLayout).toInt(), int(QDialogButtonBox::KdeLayout));
44 QCOMPARE(hints.hint(QPlatformTheme::DialogButtonBoxButtonsHaveIcons).toBool(), true);
45 QCOMPARE(hints.hint(QPlatformTheme::UseFullScreenForPopupMenu).toBool(), true);
46 QCOMPARE(hints.hint(QPlatformTheme::KeyboardScheme).toInt(), int(QPlatformTheme::KdeKeyboardScheme));
47 QCOMPARE(hints.hint(QPlatformTheme::UiEffects).toInt(), 0);
48 QCOMPARE(hints.hint(QPlatformTheme::IconPixmapSizes).value<QList<int>>(), QList<int>({512, 256, 128, 64, 32, 22, 16, 8}));
49 QCOMPARE(hints.hint(QPlatformTheme::WheelScrollLines).toInt(), 3);
50 }
51
52 QTEST_GUILESS_MAIN(KHintsSettingsTest)
53
54 #include "khintssettings_unittest.moc"
55