summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-09-03 15:07:21 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-09-16 14:24:00 +0200
commit0246bfd40a2cc5ea9cfc035146e6dd865b334c68 (patch)
tree1a8eb37fc4864d01336b44a3073830cb8f26665b /tests/auto/widgets/dialogs
parent8aa1fc6f12858ad6f786a4a971a5758fa28d3686 (diff)
Close QDialog via QWidget::close()
By going via QWidget::close() we ensure that if there's a QWidgetWindow backing the dialog (which is almost always the case), we will plumb down to QWindow::close(), resulting in QEvent::Close events to the QWindow. Since we don't want QDialog subclasses to receive a call to a closeEvent override that they didn't receive before (and which they might interpret as rejection or cancellation), install a temporary event filter that eats the QCloseEvent resulting from the call to close(). Task-number: QTBUG-53286 Change-Id: Ie8f6f0cb3160acfd5865dc74f0a7b6d87f838724 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/widgets/dialogs')
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
index 1dd053fa3f..a509f1135a 100644
--- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
+++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
@@ -615,7 +615,9 @@ void tst_QDialog::virtualsOnClose()
dialog.show();
QVERIFY(QTest::qWaitForWindowExposed(&dialog));
dialog.accept();
- QCOMPARE(dialog.closeEventCount, 0); // we only hide the dialog
+ // we used to only hide the dialog, and we still don't want a
+ // closeEvent call for application-triggered calls to QDialog::done
+ QCOMPARE(dialog.closeEventCount, 0);
QCOMPARE(dialog.acceptCount, 1);
QCOMPARE(dialog.rejectCount, 0);
QCOMPARE(dialog.doneCount, 1);
@@ -626,7 +628,7 @@ void tst_QDialog::virtualsOnClose()
dialog.show();
QVERIFY(QTest::qWaitForWindowExposed(&dialog));
dialog.reject();
- QCOMPARE(dialog.closeEventCount, 0); // we only hide the dialog
+ QCOMPARE(dialog.closeEventCount, 0);
QCOMPARE(dialog.acceptCount, 0);
QCOMPARE(dialog.rejectCount, 1);
QCOMPARE(dialog.doneCount, 1);