summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp')
-rw-r--r--tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
index c7c9d3d359..5ae8eaf30d 100644
--- a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
+++ b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.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>
@@ -29,6 +29,8 @@ private slots:
void QTBUG_43548_initialColor();
void hexColor_data();
void hexColor();
+
+ void hideNativeByDestruction();
};
class TestNativeDialog : public QColorDialog
@@ -179,5 +181,32 @@ void tst_QColorDialog::hexColor()
QCOMPARE(color.name(QColor::HexRgb), expectedHexColor.toLower());
}
+void tst_QColorDialog::hideNativeByDestruction()
+{
+ QWidget window;
+ QWidget *child = new QWidget(&window);
+ QPointer<QColorDialog> dialog = new QColorDialog(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_QColorDialog)
#include "tst_qcolordialog.moc"