diff options
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 28 |
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 823a52ce70..47ffee1501 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); @@ -10798,5 +10800,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" |