1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 10:42:29 +01:00

Add QTests for ScreenPlay

This commit is contained in:
Elias Steurer 2021-08-14 13:39:36 +02:00
parent d2a67c292a
commit 77ed02cfc7
4 changed files with 130 additions and 77 deletions

View File

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

View File

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

View File

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

View File

@ -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 <QApplication>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QDebug>
#include <QDir>
#include <QGuiApplication>
#include <QtTest>
#include <QtWebEngine>
#define DOCTEST_CONFIG_IMPLEMENT
#define DOCTEST_CONFIG_SUPER_FAST_ASSERTS
#include <doctest/doctest.h>
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"