diff --git a/CMakeLists.txt b/CMakeLists.txt index b95c9077..212d729c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(SCREENPLAY_STEAM ON) +set(TESTS_ENABLED OFF) file(MAKE_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) @@ -21,6 +22,11 @@ elseif(APPLE) set(VCPKG_ARCH "x64-osx") endif() +if(${TESTS_ENABLED}) + enable_testing() +endif() + + set(VCPKG_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ScreenPlay-vcpkg") set(VCPKG_INSTALLED_PATH "${VCPKG_PATH}/installed/${VCPKG_ARCH}") diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 9f5cf5c8..667b9942 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -14,7 +14,6 @@ find_package(CURL CONFIG REQUIRED) find_package(sentry CONFIG REQUIRED) set(src - main.cpp app.cpp src/globalvariables.cpp src/createimportvideo.cpp @@ -67,87 +66,57 @@ find_package(Threads REQUIRED) set_source_files_properties(${l10n} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/translations") -if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - find_package( - Qt${QT_VERSION_MAJOR} - COMPONENTS Core - Quick - Gui - Widgets - WebSockets - Svg - WebEngineCore - WebEngineQuick - WebChannel - Positioning - LinguistTools) - if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - qt_add_resources(qml qml.qrc assets.qrc) - else() - qtquick_compiler_add_resources(qml qml.qrc assets.qrc) - endif() +find_package( + Qt${QT_VERSION_MAJOR} + COMPONENTS Core + Quick + Gui + Widgets + WebSockets + Svg + LinguistTools + WebEngine + QuickCompiler + Test) - add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml} ${fonts}) - - target_link_libraries( - ${PROJECT_NAME} - PRIVATE ScreenPlaySDK - ScreenPlayUtil - benchmark::benchmark - benchmark::benchmark_main - doctest::doctest - sentry::sentry - Threads::Threads - Qt${QT_VERSION_MAJOR}::Quick - Qt${QT_VERSION_MAJOR}::Gui - Qt${QT_VERSION_MAJOR}::Widgets - Qt${QT_VERSION_MAJOR}::Core - Qt${QT_VERSION_MAJOR}::WebSockets - Qt${QT_VERSION_MAJOR}::Svg - Qt6::WebEngineCore - Qt6::WebEngineQuick) - qt_add_translation(qmFiles ${l10n}) +if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + qt_add_resources(resources ScreenPlayAssets.qrc ScreenPlayQML.qrc) else() - find_package( - Qt${QT_VERSION_MAJOR} - COMPONENTS Core - Quick - Gui - Widgets - WebSockets - Svg - LinguistTools - WebEngine - QuickCompiler) - - if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - qt_add_resources(qml qml.qrc assets.qrc) - else() - qtquick_compiler_add_resources(qml qml.qrc assets.qrc) - endif() - - add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml} ${fonts}) - - target_link_libraries( - ${PROJECT_NAME} - PRIVATE ScreenPlaySDK - ScreenPlayUtil - benchmark::benchmark - benchmark::benchmark_main - doctest::doctest - sentry::sentry - Threads::Threads - Qt${QT_VERSION_MAJOR}::Quick - Qt${QT_VERSION_MAJOR}::Gui - Qt${QT_VERSION_MAJOR}::Widgets - Qt${QT_VERSION_MAJOR}::Core - Qt${QT_VERSION_MAJOR}::WebSockets - Qt${QT_VERSION_MAJOR}::Svg - Qt5::WebEngine) - qt5_add_translation(qmFiles ${l10n}) + qtquick_compiler_add_resources(resources ScreenPlayAssets.qrc ScreenPlayQML.qrc) endif() +add_library(ScreenPlayLib ${src} ${headers} ${resources} ${resources} ${fonts}) + +target_include_directories(ScreenPlayLib PUBLIC ./ src/ ) + + +target_link_libraries( + ScreenPlayLib + PUBLIC ScreenPlaySDK + ScreenPlayUtil + benchmark::benchmark + benchmark::benchmark_main + doctest::doctest + sentry::sentry + Threads::Threads + Qt${QT_VERSION_MAJOR}::Quick + Qt${QT_VERSION_MAJOR}::Gui + Qt${QT_VERSION_MAJOR}::Widgets + Qt${QT_VERSION_MAJOR}::Core + Qt${QT_VERSION_MAJOR}::WebSockets + Qt${QT_VERSION_MAJOR}::Svg + Qt5::WebEngine) + +add_executable(tst_ScreenPlay tests/tst_main.cpp) +target_link_libraries(tst_ScreenPlay PRIVATE ScreenPlayLib Qt5::Test) + +add_executable(${PROJECT_NAME} main.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE ScreenPlayLib) + +qt5_add_translation(qmFiles ${l10n}) + + qt_add_big_resources(fonts fonts.qrc) target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}") diff --git a/ScreenPlay/main.cpp b/ScreenPlay/main.cpp index 074f0453..b276d98f 100644 --- a/ScreenPlay/main.cpp +++ b/ScreenPlay/main.cpp @@ -44,6 +44,9 @@ int main(int argc, char* argv[]) { + Q_INIT_RESOURCE(ScreenPlayQML); + Q_INIT_RESOURCE(ScreenPlayAssets); + QtWebEngine::initialize(); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); diff --git a/ScreenPlay/tests/tst_main.cpp b/ScreenPlay/tests/tst_main.cpp new file mode 100644 index 00000000..52e1cc61 --- /dev/null +++ b/ScreenPlay/tests/tst_main.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Elias Steurer (Kelteseth) +** Contact: https://screen-play.app +** +** This file is part of ScreenPlay. ScreenPlay is licensed under a dual license in +** order to ensure its sustainability. When you contribute to ScreenPlay +** you accept that your work will be available under the two following licenses: +** +** $SCREENPLAY_BEGIN_LICENSE$ +** +** #### Affero General Public License Usage (AGPLv3) +** Alternatively, this file may be used under the terms of the GNU Affero +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file "ScreenPlay License.md" included in the +** packaging of this App. Please review the following information to +** ensure the GNU Affero Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/agpl-3.0.en.html. +** +** #### Commercial License +** This code is owned by Elias Steurer. By changing/adding to the code you agree to the +** terms written in: +** * Legal/corporate_contributor_license_agreement.md - For corporate contributors +** * Legal/individual_contributor_license_agreement.md - For individual contributors +** +** #### Additional Limitations to the AGPLv3 and Commercial Lincese +** This License does not grant any rights in the trademarks, +** service marks, or logos. +** +** +** $SCREENPLAY_END_LICENSE$ +** +****************************************************************************/ + +#include "app.h" +#include +#include +#include +#include +#include +#include +#include +#include +#define DOCTEST_CONFIG_IMPLEMENT +#define DOCTEST_CONFIG_SUPER_FAST_ASSERTS +#include + +class ScreenPlayTest : public QObject { + Q_OBJECT + +private slots: + void main_test(); + +private: + QQuickWindow* m_window = nullptr; +}; + +void ScreenPlayTest::main_test() +{ + Q_INIT_RESOURCE(ScreenPlayQML); + Q_INIT_RESOURCE(ScreenPlayAssets); + +// QtWebEngine::initialize(); +// QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +// QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + + ScreenPlay::App app; + app.init(); + + QTest::qWait(10000); +} + +QTEST_MAIN(ScreenPlayTest) + +#include "tst_main.moc"