mirror of
https://github.com/QuasarApp/CMakeProject.git
synced 2025-04-26 13:44:34 +00:00
added new testcore lib for testing private sections of the modules
This commit is contained in:
parent
ae3db6afc3
commit
8fef03dc1e
1
.gitignore
vendored
1
.gitignore
vendored
@ -72,3 +72,4 @@ AndroidManifest.xml
|
|||||||
src/Example/Deploy/RENAME_ME.json
|
src/Example/Deploy/RENAME_ME.json
|
||||||
src/Library/src/public/RENAME_ME/global.h
|
src/Library/src/public/RENAME_ME/global.h
|
||||||
doxygen.conf
|
doxygen.conf
|
||||||
|
Distro
|
||||||
|
@ -44,6 +44,10 @@ make_directory(Distro)
|
|||||||
|
|
||||||
initAll()
|
initAll()
|
||||||
|
|
||||||
|
if (RENAME_ME_TESTS)
|
||||||
|
add_subdirectory(src/testcore)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(src/RENAME_ME)
|
add_subdirectory(src/RENAME_ME)
|
||||||
|
|
||||||
if (DEFINED RENAME_ME_EXAMPLE)
|
if (DEFINED RENAME_ME_EXAMPLE)
|
||||||
|
@ -25,7 +25,11 @@ set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/private")
|
|||||||
|
|
||||||
add_library(${CURRENT_PROJECT} ${SOURCE_CPP} ${SOURCE_QRC})
|
add_library(${CURRENT_PROJECT} ${SOURCE_CPP} ${SOURCE_QRC})
|
||||||
|
|
||||||
target_link_libraries(${CURRENT_PROJECT} PUBLIC Qt${QT_VERSION_MAJOR}::Core )
|
if (RENAME_ME_TESTS)
|
||||||
|
target_link_libraries(${CURRENT_PROJECT} PUBLIC ${PROJECT_NAME}testcore)
|
||||||
|
else()
|
||||||
|
target_link_libraries(${CURRENT_PROJECT} PUBLIC Qt${QT_VERSION_MAJOR}::Core )
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR})
|
target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR})
|
||||||
target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR})
|
target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR})
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
#define RENAME_ME_VERSION "0.88.6523639"
|
#define RENAME_ME_VERSION "0.89.ae3db6a"
|
||||||
|
|
||||||
#if defined(RENAME_ME_LIBRARY)
|
#if defined(RENAME_ME_LIBRARY)
|
||||||
# define RENAME_ME_EXPORT Q_DECL_EXPORT
|
# define RENAME_ME_EXPORT Q_DECL_EXPORT
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"bin": [
|
"bin": [
|
||||||
"src/build/Debug/RENAME_MEEaxample",
|
"src/example/RENAME_ME_example",
|
||||||
"src/build/Debug/RENAME_MEEaxample.exe"
|
"src/example/RENAME_ME_example.exe"
|
||||||
],
|
],
|
||||||
"clear": true,
|
"clear": true,
|
||||||
"binPrefix": "/media/D/builds/build-CMakeProject-Desktop_Qt_6_5_2_GCC_64bit-Debug",
|
"binPrefix": "/media/D/builds/build-CMakeProject-Desktop_Qt_6_5_2_GCC_64bit-Debug",
|
||||||
@ -21,7 +21,7 @@
|
|||||||
],
|
],
|
||||||
"extraLib": "crypto",
|
"extraLib": "crypto",
|
||||||
"targetDir": "/media/D/builds/CMakeProject/Distro",
|
"targetDir": "/media/D/builds/CMakeProject/Distro",
|
||||||
"deployVersion": "0.87.648a8dc",
|
"deployVersion": "0.89.ae3db6a"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
src/testcore/CMakeLists.txt
Normal file
32
src/testcore/CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2020-2023 QuasarApp.
|
||||||
|
# Distributed under the GPLv3 software license, see the accompanying
|
||||||
|
# Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
# of this license document, but changing it is not allowed.
|
||||||
|
#
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.19)
|
||||||
|
|
||||||
|
set(CURRENT_PROJECT "${PROJECT_NAME}testcore")
|
||||||
|
add_definitions(-DTEST_CORE_LIBRARY)
|
||||||
|
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SOURCE_CPP
|
||||||
|
"*.cpp"
|
||||||
|
"*.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SOURCE_QRC
|
||||||
|
"*.qrc"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
|
add_library(${CURRENT_PROJECT} ${SOURCE_CPP} ${SOURCE_QRC})
|
||||||
|
|
||||||
|
target_link_libraries(${CURRENT_PROJECT} PUBLIC Qt${QT_VERSION_MAJOR}::Core )
|
||||||
|
|
||||||
|
target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR})
|
||||||
|
target_include_directories(${CURRENT_PROJECT} PRIVATE ${PRIVATE_INCUDE_DIR})
|
||||||
|
|
||||||
|
configure_file_in(${CURRENT_PROJECT} "${CMAKE_CURRENT_SOURCE_DIR}/testcore/global.h")
|
20
src/testcore/testcore/global.h
Normal file
20
src/testcore/testcore/global.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
//#
|
||||||
|
//# Copyright (C) 2018-2023 QuasarApp.
|
||||||
|
//# Distributed under the GPLv3 software license, see the accompanying
|
||||||
|
//# Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
//# of this license document, but changing it is not allowed.
|
||||||
|
//#
|
||||||
|
|
||||||
|
#ifndef TEST_CORE_GLOBAL_H
|
||||||
|
#define TEST_CORE_GLOBAL_H
|
||||||
|
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
#if defined(TEST_CORE_LIBRARY)
|
||||||
|
# define TEST_CORE_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define TEST_CORE_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //TEST_CORE_GLOBAL_H
|
||||||
|
|
20
src/testcore/testcore/global.h.in
Normal file
20
src/testcore/testcore/global.h.in
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
//#
|
||||||
|
//# Copyright (C) 2018-2023 QuasarApp.
|
||||||
|
//# Distributed under the GPLv3 software license, see the accompanying
|
||||||
|
//# Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
//# of this license document, but changing it is not allowed.
|
||||||
|
//#
|
||||||
|
|
||||||
|
#ifndef TEST_CORE_GLOBAL_H
|
||||||
|
#define TEST_CORE_GLOBAL_H
|
||||||
|
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
#if defined(TEST_CORE_LIBRARY)
|
||||||
|
# define TEST_CORE_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define TEST_CORE_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //TEST_CORE_GLOBAL_H
|
||||||
|
|
16
src/testcore/testcore/itest.h
Normal file
16
src/testcore/testcore/itest.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef ITEST_H
|
||||||
|
#define ITEST_H
|
||||||
|
|
||||||
|
#include "testcore/global.h"
|
||||||
|
|
||||||
|
namespace testcore {
|
||||||
|
|
||||||
|
class TEST_CORE_EXPORT ITest {
|
||||||
|
public:
|
||||||
|
ITest() = default;
|
||||||
|
virtual ~ITest() = default;
|
||||||
|
|
||||||
|
virtual void test() = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // ITEST_H
|
@ -12,6 +12,8 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
|
namespace testcore {
|
||||||
|
|
||||||
bool TestUtils::funcPrivateConnect(const std::function<bool()> &requestFunc,
|
bool TestUtils::funcPrivateConnect(const std::function<bool()> &requestFunc,
|
||||||
const std::function<bool()> &checkFunc,
|
const std::function<bool()> &checkFunc,
|
||||||
const std::function<QMetaObject::Connection()> &connectFunction) const {
|
const std::function<QMetaObject::Connection()> &connectFunction) const {
|
||||||
@ -50,4 +52,4 @@ bool TestUtils::wait(const std::function<bool()> &forWait, int msec) const {
|
|||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
return forWait();
|
return forWait();
|
||||||
}
|
}
|
||||||
|
}
|
@ -11,8 +11,11 @@
|
|||||||
|
|
||||||
#include "functional"
|
#include "functional"
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
|
#include "testcore/global.h"
|
||||||
|
|
||||||
class TestUtils
|
namespace testcore {
|
||||||
|
|
||||||
|
class TEST_CORE_EXPORT TestUtils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestUtils();
|
TestUtils();
|
||||||
@ -28,5 +31,5 @@ public:
|
|||||||
const std::function<bool ()> &checkFunc) const;
|
const std::function<bool ()> &checkFunc) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
#endif // TESTUTILS_H
|
#endif // TESTUTILS_H
|
@ -41,7 +41,7 @@ private:
|
|||||||
* @brief initTest This method prepare @a test for run in the QApplication loop.
|
* @brief initTest This method prepare @a test for run in the QApplication loop.
|
||||||
* @param test are input test case class.
|
* @param test are input test case class.
|
||||||
*/
|
*/
|
||||||
void initTest(Test* test);
|
void initTest(testcore::ITest* test);
|
||||||
|
|
||||||
QCoreApplication *_app = nullptr;
|
QCoreApplication *_app = nullptr;
|
||||||
};
|
};
|
||||||
@ -71,7 +71,7 @@ tstMain::~tstMain() {
|
|||||||
delete _app;
|
delete _app;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tstMain::initTest(Test *test) {
|
void tstMain::initTest(testcore::ITest *test) {
|
||||||
QTimer::singleShot(0, this, [this, test]() {
|
QTimer::singleShot(0, this, [this, test]() {
|
||||||
test->test();
|
test->test();
|
||||||
delete test;
|
delete test;
|
||||||
|
@ -8,12 +8,13 @@
|
|||||||
|
|
||||||
#ifndef EXAMPLE_TEST_H
|
#ifndef EXAMPLE_TEST_H
|
||||||
#define EXAMPLE_TEST_H
|
#define EXAMPLE_TEST_H
|
||||||
#include "test.h"
|
|
||||||
#include "testutils.h"
|
#include <testcore/itest.h>
|
||||||
|
#include "testcore/testutils.h"
|
||||||
|
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
class ExampleTest: public Test, protected TestUtils
|
class ExampleTest: public testcore::ITest, protected testcore::TestUtils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExampleTest();
|
ExampleTest();
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
//#
|
|
||||||
//# Copyright (C) 2020-2023 QuasarApp.
|
|
||||||
//# Distributed under the GPLv3 software license, see the accompanying
|
|
||||||
//# Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
//# of this license document, but changing it is not allowed.
|
|
||||||
//#
|
|
||||||
|
|
||||||
|
|
||||||
#include "test.h"
|
|
@ -1,20 +0,0 @@
|
|||||||
//#
|
|
||||||
//# Copyright (C) 2020-2023 QuasarApp.
|
|
||||||
//# Distributed under the GPLv3 software license, see the accompanying
|
|
||||||
//# Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
//# of this license document, but changing it is not allowed.
|
|
||||||
//#
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef TEST_H
|
|
||||||
#define TEST_H
|
|
||||||
|
|
||||||
class Test
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Test() = default;
|
|
||||||
virtual ~Test() = default;
|
|
||||||
virtual void test() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TEST_H
|
|
Loading…
x
Reference in New Issue
Block a user