diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2024-02-21 12:51:49 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2024-02-22 16:54:25 +0100 |
commit | 576c9160b12ac5efc76d06ca7ccc856aad2b051a (patch) | |
tree | 004b5e0dd7118bae77e36e0946e4d656bcfaf28c /tests/auto/widgets/kernel/qapplication | |
parent | b697de79b041cd47e86b578a3a119fb3e7b62f71 (diff) |
Try to stabilize tst_QApplication::abortQuitOnShow
The test has been very flaky recently. A zero timer might be processed
before the window became visible, so only start closing once the window
has been shown.
Pick-to: 6.7 6.6
Change-Id: If7983723bb8abd2f3495fb21114c517289ebe8d9
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/widgets/kernel/qapplication')
-rw-r--r-- | tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 2d0758bfde..52fdc63e08 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -2574,10 +2574,22 @@ public: explicit ShowCloseShowWidget(bool showAgain, QWidget *parent = nullptr) : QWidget(parent), showAgain(showAgain) { - QTimer::singleShot(0, this, &ShowCloseShowWidget::doClose); QTimer::singleShot(500, this, [] () { QCoreApplication::exit(1); }); } + bool shown = false; + +protected: + void showEvent(QShowEvent *) override + { + QTimer::singleShot(0, this, &ShowCloseShowWidget::doClose); + shown = true; + } + void hideEvent(QHideEvent *) override + { + shown = false; + } + private slots: void doClose() { close(); @@ -2596,11 +2608,13 @@ void tst_QApplication::abortQuitOnShow() ShowCloseShowWidget window1(false); window1.setWindowTitle(QLatin1String(QTest::currentTestFunction())); window1.show(); + QVERIFY(QTest::qWaitFor([&window1](){ return window1.shown; })); QCOMPARE(QCoreApplication::exec(), 0); ShowCloseShowWidget window2(true); window2.setWindowTitle(QLatin1String(QTest::currentTestFunction())); window2.show(); + QVERIFY(QTest::qWaitFor([&window2](){ return window2.shown; })); QCOMPARE(QCoreApplication::exec(), 1); } |