File indexing completed on 2024-12-29 05:08:32
0001 /* 0002 * This file is part of the KDE wacomtablet project. For copyright 0003 * information and license terms see the AUTHORS and COPYING files 0004 * in the top-level directory of this distribution. 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public License as 0008 * published by the Free Software Foundation; either version 2 of 0009 * the License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #include "../profilemanagementmocks.h" 0021 #include "kcmodule/tabletpagewidget.h" 0022 0023 #include "deviceprofile.h" 0024 #include "deviceprofiledefaults.h" 0025 #include "deviceproperty.h" 0026 #include "screenrotation.h" 0027 0028 #include "ui_tabletpagewidget.h" 0029 0030 #include <QtTest> 0031 0032 #include <QSlider> 0033 0034 using namespace Wacom; 0035 0036 class TestTabletPageWidget : public QObject 0037 { 0038 Q_OBJECT 0039 0040 private slots: 0041 void initTestCase(); 0042 void cleanupTestCase(); 0043 void testTabletSettingsPersistency(); 0044 void testSettingsTablet(); 0045 0046 private: 0047 ProfileManagementIntegrityChecker p; 0048 TabletPageWidget *_testObject; 0049 }; 0050 0051 void TestTabletPageWidget::initTestCase() 0052 { 0053 p._savedProfiles.clear(); 0054 p._presetProfiles.clear(); 0055 _testObject = new TabletPageWidget(); 0056 } 0057 0058 void TestTabletPageWidget::cleanupTestCase() 0059 { 0060 delete _testObject; 0061 } 0062 0063 void TestTabletPageWidget::testTabletSettingsPersistency() 0064 { 0065 QVERIFY(_testObject != nullptr); 0066 0067 DeviceProfile stylus; 0068 DeviceProfile eraser; 0069 0070 stylus.setDeviceType(DeviceType::Stylus); 0071 eraser.setDeviceType(DeviceType::Eraser); 0072 setupDefaultStylus(stylus); 0073 setupDefaultStylus(eraser); 0074 0075 p._presetProfiles[DeviceType::Stylus] = stylus; 0076 p._presetProfiles[DeviceType::Eraser] = eraser; 0077 0078 _testObject->loadFromProfile(p); 0079 _testObject->saveToProfile(p); 0080 0081 for (const DeviceProperty &property : DeviceProperty::list()) { 0082 // qDebug() << "Comparing" << property.key(); 0083 QCOMPARE(p._savedProfiles[DeviceType::Stylus].getProperty(property.id()), p._presetProfiles[DeviceType::Stylus].getProperty(property.id())); 0084 QCOMPARE(p._savedProfiles[DeviceType::Eraser].getProperty(property.id()), p._presetProfiles[DeviceType::Eraser].getProperty(property.id())); 0085 } 0086 } 0087 0088 void TestTabletPageWidget::testSettingsTablet() 0089 { 0090 DeviceProfile stylus; 0091 stylus.setDeviceType(DeviceType::Stylus); 0092 setupDefaultStylus(stylus); 0093 stylus.setProperty(Property::Mode, QLatin1String("relative")); 0094 0095 p._presetProfiles[DeviceType::Stylus] = stylus; 0096 0097 _testObject->loadFromProfile(p); 0098 0099 _testObject->findChild<QRadioButton *>(QLatin1String("trackRelativeRadioButton"))->click(); 0100 0101 _testObject->saveToProfile(p); 0102 for (const DeviceProperty &property : DeviceProperty::list()) { 0103 // qDebug() << "Comparing" << property.key(); 0104 QCOMPARE(p._savedProfiles[DeviceType::Stylus].getProperty(property.id()), p._presetProfiles[DeviceType::Stylus].getProperty(property.id())); 0105 } 0106 } 0107 0108 QTEST_MAIN(TestTabletPageWidget) 0109 0110 #include "testtabletpage.moc"