Initial commit

This commit is contained in:
Andrei Yankovich 2020-09-06 16:12:09 +03:00
commit 9b197a851d
17 changed files with 3141 additions and 0 deletions

54
.gitignore vendored Normal file
View File

@ -0,0 +1,54 @@
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.so.*
*.dll
*.dylib
# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
tests/build/
src/build/
*.qm
*.prl
# Qt unit tests
target_wrapper.*
# QtCreator
*.autosave
# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*
# QtCreator CMake
CMakeLists.txt.user*
# QtCreator 4.8< compilation database
compile_commands.json
# QtCreator local machine specific files for imported projects
*creator.user*

6
.gitmodules vendored Normal file
View File

@ -0,0 +1,6 @@
[submodule "CMake"]
path = CMake
url = https://github.com/QuasarApp/CMake.git
[submodule "DoxyStyle"]
path = DoxyStyle
url = https://github.com/QuasarApp/DoxyStyle.git

30
CMakeLists.txt Normal file
View File

@ -0,0 +1,30 @@
#
# Copyright (C) 2020-2020 QuasarApp.
# Distributed under the lgplv3 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.14)
project(RENAME_ME)
if(TARGET ${PROJECT_NAME})
message("The ${PROJECT_NAME} arledy included in main Project")
return()
endif()
find_package(Qt5 COMPONENTS Core Test QUIET)
include(CMake/ccache.cmake)
include(CMake/QuasarAppCITargets.cmake)
# Add sub directories
add_subdirectory(src)
if (EXISTS ${Qt5_DIR})
add_subdirectory(tests)
endif()
initAll()
addDoc(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf)

165
LICENSE Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

15
README.md Normal file
View File

@ -0,0 +1,15 @@
# CMakeProject
Template repository for cmake project
Fork me and replase RENAME_ME to Name of your new project.
1. Clone this repository
2. Run ./init.sh NewProjectName
# This template supports next build targets:
| Command or make target | Description |
|------|------|
| **make test** | The run tests for a project (dependet of Qt Tests, so you need to add Qt in Cmake using CMAKE_PREFIX_PATH) |
| **make doc** | The generate a documentation for a project (dependet of doxygen) |
| **make deploy** | The generate distribution for a project (dependet of CQtDeployer) |
| **make release** | The prepare Qt Installer framework repository for a project, generate a snap package and APK file for android (dependet of CQtDeployer, snapcraft, AndroidDeployer). |

2495
doxygen.conf Normal file

File diff suppressed because it is too large Load Diff

31
init.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
echo "Project name: $1"
if [ $# -ne 1 ]
then
echo "You call this script wtth wrong arguments."
echo "Example for start script:"
echo "./init.sh MyCmakeProject"
exit 1
fi
REPLACESTRING="s+RENAME_ME+$1+g"
echo $REPLACESTRING
find . -type f -exec sed -i $REPLACESTRING {} +
find . -type f -exec sed -i $REPLACESTRING {} +
#find . -type f -exec sed -i 's+http://example.com+https://example.com+g' {} +
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $path
done

44
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,44 @@
#
# Copyright (C) 2020-2020 QuasarApp.
# Distributed under the lgplv3 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.14)
include(../CMake/ProjectOut.cmake)
include(../CMake/Version.cmake)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-DRENAME_ME_LIBRARY)
find_package(Qt5 COMPONENTS Core REQUIRED)
file(GLOB SOURCE_CPP
"*.cpp" "*.qrc"
"src/*.cpp" "src/*.qrc"
"src/Private/*.cpp" "src/Private/*.qrc"
)
set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/Private")
add_library(${PROJECT_NAME} SHARED ${SOURCE_CPP})
target_link_libraries(${PROJECT_NAME} PUBLIC Qt5::Core)
target_include_directories(${PROJECT_NAME} PUBLIC ${PUBLIC_INCUDE_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${PRIVATE_INCUDE_DIR})
setVersion(0 0 1)

73
tests/.gitignore vendored Normal file
View File

@ -0,0 +1,73 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe

37
tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,37 @@
#
# Copyright (C) 2020-2020 QuasarApp.
# Distributed under the lgplv3 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.14)
set(CURRENT_PROJECT ${PROJECT_NAME}Test)
include(../CMake/ProjectOut.cmake)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
file(GLOB SOURCE_CPP
"*.cpp" "*.qrc"
"units/*.cpp" "units/*.qrc"
)
set(PUBLIC_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(PUBLIC_INCUDE_DIR ${PUBLIC_INCUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/units")
add_executable(${CURRENT_PROJECT} ${SOURCE_CPP})
target_link_libraries(${CURRENT_PROJECT} PRIVATE Qt5::Test)
target_include_directories(${CURRENT_PROJECT} PUBLIC ${PUBLIC_INCUDE_DIR})
include(../CMake/QuasarAppCITargets.cmake)
initTests()
addTests(${PROJECT_NAME} ${CURRENT_PROJECT})

77
tests/tstMain.cpp Normal file
View File

@ -0,0 +1,77 @@
#include <QtTest>
#include "exampletest.h"
/**
* @brief The tstMain class - this is main test class
*/
class tstMain : public QObject
{
Q_OBJECT
private:
QList<Test*> _tests;
public:
tstMain();
~tstMain();
private slots:
void initTestCase();
void unitTests();
};
/**
* @brief tstMain::tstMain
* init all availabel units for testsing
*/
tstMain::tstMain() {
// init xample unit test
_tests.push_back(new ExampleTest());
}
tstMain::~tstMain() {
}
/**
* @brief tstMain::initTestCase - this method contains initialization of the data tests.
*/
void tstMain::initTestCase() {
}
/**
* @brief tstMain::unitTests create application for testing
*/
void tstMain::unitTests() {
int argc =0;
char * argv[] = {nullptr};
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationName("testRENAME_ME");
QCoreApplication::setOrganizationName("QuasarApp");
auto path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QDir(path).removeRecursively();
QTimer::singleShot(0, [&app, this]() {
for (auto test : _tests ) {
test->test();
delete test;
}
app.exit(0);
});
app.exec();
}
QTEST_APPLESS_MAIN(tstMain)
#include "tstMain.moc"

View File

@ -0,0 +1,14 @@
#include "exampletest.h"
ExampleTest::ExampleTest() {
}
ExampleTest::~ExampleTest() {
}
void ExampleTest::test() {
QVERIFY(true);
}

18
tests/units/exampletest.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef EXAMPLE_TEST_H
#define EXAMPLE_TEST_H
#include "test.h"
#include "testutils.h"
#include <QtTest>
class ExampleTest: public Test, protected TestUtils
{
public:
ExampleTest();
~ExampleTest();
void test();
};
#endif // EXAMPLE_TEST_H

1
tests/units/test.cpp Normal file
View File

@ -0,0 +1 @@
#include "test.h"

12
tests/units/test.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef TEST_H
#define TEST_H
class Test
{
public:
Test() = default;
virtual ~Test() = default;
virtual void test() = 0;
};
#endif // TEST_H

45
tests/units/testutils.cpp Normal file
View File

@ -0,0 +1,45 @@
#include "testutils.h"
#include <QCoreApplication>
#include <QDateTime>
#include <QVariantMap>
bool TestUtils::funcPrivateConnect(const std::function<bool()> &requestFunc,
const std::function<bool()> &checkFunc,
const std::function<QMetaObject::Connection()> &connectFunction) const {
QMetaObject::Connection m_connection = connectFunction();
if (requestFunc && !requestFunc()) {
QObject::disconnect(m_connection);
return false;
}
bool return_value = TestUtils::wait(checkFunc, 10000);
QObject::disconnect(m_connection);
return return_value;
}
bool TestUtils::funcPrivateConnect(const std::function<bool ()> &requestFunc,
const std::function<bool ()> &checkFunc) const {
return funcPrivateConnect(requestFunc, checkFunc, [](){return QMetaObject::Connection();});
}
TestUtils::TestUtils()
{
}
TestUtils::~TestUtils() {
}
bool TestUtils::wait(const std::function<bool()> &forWait, int msec) const {
auto curmsec = QDateTime::currentMSecsSinceEpoch() + msec;
while (curmsec > QDateTime::currentMSecsSinceEpoch() && !forWait()) {
QCoreApplication::processEvents();
}
QCoreApplication::processEvents();
return forWait();
}

24
tests/units/testutils.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef TESTUTILS_H
#define TESTUTILS_H
#include "functional"
#include <QMetaObject>
class TestUtils
{
public:
TestUtils();
virtual ~TestUtils();
bool wait(const std::function<bool()> &forWait, int msec) const;
bool funcPrivateConnect(const std::function<bool ()> &requestFunc,
const std::function<bool ()> &checkFunc,
const std::function<QMetaObject::Connection ()> &connectFunction) const;
bool funcPrivateConnect(const std::function<bool ()> &requestFunc,
const std::function<bool ()> &checkFunc) const;
};
#endif // TESTUTILS_H