diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f82e85d77..a2db3bbac 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -29,12 +29,13 @@ set(testsslsocketlinereader_sources ecm_add_test(testsslsocketlinereader.cpp ${testsslsocketlinereader_sources} TEST_NAME testsslsocketlinereader LINK_LIBRARIES ${kdeconnect_libraries}) set(kdeconnectconfigtest_sources + ../core/backends/devicelink.cpp ../core/backends/pairinghandler.cpp ../core/dbushelper.cpp ../core/device.cpp ../core/pluginloader.cpp ) -ecm_add_test(kdeconnectconfigtest.cpp ${kdeconnectconfigtest_sources} TEST_NAME kdeconnectconfgtest LINK_LIBRARIES ${kdeconnect_libraries}) +ecm_add_test(kdeconnectconfigtest.cpp ${kdeconnectconfigtest_sources} TEST_NAME kdeconnectconfigtest LINK_LIBRARIES ${kdeconnect_libraries}) set(lanlinkprovidertest_sources ../core/backends/devicelink.cpp @@ -54,4 +55,4 @@ ecm_add_test(lanlinkprovidertest.cpp ${lanlinkprovidertest_sources} TEST_NAME ecm_add_test(devicetest.cpp ${lanlinkprovidertest_sources} TEST_NAME devicetest LINK_LIBRARIES ${kdeconnect_libraries}) -ecm_add_test(downloadjobtest.cpp ../core/backends/lan/downloadjob.cpp TEST_NAME downloadjobtest LINK_LIBRARIES ${kdeconnect_libraries}) \ No newline at end of file +ecm_add_test(downloadjobtest.cpp ../core/backends/lan/downloadjob.cpp TEST_NAME downloadjobtest LINK_LIBRARIES ${kdeconnect_libraries}) diff --git a/tests/pluginloadtest.cpp b/tests/pluginloadtest.cpp index b70eea222..dfa04accf 100644 --- a/tests/pluginloadtest.cpp +++ b/tests/pluginloadtest.cpp @@ -33,38 +33,7 @@ #include "core/kdeconnectplugin.h" #include #include "kdeconnect-version.h" - -class TestDaemon : public Daemon -{ -Q_OBJECT -public: - TestDaemon(QObject* parent = Q_NULLPTR) - : Daemon(parent, true) - , m_nam(Q_NULLPTR) - { - } - - void requestPairing(PairingHandler* d) Q_DECL_OVERRIDE - { - d->acceptPairing(); - } - - void reportError(const QString & title, const QString & description) Q_DECL_OVERRIDE - { - qWarning() << "error:" << title << description; - } - - QNetworkAccessManager* networkAccessManager() Q_DECL_OVERRIDE - { - if (!m_nam) { - m_nam = new KIO::AccessManager(this); - } - return m_nam; - } - -private: - QNetworkAccessManager* m_nam; -}; +#include "testdaemon.h" class PluginLoadTest : public QObject { diff --git a/tests/sendfiletest.cpp b/tests/sendfiletest.cpp index 3402fe04d..28f207dd3 100644 --- a/tests/sendfiletest.cpp +++ b/tests/sendfiletest.cpp @@ -33,38 +33,7 @@ #include "core/kdeconnectplugin.h" #include #include "kdeconnect-version.h" - -class TestDaemon : public Daemon -{ -Q_OBJECT -public: - TestDaemon(QObject* parent = Q_NULLPTR) - : Daemon(parent, true) - , m_nam(Q_NULLPTR) - { - } - - void requestPairing(PairingHandler* d) Q_DECL_OVERRIDE - { - d->acceptPairing(); - } - - void reportError(const QString & title, const QString & description) Q_DECL_OVERRIDE - { - qWarning() << "error:" << title << description; - } - - QNetworkAccessManager* networkAccessManager() Q_DECL_OVERRIDE - { - if (!m_nam) { - m_nam = new KIO::AccessManager(this); - } - return m_nam; - } - -private: - QNetworkAccessManager* m_nam; -}; +#include "testdaemon.h" class TestSendFile : public QObject { diff --git a/tests/testdaemon.h b/tests/testdaemon.h new file mode 100644 index 000000000..809dfbf49 --- /dev/null +++ b/tests/testdaemon.h @@ -0,0 +1,57 @@ +/** + * Copyright 2015 Aleix Pol Gonzalez + * + * 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) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * 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 . + */ + +#ifndef TESTDAEMON_H +#define TESTDAEMON_H + +#include +#include + +class TestDaemon : public Daemon +{ +public: + TestDaemon(QObject* parent = Q_NULLPTR) + : Daemon(parent, true) + , m_nam(Q_NULLPTR) + { + } + + void reportError(const QString & title, const QString & description) Q_DECL_OVERRIDE + { + qWarning() << "error:" << title << description; + } + + void askPairingConfirmation(PairingHandler * d) override { + d->acceptPairing(); + } + + QNetworkAccessManager* networkAccessManager() Q_DECL_OVERRIDE + { + if (!m_nam) { + m_nam = new KIO::AccessManager(this); + } + return m_nam; + } + +private: + QNetworkAccessManager* m_nam; +}; + +#endif