summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-09-18 13:52:24 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-09-20 19:00:05 +0200
commit6dc587dfdd2bad2bcf81b05266cc57a9b9accf7b (patch)
tree2eb21f6b516599f6c53c779aa959d325fe30ee7f /tests/auto/gui
parent8fcfd7f59136be08bb418b9f26910af8405faf13 (diff)
Un-blacklist quitOnLastWindowClosedMulti test on macOS in CI
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ø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/kernel/qguiapplication/BLACKLIST3
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp21
2 files changed, 11 insertions, 13 deletions
diff --git a/tests/auto/gui/kernel/qguiapplication/BLACKLIST b/tests/auto/gui/kernel/qguiapplication/BLACKLIST
index 58ca7bf782..e6ffe78ae3 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 c8fedbf8fc..e55fbf2137 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()