From 274e973dbe696f89d56d5a78d73208e27c638a77 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Tue, 31 Mar 2020 16:43:54 +0300 Subject: Fix flakiness in tst_QApplication::testDeleteLater DeleteLaterWidget is a main application window of the test. So, its show() function should be called explicitly before starting the main event loop. Otherwise, it remains hidden for the whole time, which causes an incorrect emission of QApplication::lastWindowClosed signal when a dialog window is closed in the middle of the test. Also, fix synchronization between deferred deletion and timer event. Change-Id: Id3ce5adbcd9e5e22508825c52025eeea70202354 Reviewed-by: Thiago Macieira --- tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 3debfd4231..28bf851d37 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -1229,6 +1229,11 @@ void DeleteLaterWidget::runTest() QCoreApplication::processEvents(); + // At this point, the event queue is empty. As we want a deferred + // deletion to occur before the timer event, we should provoke the + // event dispatcher for the next spin. + QCoreApplication::eventDispatcher()->interrupt(); + QVERIFY(!stillAlive); // verify at the end to make test terminate } @@ -1258,8 +1263,10 @@ void tst_QApplication::testDeleteLater() QObject *stillAlive = wgt->findChild("deleteLater"); QVERIFY(stillAlive); + wgt->show(); QCoreApplication::exec(); + QVERIFY(wgt->isHidden()); delete wgt; } -- cgit v1.2.3