diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2024-02-02 12:32:37 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2024-02-08 15:40:04 +0100 |
commit | a61ac2ca58eb705021176720d481c0eb4c925c2a (patch) | |
tree | 1d2ec54e100b54f1dbe5de3102b30f756263b6d7 /tests/auto/cmake | |
parent | 95c20ffac3473f9188df363aebcb911589645806 (diff) |
CMake: Add test for configuring a standalone test
A standalone test is one that uses
find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
in its project code.
To ensure we don't accidentally regress this feature, test it as a
cmake test.
Also run test, this somewhat covers testing qt_internal_add_test.
Pick-to: 6.5 6.6 6.7
Change-Id: Ia9f27eef2bd7bd5bb57b96e553304924db252365
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/cmake')
-rw-r--r-- | tests/auto/cmake/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tests/auto/cmake/test_standalone_test/CMakeLists.txt | 14 | ||||
-rw-r--r-- | tests/auto/cmake/test_standalone_test/tst_standalone_test.cpp | 22 |
3 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 7152f820f5..25151ddbb1 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -339,6 +339,12 @@ if(is_qt_build_platform) set_tests_properties(test_import_plugins PROPERTIES FIXTURES_REQUIRED build_mockplugins) endif() +if(NOT NO_GUI) + _qt_internal_test_expect_pass(test_standalone_test + BINARY "${CMAKE_CTEST_COMMAND}" + BINARY_ARGS "-V") +endif() + _qt_internal_test_expect_pass(test_versionless_targets) if(NOT NO_GUI) diff --git a/tests/auto/cmake/test_standalone_test/CMakeLists.txt b/tests/auto/cmake/test_standalone_test/CMakeLists.txt new file mode 100644 index 0000000000..169d824c88 --- /dev/null +++ b/tests/auto/cmake/test_standalone_test/CMakeLists.txt @@ -0,0 +1,14 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(tststandalone_test LANGUAGES CXX) +find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) + +qt_internal_add_test(tst_standalone_test + GUI + SOURCES + tst_standalone_test.cpp + LIBRARIES + Qt::Gui +) diff --git a/tests/auto/cmake/test_standalone_test/tst_standalone_test.cpp b/tests/auto/cmake/test_standalone_test/tst_standalone_test.cpp new file mode 100644 index 0000000000..b9a7089218 --- /dev/null +++ b/tests/auto/cmake/test_standalone_test/tst_standalone_test.cpp @@ -0,0 +1,22 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include <QTest> +#include <QWindow> + +class tst_standalone_test : public QObject +{ + Q_OBJECT + +private slots: + void testLaunched() + { + QWindow w; + w.show(); + QVERIFY(QTest::qWaitForWindowActive(&w)); + } +}; + +QTEST_MAIN(tst_standalone_test) + +#include "tst_standalone_test.moc" |