summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs/qfontdialog
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/dialogs/qfontdialog')
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/CMakeLists.txt6
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp30
2 files changed, 35 insertions, 1 deletions
diff --git a/tests/auto/widgets/dialogs/qfontdialog/CMakeLists.txt b/tests/auto/widgets/dialogs/qfontdialog/CMakeLists.txt
index 796bf40ac5..b1bbf62cc7 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/CMakeLists.txt
+++ b/tests/auto/widgets/dialogs/qfontdialog/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qfontdialog Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qfontdialog LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Resources:
set_source_files_properties("../../../shared/resources/test.ttf"
PROPERTIES QT_RESOURCE_ALIAS "test.ttf"
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
index 0a77bc3808..01f3e7ec95 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -45,6 +45,7 @@ private slots:
void qtbug_41513_stylesheetStyle();
#endif
+ void hideNativeByDestruction();
private:
void runSlotWithFailsafeTimer(const char *member);
@@ -238,5 +239,32 @@ void tst_QFontDialog::testNonStandardFontSize()
qWarning("Fail using a non-standard font size.");
}
+void tst_QFontDialog::hideNativeByDestruction()
+{
+ QWidget window;
+ QWidget *child = new QWidget(&window);
+ QPointer<QFontDialog> dialog = new QFontDialog(child);
+ // Make it application modal so that we don't end up with a sheet on macOS
+ dialog->setWindowModality(Qt::ApplicationModal);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+ dialog->open();
+
+ // We test that the dialog opens and closes by watching the activation of the
+ // transient parent window. If it doesn't deactivate, then we have to skip.
+ const auto windowActive = [&window]{ return window.isActiveWindow(); };
+ const auto windowInactive = [&window]{ return !window.isActiveWindow(); };
+ if (!QTest::qWaitFor(windowInactive, 2000))
+ QSKIP("Dialog didn't activate");
+
+ // This should destroy the dialog and close the native window
+ child->deleteLater();
+ QTRY_VERIFY(!dialog);
+ // If the native window is still open, then the transient parent can't become
+ // active
+ window.activateWindow();
+ QVERIFY(QTest::qWaitFor(windowActive));
+}
+
QTEST_MAIN(tst_QFontDialog)
#include "tst_qfontdialog.moc"