summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp66
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h1
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp2
3 files changed, 68 insertions, 1 deletions
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
index a0f24b735c..e4036341fd 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
@@ -617,6 +617,72 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents()
} while (t.elapsed() < 1000);
}
+class QuitBlocker : public QObject
+{
+ Q_OBJECT
+
+public:
+ bool eventFilter(QObject *, QEvent *event)
+ {
+ if (event->type() == QEvent::Quit) {
+ event->ignore();
+ return true;
+ }
+
+ return false;
+ }
+};
+
+void tst_QCoreApplication::quit()
+{
+ TestApplication::quit(); // Should not do anything
+
+ {
+ int argc = 1;
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
+ TestApplication app(argc, argv);
+
+ EventSpy spy;
+ app.installEventFilter(&spy);
+
+ {
+ QTimer::singleShot(0, &app, SLOT(quit()));
+ app.exec();
+ QVERIFY(spy.recordedEvents.contains(QEvent::Quit));
+ }
+
+ spy.recordedEvents.clear();
+
+ {
+ QTimer::singleShot(0, qApp, SLOT(quit()));
+ app.exec();
+ QVERIFY(spy.recordedEvents.contains(QEvent::Quit));
+ }
+
+ spy.recordedEvents.clear();
+
+ {
+ QTimer::singleShot(0, [&]{ TestApplication::quit(); });
+ app.exec();
+ QVERIFY(spy.recordedEvents.contains(QEvent::Quit));
+ }
+
+ spy.recordedEvents.clear();
+
+ {
+ QuitBlocker quitBlocker;
+ app.installEventFilter(&quitBlocker);
+
+ QTimer::singleShot(0, [&]{ TestApplication::quit(); });
+ QTimer::singleShot(200, [&]{ TestApplication::exit(); });
+ app.exec();
+ QVERIFY(!spy.recordedEvents.contains(QEvent::Quit));
+ }
+ }
+
+ TestApplication::quit(); // Should not do anything
+}
+
void tst_QCoreApplication::reexec()
{
int argc = 1;
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
index 2a23cf0751..b8475fd8c2 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
@@ -49,6 +49,7 @@ private slots:
void applicationPid();
void globalPostedEventsCount();
void processEventsAlwaysSendsPostedEvents();
+ void quit();
void reexec();
void execAfterExit();
void eventLoopExecAfterExit();
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 0ba42c0e36..e8fd5b49cd 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -675,7 +675,7 @@ void tst_QApplication::quitOnLastWindowClosed()
bool quitApplicationTriggered = false;
auto quitSlot = [&quitApplicationTriggered] () {
quitApplicationTriggered = true;
- QCoreApplication::quit();
+ QCoreApplication::exit();
};
{