diff options
author | Dominik Holland <dominik.holland@qt.io> | 2021-06-25 14:51:53 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@qt.io> | 2021-06-30 13:57:41 +0200 |
commit | 649a75cd251c39aee7c8c5f69825ce9e64af32de (patch) | |
tree | 8723a06c13c51c8c1633920a450a185feaa57e45 | |
parent | cd088bb1b7c305e3455bc19a416d29c1cffc3b9e (diff) | |
download | qtapplicationmanager-649a75cd251c39aee7c8c5f69825ce9e64af32de.tar.gz |
Add support for running qml-only autotests
This adds a new qt_am_internal_add_qml_test function which takes care
to create the wrappers for all configurations we want to test.
Change-Id: I717cb5aff20ef5aa9ad156d9531a29c547f5d836
Reviewed-by: Robert Griebl <robert.griebl@qt.io>
20 files changed, 186 insertions, 56 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 00486023..c350b52f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,8 @@ find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS DltLogging ) +include(src/main-lib/Qt6AppManMainPrivateMacros.cmake) + if(NOT TARGET Qt::Gui OR NOT TARGET Qt::Quick) message(NOTICE "Skipping the build as QtGui and/or QtQuick are not available.") return() diff --git a/src/main-lib/Qt6AppManMainPrivateMacros.cmake b/src/main-lib/Qt6AppManMainPrivateMacros.cmake index e163ff34..7d3582b9 100644 --- a/src/main-lib/Qt6AppManMainPrivateMacros.cmake +++ b/src/main-lib/Qt6AppManMainPrivateMacros.cmake @@ -17,13 +17,17 @@ function(qt6_am_add_systemui_wrapper target) cmake_parse_arguments( PARSE_ARGV 1 ARG - "NO_INSTALL" "MAIN_QML_FILE" "CONFIG_YAML;EXTRA_FILES;EXTRA_ARGS" + "NO_INSTALL" "MAIN_QML_FILE;EXECUTABLE" "CONFIG_YAML;EXTRA_FILES;EXTRA_ARGS" ) file(CONFIGURE OUTPUT main.cpp CONTENT "int main(int, char *[]){}" ) + if (NOT ARG_EXECUTABLE) + set(ARG_EXECUTABLE "${QT_CMAKE_EXPORT_NAMESPACE}::appman") + endif() + set(CMD_ARGS) set(ALL_EXTRA_FILES) if (ARG_MAIN_QML_FILE) @@ -41,10 +45,14 @@ function(qt6_am_add_systemui_wrapper target) if (ARG_EXTRA_FILES) foreach(F ${ARG_EXTRA_FILES}) - file(GLOB_RECURSE MY_EXTRA_FILES - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - "${F}/*" - ) + if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${F}) + file(GLOB_RECURSE MY_EXTRA_FILES + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + "${F}/*" + ) + else() + set(MY_EXTRA_FILES ${F}) + endif() list(APPEND ALL_EXTRA_FILES ${MY_EXTRA_FILES}) foreach(B ${MY_EXTRA_FILES}) qt_am_internal_create_copy_command(${B}) @@ -74,7 +82,7 @@ if defined QT_PLUGIN_PATH ( ) else ( set QT_PLUGIN_PATH=${plugindir} ) -${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}/$<TARGET_FILE_NAME:${QT_CMAKE_EXPORT_NAMESPACE}::appman> ${CMD_ARGS_STR} ${CMD_EXTRA_ARGS_STR} ${ARG_MAIN_QML_FILE} %* +${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}/$<TARGET_FILE_NAME:${ARG_EXECUTABLE}> ${CMD_ARGS_STR} ${CMD_EXTRA_ARGS_STR} ${ARG_MAIN_QML_FILE} %* EndLocal " ) @@ -83,7 +91,7 @@ EndLocal set(WRAPPER_SCRIPT "_${target}${WRAPPER_SUFFIX}") file(GENERATE OUTPUT ${WRAPPER_SCRIPT} CONTENT "#!/bin/sh -exec ${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}/$<TARGET_FILE_NAME:${QT_CMAKE_EXPORT_NAMESPACE}::appman> ${CMD_ARGS_STR} ${CMD_EXTRA_ARGS_STR} ${ARG_MAIN_QML_FILE} \"$@\"; +exec ${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}/$<TARGET_FILE_NAME:${ARG_EXECUTABLE}> ${CMD_ARGS_STR} ${CMD_EXTRA_ARGS_STR} ${ARG_MAIN_QML_FILE} \"$@\"; " ) endif() @@ -126,3 +134,96 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) qt6_am_add_systemui_wrapper(${ARGV}) endfunction() endif() + +function (qt_am_internal_add_qml_test target) + cmake_parse_arguments( + PARSE_ARGV 1 + ARG + "" "TEST_FILE;TESTDATA_DIR" "CONFIG_YAML;EXTRA_FILES;CONFIGURATIONS" + ) + + if (NOT ARG_TEST_FILE) + message(FATAL_ERROR "TEST_FILE needs to be provided") + endif() + + if (NOT ARG_CONFIGURATIONS) + set(ARG_CONFIGURATIONS CONFIG NAME single-process ARGS --force-single-process) + + if (FEATURE_am_multi_process) + list(APPEND ARG_CONFIGURATIONS CONFIG NAME multi-process ARGS --force-multi-process) + endif() + endif() + + # Parse the CONFIGURATIONS arguments and split it into multiple configurations + # Each configuration needs to start with the CONFIG keyword + # Because cmake doesn't support nested lists, we create a string for every configuration + set(CONFIGS) + foreach(CONFIGURATION ${ARG_CONFIGURATIONS}) + if (CONFIGURATION STREQUAL "CONFIG") + list(JOIN CONFIG " " CONFIG_STR) + list(APPEND CONFIGS "${CONFIG_STR}") + set(CONFIG) + else() + list(APPEND CONFIG ${CONFIGURATION}) + endif() + endforeach() + list(JOIN CONFIG " " CONFIG_STR) + list(APPEND CONFIGS "${CONFIG_STR}") + + foreach(CONFIG ${CONFIGS}) + # Convert the configuration string back to a list of options + string(REPLACE " " ";" CONFIG ${CONFIG}) + cmake_parse_arguments( + CONFIG_ARG + "" "NAME;CONDITION" "ARGS" ${CONFIG} + ) + + if (NOT CONFIG_ARG_NAME) + message(FATAL_ERROR "CONFIGURATION needs to have a NAME") + endif() + + if (NOT CONFIG_ARG_CONDITION) + set(CONFIG_ARG_CONDITION ON) + endif() + + qt_evaluate_config_expression(result ${CONFIG_ARG_CONDITION}) + if (${result}) + set(WRAPPER_ARGS) + if (ARG_CONFIG_YAML) + list(APPEND WRAPPER_ARGS CONFIG_YAML ${ARG_CONFIG_YAML}) + endif() + + if (ARG_EXTRA_FILES) + list(APPEND WRAPPER_ARGS EXTRA_FILES ${ARG_EXTRA_FILES}) + endif() + + if (ARG_TESTDATA_DIR) + list(APPEND WRAPPER_ARGS EXTRA_ARGS "-o \'systemProperties: { public: { AM_TESTDATA_DIR: ${ARG_TESTDATA_DIR} } }'") + endif() + + list(APPEND WRAPPER_ARGS EXTRA_ARGS --no-cache --no-dlt-logging) + if (APPLE) + list(APPEND WRAPPER_ARGS EXTRA_ARGS --dbus=none) + endif() + + if (CONFIG_ARG_ARGS) + list(APPEND WRAPPER_ARGS EXTRA_ARGS ${CONFIG_ARG_ARGS} --) + else() + list(APPEND WRAPPER_ARGS EXTRA_ARGS --) + endif() + + qt6_am_add_systemui_wrapper(${target}_${CONFIG_ARG_NAME} + EXECUTABLE ${QT_CMAKE_EXPORT_NAMESPACE}::appman-qmltestrunner + MAIN_QML_FILE ${ARG_TEST_FILE} + NO_INSTALL + ${EXTRA_FILES_ARG_STR} + ${WRAPPER_ARGS} + ) + + qt_internal_add_test(${target}_${CONFIG_ARG_NAME} + ) + endif() + endforeach() + +endfunction() + diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index 1f6dcca8..66d5d849 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -10,7 +10,7 @@ add_subdirectory(main) add_subdirectory(packagecreator) add_subdirectory(packageextractor) add_subdirectory(packager-tool) -#add_subdirectory(qml) +add_subdirectory(qml) add_subdirectory(runtime) add_subdirectory(signature) add_subdirectory(utilities) diff --git a/tests/auto/qml/CMakeLists.txt b/tests/auto/qml/CMakeLists.txt index 73ee13fe..8e064d95 100644 --- a/tests/auto/qml/CMakeLists.txt +++ b/tests/auto/qml/CMakeLists.txt @@ -1,5 +1,12 @@ # Generated from qml.pro. +# Setup the test when called as a completely standalone project. +if(TARGET Qt6::Core) + # Tests are built as part of the qtsensors build tree. + # Setup paths so that the Qt packages are found. + qt_internal_set_up_build_dir_package_paths() +endif() + add_subdirectory(simple) add_subdirectory(windowmanager) add_subdirectory(windowmapping) diff --git a/tests/auto/qml/configs/CMakeLists.txt b/tests/auto/qml/configs/CMakeLists.txt index 8bc54456..4b630f3e 100644 --- a/tests/auto/qml/configs/CMakeLists.txt +++ b/tests/auto/qml/configs/CMakeLists.txt @@ -4,10 +4,16 @@ ## configs Binary: ##################################################################### -qt_internal_add_executable(configs - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_configs + CONFIG_YAML am-config.yaml + EXTRA_FILES apps am-config-nodbus.yaml + TEST_FILE tst_configs.qml + CONFIGURATIONS + CONFIG NAME single-process ARGS --force-single-process --single-app apps/test.configs.app/info.yaml + CONFIG NAME multi-process CONDITION FEATURE_am_multi_process ARGS --force-multi-process + CONFIG NAME no-dbus CONDITION FEATURE_am_multi_process ARGS -c am-config-nodbus.yaml --dbus none + CONFIG NAME single-app CONDITION FEATURE_am_multi_process ARGS --single-app apps/test.configs.app/info.yaml + CONFIG NAME no-installer CONDITION FEATURE_am_multi_process ARGS --disable-installer --wayland-socket-name wayland-am ) #### Keys ignored in scope 1:.:.:configs.pro:<TRUE>: diff --git a/tests/auto/qml/crash/CMakeLists.txt b/tests/auto/qml/crash/CMakeLists.txt index 2ba8b4a4..96bda205 100644 --- a/tests/auto/qml/crash/CMakeLists.txt +++ b/tests/auto/qml/crash/CMakeLists.txt @@ -4,10 +4,10 @@ ## crash Binary: ##################################################################### -qt_internal_add_executable(crash - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_crash + CONFIG_YAML am-config.yaml + TEST_FILE tst_crash.qml + MODE multi-process ) #### Keys ignored in scope 1:.:.:crash.pro:<TRUE>: diff --git a/tests/auto/qml/installer/CMakeLists.txt b/tests/auto/qml/installer/CMakeLists.txt index 6daf54ee..8e3d016c 100644 --- a/tests/auto/qml/installer/CMakeLists.txt +++ b/tests/auto/qml/installer/CMakeLists.txt @@ -4,10 +4,11 @@ ## installer Binary: ##################################################################### -qt_internal_add_executable(installer - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_installer + CONFIG_YAML am-config.yaml + EXTRA_FILES apps + TESTDATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../data + TEST_FILE tst_installer.qml ) #### Keys ignored in scope 1:.:.:installer.pro:<TRUE>: diff --git a/tests/auto/qml/intents/CMakeLists.txt b/tests/auto/qml/intents/CMakeLists.txt index 20543415..1bf67f22 100644 --- a/tests/auto/qml/intents/CMakeLists.txt +++ b/tests/auto/qml/intents/CMakeLists.txt @@ -4,10 +4,14 @@ ## intents Binary: ##################################################################### -qt_internal_add_executable(intents - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_intents + CONFIG_YAML am-config.yaml + EXTRA_FILES apps am-config-quick.yaml + TEST_FILE tst_intents.qml + CONFIGURATIONS + CONFIG NAME single-process ARGS --force-single-process + CONFIG NAME multi-process CONDITION FEATURE_am_multi_process ARGS --force-multi-process + CONFIG NAME config-quick CONDITION FEATURE_am_multi_process ARGS --force-multi-process -c am-config-quick.yaml ) #### Keys ignored in scope 1:.:.:intents.pro:<TRUE>: diff --git a/tests/auto/qml/lifecycle/CMakeLists.txt b/tests/auto/qml/lifecycle/CMakeLists.txt index 36b09f7c..fce5166b 100644 --- a/tests/auto/qml/lifecycle/CMakeLists.txt +++ b/tests/auto/qml/lifecycle/CMakeLists.txt @@ -4,10 +4,10 @@ ## lifecycle Binary: ##################################################################### -qt_internal_add_executable(lifecycle - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_lifecycle + CONFIG_YAML am-config.yaml + EXTRA_FILES apps + TEST_FILE tst_lifecycle.qml ) #### Keys ignored in scope 1:.:.:lifecycle.pro:<TRUE>: diff --git a/tests/auto/qml/processtitle/CMakeLists.txt b/tests/auto/qml/processtitle/CMakeLists.txt index 55cd61b9..4e02f2b0 100644 --- a/tests/auto/qml/processtitle/CMakeLists.txt +++ b/tests/auto/qml/processtitle/CMakeLists.txt @@ -4,10 +4,9 @@ ## processtitle Binary: ##################################################################### -qt_internal_add_executable(processtitle - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_processtitle + CONFIG_YAML am-config.yaml + TEST_FILE tst_processtitle.qml ) #### Keys ignored in scope 1:.:.:processtitle.pro:<TRUE>: diff --git a/tests/auto/qml/quicklaunch/CMakeLists.txt b/tests/auto/qml/quicklaunch/CMakeLists.txt index 9fcb8aeb..d6bffa0d 100644 --- a/tests/auto/qml/quicklaunch/CMakeLists.txt +++ b/tests/auto/qml/quicklaunch/CMakeLists.txt @@ -4,10 +4,10 @@ ## quicklaunch Binary: ##################################################################### -qt_internal_add_executable(quicklaunch - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_quicklaunch + CONFIG_YAML am-config.yaml + EXTRA_FILES apps + TEST_FILE tst_quicklaunch.qml ) #### Keys ignored in scope 1:.:.:quicklaunch.pro:<TRUE>: diff --git a/tests/auto/qml/resources/CMakeLists.txt b/tests/auto/qml/resources/CMakeLists.txt index 0893a7ac..631e776b 100644 --- a/tests/auto/qml/resources/CMakeLists.txt +++ b/tests/auto/qml/resources/CMakeLists.txt @@ -7,6 +7,8 @@ qt_internal_add_cmake_library(systemuiplugin MODULE OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + PUBLIC_LIBRARIES + Qt::Core ) # Resources: @@ -21,6 +23,13 @@ qt_internal_add_resource(systemuiplugin "systemuiplugin" ${systemuiplugin_resource_files} ) +qt_am_internal_add_qml_test(tst_resource + CONFIG_YAML am-config.yaml + EXTRA_FILES apps relative qml + TEST_FILE tst_resource.qml +) + +qt_add_binary_resources(systemuifile systemuifile.qrc) #### Keys ignored in scope 2:.:.:test.pro:<TRUE>: # AM_CONFIG = "am-config.yaml" diff --git a/tests/auto/qml/resources/appcommon/CMakeLists.txt b/tests/auto/qml/resources/appcommon/CMakeLists.txt index 45d12696..b433436e 100644 --- a/tests/auto/qml/resources/appcommon/CMakeLists.txt +++ b/tests/auto/qml/resources/appcommon/CMakeLists.txt @@ -1,2 +1,3 @@ # Generated from appcommon.pro. +qt_add_binary_resources(appcommonfile appcommonfile.qrc) diff --git a/tests/auto/qml/resources/apps/app1/CMakeLists.txt b/tests/auto/qml/resources/apps/app1/CMakeLists.txt index 7ff28b4a..769caf73 100644 --- a/tests/auto/qml/resources/apps/app1/CMakeLists.txt +++ b/tests/auto/qml/resources/apps/app1/CMakeLists.txt @@ -23,6 +23,7 @@ qt_internal_add_resource(app1plugin "app1plugin" ${app1plugin_resource_files} ) +qt_add_binary_resources(app1file app1file.qrc) #### Keys ignored in scope 1:.:.:app1.pro:<TRUE>: # OTHER_FILES = "info.yaml" "icon.png" diff --git a/tests/auto/qml/resources/apps/app2/CMakeLists.txt b/tests/auto/qml/resources/apps/app2/CMakeLists.txt index 03a5a5a1..94e5dcdc 100644 --- a/tests/auto/qml/resources/apps/app2/CMakeLists.txt +++ b/tests/auto/qml/resources/apps/app2/CMakeLists.txt @@ -1,2 +1,3 @@ # Generated from app2.pro. +qt_add_binary_resources(app2 app2.qrc) diff --git a/tests/auto/qml/simple/CMakeLists.txt b/tests/auto/qml/simple/CMakeLists.txt index 9e793676..09038451 100644 --- a/tests/auto/qml/simple/CMakeLists.txt +++ b/tests/auto/qml/simple/CMakeLists.txt @@ -4,10 +4,10 @@ ## simple Binary: ##################################################################### -qt_internal_add_executable(simple - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_simple + CONFIG_YAML am-config.yaml + EXTRA_FILES apps + TEST_FILE tst_applicationmanager.qml ) #### Keys ignored in scope 1:.:.:simple.pro:<TRUE>: diff --git a/tests/auto/qml/windowitem/CMakeLists.txt b/tests/auto/qml/windowitem/CMakeLists.txt index 271566ee..1d02e4ae 100644 --- a/tests/auto/qml/windowitem/CMakeLists.txt +++ b/tests/auto/qml/windowitem/CMakeLists.txt @@ -4,10 +4,10 @@ ## windowitem Binary: ##################################################################### -qt_internal_add_executable(windowitem - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_windowitem + CONFIG_YAML am-config.yaml + EXTRA_FILES apps + TEST_FILE tst_windowitem.qml ) #### Keys ignored in scope 1:.:.:windowitem.pro:<TRUE>: diff --git a/tests/auto/qml/windowitem2/CMakeLists.txt b/tests/auto/qml/windowitem2/CMakeLists.txt index 482405d9..0931d95c 100644 --- a/tests/auto/qml/windowitem2/CMakeLists.txt +++ b/tests/auto/qml/windowitem2/CMakeLists.txt @@ -4,10 +4,10 @@ ## windowitem2 Binary: ##################################################################### -qt_internal_add_executable(windowitem2 - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_windowitem2 + CONFIG_YAML am-config.yaml + EXTRA_FILES apps + TEST_FILE tst_windowitem2.qml ) #### Keys ignored in scope 1:.:.:windowitem2.pro:<TRUE>: diff --git a/tests/auto/qml/windowmanager/CMakeLists.txt b/tests/auto/qml/windowmanager/CMakeLists.txt index 4f0d2d91..ad0a1d2d 100644 --- a/tests/auto/qml/windowmanager/CMakeLists.txt +++ b/tests/auto/qml/windowmanager/CMakeLists.txt @@ -4,10 +4,8 @@ ## windowmanager Binary: ##################################################################### -qt_internal_add_executable(windowmanager - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_windowmanager + TEST_FILE tst_windowmanager.qml ) #### Keys ignored in scope 1:.:.:windowmanager.pro:<TRUE>: diff --git a/tests/auto/qml/windowmapping/CMakeLists.txt b/tests/auto/qml/windowmapping/CMakeLists.txt index d071c8e1..37ee39ec 100644 --- a/tests/auto/qml/windowmapping/CMakeLists.txt +++ b/tests/auto/qml/windowmapping/CMakeLists.txt @@ -4,10 +4,10 @@ ## windowmapping Binary: ##################################################################### -qt_internal_add_executable(windowmapping - GUI - PUBLIC_LIBRARIES - Qt::Gui +qt_am_internal_add_qml_test(tst_windowmapping + CONFIG_YAML am-config.yaml + EXTRA_FILES apps + TEST_FILE tst_windowmapping.qml ) #### Keys ignored in scope 1:.:.:windowmapping.pro:<TRUE>: |