From 6dc587dfdd2bad2bcf81b05266cc57a9b9accf7b Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sat, 18 Sep 2021 13:52:24 +0200 Subject: [PATCH] Un-blacklist quitOnLastWindowClosedMulti test on macOS in CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the recent refactoring in 28b14b966fe8535d7a81914b70759546b694e31b this test should run stable on all platforms. However, the way the test was written made it quite flaky. Simplify it to verify that closing one window doesn't prevent a second timer to fire (which it would if closing the first window already quit the application). Change-Id: I0306792cd7573ebd3418d1aabffe2b78700ec2d9 Reviewed-by: Tor Arne Vestbø --- .../auto/gui/kernel/qguiapplication/BLACKLIST | 3 --- .../qguiapplication/tst_qguiapplication.cpp | 21 ++++++++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/auto/gui/kernel/qguiapplication/BLACKLIST b/tests/auto/gui/kernel/qguiapplication/BLACKLIST index 58ca7bf7824..e6ffe78ae35 100644 --- a/tests/auto/gui/kernel/qguiapplication/BLACKLIST +++ b/tests/auto/gui/kernel/qguiapplication/BLACKLIST @@ -1,6 +1,3 @@ [focusObject] ubuntu-16.04 opensuse-42.3 - -[quitOnLastWindowClosedMulti] -macos ci diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index c8fedbf8fc7..e55fbf2137d 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -905,11 +905,7 @@ void tst_QGuiApplication::quitOnLastWindowClosedMulti() QGuiApplication app(argc, nullptr); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); - QTimer timer; - timer.setInterval(100); - QSignalSpy spyAboutToQuit(&app, &QCoreApplication::aboutToQuit); - QSignalSpy spyTimeout(&timer, &QTimer::timeout); QWindow mainWindow; mainWindow.setTitle(QStringLiteral("quitOnLastWindowClosedMultiMainWindow")); @@ -928,15 +924,20 @@ void tst_QGuiApplication::quitOnLastWindowClosedMulti() dialog.show(); QVERIFY(QTest::qWaitForWindowExposed(&dialog)); - timer.start(); - QTimer::singleShot(1000, &mainWindow, &QWindow::close); // This should not quit the application - QTimer::singleShot(2000, &app, &QCoreApplication::quit); + bool prematureQuit = true; + QTimer::singleShot(100, &mainWindow, [&]{ + prematureQuit = true; // this should be reset by the other timer + mainWindow.close(); + }); + QTimer::singleShot(500, &mainWindow, [&]{ + prematureQuit = false; // if we don't get here, then the app quit prematurely + dialog.close(); + }); app.exec(); - QCOMPARE(spyAboutToQuit.count(), 1); - // Should be around 20 if closing did not cause the quit - QVERIFY2(spyTimeout.count() > 15, QByteArray::number(spyTimeout.count()).constData()); + QVERIFY(!prematureQuit); + QCOMPARE(spyAboutToQuit.count(), 1); // fired only once } void tst_QGuiApplication::dontQuitOnLastWindowClosed()