diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2012-10-05 15:32:34 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-12 00:19:36 (GMT) |
commit | 620d523508845ccad6e4baf0d17712169a141853 (patch) | |
tree | 3d28b6053548fb4b20639ea67f31cd1c634cc5cb /tests | |
parent | ceddcb631348f3b150f6e1882fa1a265c503c6df (diff) | |
download | Qt-620d523508845ccad6e4baf0d17712169a141853.zip Qt-620d523508845ccad6e4baf0d17712169a141853.tar.gz Qt-620d523508845ccad6e4baf0d17712169a141853.tar.bz2 |
Fix the guiapplauncher test.
The test historically relied on obscure environment variables
to determine whether the examples, demos should be run.
Remove that code and check whether the executables exist.
In the Window manager code, no longer exclude WS_POPUP windows,
which seems to fail with the current Qt 4.8.
Task-number: QTQAINFRA-428
Change-Id: I88d2be085cb543effc800115885e8ff86a1cf7ba
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/guiapplauncher/tst_guiapplauncher.cpp | 137 | ||||
-rw-r--r-- | tests/auto/guiapplauncher/windowmanager.cpp | 2 |
2 files changed, 80 insertions, 59 deletions
diff --git a/tests/auto/guiapplauncher/tst_guiapplauncher.cpp b/tests/auto/guiapplauncher/tst_guiapplauncher.cpp index f066f66..c7146ae 100644 --- a/tests/auto/guiapplauncher/tst_guiapplauncher.cpp +++ b/tests/auto/guiapplauncher/tst_guiapplauncher.cpp @@ -74,6 +74,10 @@ struct Example { int upTimeMS; }; +static const char designerC[] = "Designer"; +static const char linguistC[] = "Linguist"; +static const char qtDemoC[] = "qtdemo"; + const struct Example examples[] = { {"animation/animatedtiles Example", "animation/animatedtiles", "animatedtiles", 0, -1}, {"animation/appchooser Example", "animation/appchooser", "appchooser", 10, -1}, @@ -244,8 +248,8 @@ public: typedef QPair<const char*, AppLaunchData> TestDataEntry; typedef QList<TestDataEntry> TestDataEntries; - enum { TestTools = 0x1, TestDemo = 0x2, TestExamples = 0x4, - TestAll = TestTools|TestDemo|TestExamples }; + enum { TestTools = 0x1, TestQtDemo = 0x2, TestDemos = 0x4, TestExamples = 0x8, + TestAll = TestTools|TestQtDemo|TestDemos|TestExamples }; tst_GuiAppLauncher(); @@ -261,26 +265,48 @@ private: QString workingDir() const; private: + static QString guiBinary(QString in); + inline QString toolsBinary(const QString &tool) const + { return m_binPath + tst_GuiAppLauncher::guiBinary(tool); } + QString sampleBinary(const QString &root, const Example &e) const; + TestDataEntries exampleData(unsigned priority, const QString &path, + const Example *exArray, unsigned n) const; + bool runApp(const AppLaunchData &data, QString *errorMessage) const; TestDataEntries testData() const; - const unsigned m_testMask; + unsigned m_testMask; + const bool m_debugBuild; const unsigned m_examplePriority; const QString m_dir; + const QString m_binPath; + const QString m_examplesPath; + const QString m_demosPath; const QSharedPointer<WindowManager> m_wm; }; -// Test mask from environment as test lib does not allow options. -static inline unsigned testMask() +// Cross platform galore! +QString tst_GuiAppLauncher::guiBinary(QString in) +{ +#ifdef Q_OS_MAC + return in + QLatin1String(".app/Contents/MacOS/") + in; +#endif + in[0] = in.at(0).toLower(); +#ifdef Q_OS_WIN + in += QLatin1String(".exe"); +#endif + return in; +} + +QString tst_GuiAppLauncher::sampleBinary(const QString &root, const Example &e) const { - unsigned testMask = tst_GuiAppLauncher::TestAll; - if (!qgetenv("QT_TEST_NOTOOLS").isEmpty()) - testMask &= ~ tst_GuiAppLauncher::TestTools; - if (!qgetenv("QT_TEST_NOEXAMPLES").isEmpty()) - testMask &= ~tst_GuiAppLauncher::TestExamples; - if (!qgetenv("QT_TEST_NODEMOS").isEmpty()) - testMask &= ~tst_GuiAppLauncher::TestDemo; - return testMask; + + QString binary = root + QLatin1String(e.directory) + '/'; +#ifdef Q_OS_WIN + binary += m_debugBuild ? QLatin1String("debug/") : QLatin1String("release/"); +#endif + binary += guiBinary(QLatin1String(e.binary)); + return binary; } static inline unsigned testExamplePriority() @@ -296,9 +322,13 @@ static inline unsigned testExamplePriority() } tst_GuiAppLauncher::tst_GuiAppLauncher() : - m_testMask(testMask()), + m_testMask(tst_GuiAppLauncher::TestAll), + m_debugBuild(QLibraryInfo::buildKey().contains(QLatin1String("debug"))), m_examplePriority(testExamplePriority()), m_dir(QLatin1String(SRCDIR)), + m_binPath(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1Char('/')), + m_examplesPath(QLibraryInfo::location(QLibraryInfo::ExamplesPath) + QLatin1Char('/')), + m_demosPath(QLibraryInfo::location(QLibraryInfo::DemosPath) + QLatin1Char('/')), m_wm(WindowManager::create()) { } @@ -322,6 +352,26 @@ void tst_GuiAppLauncher::initTestCase() message = QString::fromLatin1("Invalid working directory %1").arg(m_dir); QFAIL(message.toLocal8Bit().constData()); } + if (!QFileInfo(toolsBinary(QLatin1String(designerC))).exists()) { + m_testMask &= ~TestTools; + qWarning("Not testing tools."); + } + if (!QFileInfo(toolsBinary(QLatin1String(qtDemoC))).exists()) { + m_testMask &= ~TestQtDemo; + qWarning("Not testing qtdemo."); + } + const QString firstExampleBinary = sampleBinary(m_examplesPath, examples[0]); + if (!QFileInfo(firstExampleBinary).exists()) { + m_testMask &= ~TestExamples; + qWarning("Not testing examples, '%s' cannot be found.", + qPrintable(QDir::toNativeSeparators(firstExampleBinary))); + } + const QString firstDemoBinary = sampleBinary(m_demosPath, demos[0]); + if (!QFileInfo(firstDemoBinary).exists()) { + m_testMask &= ~TestDemos; + qWarning("Not testing demos, '%s' cannot be found.", + qPrintable(QDir::toNativeSeparators(firstDemoBinary))); + } } void tst_GuiAppLauncher::run() @@ -334,19 +384,6 @@ void tst_GuiAppLauncher::run() QVERIFY2(rc, qPrintable(errorMessage)); } -// Cross platform galore! -static inline QString guiBinary(QString in) -{ -#ifdef Q_OS_MAC - return in + QLatin1String(".app/Contents/MacOS/") + in; -#endif - in[0] = in.at(0).toLower(); -#ifdef Q_OS_WIN - in += QLatin1String(".exe"); -#endif - return in; -} - void tst_GuiAppLauncher::run_data() { QTest::addColumn<AppLaunchData>("data"); @@ -355,13 +392,12 @@ void tst_GuiAppLauncher::run_data() } // Read out the examples array structures and convert to test data. -static tst_GuiAppLauncher::TestDataEntries exampleData(unsigned priority, - const QString &path, - bool debug, - const Example *exArray, - unsigned n) +tst_GuiAppLauncher::TestDataEntries + tst_GuiAppLauncher::exampleData(unsigned priority, + const QString &path, + const Example *exArray, + unsigned n) const { - Q_UNUSED(debug) tst_GuiAppLauncher::TestDataEntries rc; const QChar slash = QLatin1Char('/'); AppLaunchData data; @@ -369,13 +405,8 @@ static tst_GuiAppLauncher::TestDataEntries exampleData(unsigned priority, const Example &example = exArray[e]; if (example.priority <= priority) { data.clear(); - const QString examplePath = path + slash + QLatin1String(example.directory); - data.binary = examplePath + slash; -#ifdef Q_OS_WIN - data.binary += debug? QLatin1String("debug/") : QLatin1String("release/"); -#endif - data.binary += guiBinary(QLatin1String(example.binary)); - data.workingDirectory = examplePath; + data.binary = sampleBinary(path, example); + data.workingDirectory = path + slash + QLatin1String(example.directory); if (example.upTimeMS > 0) data.upTimeMS = example.upTimeMS; rc.append(tst_GuiAppLauncher::TestDataEntry(example.name, data)); @@ -387,42 +418,32 @@ static tst_GuiAppLauncher::TestDataEntries exampleData(unsigned priority, tst_GuiAppLauncher::TestDataEntries tst_GuiAppLauncher::testData() const { TestDataEntries rc; - const QChar slash = QLatin1Char('/'); - const QString binPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + slash; - const bool debug = QLibraryInfo::buildKey().contains(QLatin1String("debug")); - Q_UNUSED(debug) - AppLaunchData data; if (m_testMask & TestTools) { - data.binary = binPath + guiBinary(QLatin1String("Designer")); + data.binary = toolsBinary(QLatin1String(designerC)); data.args.append(m_dir + QLatin1String("test.ui")); rc.append(TestDataEntry("Qt Designer", data)); data.clear(); - data.binary = binPath + guiBinary(QLatin1String("Linguist")); + data.binary = toolsBinary(QLatin1String(linguistC)); data.splashScreen = true; data.upTimeMS = 5000; // Slow loading data.args.append(m_dir + QLatin1String("test.ts")); rc.append(TestDataEntry("Qt Linguist", data)); } - if (m_testMask & TestDemo) { + if (m_testMask & TestQtDemo) { data.clear(); data.upTimeMS = 5000; // Startup animation - data.binary = binPath + guiBinary(QLatin1String("qtdemo")); + data.binary = toolsBinary(QLatin1String(qtDemoC)); rc.append(TestDataEntry("Qt Demo", data)); - - const QString demosPath = QLibraryInfo::location(QLibraryInfo::DemosPath); - if (!demosPath.isEmpty()) - rc += exampleData(m_examplePriority, demosPath, debug, demos, sizeof(demos)/sizeof(Example)); } - if (m_testMask & TestExamples) { - const QString examplesPath = QLibraryInfo::location(QLibraryInfo::ExamplesPath); - if (!examplesPath.isEmpty()) - rc += exampleData(m_examplePriority, examplesPath, debug, examples, sizeof(examples)/sizeof(Example)); - } + if (m_testMask & TestDemos) + rc += exampleData(m_examplePriority, m_demosPath, demos, sizeof(demos)/sizeof(Example)); + if (m_testMask & TestExamples) + rc += exampleData(m_examplePriority, m_examplesPath, examples, sizeof(examples)/sizeof(Example)); qDebug("Running %d tests...", rc.size()); return rc; } diff --git a/tests/auto/guiapplauncher/windowmanager.cpp b/tests/auto/guiapplauncher/windowmanager.cpp index 79d2dd8..72d2f2a 100644 --- a/tests/auto/guiapplauncher/windowmanager.cpp +++ b/tests/auto/guiapplauncher/windowmanager.cpp @@ -360,7 +360,7 @@ static inline bool isQtMainWindow(HWND hwnd) if (!(windowInfo.dwWindowStatus & WS_ACTIVECAPTION)) return false; // Check the style for a real mainwindow - const DWORD excluded = WS_DISABLED | WS_POPUP; + const DWORD excluded = WS_DISABLED; const DWORD required = WS_CAPTION | WS_SYSMENU | WS_VISIBLE; return (windowInfo.dwStyle & excluded) == 0 && (windowInfo.dwStyle & required) == required; |