mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Add QTests for ScreenPlay
This commit is contained in:
parent
d2a67c292a
commit
77ed02cfc7
@ -8,6 +8,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
set(SCREENPLAY_STEAM ON)
|
set(SCREENPLAY_STEAM ON)
|
||||||
|
set(TESTS_ENABLED OFF)
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
|
file(MAKE_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
|
||||||
|
|
||||||
@ -21,6 +22,11 @@ elseif(APPLE)
|
|||||||
set(VCPKG_ARCH "x64-osx")
|
set(VCPKG_ARCH "x64-osx")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(${TESTS_ENABLED})
|
||||||
|
enable_testing()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
set(VCPKG_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ScreenPlay-vcpkg")
|
set(VCPKG_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ScreenPlay-vcpkg")
|
||||||
set(VCPKG_INSTALLED_PATH "${VCPKG_PATH}/installed/${VCPKG_ARCH}")
|
set(VCPKG_INSTALLED_PATH "${VCPKG_PATH}/installed/${VCPKG_ARCH}")
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ find_package(CURL CONFIG REQUIRED)
|
|||||||
find_package(sentry CONFIG REQUIRED)
|
find_package(sentry CONFIG REQUIRED)
|
||||||
|
|
||||||
set(src
|
set(src
|
||||||
main.cpp
|
|
||||||
app.cpp
|
app.cpp
|
||||||
src/globalvariables.cpp
|
src/globalvariables.cpp
|
||||||
src/createimportvideo.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")
|
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")
|
find_package(
|
||||||
qt_add_resources(qml qml.qrc assets.qrc)
|
Qt${QT_VERSION_MAJOR}
|
||||||
else()
|
COMPONENTS Core
|
||||||
qtquick_compiler_add_resources(qml qml.qrc assets.qrc)
|
Quick
|
||||||
endif()
|
Gui
|
||||||
|
Widgets
|
||||||
|
WebSockets
|
||||||
|
Svg
|
||||||
|
LinguistTools
|
||||||
|
WebEngine
|
||||||
|
QuickCompiler
|
||||||
|
Test)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml} ${fonts})
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||||
|
qt_add_resources(resources ScreenPlayAssets.qrc ScreenPlayQML.qrc)
|
||||||
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})
|
|
||||||
else()
|
else()
|
||||||
find_package(
|
qtquick_compiler_add_resources(resources ScreenPlayAssets.qrc ScreenPlayQML.qrc)
|
||||||
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})
|
|
||||||
endif()
|
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)
|
qt_add_big_resources(fonts fonts.qrc)
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}")
|
target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}")
|
||||||
|
@ -44,6 +44,9 @@
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
Q_INIT_RESOURCE(ScreenPlayQML);
|
||||||
|
Q_INIT_RESOURCE(ScreenPlayAssets);
|
||||||
|
|
||||||
QtWebEngine::initialize();
|
QtWebEngine::initialize();
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||||
|
75
ScreenPlay/tests/tst_main.cpp
Normal file
75
ScreenPlay/tests/tst_main.cpp
Normal 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"
|
Loading…
Reference in New Issue
Block a user