4
0
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
Some checks failed
buildbot/DocsGenerator Build finished.
buildbot/AndroidBuilder_v8Qt6 Build finished.
buildbot/LinuxCMakeBuilderQt6 Build finished.
buildbot/WindowsCMakeBuilder Build finished.
buildbot/IOSCMakeBuilder Build finished.

This commit is contained in:
Andrei Yankovich 2023-10-14 12:05:14 +02:00
parent ae3db6afc3
commit 8fef03dc1e
15 changed files with 116 additions and 42 deletions

1
.gitignore vendored
View File

@ -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

View File

@ -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)

View File

@ -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})

View File

@ -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

View File

@ -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"
} }

View 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")

View 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

View 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

View 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

View File

@ -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();
} }
}

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -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"

View File

@ -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