1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #include "testbauhaus.h"
41 TestBauhaus::TestBauhaus()
44 foreach (const QString &string, QProcess::systemEnvironment()) {
45 if (string.contains("qtdir", Qt::CaseInsensitive)) {
46 m_qtDir = string.split("=").last();
50 Q_ASSERT(!m_qtDir.isEmpty());
52 m_creatorDir = QString(WORKDIR) + "../../../../..";
54 m_executable = m_creatorDir + "/bin/qtcreator.exe";
56 m_executable = m_creatorDir + "/bin/qtcreator";
59 Q_ASSERT(QFileInfo(m_executable).exists());
62 bool TestBauhaus::loadFile(const QString &fileName)
65 qDebug() << "starting: " << fileName;
66 Q_ASSERT(QFileInfo(fileName).exists());
68 process.start(m_executable, QStringList() << fileName);
69 if (!process.waitForStarted())
71 if (!QProcess::Running == process.state()) {
75 if (!QProcess::Running == process.state()) {
81 QStringList findAllQmlFiles(const QDir &dir)
84 foreach (const QString &file, dir.entryList(QStringList() << "*.qml", QDir::Files)) {
85 files += dir.absoluteFilePath(file);
88 foreach (const QString &directory, dir.entryList(QStringList(), QDir::AllDirs | QDir::NoDotAndDotDot))
89 files += findAllQmlFiles(QDir(dir.absoluteFilePath(directory)));
93 void TestBauhaus::loadExamples_data()
95 QTest::addColumn<QString>("filePath");
96 foreach (const QString &file, findAllQmlFiles(QDir(m_qtDir + "/examples/declarative"))) {
97 QTest::newRow("file") << file;
101 void TestBauhaus::loadExamples()
103 QFETCH(QString, filePath);
104 if (!loadFile(filePath))
105 QFAIL(filePath.toAscii());
108 void TestBauhaus::loadDemos_data()
110 QTest::addColumn<QString>("filePath");
111 foreach (const QString &file, findAllQmlFiles(QDir(m_qtDir + "/demos/declarative"))) {
112 QTest::newRow("file") << file;
116 void TestBauhaus::loadDemos()
118 QFETCH(QString, filePath);
119 if (!loadFile(filePath))
120 QFAIL(filePath.toAscii());
123 void TestBauhaus::loadCreator_data()
125 QTest::addColumn<QString>("filePath");
126 foreach (const QString &file, findAllQmlFiles(QDir(m_creatorDir))) {
127 QTest::newRow("file") << file;
131 void TestBauhaus::loadCreator()
133 QFETCH(QString, filePath);
134 if (!loadFile(filePath))
135 QFAIL(filePath.toAscii());
138 QTEST_MAIN(TestBauhaus);