diff options
Diffstat (limited to 'tests/auto/cmake')
14 files changed, 231 insertions, 23 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index ff3edf922a..b95c530640 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -251,7 +251,9 @@ _qt_internal_test_expect_pass(test_add_resources_binary_generated BINARY test_add_resources_binary_generated) include(test_plugin_shared_static_flavor.cmake) -_qt_internal_test_expect_pass(test_init_resources_static_plugin - BINARY test_init_resources_static_plugin) _qt_internal_test_expect_pass(tst_qaddpreroutine BINARY tst_qaddpreroutine) + +_qt_internal_test_expect_pass(test_static_resources + BINARY "${CMAKE_CTEST_COMMAND}" + BINARY_ARGS "-V") diff --git a/tests/auto/cmake/test_static_resources/.cmake.conf b/tests/auto/cmake/test_static_resources/.cmake.conf new file mode 100644 index 0000000000..4e73b3d607 --- /dev/null +++ b/tests/auto/cmake/test_static_resources/.cmake.conf @@ -0,0 +1 @@ +set(QT_REPO_MODULE_VERSION "6.2.0") diff --git a/tests/auto/cmake/test_static_resources/CMakeLists.txt b/tests/auto/cmake/test_static_resources/CMakeLists.txt new file mode 100644 index 0000000000..06c7195625 --- /dev/null +++ b/tests/auto/cmake/test_static_resources/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.15.0) + +include(.cmake.conf) + +project(TestStaticResources + DESCRIPTION "Test of the static resources" + HOMEPAGE_URL "https://qt.io/" + LANGUAGES CXX C + VERSION "${QT_REPO_MODULE_VERSION}" +) + +find_package(Qt6 COMPONENTS Core BuildInternals Test CONFIG REQUIRED) +set(QT_NO_INTERNAL_COMPATIBILITY_FUNCTIONS TRUE) + +qt_build_repo_begin() + +enable_testing() +add_subdirectory(mock_static_resources1) +add_subdirectory(test_init_resources_static_plugin) +add_subdirectory(test_static_resources_propagation) + +qt_build_repo_end() diff --git a/tests/auto/cmake/test_static_resources/mock_static_resources1/CMakeLists.txt b/tests/auto/cmake/test_static_resources/mock_static_resources1/CMakeLists.txt new file mode 100644 index 0000000000..973f8b3279 --- /dev/null +++ b/tests/auto/cmake/test_static_resources/mock_static_resources1/CMakeLists.txt @@ -0,0 +1,17 @@ +qt_internal_add_module(MockStaticResources1 + STATIC + PLUGIN_TYPES mockstaticresources + SOURCES + dummy.cpp + LIBRARIES + Qt::CorePrivate + PUBLIC_LIBRARIES + Qt::Core +) + +qt_internal_add_resource(MockStaticResources1 "teststaticmodule1" + PREFIX + "/teststaticmodule1" + FILES + "testfile1.txt" +) diff --git a/tests/auto/cmake/test_static_resources/mock_static_resources1/configure.cmake b/tests/auto/cmake/test_static_resources/mock_static_resources1/configure.cmake new file mode 100644 index 0000000000..46da2db2b8 --- /dev/null +++ b/tests/auto/cmake/test_static_resources/mock_static_resources1/configure.cmake @@ -0,0 +1,2 @@ +# This is needed so that MODULE_PLUGIN_TYPES property is set on the exported target. +# Fun times. diff --git a/tests/auto/cmake/test_static_resources/mock_static_resources1/dummy.cpp b/tests/auto/cmake/test_static_resources/mock_static_resources1/dummy.cpp new file mode 100644 index 0000000000..47a48945a2 --- /dev/null +++ b/tests/auto/cmake/test_static_resources/mock_static_resources1/dummy.cpp @@ -0,0 +1,29 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +void dummy() { } diff --git a/tests/auto/cmake/test_init_resources_static_plugin/testfile1.txt b/tests/auto/cmake/test_static_resources/mock_static_resources1/testfile1.txt index e69de29bb2..e69de29bb2 100644 --- a/tests/auto/cmake/test_init_resources_static_plugin/testfile1.txt +++ b/tests/auto/cmake/test_static_resources/mock_static_resources1/testfile1.txt diff --git a/tests/auto/cmake/test_init_resources_static_plugin/CMakeLists.txt b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt index a0e40585e3..07ce26e052 100644 --- a/tests/auto/cmake/test_init_resources_static_plugin/CMakeLists.txt +++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt @@ -1,27 +1,7 @@ -cmake_minimum_required(VERSION 3.16) - -if(DEFINED CMAKE_Core_MODULE_MAJOR_VERSION) - set(project_version "${CMAKE_Core_MODULE_MAJOR_VERSION}.\ -${CMAKE_Core_MODULE_MINOR_VERSION}.${CMAKE_Core_MODULE_PATCH_VERSION}" - ) -else() - set(project_version "6.0.0") -endif() - -project(TestInitResourcesStaticPlugin - LANGUAGES CXX - VERSION "${project_version}" -) - -find_package(Qt6 COMPONENTS Core BuildInternals CONFIG REQUIRED) -qt_prepare_standalone_project() - -find_package(Qt6 COMPONENTS Gui Test CONFIG REQUIRED) # Add gui since Core have no plugin types - qt_internal_add_plugin(TestInitResourcesStaticPlugin STATIC OUTPUT_NAME testinitresourcesstaticplugin - TYPE generic + TYPE mockstaticresources SOURCES pluginmain.cpp SKIP_INSTALL diff --git a/tests/auto/cmake/test_init_resources_static_plugin/pluginmain.cpp b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/pluginmain.cpp index 992c948e55..992c948e55 100644 --- a/tests/auto/cmake/test_init_resources_static_plugin/pluginmain.cpp +++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/pluginmain.cpp diff --git a/tests/auto/cmake/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp index 73452258e4..73452258e4 100644 --- a/tests/auto/cmake/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp +++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp diff --git a/tests/auto/cmake/test_init_resources_static_plugin/testfile2.txt b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile1.txt index e69de29bb2..e69de29bb2 100644 --- a/tests/auto/cmake/test_init_resources_static_plugin/testfile2.txt +++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile1.txt diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile2.txt b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile2.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile2.txt diff --git a/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt new file mode 100644 index 0000000000..40c922fd8b --- /dev/null +++ b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt @@ -0,0 +1,96 @@ +# Add a dummy library that links the static "Qt" module containing resources +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" CONTENT "void dummy() { }") +add_library(dummy STATIC "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") +target_link_libraries(dummy PRIVATE MockStaticResources1) + + +# Add the executable using qt_add_executable that needs to initialize the propagated resources. +# Finalize it implicitly(since CMake version 3.19). +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19) + qt_add_executable(test_static_resources_propagation main.cpp) + set_target_properties(test_static_resources_propagation PROPERTIES + AUTOMOC TRUE + ) + target_link_libraries(test_static_resources_propagation + PRIVATE + dummy + Qt::Core + Qt::Test + ) + add_test(NAME test_static_resources_propagation + COMMAND test_static_resources_propagation + ) +endif() + + +# Add the executable using qt_add_executable that needs to initialize the propagated resources. +# Finalize it explicitly. +qt_add_executable(test_static_resources_propagation_manual_finalize main.cpp MANUAL_FINALIZATION) +set_target_properties(test_static_resources_propagation_manual_finalize PROPERTIES + AUTOMOC TRUE +) +target_link_libraries(test_static_resources_propagation_manual_finalize + PRIVATE + dummy + Qt::Core + Qt::Test +) +add_test(NAME test_static_resources_propagation_manual_finalize + COMMAND test_static_resources_propagation_manual_finalize +) +qt_finalize_target(test_static_resources_propagation_manual_finalize) + + +# Add the executable using add_executable that needs to initialize the propagated resources. +# Finalize it explicitly. +add_executable(test_static_resources_propagation_non_qt main.cpp) +set_target_properties(test_static_resources_propagation_non_qt PROPERTIES + AUTOMOC TRUE +) +target_link_libraries(test_static_resources_propagation_non_qt + PRIVATE + dummy + Qt::Core + Qt::Test +) +qt_finalize_target(test_static_resources_propagation_non_qt) +add_test(NAME test_static_resources_propagation_non_qt + COMMAND test_static_resources_propagation_non_qt +) + + +if(NOT GCC AND NOT MINGW AND NOT CLANG) + ## Add the executable using add_executable, expecting resources to be linked regardless of order. + add_executable(test_static_resources_propagation_non_ld main.cpp) + set_target_properties(test_static_resources_propagation_non_ld PROPERTIES + AUTOMOC TRUE + ) + target_link_libraries(test_static_resources_propagation_non_ld + PRIVATE + dummy + Qt::Core + Qt::Test + ) + add_test(NAME test_static_resources_propagation_non_ld + COMMAND test_static_resources_propagation_non_ld + ) + + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19) + qt_add_executable(test_static_resources_propagation_not_finalize main.cpp) + qt6_enable_resource_objects_finalizer_mode( + test_static_resources_propagation_not_finalize FALSE + ) + set_target_properties(test_static_resources_propagation_not_finalize PROPERTIES + AUTOMOC TRUE + ) + target_link_libraries(test_static_resources_propagation_not_finalize + PRIVATE + dummy + Qt::Core + Qt::Test + ) + add_test(NAME test_static_resources_propagation_not_finalize + COMMAND test_static_resources_propagation_not_finalize + ) + endif() +endif() diff --git a/tests/auto/cmake/test_static_resources/test_static_resources_propagation/main.cpp b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/main.cpp new file mode 100644 index 0000000000..4dee8eb0c7 --- /dev/null +++ b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QtCore/qfile.h> +#include <QtCore/qobject.h> +#include <QtPlugin> + +class TestStaticResourcePropagation : public QObject +{ + Q_OBJECT +private slots: + void resourceFilesExist(); +}; + +void TestStaticResourcePropagation::resourceFilesExist() +{ + bool result = QFile::exists(":/teststaticmodule1/testfile1.txt"); + QVERIFY(result); +} + +QTEST_MAIN(TestStaticResourcePropagation) +#include "main.moc" |