summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-05-02 13:15:15 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-05-02 13:15:15 +0200
commit7de400052f7df52095103f56f1cb753854be1af1 (patch)
tree823c01302efd5d2181a3b3a55eb2937e52c849b1 /tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
parent8b098e6544221a96bc6a41a6bfcc0dfa7cf805e6 (diff)
parent364bd6ca74b059ffe8ae367e1562645a3ed0855e (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp')
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index e1c4019fba..ff2d8fd191 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -401,6 +401,8 @@ private slots:
void tabletTracking();
+ void closeEvent();
+
private:
bool ensureScreenSize(int width, int height);
@@ -10808,5 +10810,31 @@ void tst_QWidget::tabletTracking()
QTRY_COMPARE(widget.moveEventCount, 3);
}
+class CloseCountingWidget : public QWidget
+{
+public:
+ int closeCount = 0;
+ void closeEvent(QCloseEvent *ev) override;
+};
+
+void CloseCountingWidget::closeEvent(QCloseEvent *ev)
+{
+ ++closeCount;
+ ev->accept();
+}
+
+void tst_QWidget::closeEvent()
+{
+ CloseCountingWidget widget;
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ // Yes we call the close() function twice. This mimics the behavior of QTBUG-43344 where
+ // QApplication first closes all windows and then QCocoaApplication flushes window system
+ // events, triggering more close events.
+ widget.windowHandle()->close();
+ widget.windowHandle()->close();
+ QCOMPARE(widget.closeCount, 1);
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"