File indexing completed on 2025-01-26 05:09:26

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 "tablethandlermock.h"
0021 
0022 using namespace Wacom;
0023 
0024 TabletHandlerMock::TabletHandlerMock()
0025     : TabletHandlerInterface(nullptr)
0026 {
0027     m_profile = QLatin1String("default");
0028 
0029     m_profiles.append(QLatin1String("default"));
0030     m_profiles.append(QLatin1String("myprofile"));
0031 }
0032 
0033 TabletHandlerMock::~TabletHandlerMock()
0034 {
0035 }
0036 
0037 void TabletHandlerMock::emitProfileChanged(const QString &tabletId, const QString &profile)
0038 {
0039     emit profileChanged(tabletId, profile);
0040 }
0041 
0042 void TabletHandlerMock::emitTabletAdded(const TabletInformation &info)
0043 {
0044     emit tabletAdded(info);
0045 }
0046 
0047 void TabletHandlerMock::emitTabletRemoved(const QString &tabletId)
0048 {
0049     emit tabletRemoved(tabletId);
0050 }
0051 
0052 QString TabletHandlerMock::getProperty(const QString &tabletId, const DeviceType &deviceType, const Property &property) const
0053 {
0054     Q_UNUSED(tabletId)
0055     QString prop = property.key();
0056 
0057     if (m_deviceType != deviceType.key()) {
0058         return QLatin1String("ERROR: DEVICE DOES NOT MATCH!");
0059     }
0060 
0061     if (m_property.compare(prop, Qt::CaseInsensitive) != 0) {
0062         return QLatin1String("ERROR: PROPERTY DOES NOT MATCH!");
0063     }
0064 
0065     return m_propertyValue;
0066 }
0067 
0068 QStringList TabletHandlerMock::listProfiles(const QString &tabletId)
0069 {
0070     Q_UNUSED(tabletId)
0071     return m_profiles;
0072 }
0073 
0074 void TabletHandlerMock::setProfile(const QString &tabletId, const QString &profile)
0075 {
0076     m_profile = profile;
0077     emitProfileChanged(tabletId, profile);
0078 }
0079 
0080 void TabletHandlerMock::setProperty(const QString &tabletId, const DeviceType &deviceType, const Property &property, const QString &value)
0081 {
0082     Q_UNUSED(tabletId)
0083     m_deviceType = deviceType.key();
0084     m_property = property.key();
0085     m_propertyValue = value;
0086 }
0087 
0088 QStringList TabletHandlerMock::getProfileRotationList(const QString &tabletId)
0089 {
0090     Q_UNUSED(tabletId)
0091     return m_rotationList;
0092 }
0093 
0094 void TabletHandlerMock::setProfileRotationList(const QString &tabletId, const QStringList &rotationList)
0095 {
0096     Q_UNUSED(tabletId)
0097     m_rotationList = rotationList;
0098 }
0099 
0100 #include "moc_tablethandlermock.cpp"