diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-02-11 01:10:07 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-15 20:47:32 +0100 |
commit | 394315d902d9068a53439737906c00d48023d182 (patch) | |
tree | 7d5d09f1b4386fefdbe702a33ab8e30e08739758 /tests/auto/gui | |
parent | c455674555b263c98fe613612babab3efcf10345 (diff) |
Move the removal of the Quit event to QWindow.
Change-Id: If524127ba9dab9ef065aaf4079294295eef8e49b
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 2fd875b7f4..8d0836e7c3 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -53,6 +53,7 @@ private slots: void focusObject(); void allWindows(); void topLevelWindows(); + void abortQuitOnShow(); }; class DummyWindow : public QWindow @@ -152,5 +153,44 @@ void tst_QGuiApplication::topLevelWindows() QCOMPARE(app.topLevelWindows().count(), 0); } +class ShowCloseShowWindow : public QWindow +{ + Q_OBJECT +public: + ShowCloseShowWindow(bool showAgain, QWindow *parent = 0) + : QWindow(parent), showAgain(showAgain) + { + QTimer::singleShot(0, this, SLOT(doClose())); + QTimer::singleShot(500, this, SLOT(exitApp())); + } + +private slots: + void doClose() { + close(); + if (showAgain) + show(); + } + + void exitApp() { + qApp->exit(1); + } + +private: + bool showAgain; +}; + +void tst_QGuiApplication::abortQuitOnShow() +{ + int argc = 0; + QGuiApplication app(argc, 0); + QWindow *window1 = new ShowCloseShowWindow(false); + window1->show(); + QCOMPARE(app.exec(), 0); + + QWindow *window2 = new ShowCloseShowWindow(true); + window2->show(); + QCOMPARE(app.exec(), 1); +} + QTEST_APPLESS_MAIN(tst_QGuiApplication) #include "tst_qguiapplication.moc" |