Android: add an appless test that recreates QGuiApplication
Make sure this works and doesn't cause any QJniEnvironment or other JNI object lifetime issues. Change-Id: I08b55982266dfb1821517449f6eb9f2796cea9b7 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
This commit is contained in:
parent
beeb531c32
commit
f419a8d67f
@ -3,6 +3,7 @@
|
||||
|
||||
if(ANDROID)
|
||||
add_subdirectory(android)
|
||||
add_subdirectory(android_appless)
|
||||
endif()
|
||||
if(WIN32)
|
||||
add_subdirectory(windows)
|
||||
|
19
tests/auto/corelib/platform/android_appless/CMakeLists.txt
Normal file
19
tests/auto/corelib/platform/android_appless/CMakeLists.txt
Normal file
@ -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
|
||||
)
|
@ -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 <QTest>
|
||||
#include <QTimer>
|
||||
#include <QGuiApplication>
|
||||
#include <QWindow>
|
||||
|
||||
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<char *>("tst_android_appless") };
|
||||
|
||||
|
||||
void tst_AndroidAppless::app_data()
|
||||
{
|
||||
QTest::addColumn<QString>("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"
|
||||
|
Loading…
Reference in New Issue
Block a user