mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(test): Move mocks into their own library
Avoid re-compiling sources for each test that uses them.
This commit is contained in:
parent
40846f886c
commit
bc751c8e1c
@ -22,24 +22,21 @@
|
|||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
set(MOCK_SOURCES
|
|
||||||
test/mock/mockcoreidhandler.cpp
|
|
||||||
test/mock/mockgroupquery.cpp
|
|
||||||
test/mock/mockcoresettings.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
function(auto_test subsystem module extra_deps)
|
function(auto_test subsystem module extra_deps)
|
||||||
add_executable(test_${module}
|
add_executable(test_${module}
|
||||||
test/${subsystem}/${module}_test.cpp ${extra_deps} ${MOCK_SOURCES})
|
test/${subsystem}/${module}_test.cpp ${extra_deps})
|
||||||
target_link_libraries(test_${module}
|
target_link_libraries(test_${module}
|
||||||
${PROJECT_NAME}_static
|
${PROJECT_NAME}_static
|
||||||
${CHECK_LIBRARIES}
|
${CHECK_LIBRARIES}
|
||||||
Qt5::Test)
|
Qt5::Test
|
||||||
|
mock_library)
|
||||||
add_test(
|
add_test(
|
||||||
NAME test_${module}
|
NAME test_${module}
|
||||||
COMMAND ${TEST_CROSSCOMPILING_EMULATOR} test_${module})
|
COMMAND ${TEST_CROSSCOMPILING_EMULATOR} test_${module})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
add_subdirectory(test/mock)
|
||||||
|
|
||||||
auto_test(core core "${${PROJECT_NAME}_RESOURCES}")
|
auto_test(core core "${${PROJECT_NAME}_RESOURCES}")
|
||||||
auto_test(core core_online "${${PROJECT_NAME}_RESOURCES}")
|
auto_test(core core_online "${${PROJECT_NAME}_RESOURCES}")
|
||||||
auto_test(core contactid "")
|
auto_test(core contactid "")
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "src/model/ibootstraplistgenerator.h"
|
#include "src/model/ibootstraplistgenerator.h"
|
||||||
#include "src/net/bootstrapnodeupdater.h"
|
#include "src/net/bootstrapnodeupdater.h"
|
||||||
#include "src/persistence/settings.h"
|
#include "src/persistence/settings.h"
|
||||||
#include "test/mock/mockcoresettings.h"
|
#include "mock/mockcoresettings.h"
|
||||||
|
|
||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "src/net/bootstrapnodeupdater.h"
|
#include "src/net/bootstrapnodeupdater.h"
|
||||||
#include "src/model/ibootstraplistgenerator.h"
|
#include "src/model/ibootstraplistgenerator.h"
|
||||||
#include "src/persistence/settings.h"
|
#include "src/persistence/settings.h"
|
||||||
#include "test/mock/mockcoresettings.h"
|
#include "mock/mockcoresettings.h"
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
30
test/mock/CMakeLists.txt
Normal file
30
test/mock/CMakeLists.txt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Copyright © 2022 by The qTox Project Contributors
|
||||||
|
#
|
||||||
|
# This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||||
|
# qTox is libre 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 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
|
add_library(mock_library STATIC
|
||||||
|
include/mock/mockcoreidhandler.h
|
||||||
|
src/mockcoreidhandler.cpp
|
||||||
|
include/mock/mockgroupquery.h
|
||||||
|
src/mockgroupquery.cpp
|
||||||
|
include/mock/mockcoresettings.h
|
||||||
|
src/mockcoresettings.cpp)
|
||||||
|
|
||||||
|
target_include_directories(mock_library PUBLIC include/)
|
||||||
|
target_link_libraries(mock_library
|
||||||
|
util_library
|
||||||
|
Qt5::Core
|
||||||
|
Qt5::Network
|
||||||
|
Qt5::Gui)
|
@ -17,6 +17,6 @@
|
|||||||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mockcoreidhandler.h"
|
#include "mock/mockcoreidhandler.h"
|
||||||
|
|
||||||
MockCoreIdHandler::~MockCoreIdHandler() = default;
|
MockCoreIdHandler::~MockCoreIdHandler() = default;
|
@ -17,6 +17,6 @@
|
|||||||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "test/mock/mockcoresettings.h"
|
#include "mock/mockcoresettings.h"
|
||||||
|
|
||||||
MockSettings::~MockSettings() = default;
|
MockSettings::~MockSettings() = default;
|
@ -17,6 +17,6 @@
|
|||||||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mockgroupquery.h"
|
#include "mock/mockgroupquery.h"
|
||||||
|
|
||||||
MockGroupQuery::~MockGroupQuery() = default;
|
MockGroupQuery::~MockGroupQuery() = default;
|
@ -25,8 +25,8 @@
|
|||||||
#include "src/persistence/igroupsettings.h"
|
#include "src/persistence/igroupsettings.h"
|
||||||
#include "util/interface.h"
|
#include "util/interface.h"
|
||||||
|
|
||||||
#include "test/mock/mockcoreidhandler.h"
|
#include "mock/mockcoreidhandler.h"
|
||||||
#include "test/mock/mockgroupquery.h"
|
#include "mock/mockgroupquery.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
#include "src/model/notificationgenerator.h"
|
#include "src/model/notificationgenerator.h"
|
||||||
|
|
||||||
#include "test/mock/mockcoreidhandler.h"
|
#include "mock/mockcoreidhandler.h"
|
||||||
#include "test/mock/mockgroupquery.h"
|
#include "mock/mockgroupquery.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user