File indexing completed on 2024-04-14 04:51:53
0001 /** 0002 * SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #ifndef TESTDAEMON_H 0008 #define TESTDAEMON_H 0009 0010 #include <core/backends/pairinghandler.h> 0011 #include <core/daemon.h> 0012 0013 #include <KJobTrackerInterface> 0014 #include <QCoreApplication> 0015 0016 class TestDaemon : public Daemon 0017 { 0018 public: 0019 TestDaemon(QObject *parent = nullptr) 0020 : Daemon(parent, true) 0021 , m_jobTrackerInterface(nullptr) 0022 { 0023 // Necessary to force the event loop to run because the test harness seems to behave differently 0024 // and we need the QTimer::SingleShot in Daemon's constructor to fire 0025 QCoreApplication::processEvents(); 0026 } 0027 0028 void addDevice(Device *device) 0029 { 0030 Daemon::addDevice(device); 0031 } 0032 0033 void reportError(const QString &title, const QString &description) override 0034 { 0035 qWarning() << "error:" << title << description; 0036 } 0037 0038 void askPairingConfirmation(Device *d) override 0039 { 0040 d->acceptPairing(); 0041 } 0042 0043 Q_SCRIPTABLE virtual void sendSimpleNotification(const QString &eventId, const QString &title, const QString &text, const QString &iconName) override 0044 { 0045 qDebug() << eventId << title << text << iconName; 0046 } 0047 0048 void quit() override 0049 { 0050 qDebug() << "quit was called"; 0051 } 0052 0053 KJobTrackerInterface *jobTracker() override 0054 { 0055 if (!m_jobTrackerInterface) { 0056 m_jobTrackerInterface = new KJobTrackerInterface(); 0057 } 0058 return m_jobTrackerInterface; 0059 } 0060 0061 private: 0062 KJobTrackerInterface *m_jobTrackerInterface; 0063 }; 0064 0065 #endif