Refactor tst_QDockWidget::closeAndDelete()

The test function was temporarily blacklisted on Ubuntu, but also
failing on other Linux platforms (e.g. openSuSE).

It tested, whether closing all dock widgets and the main window, would
close the application as well. It used one single shot timer, to close
the windows and later one to check, whether the application was shut
down.

While that mechanism must work in an application environment, it is not
guaranteed to work in testlib. More specifically, I could happen that
the XCB / glib event loop continued to spin and wait for events.

=> Check the signal QGuiApplication::lastWindowClosed() instead. If the
signal is fired, it is proven that all windows have been closed and
the application would quit in a production environment.

The underlying test case was: Application didn't quit with the last
dock widget closed, because there was a dangling
QDockWidgetGroupWindow.

=> finally: Clean up BLACKLIST

Pick-to: 6.5
Change-Id: Ic5fde5967fc8dde70ab64dc30cc7367c908b5c51
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 0b10b7476cf9d41086063ec49555425c6871041c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Axel Spoerl 2023-11-17 12:25:14 +01:00 committed by Qt Cherry-pick Bot
parent 9c9bb25c72
commit 3033e78033
2 changed files with 19 additions and 26 deletions

View File

@ -5,23 +5,22 @@ android
# QDockWidget::isFloating() is flaky after state change on these OS # QDockWidget::isFloating() is flaky after state change on these OS
[closeAndDelete] [closeAndDelete]
macos macos
[floatingTabs] b2qt
arm
android
# QTBUG-103091 # QTBUG-103091
[floatingTabs]
arm
android
qnx qnx
macos macos
[closeAndDelete]
b2qt b2qt
[floatingTabs]
macos b2qt arm android # QTBUG-103091
[closeAndDelete] [hoverWithoutDrop]
arm
android
qnx
macos
b2qt b2qt
[floatingTabs]
arm
[closeAndDelete]
macos b2qt arm android
[floatingTabs]
arm
[closeAndDelete]
android
[floatingTabs]
android

View File

@ -1529,7 +1529,6 @@ void tst_QDockWidget::closeAndDelete()
QSKIP("Test skipped on Wayland."); QSKIP("Test skipped on Wayland.");
#ifdef QT_BUILD_INTERNAL #ifdef QT_BUILD_INTERNAL
// Create a mainwindow with a central widget and two dock widgets // Create a mainwindow with a central widget and two dock widgets
QObject localContext;
QPointer<QDockWidget> d1; QPointer<QDockWidget> d1;
QPointer<QDockWidget> d2; QPointer<QDockWidget> d2;
QPointer<QWidget> cent; QPointer<QWidget> cent;
@ -1555,8 +1554,10 @@ void tst_QDockWidget::closeAndDelete()
qWarning("OS flakiness: D2 is docked and reports being floating"); qWarning("OS flakiness: D2 is docked and reports being floating");
// Close everything with a single shot. Expected behavior: Event loop stops // Close everything with a single shot. Expected behavior: Event loop stops
bool eventLoopStopped = true; QSignalSpy closeSpy(qApp, &QApplication::lastWindowClosed);
QTimer::singleShot(0, &localContext, [mainWindow, d1, d2] { QObject localContext;
QTimer::singleShot(0, &localContext, [&](){
mainWindow->close(); mainWindow->close();
QTRY_VERIFY(!mainWindow->isVisible()); QTRY_VERIFY(!mainWindow->isVisible());
QTRY_VERIFY(d1->isVisible()); QTRY_VERIFY(d1->isVisible());
@ -1565,19 +1566,12 @@ void tst_QDockWidget::closeAndDelete()
d2->close(); d2->close();
QTRY_VERIFY(!d1->isVisible()); QTRY_VERIFY(!d1->isVisible());
QTRY_VERIFY(!d2->isVisible()); QTRY_VERIFY(!d2->isVisible());
}); QTRY_COMPARE(closeSpy.count(), 1);
// Fallback timer to report event loop still running
QTimer::singleShot(100, &localContext, [&eventLoopStopped] {
qCDebug(lcTestDockWidget) << "Last dock widget hasn't shout down event loop!";
eventLoopStopped = false;
QApplication::quit(); QApplication::quit();
}); });
QApplication::exec(); QApplication::exec();
QTRY_VERIFY(eventLoopStopped);
// Check heap cleanup // Check heap cleanup
qCDebug(lcTestDockWidget) << "Deleting mainWindow"; qCDebug(lcTestDockWidget) << "Deleting mainWindow";
up_mainWindow.reset(); up_mainWindow.reset();