diff --git a/tests/auto/corelib/platform/CMakeLists.txt b/tests/auto/corelib/platform/CMakeLists.txt index 5f127f4e91..3455736eab 100644 --- a/tests/auto/corelib/platform/CMakeLists.txt +++ b/tests/auto/corelib/platform/CMakeLists.txt @@ -3,6 +3,7 @@ if(ANDROID) add_subdirectory(android) + add_subdirectory(android_appless) endif() if(WIN32) add_subdirectory(windows) diff --git a/tests/auto/corelib/platform/android_appless/CMakeLists.txt b/tests/auto/corelib/platform/android_appless/CMakeLists.txt new file mode 100644 index 0000000000..bcb7024b29 --- /dev/null +++ b/tests/auto/corelib/platform/android_appless/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## tst_android_appless Test: +##################################################################### + +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_android_appless LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + +qt_internal_add_test(tst_android_appless + SOURCES + tst_android_appless.cpp + LIBRARIES + Qt::Gui +) diff --git a/tests/auto/corelib/platform/android_appless/tst_android_appless.cpp b/tests/auto/corelib/platform/android_appless/tst_android_appless.cpp new file mode 100644 index 0000000000..19d7d2f4bb --- /dev/null +++ b/tests/auto/corelib/platform/android_appless/tst_android_appless.cpp @@ -0,0 +1,53 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include +#include +#include +#include + +using namespace Qt::StringLiterals; + +class tst_AndroidAppless : public QObject +{ + Q_OBJECT +private slots: + void app_data(); + void app(); + +}; + +#define CREATE_DUMMY_ARGC_ARGV() \ + int argc = 1; \ + char *argv[] = { const_cast("tst_android_appless") }; + + +void tst_AndroidAppless::app_data() +{ + QTest::addColumn("displayName"); + QTest::addRow("one") << "The first QGuiApplication instance"; + QTest::addRow("two") << "The second QGuiApplication instance"; +} + +void tst_AndroidAppless::app() +{ + QFETCH(const QString, displayName); + CREATE_DUMMY_ARGC_ARGV() + + QGuiApplication app(argc, argv); + app.setApplicationDisplayName(displayName); + + QWindow window; + window.show(); + + QTimer::singleShot(1000, &app, QGuiApplication::quit); + + window.show(); + app.exec(); +} + +#undef CREATE_DUMMY_ARGC_ARGV + +QTEST_APPLESS_MAIN(tst_AndroidAppless) +#include "tst_android_appless.moc" +