diff options
Diffstat (limited to 'tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp')
-rw-r--r-- | tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 6b8700f580..d1a50e3d69 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -1004,8 +1004,8 @@ void tst_QGuiApplication::quitOnLastWindowClosedWithEventLoopLocker() }); { - // Disabling QEventLoopLocker support should not affect - // quitting when last window is closed. + // Disabling QEventLoopLocker automatic quit should not affect + // quitting when last window is closed if there are no lockers. app.setQuitLockEnabled(false); QuitSpy quitSpy; @@ -1019,8 +1019,40 @@ void tst_QGuiApplication::quitOnLastWindowClosedWithEventLoopLocker() } { - // Disabling quitOnLastWindowClosed support should not affect - // quitting when last QEventLoopLocker goes out of scope. + // Disabling QEventLoopLocker automatic quit should still block + // quitting when last window is closed if there is a locker alive. + app.setQuitLockEnabled(false); + + QScopedPointer<QEventLoopLocker> locker(new QEventLoopLocker); + + QuitSpy quitSpy; + QWindow window; + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + QTimer::singleShot(0, &window, &QWindow::close); + QTimer::singleShot(200, &app, []{ QCoreApplication::exit(0); }); + app.exec(); + QCOMPARE(quitSpy.quits, 0); + } + + { + // Disabling quitOnLastWindowClosed automatic quit should not affect + // quitting when last QEventLoopLocker goes out of scope if + // there are no windows. + app.setQuitLockEnabled(true); + app.setQuitOnLastWindowClosed(false); + + QuitSpy quitSpy; + QScopedPointer<QEventLoopLocker> locker(new QEventLoopLocker); + QTimer::singleShot(0, [&]{ locker.reset(nullptr); }); + QTimer::singleShot(200, &app, []{ QCoreApplication::exit(0); }); + app.exec(); + QCOMPARE(quitSpy.quits, 1); + } + + { + // Disabling quitOnLastWindowClosed automatic quit should still block + // quitting via QEventLoopLocker if there's a window alive. app.setQuitLockEnabled(true); app.setQuitOnLastWindowClosed(false); @@ -1032,7 +1064,7 @@ void tst_QGuiApplication::quitOnLastWindowClosedWithEventLoopLocker() QTimer::singleShot(0, [&]{ locker.reset(nullptr); }); QTimer::singleShot(200, &app, []{ QCoreApplication::exit(0); }); app.exec(); - QCOMPARE(quitSpy.quits, 1); + QCOMPARE(quitSpy.quits, 0); } { |