diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2020-03-31 16:43:54 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2020-04-03 17:05:27 +0300 |
commit | 274e973dbe696f89d56d5a78d73208e27c638a77 (patch) | |
tree | 755f0aca3ab36b32a0771c55bba4cd8a3dc6bf50 /tests | |
parent | 333d7e6de434fbe7777f948761ac5e7b5065d83f (diff) | |
download | qtbase-274e973dbe696f89d56d5a78d73208e27c638a77.tar.gz |
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')
-rw-r--r-- | tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 7 |
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; } |