diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2011-01-27 10:49:49 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2011-01-27 13:57:43 (GMT) |
commit | 2e72a8b19ea6c674fb4777860dac50faa5d387e6 (patch) | |
tree | e5c684f88671eee9a09a83e7374c1227d7d577ac /tests/auto/qcoreapplication | |
parent | bd6c9225328b6042ff14dfddb28e2e1279ba0e46 (diff) | |
download | Qt-2e72a8b19ea6c674fb4777860dac50faa5d387e6.zip Qt-2e72a8b19ea6c674fb4777860dac50faa5d387e6.tar.gz Qt-2e72a8b19ea6c674fb4777860dac50faa5d387e6.tar.bz2 |
Restore Qt 4.6 behaviour: exec() always enters the event loop.
In Qt 4.6 as well as 4.7's QCoreApplication and QEventLoop, calling
exec() always enters the event loop, even if you had tried to
quit()/exit() it before entering, with one exception (noted in the
unit tests; this difference has been in Qt since at least Qt 4.2).
Add unit tests to ensure all of the three classes have the same
behaviour.
Decide if we want to match the behaviours in Qt 4.8.
Reviewed-by: Bradley T. Hughes
Diffstat (limited to 'tests/auto/qcoreapplication')
-rw-r--r-- | tests/auto/qcoreapplication/tst_qcoreapplication.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp index 95055d1..bc69461 100644 --- a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp @@ -59,6 +59,9 @@ private slots: void applicationPid(); void globalPostedEventsCount(); void processEventsAlwaysSendsPostedEvents(); + void reexec(); + void execAfterExit(); + void eventLoopExecAfterExit(); }; class EventSpy : public QObject @@ -524,5 +527,47 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() } while (t.elapsed() < 3000); } +void tst_QCoreApplication::reexec() +{ + int argc = 1; + char *argv[] = { "tst_qcoreapplication" }; + QCoreApplication app(argc, argv); + + // exec once + QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); + QCOMPARE(app.exec(), 0); + + // and again + QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); + QCOMPARE(app.exec(), 0); +} + +void tst_QCoreApplication::execAfterExit() +{ + int argc = 1; + char *argv[] = { "tst_qcoreapplication" }; + QCoreApplication app(argc, argv); + + app.exit(1); + QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); + QCOMPARE(app.exec(), 0); +} + +void tst_QCoreApplication::eventLoopExecAfterExit() +{ + int argc = 1; + char *argv[] = { "tst_qcoreapplication" }; + QCoreApplication app(argc, argv); + + // exec once and exit + QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection); + QCOMPARE(app.exec(), 0); + + // and again, but this time using a QEventLoop + QEventLoop loop; + QMetaObject::invokeMethod(&loop, "quit", Qt::QueuedConnection); + QCOMPARE(loop.exec(), 0); +} + QTEST_APPLESS_MAIN(tst_QCoreApplication) #include "tst_qcoreapplication.moc" |