diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-20 16:12:25 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-20 16:12:25 (GMT) |
commit | 372af5d18bb85c41ce336f2bbf72b44646d8a79f (patch) | |
tree | 06c487f426fee92cf01eb8c1601ce44f99ee79ba /tests | |
parent | dfc61f6b59886f7d223722bf149342cdd46581a8 (diff) | |
parent | 83245ed872b6265d872a8ab0235c9dbd1f2daf4b (diff) | |
download | Qt-372af5d18bb85c41ce336f2bbf72b44646d8a79f.zip Qt-372af5d18bb85c41ce336f2bbf72b44646d8a79f.tar.gz Qt-372af5d18bb85c41ce336f2bbf72b44646d8a79f.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
Removed a change from the 4.7.0 change log.
Improve look and feel of itemviews on mac
doc: Fixed many broken links.
doc: Fixed many broken links.
update 4.7.0 changes
QPushButton's click area exceeds the button area by far on Mac OS X
QApplication::closeAllWindows() should ignore windows being closed
Examples: Fix compilation with namespace.
Use QApplication::arguments() to check for command line args
Added support for .rc files on VS2010.
Doc: Updating CSS and JS
Docs: added an intro for qml, Quick for Beginners.
Fix crash on exit in native wifi plugin on Vista+ when run in debugger.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qapplication/tst_qapplication.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 459ac2b..43fbba1 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -106,6 +106,7 @@ private slots: void lastWindowClosed(); void quitOnLastWindowClosed(); + void closeAllWindows(); void testDeleteLater(); void testDeleteLaterProcessEvents(); @@ -745,6 +746,83 @@ void tst_QApplication::quitOnLastWindowClosed() } } +class PromptOnCloseWidget : public QWidget +{ +public: + void closeEvent(QCloseEvent *event) + { + QMessageBox *messageBox = new QMessageBox(this); + messageBox->setWindowTitle("Unsaved data"); + messageBox->setText("Would you like to save or discard your current data?"); + messageBox->setStandardButtons(QMessageBox::Save|QMessageBox::Discard|QMessageBox::Cancel); + messageBox->setDefaultButton(QMessageBox::Save); + + messageBox->show(); + QTest::qWaitForWindowShown(messageBox); + + // verify that all windows are visible + foreach (QWidget *w, qApp->topLevelWidgets()) + QVERIFY(w->isVisible()); + // flush event queue + qApp->processEvents(); + // close all windows + qApp->closeAllWindows(); + + if (messageBox->standardButton(messageBox->clickedButton()) == QMessageBox::Cancel) + event->ignore(); + else + event->accept(); + + delete messageBox; + } +}; + +void tst_QApplication::closeAllWindows() +{ + int argc = 0; + QApplication app(argc, 0, QApplication::GuiServer); + + // create some windows + new QWidget; + new QWidget; + new QWidget; + + // show all windows + foreach (QWidget *w, app.topLevelWidgets()) { + w->show(); + QTest::qWaitForWindowShown(w); + } + // verify that they are visible + foreach (QWidget *w, app.topLevelWidgets()) + QVERIFY(w->isVisible()); + // empty event queue + app.processEvents(); + // close all windows + app.closeAllWindows(); + // all windows should no longer be visible + foreach (QWidget *w, app.topLevelWidgets()) + QVERIFY(!w->isVisible()); + + // add a window that prompts the user when closed + PromptOnCloseWidget *promptOnCloseWidget = new PromptOnCloseWidget; + // show all windows + foreach (QWidget *w, app.topLevelWidgets()) { + w->show(); + QTest::qWaitForWindowShown(w); + } + // close the last window to open the prompt (eventloop recurses) + promptOnCloseWidget->close(); + // all windows should not be visible, except the one that opened the prompt + foreach (QWidget *w, app.topLevelWidgets()) { + if (w == promptOnCloseWidget) + QVERIFY(w->isVisible()); + else + QVERIFY(!w->isVisible()); + } + + qDeleteAll(app.topLevelWidgets()); +} + bool isPathListIncluded(const QStringList &l, const QStringList &r) { int size = r.count(); |