From bb242d82c5b1c52570ff01379c7203c46cf0b306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 15 Aug 2012 20:53:05 +0200 Subject: [PATCH] Adding a unit test for TabBoxConfig Currently only testing the default ctor and assignment operator. Inspired by bug fixed with commit 4276161. REVIEW: 106048 --- tabbox/tests/CMakeLists.txt | 11 ++++ tabbox/tests/test_tabbox_config.cpp | 88 +++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 tabbox/tests/test_tabbox_config.cpp diff --git a/tabbox/tests/CMakeLists.txt b/tabbox/tests/CMakeLists.txt index a0df42510e..83809ad83e 100644 --- a/tabbox/tests/CMakeLists.txt +++ b/tabbox/tests/CMakeLists.txt @@ -33,3 +33,14 @@ set( testTabBoxHandler_SRCS kde4_add_unit_test( testTabBoxHandler TESTNAME testTabBoxHandler ${testTabBoxHandler_SRCS} ) target_link_libraries( testTabBoxHandler ${KDE4_KDEUI_LIBS} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} ${QT_QTTEST_LIBRARY} ${X11_LIBRARIES} ) + +######################################################## +# Test TabBox::TabBoxConfig +######################################################## +set( testTabBoxConfig_SRCS + ../tabboxconfig.cpp + test_tabbox_config.cpp +) + +kde4_add_unit_test( testTabBoxConfig TESTNAME testTabBoxConfig ${testTabBoxConfig_SRCS} ) +target_link_libraries( testTabBoxConfig ${QT_QTTEST_LIBRARY} ) diff --git a/tabbox/tests/test_tabbox_config.cpp b/tabbox/tests/test_tabbox_config.cpp new file mode 100644 index 0000000000..6843834288 --- /dev/null +++ b/tabbox/tests/test_tabbox_config.cpp @@ -0,0 +1,88 @@ +/******************************************************************** +KWin - the KDE window manager +This file is part of the KDE project. + +Copyright (C) 2012 Martin Gräßlin + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +#include "../tabboxconfig.h" +#include +using namespace KWin; +using namespace KWin::TabBox; + +class TestTabBoxConfig : public QObject +{ + Q_OBJECT +private slots: + void testDefaultCtor(); + void testAssignmentOperator(); +}; + +void TestTabBoxConfig::testDefaultCtor() +{ + TabBoxConfig config; + QCOMPARE(config.isShowTabBox(), TabBoxConfig::defaultShowTabBox()); + QCOMPARE(config.isHighlightWindows(), TabBoxConfig::defaultHighlightWindow()); + QCOMPARE(config.isShowOutline(), TabBoxConfig::defaultShowOutline()); + QCOMPARE(config.tabBoxMode(), TabBoxConfig::ClientTabBox); + QCOMPARE(config.clientDesktopMode(), TabBoxConfig::defaultDesktopMode()); + QCOMPARE(config.clientActivitiesMode(), TabBoxConfig::defaultActivitiesMode()); + QCOMPARE(config.clientApplicationsMode(), TabBoxConfig::defaultApplicationsMode()); + QCOMPARE(config.clientMinimizedMode(), TabBoxConfig::defaultMinimizedMode()); + QCOMPARE(config.showDesktopMode(), TabBoxConfig::defaultShowDesktopMode()); + QCOMPARE(config.clientMultiScreenMode(), TabBoxConfig::defaultMultiScreenMode()); + QCOMPARE(config.clientSwitchingMode(), TabBoxConfig::defaultSwitchingMode()); + QCOMPARE(config.desktopSwitchingMode(), TabBoxConfig::MostRecentlyUsedDesktopSwitching); + QCOMPARE(config.layoutName(), TabBoxConfig::defaultLayoutName()); +} + +void TestTabBoxConfig::testAssignmentOperator() +{ + TabBoxConfig config; + // changing all values of the config object + config.setShowTabBox(!TabBoxConfig::defaultShowTabBox()); + config.setHighlightWindows(!TabBoxConfig::defaultHighlightWindow()); + config.setShowOutline(!TabBoxConfig::defaultShowOutline()); + config.setTabBoxMode(TabBoxConfig::DesktopTabBox); + config.setClientDesktopMode(TabBoxConfig::AllDesktopsClients); + config.setClientActivitiesMode(TabBoxConfig::AllActivitiesClients); + config.setClientApplicationsMode(TabBoxConfig::OneWindowPerApplication); + config.setClientMinimizedMode(TabBoxConfig::ExcludeMinimizedClients); + config.setShowDesktopMode(TabBoxConfig::ShowDesktopClient); + config.setClientMultiScreenMode(TabBoxConfig::ExcludeCurrentScreenClients); + config.setClientSwitchingMode(TabBoxConfig::StackingOrderSwitching); + config.setDesktopSwitchingMode(TabBoxConfig::StaticDesktopSwitching); + config.setLayoutName(QString("grid")); + TabBoxConfig config2; + config2 = config; + // verify the config2 values + QCOMPARE(config2.isShowTabBox(), !TabBoxConfig::defaultShowTabBox()); + QCOMPARE(config2.isHighlightWindows(), !TabBoxConfig::defaultHighlightWindow()); + QCOMPARE(config2.isShowOutline(), !TabBoxConfig::defaultShowOutline()); + QCOMPARE(config2.tabBoxMode(), TabBoxConfig::DesktopTabBox); + QCOMPARE(config2.clientDesktopMode(), TabBoxConfig::AllDesktopsClients); + QCOMPARE(config2.clientActivitiesMode(), TabBoxConfig::AllActivitiesClients); + QCOMPARE(config2.clientApplicationsMode(), TabBoxConfig::OneWindowPerApplication); + QCOMPARE(config2.clientMinimizedMode(), TabBoxConfig::ExcludeMinimizedClients); + QCOMPARE(config2.showDesktopMode(), TabBoxConfig::ShowDesktopClient); + QCOMPARE(config2.clientMultiScreenMode(), TabBoxConfig::ExcludeCurrentScreenClients); + QCOMPARE(config2.clientSwitchingMode(), TabBoxConfig::StackingOrderSwitching); + QCOMPARE(config2.desktopSwitchingMode(), TabBoxConfig::StaticDesktopSwitching); + QCOMPARE(config2.layoutName(), QString("grid")); +} + +QTEST_MAIN(TestTabBoxConfig) + +#include "test_tabbox_config.moc"