diff options
Diffstat (limited to 'tests/auto')
-rwxr-xr-x | tests/auto/bic/gen.sh | 2 | ||||
-rw-r--r-- | tests/auto/bic/tst_bic.cpp | 12 | ||||
-rw-r--r-- | tests/auto/qapplication/tst_qapplication.cpp | 78 |
3 files changed, 88 insertions, 4 deletions
diff --git a/tests/auto/bic/gen.sh b/tests/auto/bic/gen.sh index 8005880..7bcad24 100755 --- a/tests/auto/bic/gen.sh +++ b/tests/auto/bic/gen.sh @@ -56,7 +56,7 @@ fi for module in $modules; do echo "#include <$module/$module>" >test.cpp - g++ -c -I$QTDIR/include -DQT_NO_STL -DQT3_SUPPORT -fdump-class-hierarchy test.cpp + ${CXX-g++} $CXXFLAGS -c -I$QTDIR/include -DQT_NO_STL -DQT3_SUPPORT -fdump-class-hierarchy test.cpp mv test.cpp*.class $module.$2.txt # Remove template classes from the output perl -pi -e '$skip = 1 if (/^(Class|Vtable).*</); diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index 400fcc1..504512d 100644 --- a/tests/auto/bic/tst_bic.cpp +++ b/tests/auto/bic/tst_bic.cpp @@ -178,13 +178,17 @@ void tst_Bic::sizesAndVTables_data() QSKIP("Test not implemented for this compiler/platform", SkipAll); #else -#if defined Q_OS_LINUX && defined Q_WS_X11 +#if defined(FILESUFFIX) + // cross-testing +#elif defined Q_OS_LINUX && defined Q_WS_X11 # if defined(__powerpc__) && !defined(__powerpc64__) # define FILESUFFIX "linux-gcc-ppc32" # elif defined(__amd64__) # define FILESUFFIX "linux-gcc-amd64" # elif defined(__i386__) # define FILESUFFIX "linux-gcc-ia32" +# elif defined(__ARMEL__) +# define FILESUFFIX "linux-gcc-armel" # endif #elif defined Q_OS_MAC && defined(__powerpc__) # define FILESUFFIX "macx-gcc-ppc32" @@ -233,9 +237,11 @@ QBic::Info tst_Bic::getCurrentInfo(const QString &libName) #ifdef Q_OS_WIN qtDir.replace('\\', '/'); #endif - QString compilerName = "g++"; + QString compilerName = QString::fromLocal8Bit(qgetenv("CXX")); + if (compilerName.isEmpty()) + compilerName = "g++"; - QStringList args; + QStringList args = QString::fromLocal8Bit(qgetenv("CXXFLAGS")).split(' '); args << "-c" << "-I" + qtDir + "/include" #ifdef Q_OS_MAC 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(); |