aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@theqtcompany.com>2015-02-10 14:20:43 +0100
committerChristian Stenger <christian.stenger@theqtcompany.com>2015-02-17 10:26:28 +0200
commit213a687f454682b8cd1e79fc27762ac6f374502e (patch)
treef4d1fd940546a261862ecdfc389575390c1b24e3
parent751d2e2bb1f0f2829fff8dac15b534fbadc25b3c (diff)
Rework parsing and provide unit test
Handling of parsing has slightly changed. The parser now uses simple states to be capable of postponing triggered parses if there is already a parsing in progress. Furthermore the parser now waits for the current project to be completely scanned. Change-Id: I6d4968d28194ba8d23d3a0ee6ab454d81a549e67 Reviewed-by: Andre Poenitz <andre.poenitz@theqtcompany.com>
-rw-r--r--plugins/autotest/autotest.pro5
-rw-r--r--plugins/autotest/autotestplugin.cpp12
-rw-r--r--plugins/autotest/autotestplugin.h1
-rw-r--r--plugins/autotest/autotestunittests.cpp123
-rw-r--r--plugins/autotest/autotestunittests.h55
-rw-r--r--plugins/autotest/autotestunittests.qrc32
-rw-r--r--plugins/autotest/testcodeparser.cpp144
-rw-r--r--plugins/autotest/testcodeparser.h20
-rw-r--r--plugins/autotest/testtreemodel.cpp23
-rw-r--r--plugins/autotest/testtreemodel.h5
-rw-r--r--plugins/autotest/unit_test/mixed_atp/mixed_atp.pro5
-rw-r--r--plugins/autotest/unit_test/mixed_atp/src/main.cpp8
-rw-r--r--plugins/autotest/unit_test/mixed_atp/src/src.pro6
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/auto.pro15
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/bench/bench.pro12
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/bench/tst_benchtest.cpp63
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/dummy.pro10
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.cpp82
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.h43
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/gui/gui.pro8
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/gui/tst_guitest.cpp89
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/TestDummy.qml10
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/bar/tst_foo.qml29
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/main.cpp3
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/notlisted/tst_bla.qml29
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/quickauto.pro14
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test1.qml33
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml47
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test3.qml30
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/main.cpp3
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.pro11
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test1.qml33
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test2.qml33
-rw-r--r--plugins/autotest/unit_test/mixed_atp/tests/tests.pro4
-rw-r--r--plugins/autotest/unit_test/plain/plain.pro4
-rw-r--r--plugins/autotest/unit_test/plain/test_plain/test_plain.pro13
-rw-r--r--plugins/autotest/unit_test/plain/test_plain/tst_simple.cpp65
-rw-r--r--plugins/autotest/unit_test/plain/test_plain/tst_simple.h4
38 files changed, 1108 insertions, 18 deletions
diff --git a/plugins/autotest/autotest.pro b/plugins/autotest/autotest.pro
index ecc8934575..4d3c6643f2 100644
--- a/plugins/autotest/autotest.pro
+++ b/plugins/autotest/autotest.pro
@@ -56,3 +56,8 @@ RESOURCES += \
FORMS += \
testsettingspage.ui
+equals(TEST, 1) {
+ HEADERS += autotestunittests.h
+ SOURCES += autotestunittests.cpp
+ RESOURCES += autotestunittests.qrc
+}
diff --git a/plugins/autotest/autotestplugin.cpp b/plugins/autotest/autotestplugin.cpp
index 624812200c..46e2a311d9 100644
--- a/plugins/autotest/autotestplugin.cpp
+++ b/plugins/autotest/autotestplugin.cpp
@@ -44,6 +44,10 @@
#include <QtPlugin>
+#ifdef WITH_TESTS
+#include "autotestunittests.h"
+#endif
+
using namespace Autotest::Internal;
static AutotestPlugin *m_instance = 0;
@@ -151,3 +155,11 @@ void AutotestPlugin::triggerAction()
tr("This is an action from Autotest."));
}
+QList<QObject *> AutotestPlugin::createTestObjects() const
+{
+ QList<QObject *> tests;
+#ifdef WITH_TESTS
+ tests << new AutoTestUnitTests(TestTreeModel::instance());
+#endif
+ return tests;
+}
diff --git a/plugins/autotest/autotestplugin.h b/plugins/autotest/autotestplugin.h
index be4a803717..af5fcc91db 100644
--- a/plugins/autotest/autotestplugin.h
+++ b/plugins/autotest/autotestplugin.h
@@ -52,6 +52,7 @@ private slots:
private:
bool checkLicense();
void initializeMenuEntries();
+ QList<QObject *> createTestObjects() const;
const QSharedPointer<TestSettings> m_settings;
};
diff --git a/plugins/autotest/autotestunittests.cpp b/plugins/autotest/autotestunittests.cpp
new file mode 100644
index 0000000000..50556d7e00
--- /dev/null
+++ b/plugins/autotest/autotestunittests.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#include "autotestconstants.h"
+#include "autotestunittests.h"
+#include "testcodeparser.h"
+#include "testtreemodel.h"
+
+#include <cpptools/cppmodelmanager.h>
+#include <cpptools/cpptoolstestcase.h>
+
+#include <projectexplorer/kitinformation.h>
+#include <projectexplorer/kitmanager.h>
+#include <projectexplorer/projectexplorer.h>
+#include <projectexplorer/toolchain.h>
+
+#include <QSignalSpy>
+#include <QTest>
+#include <QTime>
+
+#include <coreplugin/navigationwidget.h>
+
+#include <qtsupport/qtkitinformation.h>
+
+using namespace Core;
+using namespace ProjectExplorer;
+using namespace Utils;
+
+namespace Autotest {
+namespace Internal {
+
+AutoTestUnitTests::AutoTestUnitTests(TestTreeModel *model, QObject *parent)
+ : QObject(parent),
+ m_model(model),
+ m_tmpDir(0),
+ m_isQt4(false)
+{
+}
+
+void AutoTestUnitTests::initTestCase()
+{
+ const QList<Kit *> allKits = KitManager::kits();
+ if (allKits.count() != 1)
+ QSKIP("This test requires exactly one kit to be present");
+ if (auto qtVersion = QtSupport::QtKitInformation::qtVersion(allKits.first()))
+ m_isQt4 = qtVersion->qtVersionString().startsWith(QLatin1Char('4'));
+ else
+ QSKIP("Could not figure out which Qt version is used for default kit.");
+ const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first());
+ if (!toolchain)
+ QSKIP("This test requires that there is a kit with a toolchain.");
+
+ m_tmpDir = new CppTools::Tests::TemporaryCopiedDir(QLatin1String(":/unit_test"));
+}
+
+void AutoTestUnitTests::cleanupTestCase()
+{
+ delete m_tmpDir;
+}
+
+void AutoTestUnitTests::testCodeParser()
+{
+ QFETCH(QString, projectFilePath);
+ QFETCH(int, expectedAutoTestsCount);
+ QFETCH(int, expectedNamedQuickTestsCount);
+ QFETCH(int, expectedUnnamedQuickTestsCount);
+
+ NavigationWidget *navigation = NavigationWidget::instance();
+ navigation->activateSubWidget(Constants::AUTOTEST_ID);
+
+ CppTools::Tests::ProjectOpenerAndCloser projectManager;
+ const CppTools::ProjectInfo projectInfo = projectManager.open(projectFilePath, true);
+ QVERIFY(projectInfo.isValid());
+
+ QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
+ QVERIFY(parserSpy.wait(20000));
+
+ if (m_isQt4)
+ expectedNamedQuickTestsCount = expectedUnnamedQuickTestsCount = 0;
+
+ QCOMPARE(m_model->autoTestsCount(), expectedAutoTestsCount);
+ QCOMPARE(m_model->namedQuickTestsCount(), expectedNamedQuickTestsCount);
+ QCOMPARE(m_model->unnamedQuickTestsCount(), expectedUnnamedQuickTestsCount);
+
+ QCOMPARE(m_model->parser()->autoTestsCount(), expectedAutoTestsCount);
+ QCOMPARE(m_model->parser()->namedQuickTestsCount(), expectedNamedQuickTestsCount);
+ QCOMPARE(m_model->parser()->unnamedQuickTestsCount(), expectedUnnamedQuickTestsCount);
+
+}
+
+void AutoTestUnitTests::testCodeParser_data()
+{
+ QTest::addColumn<QString>("projectFilePath");
+ QTest::addColumn<int>("expectedAutoTestsCount");
+ QTest::addColumn<int>("expectedNamedQuickTestsCount");
+ QTest::addColumn<int>("expectedUnnamedQuickTestsCount");
+
+
+ QTest::newRow("plainAutoTest")
+ << QString(m_tmpDir->path() + QLatin1String("/plain/plain.pro"))
+ << 1 << 0 << 0;
+ QTest::newRow("mixedAutoTestAndQuickTests")
+ << QString(m_tmpDir->path() + QLatin1String("/mixed_atp/mixed_atp.pro"))
+ << 3 << 5 << 3;
+}
+
+} // namespace Internal
+} // namespace Autotest
diff --git a/plugins/autotest/autotestunittests.h b/plugins/autotest/autotestunittests.h
new file mode 100644
index 0000000000..16c6042b5d
--- /dev/null
+++ b/plugins/autotest/autotestunittests.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#ifndef AUTOTESTUNITTESTS_H
+#define AUTOTESTUNITTESTS_H
+
+#include <QObject>
+#include <QTemporaryDir>
+
+namespace CppTools { namespace Tests { class TemporaryCopiedDir; } }
+
+namespace Autotest {
+namespace Internal {
+
+class TestTreeModel;
+
+class AutoTestUnitTests : public QObject
+{
+ Q_OBJECT
+public:
+ explicit AutoTestUnitTests(TestTreeModel *model, QObject *parent = 0);
+
+signals:
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void testCodeParser();
+ void testCodeParser_data();
+
+private:
+ TestTreeModel *m_model;
+ CppTools::Tests::TemporaryCopiedDir *m_tmpDir;
+ bool m_isQt4;
+};
+
+} // namespace Internal
+} // namespace Autotest
+
+#endif // AUTOTESTUNITTESTS_H
diff --git a/plugins/autotest/autotestunittests.qrc b/plugins/autotest/autotestunittests.qrc
new file mode 100644
index 0000000000..6fb5348e54
--- /dev/null
+++ b/plugins/autotest/autotestunittests.qrc
@@ -0,0 +1,32 @@
+<RCC>
+ <qresource prefix="/">
+ <file>unit_test/mixed_atp/src/main.cpp</file>
+ <file>unit_test/mixed_atp/tests/auto/bench/tst_benchtest.cpp</file>
+ <file>unit_test/mixed_atp/tests/auto/dummy/tst_foo.cpp</file>
+ <file>unit_test/mixed_atp/tests/auto/dummy/tst_foo.h</file>
+ <file>unit_test/mixed_atp/tests/auto/gui/tst_guitest.cpp</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto/bar/tst_foo.qml</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto/notlisted/tst_bla.qml</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto/main.cpp</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto/TestDummy.qml</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto/tst_test1.qml</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto/tst_test3.qml</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto2/main.cpp</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto2/tst_test1.qml</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto2/tst_test2.qml</file>
+ <file>unit_test/plain/test_plain/tst_simple.cpp</file>
+ <file>unit_test/plain/test_plain/tst_simple.h</file>
+ <file>unit_test/plain/plain.pro</file>
+ <file>unit_test/mixed_atp/mixed_atp.pro</file>
+ <file>unit_test/plain/test_plain/test_plain.pro</file>
+ <file>unit_test/mixed_atp/tests/tests.pro</file>
+ <file>unit_test/mixed_atp/src/src.pro</file>
+ <file>unit_test/mixed_atp/tests/auto/bench/bench.pro</file>
+ <file>unit_test/mixed_atp/tests/auto/dummy/dummy.pro</file>
+ <file>unit_test/mixed_atp/tests/auto/gui/gui.pro</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto/quickauto.pro</file>
+ <file>unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.pro</file>
+ <file>unit_test/mixed_atp/tests/auto/auto.pro</file>
+ </qresource>
+</RCC>
diff --git a/plugins/autotest/testcodeparser.cpp b/plugins/autotest/testcodeparser.cpp
index a33a6cac9b..0f950d305b 100644
--- a/plugins/autotest/testcodeparser.cpp
+++ b/plugins/autotest/testcodeparser.cpp
@@ -49,7 +49,10 @@ TestCodeParser::TestCodeParser(TestTreeModel *parent)
: QObject(parent),
m_model(parent),
m_parserEnabled(true),
- m_pendingUpdate(false)
+ m_pendingUpdate(false),
+ m_fullUpdatePostPoned(false),
+ m_partialUpdatePostPoned(false),
+ m_parserState(Idle)
{
// connect to ProgressManager to post-pone test parsing when CppModelManager is parsing
auto progressManager = qobject_cast<Core::ProgressManager *>(Core::ProgressManager::instance());
@@ -57,6 +60,8 @@ TestCodeParser::TestCodeParser(TestTreeModel *parent)
this, &TestCodeParser::onTaskStarted);
connect(progressManager, &Core::ProgressManager::allTasksFinished,
this, &TestCodeParser::onAllTasksFinished);
+ connect(this, &TestCodeParser::partialParsingFinished,
+ this, &TestCodeParser::onPartialParsingFinished);
}
TestCodeParser::~TestCodeParser()
@@ -81,25 +86,26 @@ void TestCodeParser::updateTestTree()
{
if (!m_parserEnabled) {
m_pendingUpdate = true;
- qDebug() << "Skipped update due to running parser or pro file evaluate";
return;
}
- qDebug("updating TestTreeModel");
-
- clearMaps();
- emit cacheCleared();
-
if (ProjectExplorer::Project *project = currentProject()) {
if (auto qmakeProject = qobject_cast<QmakeProjectManager::QmakeProject *>(project)) {
+ if (qmakeProject->asyncUpdateState() != QmakeProjectManager::QmakeProject::Base) {
+ m_pendingUpdate = true;
+ return;
+ }
connect(qmakeProject, &QmakeProjectManager::QmakeProject::proFilesEvaluated,
this, &TestCodeParser::onProFileEvaluated, Qt::UniqueConnection);
}
} else
return;
- scanForTests();
m_pendingUpdate = false;
+
+ clearMaps();
+ emit cacheCleared();
+ scanForTests();
}
/****** scan for QTest related stuff helpers ******/
@@ -443,7 +449,7 @@ void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &docume
} else if (!project->files(ProjectExplorer::Project::AllFiles).contains(fileName)) {
return;
}
- checkDocumentForTestCode(document);
+ scanForTests(QStringList(fileName));
}
void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document)
@@ -464,15 +470,17 @@ void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document)
const CPlusPlus::Snapshot snapshot = CppTools::CppModelManager::instance()->snapshot();
if (m_quickDocMap.contains(fileName)
&& snapshot.contains(m_quickDocMap[fileName].referencingFile())) {
- checkDocumentForTestCode(snapshot.document(m_quickDocMap[fileName].referencingFile()));
+ if (!m_quickDocMap[fileName].referencingFile().isEmpty())
+ scanForTests(QStringList(m_quickDocMap[fileName].referencingFile()));
}
if (!m_quickDocMap.contains(tr(Constants::UNNAMED_QUICKTESTS)))
return;
// special case of having unnamed TestCases
const QString &mainFile = m_model->getMainFileForUnnamedQuickTest(fileName);
- if (!mainFile.isEmpty() && snapshot.contains(mainFile))
- checkDocumentForTestCode(snapshot.document(mainFile));
+ if (!mainFile.isEmpty() && snapshot.contains(mainFile)) {
+ scanForTests(QStringList(mainFile));
+ }
}
void TestCodeParser::removeFiles(const QStringList &files)
@@ -481,13 +489,62 @@ void TestCodeParser::removeFiles(const QStringList &files)
removeTestsIfNecessary(file);
}
+bool TestCodeParser::postponed(const QStringList &fileList)
+{
+ switch (m_parserState) {
+ case Idle:
+ return false;
+ case PartialParse:
+ // partial is running, postponing a full parse
+ if (fileList.isEmpty()) {
+ m_partialUpdatePostPoned = false;
+ m_postPonedFiles.clear();
+ m_fullUpdatePostPoned = true;
+ } else {
+ // partial parse triggered, but full parse is postponed already, ignoring this
+ if (m_fullUpdatePostPoned)
+ return true;
+ // partial parse triggered, postpone or add current files to already postponed partial
+ foreach (const QString &file, fileList)
+ m_postPonedFiles.insert(file);
+ m_partialUpdatePostPoned = true;
+ }
+ return true;
+ case FullParse:
+ // full parse is running, postponing another full parse
+ if (fileList.isEmpty()) {
+ m_partialUpdatePostPoned = false;
+ m_postPonedFiles.clear();
+ m_fullUpdatePostPoned = true;
+ } else {
+ // full parse already postponed, ignoring triggering a partial parse
+ if (m_fullUpdatePostPoned) {
+ return true;
+ }
+ // partial parse triggered, postpone or add current files to already postponed partial
+ foreach (const QString &file, fileList)
+ m_postPonedFiles.insert(file);
+ m_partialUpdatePostPoned = true;
+ }
+ return true;
+ }
+ QTC_ASSERT(false, return false); // should not happen at all
+}
+
void TestCodeParser::scanForTests(const QStringList &fileList)
{
+ if (postponed(fileList))
+ return;
+
QStringList list;
if (fileList.isEmpty()) {
list = currentProject()->files(ProjectExplorer::Project::AllFiles);
+ if (list.isEmpty())
+ return;
+ m_parserState = FullParse;
} else {
list << fileList;
+ m_parserState = PartialParse;
}
CppTools::CppModelManager *cppMM = CppTools::CppModelManager::instance();
@@ -499,6 +556,18 @@ void TestCodeParser::scanForTests(const QStringList &fileList)
checkDocumentForTestCode(doc);
}
}
+ switch (m_parserState) {
+ case PartialParse:
+ m_parserState = Idle;
+ emit partialParsingFinished();
+ break;
+ case FullParse:
+ m_parserState = Idle;
+ emit parsingFinished();
+ break;
+ case Idle:
+ break;
+ }
}
void TestCodeParser::clearMaps()
@@ -588,22 +657,39 @@ void TestCodeParser::removeTestsIfNecessaryByProFile(const QString &proFile)
void TestCodeParser::onTaskStarted(Core::Id type)
{
- if (type != CppTools::Constants::TASK_INDEX
- && type != QmakeProjectManager::Constants::PROFILE_EVALUATE)
+ if (type != CppTools::Constants::TASK_INDEX)
return;
m_parserEnabled = false;
}
void TestCodeParser::onAllTasksFinished(Core::Id type)
{
- if (type != CppTools::Constants::TASK_INDEX
- && type != QmakeProjectManager::Constants::PROFILE_EVALUATE)
+ // only CPP parsing is relevant as we trigger Qml parsing internally anyway
+ if (type != CppTools::Constants::TASK_INDEX)
return;
m_parserEnabled = true;
if (m_pendingUpdate)
updateTestTree();
}
+void TestCodeParser::onPartialParsingFinished()
+{
+ QTC_ASSERT(m_fullUpdatePostPoned != m_partialUpdatePostPoned
+ || ((m_fullUpdatePostPoned || m_partialUpdatePostPoned) == false),
+ m_partialUpdatePostPoned = false;m_postPonedFiles.clear(););
+ if (m_fullUpdatePostPoned) {
+ m_fullUpdatePostPoned = false;
+ updateTestTree();
+ } else if (m_partialUpdatePostPoned) {
+ m_partialUpdatePostPoned = false;
+ QStringList tmp;
+ foreach (const QString &file, m_postPonedFiles)
+ tmp << file;
+ m_postPonedFiles.clear();
+ scanForTests(tmp);
+ }
+}
+
void TestCodeParser::updateUnnamedQuickTests(const QString &fileName, const QString &mainFile,
const QMap<QString, TestCodeLocationAndType> &functions)
{
@@ -710,5 +796,31 @@ void TestCodeParser::onProFileEvaluated()
}
}
+#ifdef WITH_TESTS
+int TestCodeParser::autoTestsCount() const
+{
+ int count = 0;
+ foreach (const QString &file, m_cppDocMap.keys()) {
+ if (m_cppDocMap.value(file).referencingFile().isEmpty())
+ ++count;
+ }
+ return count;
+}
+
+int TestCodeParser::namedQuickTestsCount() const
+{
+ if (m_quickDocMap.contains(tr(Constants::UNNAMED_QUICKTESTS)))
+ return m_quickDocMap.size() - 1;
+ return m_quickDocMap.size();
+}
+
+int TestCodeParser::unnamedQuickTestsCount() const
+{
+ if (m_quickDocMap.contains(tr(Constants::UNNAMED_QUICKTESTS)))
+ return m_quickDocMap.value(tr(Constants::UNNAMED_QUICKTESTS)).testFunctions().size();
+ return 0;
+}
+#endif
+
} // namespace Internal
} // namespace Autotest
diff --git a/plugins/autotest/testcodeparser.h b/plugins/autotest/testcodeparser.h
index e2f590cabf..d846769b37 100644
--- a/plugins/autotest/testcodeparser.h
+++ b/plugins/autotest/testcodeparser.h
@@ -43,9 +43,21 @@ class TestCodeParser : public QObject
{
Q_OBJECT
public:
+ enum State {
+ Idle,
+ PartialParse,
+ FullParse
+ };
+
explicit TestCodeParser(TestTreeModel *parent = 0);
virtual ~TestCodeParser();
+#ifdef WITH_TESTS
+ int autoTestsCount() const;
+ int namedQuickTestsCount() const;
+ int unnamedQuickTestsCount() const;
+#endif
+
signals:
void cacheCleared();
void testItemCreated(const TestTreeItem &item, TestTreeModel::Type type);
@@ -55,6 +67,8 @@ signals:
void unnamedQuickTestsUpdated(const QString &filePath, const QString &mainFile,
const QMap<QString, TestCodeLocationAndType> &functions);
void unnamedQuickTestsRemoved(const QString &filePath);
+ void parsingFinished();
+ void partialParsingFinished();
public slots:
void emitUpdateTestTree();
@@ -68,6 +82,7 @@ public slots:
void onProFileEvaluated();
private:
+ bool postponed(const QStringList &fileList);
void scanForTests(const QStringList &fileList = QStringList());
void clearMaps();
void removeTestsIfNecessary(const QString &fileName);
@@ -75,6 +90,7 @@ private:
void onTaskStarted(Core::Id type);
void onAllTasksFinished(Core::Id type);
+ void onPartialParsingFinished();
void updateUnnamedQuickTests(const QString &fileName, const QString &mainFile,
const QMap<QString, TestCodeLocationAndType> &functions);
void updateModelAndCppDocMap(CPlusPlus::Document::Ptr document,
@@ -87,6 +103,10 @@ private:
QMap<QString, TestInfo> m_quickDocMap;
bool m_parserEnabled;
bool m_pendingUpdate;
+ bool m_fullUpdatePostPoned;
+ bool m_partialUpdatePostPoned;
+ QSet<QString> m_postPonedFiles;
+ State m_parserState;
};
} // namespace Internal
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp
index f2ea94d626..bccabf898a 100644
--- a/plugins/autotest/testtreemodel.cpp
+++ b/plugins/autotest/testtreemodel.cpp
@@ -61,8 +61,6 @@ TestTreeModel::TestTreeModel(QObject *parent) :
connect(m_parser, &TestCodeParser::unnamedQuickTestsRemoved,
this, &TestTreeModel::removeUnnamedQuickTests);
- m_parser->updateTestTree();
-
// CppTools::CppModelManagerInterface *cppMM = CppTools::CppModelManagerInterface::instance();
// if (cppMM) {
// // replace later on by
@@ -808,6 +806,27 @@ void TestTreeModel::processChildren(QModelIndex &parentIndex, const TestTreeItem
}
}
+#ifdef WITH_TESTS
+int TestTreeModel::autoTestsCount() const
+{
+ return m_autoTestRootItem ? m_autoTestRootItem->childCount() : 0;
+}
+
+int TestTreeModel::namedQuickTestsCount() const
+{
+ return m_quickTestRootItem
+ ? m_quickTestRootItem->childCount() - (hasUnnamedQuickTests() ? 1 : 0)
+ : 0;
+}
+
+int TestTreeModel::unnamedQuickTestsCount() const
+{
+ if (TestTreeItem *unnamed = unnamedQuickTests())
+ return unnamed->childCount();
+ return 0;
+}
+#endif
+
/***************************** Sort/Filter Model **********************************/
TestTreeSortFilterModel::TestTreeSortFilterModel(TestTreeModel *sourceModel, QObject *parent)
diff --git a/plugins/autotest/testtreemodel.h b/plugins/autotest/testtreemodel.h
index 81ad9418d9..b21eafbb7f 100644
--- a/plugins/autotest/testtreemodel.h
+++ b/plugins/autotest/testtreemodel.h
@@ -75,6 +75,11 @@ public:
QSet<QString> qmlFilesForProFile(const QString &proFile) const;
bool hasUnnamedQuickTests() const;
+#ifdef WITH_TESTS
+ int autoTestsCount() const;
+ int namedQuickTestsCount() const;
+ int unnamedQuickTestsCount() const;
+#endif
signals:
void testTreeModelChanged();
diff --git a/plugins/autotest/unit_test/mixed_atp/mixed_atp.pro b/plugins/autotest/unit_test/mixed_atp/mixed_atp.pro
new file mode 100644
index 0000000000..068ea5a3a6
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/mixed_atp.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+
+SUBDIRS += src \
+ tests
+
diff --git a/plugins/autotest/unit_test/mixed_atp/src/main.cpp b/plugins/autotest/unit_test/mixed_atp/src/main.cpp
new file mode 100644
index 0000000000..e0c10bca02
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/src/main.cpp
@@ -0,0 +1,8 @@
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ return a.exec();
+}
+
diff --git a/plugins/autotest/unit_test/mixed_atp/src/src.pro b/plugins/autotest/unit_test/mixed_atp/src/src.pro
new file mode 100644
index 0000000000..9e554af8b7
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/src/src.pro
@@ -0,0 +1,6 @@
+QT += gui widgets
+
+TEMPLATE = app
+
+SOURCES += main.cpp
+
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/auto.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/auto.pro
new file mode 100644
index 0000000000..cb4dc9ec32
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/auto.pro
@@ -0,0 +1,15 @@
+TEMPLATE = subdirs
+
+SUBDIRS = \
+ bench \
+ dummy \
+ gui
+
+greaterThan(QT_MAJOR_VERSION, 4) {
+ message("enabling quick tests")
+ SUBDIRS += quickauto \
+ quickauto2
+} else {
+ message("quick tests disabled")
+}
+
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/bench.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/bench.pro
new file mode 100644
index 0000000000..87f391f41d
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/bench.pro
@@ -0,0 +1,12 @@
+QT += testlib
+
+QT -= gui
+
+TARGET = tst_benchtest
+CONFIG += console
+CONFIG -= app_bundle
+
+TEMPLATE = app
+
+SOURCES += tst_benchtest.cpp
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/tst_benchtest.cpp b/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/tst_benchtest.cpp
new file mode 100644
index 0000000000..1d968a0147
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/bench/tst_benchtest.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+#include <QString>
+#include <QtTest>
+
+class BenchTest : public QObject
+{
+ Q_OBJECT
+
+public:
+ BenchTest();
+
+private Q_SLOTS:
+ void testCase1();
+ void testCase1_data();
+};
+
+BenchTest::BenchTest()
+{
+}
+
+void BenchTest::testCase1()
+{
+ QFETCH(bool, localAware);
+
+ QString str1 = QLatin1String("Hello World");
+ QString str2 = QLatin1String("Hallo Welt");
+ if (!localAware) {
+ QBENCHMARK {
+ str1 == str2;
+ }
+ } else {
+ QBENCHMARK {
+ str1.localeAwareCompare(str2) == 0;
+ }
+ }
+}
+
+void BenchTest::testCase1_data()
+{
+ QTest::addColumn<bool>("localAware");
+ QTest::newRow("localAware") << true;
+ QTest::newRow("simple") << false;
+}
+
+QTEST_MAIN(BenchTest)
+
+#include "tst_benchtest.moc"
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/dummy.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/dummy.pro
new file mode 100644
index 0000000000..40e95bcc39
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/dummy.pro
@@ -0,0 +1,10 @@
+QT += testlib
+QT += gui
+CONFIG += qt warn_on depend_includepath testcase
+TEMPLATE = app
+
+TARGET = tst_FooBar
+
+HEADERS += tst_foo.h
+SOURCES += tst_foo.cpp
+
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.cpp b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.cpp
new file mode 100644
index 0000000000..9dc2c9ec3a
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+#include "tst_foo.h"
+#include <QtTest>
+#include <QCoreApplication>
+#include <QDebug>
+
+Foo::Foo()
+{
+}
+
+Foo::~Foo()
+{
+}
+
+void Foo::initTestCase()
+{
+}
+
+void Foo::cleanupTestCase()
+{
+ QWARN("Warning!");
+}
+
+void Foo::test_caseZero()
+{
+ QCOMPARE(1, 2);
+}
+
+void Foo::test_case1()
+{
+ qDebug() << "test_case1";
+ QFETCH(int, val);
+
+ QEXPECT_FAIL("test2", "2", Continue);
+ QCOMPARE(val, 1);
+ QEXPECT_FAIL("test1", "bla", Abort);
+ QCOMPARE(val, 2);
+ QVERIFY2(true, "Hallo");
+}
+
+void Foo::test_case1_data()
+{
+ QTest::addColumn<int>("val");
+ QTest::newRow("test1") << 1;
+ QTest::newRow("test2") << 2;
+ QTest::newRow("test3") << 3;
+ QTest::newRow("test4") << 4;
+}
+
+void Foo::test_case2()
+{
+ QThread::sleep(1);
+ qDebug() << "test_case2 - all pass";
+ QSKIP("Skip for now", SkipAll);
+ QCOMPARE(1 ,1);
+ QVERIFY(true);
+}
+
+void Foo::test_case4()
+{
+ qDebug("äøæ");
+ QSKIP("Skipping test_case4", SkipSingle);
+ QFAIL("bla");
+}
+
+QTEST_MAIN(Foo)
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.h b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.h
new file mode 100644
index 0000000000..29bb8f5f6e
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/dummy/tst_foo.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+#ifndef FOO_H_INCLUDED
+#define FOO_H_INCLUDED
+
+#include <QObject>
+
+class Foo : public QObject
+{
+ Q_OBJECT
+
+public:
+ Foo();
+ ~Foo();
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void test_case1();
+ void test_case1_data();
+ void test_caseZero();
+ void test_case2();
+// void test_case3() {}
+ void test_case4();
+ void test_case5() {}
+};
+
+#endif
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/gui.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/gui.pro
new file mode 100644
index 0000000000..10f8f27eb8
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/gui.pro
@@ -0,0 +1,8 @@
+QT += testlib gui widgets
+
+TARGET = tst_guitest
+
+TEMPLATE = app
+
+SOURCES += tst_guitest.cpp
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/tst_guitest.cpp b/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/tst_guitest.cpp
new file mode 100644
index 0000000000..13d61ba151
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/gui/tst_guitest.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+#include <QString>
+#include <QtTest>
+#include <QApplication>
+#include <QLineEdit>
+
+class GuiTest : public QObject
+{
+ Q_OBJECT
+
+public:
+ GuiTest();
+
+private Q_SLOTS:
+ void initTestCase();
+ void cleanupTestCase();
+ void testCase1();
+ void testGui_data();
+ void testGui();
+};
+
+GuiTest::GuiTest()
+{
+}
+
+void GuiTest::initTestCase()
+{
+}
+
+void GuiTest::cleanupTestCase()
+{
+}
+
+void GuiTest::testCase1()
+{
+ QLatin1String str("Hello World");
+ QLineEdit lineEdit;
+ QTest::keyClicks(&lineEdit, str);
+ QCOMPARE(lineEdit.text(), str);
+}
+
+void GuiTest::testGui()
+{
+ QFETCH(QTestEventList, events);
+ QFETCH(QString, expected);
+ QLineEdit lineEdit;
+ events.simulate(&lineEdit);
+ QCOMPARE(lineEdit.text(), expected);
+}
+
+void GuiTest::testGui_data()
+{
+ QTest::addColumn<QTestEventList>("events");
+ QTest::addColumn<QString>("expected");
+
+ QTestEventList list1;
+ list1.addKeyClick('a');
+ QTest::newRow("char") << list1 << "a";
+
+ QTestEventList list2;
+ list2.addKeyClick('a');
+ list2.addKeyClick(Qt::Key_Backspace);
+ QTest::newRow("there and back again") << list2 << "";
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ GuiTest gt;
+ return QTest::qExec(&gt, argc, argv);
+}
+
+#include "tst_guitest.moc"
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/TestDummy.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/TestDummy.qml
new file mode 100644
index 0000000000..ae30c81143
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/TestDummy.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+import QtTest 1.0
+
+TestCase {
+ name: "HalloBallo"
+ function test_bla() {
+ verify(true, "verifying true");
+ }
+}
+
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/bar/tst_foo.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/bar/tst_foo.qml
new file mode 100644
index 0000000000..ff825cd989
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/bar/tst_foo.qml
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtTest 1.0
+
+TestCase {
+ name: "subdirTC"
+
+ function test_blabla() {
+ compare(1, 2, "Bla");
+ }
+
+}
+
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/main.cpp b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/main.cpp
new file mode 100644
index 0000000000..16a331e4cc
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/main.cpp
@@ -0,0 +1,3 @@
+#include <QtQuickTest/quicktest.h>
+
+QUICK_TEST_MAIN(blob)
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/notlisted/tst_bla.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/notlisted/tst_bla.qml
new file mode 100644
index 0000000000..325b7c4927
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/notlisted/tst_bla.qml
@@ -0,0 +1,29 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtTest 1.0
+
+TestCase {
+ name: "notlisted"
+
+ function test_blablabla() {
+ compare(1, 2, "Blubb");
+ }
+
+}
+
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/quickauto.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/quickauto.pro
new file mode 100644
index 0000000000..dfe495dc1c
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/quickauto.pro
@@ -0,0 +1,14 @@
+TEMPLATE = app
+TARGET = test_mal_qtquick
+
+CONFIG += warn_on qmltestcase
+
+DISTFILES += \
+ tst_test1.qml \
+ tst_test2.qml \
+ TestDummy.qml \
+ bar/tst_foo.qml \
+ tst_test3.qml
+
+SOURCES += \
+ main.cpp
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test1.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test1.qml
new file mode 100644
index 0000000000..8bf1379dc9
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test1.qml
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtTest 1.0
+
+TestCase {
+ name: "Banana"
+
+ function test_math() {
+ compare(5 + 5, 10, "verifying 5 + 5 = 10");
+ compare(10 - 5, 5, "verifying 10 - 5 = 5");
+ }
+
+ function test_fail() {
+ verify(false, "verifying false");
+ }
+}
+
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml
new file mode 100644
index 0000000000..c9a7f5286b
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test2.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtTest 1.0
+
+TestCase {
+ function test_str() {
+ var bla = String();
+ bla = bla.concat("Hallo", " ", "Welt");
+ var blubb = String("Hallo Welt");
+ compare(blubb, bla, "Comparing concat");
+ verify(blubb == bla, "Comparing concat equality")
+ }
+
+// nested TestCases actually fail
+// TestCase {
+// name: "boo"
+
+// function test_boo() {
+// verify(true);
+// }
+
+// TestCase {
+// name: "far"
+
+// function test_far() {
+// verify(true);
+// }
+// }
+// }
+}
+
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test3.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test3.qml
new file mode 100644
index 0000000000..3575c6b313
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto/tst_test3.qml
@@ -0,0 +1,30 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtTest 1.0
+
+TestCase {
+ function test_bolle() {
+ verify(true, "verifying true");
+ }
+
+ function test_str() {
+ compare("hallo", "hallo");
+ }
+}
+
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/main.cpp b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/main.cpp
new file mode 100644
index 0000000000..e496b3eb65
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/main.cpp
@@ -0,0 +1,3 @@
+#include <QtQuickTest/quicktest.h>
+
+QUICK_TEST_MAIN(blob2)
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.pro b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.pro
new file mode 100644
index 0000000000..61c76d1562
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/quickauto2.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+TARGET = test_mal_qtquick
+
+CONFIG += warn_on qmltestcase
+
+DISTFILES += \
+ tst_test1.qml \
+ tst_test2.qml
+
+SOURCES += \
+ main.cpp
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test1.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test1.qml
new file mode 100644
index 0000000000..8bf1379dc9
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test1.qml
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtTest 1.0
+
+TestCase {
+ name: "Banana"
+
+ function test_math() {
+ compare(5 + 5, 10, "verifying 5 + 5 = 10");
+ compare(10 - 5, 5, "verifying 10 - 5 = 5");
+ }
+
+ function test_fail() {
+ verify(false, "verifying false");
+ }
+}
+
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test2.qml b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test2.qml
new file mode 100644
index 0000000000..a72913a84e
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/auto/quickauto2/tst_test2.qml
@@ -0,0 +1,33 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+import QtQuick 2.0
+import QtTest 1.0
+
+Rectangle {
+ TestCase {
+ name: "nestedTC"
+
+ function test_str() {
+ var bla = String();
+ bla = bla.concat("Hello", " ", "World");
+ var blubb = String("Hello World");
+ compare(blubb, bla, "Comparing concat");
+ verify(blubb == bla, "Comparing concat equality")
+ }
+ }
+}
diff --git a/plugins/autotest/unit_test/mixed_atp/tests/tests.pro b/plugins/autotest/unit_test/mixed_atp/tests/tests.pro
new file mode 100644
index 0000000000..f1633f70c9
--- /dev/null
+++ b/plugins/autotest/unit_test/mixed_atp/tests/tests.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS += auto
+
diff --git a/plugins/autotest/unit_test/plain/plain.pro b/plugins/autotest/unit_test/plain/plain.pro
new file mode 100644
index 0000000000..07cbd33922
--- /dev/null
+++ b/plugins/autotest/unit_test/plain/plain.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS += test_plain
+
diff --git a/plugins/autotest/unit_test/plain/test_plain/test_plain.pro b/plugins/autotest/unit_test/plain/test_plain/test_plain.pro
new file mode 100644
index 0000000000..1e8994b34c
--- /dev/null
+++ b/plugins/autotest/unit_test/plain/test_plain/test_plain.pro
@@ -0,0 +1,13 @@
+QT += testlib
+QT += gui
+CONFIG += qt warn_on depend_includepath testcase
+
+TEMPLATE = app
+
+SOURCES += \
+ tst_simple.cpp
+
+HEADERS += \
+ tst_simple.h
+
+TARGET = totallyDifferentName
diff --git a/plugins/autotest/unit_test/plain/test_plain/tst_simple.cpp b/plugins/autotest/unit_test/plain/test_plain/tst_simple.cpp
new file mode 100644
index 0000000000..785aa6a1c8
--- /dev/null
+++ b/plugins/autotest/unit_test/plain/test_plain/tst_simple.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Creator Enterprise Auto Test Add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+#include "tst_simple.h"
+#include <QCoreApplication>
+
+namespace Foo {
+namespace Bar {
+
+class bla : public QObject
+{
+ Q_OBJECT
+
+public:
+ bla() {}
+ ~bla() {}
+
+private slots:
+ void tst_dummy() {}
+
+};
+
+class anotherBla : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void init() {}
+ void cleanup() {}
+
+ void tst_bla() {}
+ void test_foo() {}
+ void test_bar() {}
+ void tst_batz() {}
+ void test_hello() {}
+ void test_io() { qDebug("ä");}
+};
+
+} // namespace Foo
+} // namespace Bar
+
+int main(int argc, char* argv[])
+{
+ Foo::Bar::anotherBla *x2 = new Foo::Bar::anotherBla;
+ int result = QTest::qExec(x2, argc, argv);
+// multiple QTest::qExec() calls actually do not work
+// result += QTest::qExec(new Foo::Bar::bla, argc, argv);
+ return result;
+}
+
+#include "tst_simple.moc"
diff --git a/plugins/autotest/unit_test/plain/test_plain/tst_simple.h b/plugins/autotest/unit_test/plain/test_plain/tst_simple.h
new file mode 100644
index 0000000000..25523237cb
--- /dev/null
+++ b/plugins/autotest/unit_test/plain/test_plain/tst_simple.h
@@ -0,0 +1,4 @@
+#ifndef TST_SIMPLE_H
+#define TST_SIMPLE_H
+#include <QTest>
+#endif // TST_SIMPLE_H