diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-05-31 10:09:41 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-19 07:33:51 (GMT) |
commit | b1d6a93e4b0398a573add4a1eb0b6b924cc804bc (patch) | |
tree | b68e17754a603b0f2477f5b3132bf3326831c6ad | |
parent | b6505dcee680ec6894c3e08e954e970dc4a3b965 (diff) | |
download | Qt-b1d6a93e4b0398a573add4a1eb0b6b924cc804bc.zip Qt-b1d6a93e4b0398a573add4a1eb0b6b924cc804bc.tar.gz Qt-b1d6a93e4b0398a573add4a1eb0b6b924cc804bc.tar.bz2 |
Fix QApplication test for desktop.
- Set the working directory such that the binaries are found:
Mac: disable app-bundle
Windows: cd up if we are in a debug, release folder
- Suppress the debug/release folder for the wincmdline process,
make it a simple console app.
- Print proper message if process launch fails.
- Restrict insignification to qws/embedded due to an
exit crash. Expect-fail focus test on Mac.
Task-number: QTQAINFRA-428
Change-Id: I3aaa9c5faf97557717eaa84d343e5cb59f6a53e2
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
-rw-r--r-- | tests/auto/qapplication/test/test.pro | 3 | ||||
-rw-r--r-- | tests/auto/qapplication/tst_qapplication.cpp | 83 | ||||
-rw-r--r-- | tests/auto/qapplication/wincmdline/main.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qapplication/wincmdline/wincmdline.pro | 6 |
4 files changed, 61 insertions, 35 deletions
diff --git a/tests/auto/qapplication/test/test.pro b/tests/auto/qapplication/test/test.pro index 6452369..ec19b70 100644 --- a/tests/auto/qapplication/test/test.pro +++ b/tests/auto/qapplication/test/test.pro @@ -2,6 +2,7 @@ CONFIG += testcase TARGET = ../tst_qapplication QT += testlib +CONFIG -= app-bundle SOURCES += ../tst_qapplication.cpp wince* { @@ -30,4 +31,4 @@ win32 { } } -CONFIG+=insignificant_test # QTQAINFRA-428 +embedded:CONFIG+=insignificant_test # QTQAINFRA-428 diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 5835fe1..4a694e7 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -235,9 +235,18 @@ static char *argv0; tst_QApplication::tst_QApplication() { -#ifdef Q_OS_WINCE +#if defined(Q_OS_WINCE) // Clean up environment previously to launching test qputenv("QT_PLUGIN_PATH", QByteArray()); +#elif defined(Q_OS_WIN) + // Set current directory such that the test binaries are found. + QDir workingDir(QDir::current()); + const QString workingDirPath = workingDir.absolutePath(); + if (workingDirPath.endsWith(QLatin1String("debug"), Qt::CaseInsensitive) + || workingDirPath.endsWith(QLatin1String("release"), Qt::CaseInsensitive)) { + workingDir.cdUp(); + QDir::setCurrent(workingDir.absolutePath()); + } #endif } @@ -1626,6 +1635,15 @@ void tst_QApplication::testDeleteLaterProcessEvents() #endif } +static inline QByteArray msgStartProcessFailed(const QString &binary, + const QString &errorMessage) +{ + const QString message = + QString::fromLatin1("Unable to start '%1' from '%2': %3") + .arg(binary, QDir::currentPath(), errorMessage); + return message.toLocal8Bit(); +} + /* Test for crash with QApplication::setDesktopSettingsAware(false). */ @@ -1633,30 +1651,31 @@ void tst_QApplication::desktopSettingsAware() { #ifndef QT_NO_PROCESS QProcess testProcess; -#ifdef Q_OS_WINCE + QString binary = QLatin1String("desktopsettingsaware/desktopsettingsaware"); +# ifdef Q_OS_WINCE int argc = 0; QApplication tmpApp(argc, 0, QApplication::GuiServer); - testProcess.start("desktopsettingsaware/desktopsettingsaware"); -#else -#if defined(Q_OS_WIN) && defined(QT_DEBUG) - testProcess.start("desktopsettingsaware/debug/desktopsettingsaware"); -#elif defined(Q_OS_WIN) - testProcess.start("desktopsettingsaware/release/desktopsettingsaware"); -#elif defined(Q_OS_SYMBIAN) - testProcess.start("desktopsettingsaware"); -#if defined(Q_CC_NOKIAX86) +# elif defined(Q_OS_WIN) +# if defined(QT_DEBUG) + binary = QLatin1String("desktopsettingsaware/debug/desktopsettingsaware"); +# else + binary = QLatin1String("desktopsettingsaware/release/desktopsettingsaware"); +# endif // QT_DEBUG +# elif defined(Q_OS_SYMBIAN) + binary = QLatin1String("desktopsettingsaware"); +# if defined(Q_CC_NOKIAX86) QEXPECT_FAIL("", "QProcess on Q_CC_NOKIAX86 cannot launch another Qt application, due to DLL conflicts.", Abort); // TODO: Remove XFAIL, as soon as we can launch Qt applications from within Qt applications on Symbian QVERIFY(testProcess.error() != QProcess::FailedToStart); -#endif // defined(Q_CC_NOKIAX86) -#else - testProcess.start("desktopsettingsaware/desktopsettingsaware"); -#endif -#endif +# endif // defined(Q_CC_NOKIAX86) +# endif + testProcess.start(binary); + QVERIFY2(testProcess.waitForStarted(), + msgStartProcessFailed(binary, testProcess.errorString()).constData()); QVERIFY(testProcess.waitForFinished(10000)); QCOMPARE(int(testProcess.state()), int(QProcess::NotRunning)); QVERIFY(int(testProcess.error()) != int(QProcess::Crashed)); -#endif +#endif // QT_NO_PROCESS } void tst_QApplication::setActiveWindow() @@ -1779,6 +1798,9 @@ void tst_QApplication::focusChanged() tab.simulate(now); if (!tabAllControls) { +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTQAINFRA-428", Abort); +#endif QVERIFY(spy.count() == 0); QVERIFY(now == QApplication::focusWidget()); } else { @@ -2043,11 +2065,10 @@ void tst_QApplication::windowsCommandLine() QFETCH(QString, expected); QProcess testProcess; -#if defined(QT_DEBUG) - testProcess.start("wincmdline/debug/wincmdline", QStringList(args)); -#else - testProcess.start("wincmdline/release/wincmdline", QStringList(args)); -#endif + const QString binary = QLatin1String("wincmdline/wincmdline"); + testProcess.start(binary, QStringList(args)); + QVERIFY2(testProcess.waitForStarted(), + msgStartProcessFailed(binary, testProcess.errorString()).constData()); QVERIFY(testProcess.waitForFinished(10000)); QByteArray error = testProcess.readAllStandardError(); QString procError(error); @@ -2360,17 +2381,21 @@ void tst_QApplication::qtbug_12673() { #ifdef Q_OS_SYMBIAN QSKIP("This might not make sense in Symbian, but since I do not know how to test it I'll just skip it for now.", SkipAll); -#else +#endif +#ifndef QT_NO_PROCESS QProcess testProcess; QStringList arguments; -#ifdef Q_OS_MAC - testProcess.start("modal/modal.app", arguments); -#else - testProcess.start("modal/modal", arguments); -#endif +# ifdef Q_OS_MAC + const QString binary =QLatin1String("modal/modal.app"); +# else + const QString binary =QLatin1String("modal/modal"); +# endif + testProcess.start(binary, arguments); + QVERIFY2(testProcess.waitForStarted(), + msgStartProcessFailed(binary, testProcess.errorString()).constData()); QVERIFY(testProcess.waitForFinished(20000)); QCOMPARE(testProcess.exitStatus(), QProcess::NormalExit); -#endif // Q_OS_SYMBIAN +#endif // QT_NO_PROCESS } /* diff --git a/tests/auto/qapplication/wincmdline/main.cpp b/tests/auto/qapplication/wincmdline/main.cpp index fc1f370..a7c7d3f 100644 --- a/tests/auto/qapplication/wincmdline/main.cpp +++ b/tests/auto/qapplication/wincmdline/main.cpp @@ -38,11 +38,11 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include <QApplication> +#include <QCoreApplication> #include <stdio.h> int main(int argc, char *argv[]) { - QApplication app(argc, argv); + QCoreApplication app(argc, argv); if (argc > 1) fprintf(stderr, "%s", argv[1]); else diff --git a/tests/auto/qapplication/wincmdline/wincmdline.pro b/tests/auto/qapplication/wincmdline/wincmdline.pro index 8a8ca3d..2febfab 100644 --- a/tests/auto/qapplication/wincmdline/wincmdline.pro +++ b/tests/auto/qapplication/wincmdline/wincmdline.pro @@ -1,7 +1,7 @@ TEMPLATE = app -TARGET = +QT = core +CONFIG += console +DESTDIR = ./ DEPENDPATH += . INCLUDEPATH += . SOURCES += main.cpp - - |