Commit 8bcaaa7f authored by Viktor Porvaznik's avatar Viktor Porvaznik Committed by Viktor Porvaznik

Added more dummy tests

parent 6a62c550
......@@ -15,7 +15,7 @@ endfunction()
# "tests/<TESTED_CLASS>_test/<TESTED_CLASS>_test.cpp" which itself can be
# anywhere in the hierarchy (e.g. plugins, standalone apps, etc.)
function(add_to_coverage class_under_test)
set(class_to_extract "*\\/${class_under_test}.*")
set(class_to_extract "*\\/${class_under_test}.*pp")
set(test_name ${class_under_test}_test)
set(coverage_target ${class_under_test}_coverage)
add_custom_target(${coverage_target}
......
......@@ -5,7 +5,7 @@ add_executable(kdeconnect-filesync-daemon
log.cpp
index.cpp
daemon.cpp
common.cpp
util.cpp
sftp_mounter.cpp
executor.cpp
sync_operation.cpp
......
......@@ -92,26 +92,6 @@ namespace FileSync
// Normal log messages
static const QString MOUNT_POINT_FOUND = "Found mount point for device %1 at %2";
class Util
{
public:
/**
* Runs a command
* @param commandToRun
* @param stdout returned during the process execution
* @param stderr returned during the process execution
* @return error if any
*/
static int
runCommand(const QString &commandToRun, QString &stdout, QString &stderr);
static QString convertToHash(const QString &toConvert);
static QString getFileContent(const QString &filePath);
static QList<QString> scanDir(const QString &rootElement);
};
}
#endif //FILESYNC_COMMON_H
......@@ -22,6 +22,7 @@
#include "config.h"
#include "index.h"
#include "executor.h"
#include "util.h"
Q_LOGGING_CATEGORY(LOG_EXECUTOR, "kdeconnect.filesyncapp.daemon.executor");
......
......@@ -20,6 +20,7 @@
#include <log.h>
#include <sftp_mounter.h>
#include "util.h"
Q_LOGGING_CATEGORY(LOG_SFTP_MOUNTER, "kdeconnect.filesyncapp.daemon.sftpMounter");
......
......@@ -22,6 +22,7 @@
#include "sync_operation.h"
#include "log.h"
#include "common.h"
#include "util.h"
Q_LOGGING_CATEGORY(LOG_SYNC_OPERATION,
"kdeconnect.filesyncapp.daemon.syncOperation");
......
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Test)
include_directories(
${KDEConnectCore_BINARY_DIR}
${CMAKE_SOURCE_DIR}
../../
)
set(kdeconnect_libraries
kdeconnectcore
KF5::I18n
KF5::KIOWidgets
Qt5::DBus
Qt5::Network
Qt5::Test
qca-qt5
pthread
)
ecm_add_test(
../../util.cpp
../../log.cpp
../../config.cpp
config_test.cpp LINK_LIBRARIES ${kdeconnect_libraries} TEST_NAME config_test)
add_to_coverage("config")
/**
* Copyright 2019 Viktor Porvaznik <viktor.porvaznik@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include <QTest>
// Class under the test
#include "config.h"
namespace FileSync
{
class ConfigTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void test0()
{
}
};
}
QTEST_MAIN(FileSync::ConfigTest)
#include "config_test.moc"
......@@ -21,7 +21,7 @@ set(kdeconnect_libraries
)
ecm_add_test(
../../common.cpp
../../util.cpp
../../log.cpp
../../index.cpp
../../executor.cpp
......
......@@ -21,7 +21,7 @@ set(kdeconnect_libraries
)
ecm_add_test(
../../common.cpp
../../util.cpp
../../log.cpp
../../index.cpp
../../executor.cpp
......
......@@ -23,7 +23,7 @@ file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/index_test)
file(COPY test_resources DESTINATION ${CMAKE_BINARY_DIR}/index_test)
ecm_add_test(
../../common.cpp
../../util.cpp
../../sync_operation.cpp
../../log.cpp
../../index.cpp
......
......@@ -20,9 +20,12 @@
#include <QObject>
#include <QTest>
#include "index.h"
#include "common.h"
// Class under the test
#include "index.h"
namespace FileSync
{
class IndexTest : public QObject
......
......@@ -20,7 +20,7 @@ set(kdeconnect_libraries
)
ecm_add_test(
../../common.cpp
../../util.cpp
../../log.cpp
log_test.cpp LINK_LIBRARIES ${kdeconnect_libraries} TEST_NAME log_test)
......
......@@ -22,7 +22,8 @@
#include <QTest>
#include <QThread>
#include "singleton_pool.hpp"
// Class under the test
#include "log.h"
namespace FileSync
{
......@@ -31,11 +32,7 @@ namespace FileSync
Q_OBJECT
private Q_SLOTS:
/**
* Try to create and destroy single instance, and repeat verifying that
* second created instance is a different one
*/
void testCreateAndDestroyTwoInstances()
void test0()
{
}
};
......
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Test)
include_directories(
${KDEConnectCore_BINARY_DIR}
${CMAKE_SOURCE_DIR}
../../
)
set(kdeconnect_libraries
kdeconnectcore
kdeconnectinterfaces
KF5::I18n
KF5::KIOWidgets
Qt5::DBus
Qt5::Network
Qt5::Test
qca-qt5
pthread
)
ecm_add_test(
../../util.cpp
../../log.cpp
../../config.cpp
../../daemon.cpp
../../index.cpp
../../executor.cpp
../../sftp_mounter.cpp
../../sync_operation.cpp
../../../interfaces/filesyncapp_interface.cpp
../../../interfaces/json_types.cpp
../../../interfaces/sync_result.cpp
sftp_mounter_test.cpp LINK_LIBRARIES ${kdeconnect_libraries} TEST_NAME sftp_mounter_test)
add_to_coverage("sftp_mounter")
/**
* Copyright 2019 Viktor Porvaznik <viktor.porvaznik@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include <QTest>
// Class under the test
#include "sftp_mounter.h"
namespace FileSync
{
class SftpMounterTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void test0()
{
}
};
}
QTEST_MAIN(FileSync::SftpMounterTest)
#include "sftp_mounter_test.moc"
......@@ -20,7 +20,7 @@ set(kdeconnect_libraries
)
ecm_add_test(
../../common.cpp
../../util.cpp
../../sync_operation.cpp
../../log.cpp
../../index.cpp
......
......@@ -22,6 +22,7 @@
#include <QTest>
#include <QThread>
// Class under the test
#include "singleton_pool.hpp"
namespace FileSync
......
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Test)
include_directories(
${KDEConnectCore_BINARY_DIR}
${CMAKE_SOURCE_DIR}
../../
)
set(kdeconnect_libraries
kdeconnectcore
KF5::I18n
KF5::KIOWidgets
Qt5::DBus
Qt5::Network
Qt5::Test
qca-qt5
pthread
)
ecm_add_test(
../../util.cpp
../../sync_operation.cpp
sync_operation_test.cpp LINK_LIBRARIES ${kdeconnect_libraries} TEST_NAME sync_operation_test)
add_to_coverage("sync_operation")
/**
* Copyright 2019 Viktor Porvaznik <viktor.porvaznik@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include <QTest>
// Class under the test
#include "sync_operation.h"
namespace FileSync
{
class SyncOperationTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void test0()
{
}
};
}
QTEST_MAIN(FileSync::SyncOperationTest)
#include "sync_operation_test.moc"
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Test)
include_directories(
${KDEConnectCore_BINARY_DIR}
${CMAKE_SOURCE_DIR}
../../
)
set(kdeconnect_libraries
kdeconnectcore
KF5::I18n
KF5::KIOWidgets
Qt5::DBus
Qt5::Network
Qt5::Test
qca-qt5
pthread
)
ecm_add_test(
../../util.cpp
util_test.cpp LINK_LIBRARIES ${kdeconnect_libraries} TEST_NAME util_test)
add_to_coverage("util")
/**
* Copyright 2019 Viktor Porvaznik <viktor.porvaznik@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include <QTest>
#include <QThread>
// Class under the test
#include "util.h"
namespace FileSync
{
class UtilTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void test0()
{
Util::convertToHash("rest");
}
};
}
QTEST_MAIN(FileSync::UtilTest)
#include "util_test.moc"
......@@ -20,6 +20,7 @@
#include "log.h"
#include "common.h"
#include "util.h"
#include <QLoggingCategory>
#include <QtCore/QCryptographicHash>
#include <QtGui/QtGui>
......
/**
* Copyright 2019 Viktor Porvaznik <viktor.porvaznik@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef FILESYNC_UTIL_H
#define FILESYNC_UTIL_H
#include <exception>
#include <QLoggingCategory>
#include <QtCore/QString>
#include <QtCore/QProcess>
namespace FileSync
{
class Util
{
public:
/**
* Runs a command
* @param commandToRun
* @param stdout returned during the process execution
* @param stderr returned during the process execution
* @return error if any
*/
static int
runCommand(const QString &commandToRun, QString &stdout, QString &stderr);
static QString convertToHash(const QString &toConvert);
static QString getFileContent(const QString &filePath);
static QList<QString> scanDir(const QString &rootElement);
};
}
#endif //FILESYNC_UTIL_H
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Test)
include_directories(
${KDEConnectCore_BINARY_DIR}
${CMAKE_SOURCE_DIR}
../../
)
set(kdeconnect_libraries
kdeconnectcore
KF5::I18n
KF5::KIOWidgets
Qt5::DBus
Qt5::Network
Qt5::Test
qca-qt5
pthread
)
ecm_add_test(
../../sync_result.cpp
sync_result_test.cpp LINK_LIBRARIES ${kdeconnect_libraries} TEST_NAME sync_result_test)
add_to_coverage("sync_result")
/**
* Copyright 2019 Viktor Porvaznik <viktor.porvaznik@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include <QTest>
// Class under the test
#include "sync_result.h"
namespace FileSync
{
class SyncResultTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void test0()
{
}
};
}
QTEST_MAIN(FileSync::SyncResultTest)
#include "sync_result_test.moc"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment