summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2020-03-31 16:43:54 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2020-04-03 17:05:27 +0300
commit274e973dbe696f89d56d5a78d73208e27c638a77 (patch)
tree755f0aca3ab36b32a0771c55bba4cd8a3dc6bf50 /tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
parent333d7e6de434fbe7777f948761ac5e7b5065d83f (diff)
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 <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp')
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp7
1 files changed, 7 insertions, 0 deletions
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<QObject*>("deleteLater");
QVERIFY(stillAlive);
+ wgt->show();
QCoreApplication::exec();
+ QVERIFY(wgt->isHidden());
delete wgt;
}