diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 6389257..0684c4c 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,41 +1,42 @@ find_package(Qt5Test REQUIRED) include(ECMMarkAsTest) include_directories( ${CMAKE_SOURCE_DIR}/src ) include_directories( ${CMAKE_SOURCE_DIR}/src/common ) include_directories( ${CMAKE_SOURCE_DIR}/src/kded ) include_directories( ${CMAKE_SOURCE_DIR}/src/kcmodule ) set(WACOM_COMMON_TEST_LIBS wacom_common Qt5::Test) set(WACOM_KDED_TEST_LIBS kded_wacomtablet_lib ${kded_wacomtablet_LIBS} Qt5::Test) set(WACOM_KCM_TEST_LIBS kcm_testlib ${kcm_wacomtablet_LIBS} Qt5::Test) add_subdirectory(faketablet) # Add common Tests add_subdirectory( common/buttonshortcut ) add_subdirectory( common/deviceinformation ) add_subdirectory( common/deviceprofile ) add_subdirectory( common/deviceprofileconfigadaptor ) add_subdirectory( common/deviceproperty ) add_subdirectory( common/enum ) add_subdirectory( common/libwacomdata ) add_subdirectory( common/profilemanager ) add_subdirectory( common/property ) add_subdirectory( common/propertyset ) add_subdirectory( common/screenspace ) add_subdirectory( common/tabletarea ) add_subdirectory( common/tabletinformation ) add_subdirectory( common/tabletprofile ) add_subdirectory( common/tabletprofileconfigadaptor ) # Add kded Tests add_subdirectory( kded/dbustabletservice ) add_subdirectory( kded/tabletbackend ) add_subdirectory( kded/tabletdatabase ) add_subdirectory( kded/tablethandler ) add_subdirectory( kded/xinputadaptor ) add_subdirectory( kded/xsetwacomadaptor ) # Add kcm tests add_subdirectory( kcm/styluspage ) +add_subdirectory( kcm/tabletpage ) diff --git a/autotests/kcm/tabletpage/CMakeLists.txt b/autotests/kcm/tabletpage/CMakeLists.txt new file mode 100644 index 0000000..7d58e5e --- /dev/null +++ b/autotests/kcm/tabletpage/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(Test.KCM.TabletPage testtabletpage.cpp ../profilemanagementmocks.cpp) +add_test(NAME Test.KCM.TabletPage COMMAND Test.KCM.TabletPage) +ecm_mark_as_test(Test.KCM.TabletPage) +target_link_libraries(Test.KCM.TabletPage ${WACOM_KCM_TEST_LIBS}) diff --git a/autotests/kcm/tabletpage/testtabletpage.cpp b/autotests/kcm/tabletpage/testtabletpage.cpp new file mode 100644 index 0000000..6368917 --- /dev/null +++ b/autotests/kcm/tabletpage/testtabletpage.cpp @@ -0,0 +1,115 @@ +/* + * This file is part of the KDE wacomtablet project. For copyright + * information and license terms see the AUTHORS and COPYING files + * in the top-level directory of this distribution. + * + * 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 "kcmodule/tabletpagewidget.h" +#include "../profilemanagementmocks.h" + +#include "deviceprofile.h" +#include "deviceproperty.h" +#include "screenrotation.h" +#include "deviceprofiledefaults.h" + +#include "ui_tabletpagewidget.h" + +#include + +#include + +using namespace Wacom; + +class TestTabletPageWidget: public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void cleanupTestCase(); + void testTabletSettingsPersistency(); + void testSettingsTablet(); + +private: + ProfileManagementIntegrityChecker p; + TabletPageWidget * _testObject; +}; + + + +void TestTabletPageWidget::initTestCase() +{ + p._savedProfiles.clear(); + p._presetProfiles.clear(); + _testObject = new TabletPageWidget(); +} + +void TestTabletPageWidget::cleanupTestCase() +{ + delete _testObject; +} + +void TestTabletPageWidget::testTabletSettingsPersistency() +{ + QVERIFY(_testObject != nullptr); + + DeviceProfile stylus; + DeviceProfile eraser; + + stylus.setDeviceType(DeviceType::Stylus); + eraser.setDeviceType(DeviceType::Eraser); + setupDefaultStylus(stylus); + setupDefaultStylus(eraser); + + p._presetProfiles[DeviceType::Stylus] = stylus; + p._presetProfiles[DeviceType::Eraser] = eraser; + + _testObject->loadFromProfile(p); + _testObject->saveToProfile(p); + + for(const DeviceProperty& property : DeviceProperty::list()) { + //qDebug() << "Comparing" << property.key(); + QCOMPARE(p._savedProfiles[DeviceType::Stylus].getProperty(property.id()), p._presetProfiles[DeviceType::Stylus].getProperty(property.id())); + QCOMPARE(p._savedProfiles[DeviceType::Eraser].getProperty(property.id()), p._presetProfiles[DeviceType::Eraser].getProperty(property.id())); + } +} + +void TestTabletPageWidget::testSettingsTablet() +{ + DeviceProfile stylus; + stylus.setDeviceType(DeviceType::Stylus); + setupDefaultStylus(stylus); + stylus.setProperty(Property::Mode, QLatin1String("relative")); + + p._presetProfiles[DeviceType::Stylus] = stylus; + + _testObject->loadFromProfile(p); + + _testObject->findChild(QLatin1String("trackRelativeRadioButton"))->click(); + + _testObject->saveToProfile(p); + for(const DeviceProperty& property : DeviceProperty::list()) { + //qDebug() << "Comparing" << property.key(); + QCOMPARE(p._savedProfiles[DeviceType::Stylus].getProperty(property.id()), p._presetProfiles[DeviceType::Stylus].getProperty(property.id())); + } +} + +QTEST_MAIN(TestTabletPageWidget) + + + +#include "testtabletpage.moc"