Commit 5ef85949 authored by Christian Stenger's avatar Christian Stenger
Browse files

AutoTest: Add test frame work handling



Mainly a preparation for enabling/disabling test frame works.

Change-Id: I0bbea7e055a607517ef8193587c229cadf0de027
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 1681066c
......@@ -29,16 +29,20 @@ SOURCES += \
gtest/gtestresult.cpp \
gtest/gtestoutputreader.cpp \
gtest/gtestvisitors.cpp \
gtest/gtestframework.cpp \
qtest/qttesttreeitem.cpp \
qtest/qttestvisitors.cpp \
qtest/qttestconfiguration.cpp \
qtest/qttestoutputreader.cpp \
qtest/qttestresult.cpp \
qtest/qttestparser.cpp \
qtest/qttestframework.cpp \
quick/quicktestconfiguration.cpp \
quick/quicktestparser.cpp \
quick/quicktesttreeitem.cpp \
quick/quicktestvisitors.cpp
quick/quicktestvisitors.cpp \
quick/quicktestframework.cpp \
testframeworkmanager.cpp
HEADERS += \
......@@ -62,6 +66,7 @@ HEADERS += \
testnavigationwidget.h \
testoutputreader.h \
autotesticons.h \
itestframework.h \
itestparser.h \
gtest/gtestconfiguration.h \
gtest/gtestparser.h \
......@@ -70,6 +75,7 @@ HEADERS += \
gtest/gtestresult.h \
gtest/gtest_utils.h \
gtest/gtestvisitors.h \
gtest/gtestframework.h \
qtest/qttesttreeitem.h \
qtest/qttest_utils.h \
qtest/qttestresult.h \
......@@ -77,11 +83,14 @@ HEADERS += \
qtest/qttestconfiguration.h \
qtest/qttestoutputreader.h \
qtest/qttestparser.h \
qtest/qttestframework.h \
quick/quicktestconfiguration.h \
quick/quicktestparser.h \
quick/quicktesttreeitem.h \
quick/quicktest_utils.h \
quick/quicktestvisitors.h
quick/quicktestvisitors.h \
quick/quicktestframework.h \
testframeworkmanager.h
RESOURCES += \
autotest.qrc
......
......@@ -67,6 +67,9 @@ QtcPlugin {
"testtreeview.h",
"testoutputreader.cpp",
"testoutputreader.h",
"itestframework.h",
"testframeworkmanager.cpp",
"testframeworkmanager.h"
]
Group {
......
......@@ -39,6 +39,7 @@ const char AUTOTEST_CONTEXT[] = "Auto Tests";
const char TASK_INDEX[] = "AutoTest.Task.Index";
const char TASK_PARSE[] = "AutoTest.Task.Parse";
const char AUTOTEST_SETTINGS_CATEGORY[] = "ZY.Tests";
const char FRAMEWORK_PREFIX[] = "AutoTest.Framework.";
} // namespace Constants
} // namespace Autotest
......@@ -26,6 +26,7 @@
#include "autotestplugin.h"
#include "autotestconstants.h"
#include "testcodeparser.h"
#include "testframeworkmanager.h"
#include "testrunner.h"
#include "testsettings.h"
#include "testsettingspage.h"
......@@ -35,6 +36,10 @@
#include "testresultspane.h"
#include "testnavigationwidget.h"
#include "qtest/qttestframework.h"
#include "quick/quicktestframework.h"
#include "gtest/gtestframework.h"
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
#include <coreplugin/actionmanager/actionmanager.h>
......@@ -73,11 +78,7 @@ AutotestPlugin::AutotestPlugin()
AutotestPlugin::~AutotestPlugin()
{
// Delete members
TestTreeModel *model = TestTreeModel::instance();
delete model;
TestRunner *runner = TestRunner::instance();
delete runner;
delete m_frameworkManager;
}
AutotestPlugin *AutotestPlugin::instance()
......@@ -129,6 +130,12 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
initializeMenuEntries();
m_frameworkManager = TestFrameworkManager::instance();
m_frameworkManager->registerTestFramework(new QtTestFramework);
m_frameworkManager->registerTestFramework(new QuickTestFramework);
m_frameworkManager->registerTestFramework(new GTestFramework);
TestTreeModel::instance()->syncTestFrameworks();
m_settings->fromSettings(ICore::settings());
addAutoReleasedObject(new TestSettingsPage(m_settings));
addAutoReleasedObject(new TestNavigationWidgetFactory);
......
......@@ -32,6 +32,7 @@
namespace Autotest {
namespace Internal {
class TestFrameworkManager;
struct TestSettings;
class AutotestPlugin : public ExtensionSystem::IPlugin
......@@ -59,6 +60,7 @@ private:
void updateMenuItemsEnabledState();
QList<QObject *> createTestObjects() const;
const QSharedPointer<TestSettings> m_settings;
TestFrameworkManager *m_frameworkManager = 0;
};
} // namespace Internal
......
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "gtestframework.h"
#include "gtesttreeitem.h"
#include "gtestparser.h"
namespace Autotest {
namespace Internal {
ITestParser *GTestFramework::createTestParser() const
{
return new GTestParser;
}
TestTreeItem *GTestFramework::createRootNode() const
{
return new GTestTreeItem(QCoreApplication::translate("GTestFramework", "Google Tests"),
QString(), TestTreeItem::Root);
}
const char *GTestFramework::name() const
{
return "GTest";
}
unsigned GTestFramework::priority() const
{
return 10;
}
} // namespace Internal
} // namespace Autotest
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "../itestframework.h"
namespace Autotest {
namespace Internal {
class GTestFramework : public ITestFramework
{
public:
const char *name() const override;
unsigned priority() const override;
protected:
ITestParser *createTestParser() const override;
TestTreeItem *createRootNode() const override;
};
} // namespace Internal
} // namespace Autotest
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "testtreeitem.h"
#include "itestparser.h"
namespace Autotest {
namespace Internal {
class ITestFramework
{
public:
virtual ~ITestFramework() { }
virtual const char *name() const = 0;
virtual unsigned priority() const = 0; // should this be modifyable?
TestTreeItem *rootNode()
{ if (!m_rootNode)
m_rootNode = createRootNode();
return m_rootNode;
}
ITestParser *testParser()
{
if (!m_testParser)
m_testParser = createTestParser();
return m_testParser;
}
protected:
virtual ITestParser *createTestParser() const = 0;
virtual TestTreeItem *createRootNode() const = 0;
private:
TestTreeItem *m_rootNode = 0;
ITestParser *m_testParser = 0;
};
} // namespace Internal
} // namespace Autotest
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "qttestframework.h"
#include "qttestparser.h"
#include "qttesttreeitem.h"
namespace Autotest {
namespace Internal {
ITestParser *QtTestFramework::createTestParser() const
{
return new QtTestParser;
}
TestTreeItem *QtTestFramework::createRootNode() const
{
return new QtTestTreeItem(QCoreApplication::translate("QtTestFramework", "Qt Tests"),
QString(), TestTreeItem::Root);
}
const char *QtTestFramework::name() const
{
return "QtTest";
}
unsigned QtTestFramework::priority() const
{
return 1;
}
} // namespace Internal
} // namespace Autotest
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "../itestframework.h"
namespace Autotest {
namespace Internal {
class QtTestFramework : public ITestFramework
{
public:
const char *name() const override;
unsigned priority() const override;
protected:
ITestParser *createTestParser() const override;
TestTreeItem *createRootNode() const override;
};
} // namespace Internal
} // namespace Autotest
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "quicktestframework.h"
#include "quicktestparser.h"
#include "quicktesttreeitem.h"
namespace Autotest {
namespace Internal {
ITestParser *QuickTestFramework::createTestParser() const
{
return new QuickTestParser;
}
TestTreeItem *QuickTestFramework::createRootNode() const
{
return new QuickTestTreeItem(QCoreApplication::translate("QuickTestFramework", "Quick Tests"),
QString(), TestTreeItem::Root);
}
const char *QuickTestFramework::name() const
{
return "QtQuickTest";
}
unsigned QuickTestFramework::priority() const
{
return 5;
}
} // namespace Internal
} // namespace Autotest
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "../itestframework.h"
namespace Autotest {
namespace Internal {
class QuickTestFramework : public ITestFramework
{
public:
const char *name() const override;
unsigned priority() const override;
protected:
ITestParser *createTestParser() const override;
TestTreeItem *createRootNode() const override;
};
} // namespace Internal
} // namespace Autotest
......@@ -26,12 +26,7 @@
#include "autotestconstants.h"
#include "autotest_utils.h"
#include "testcodeparser.h"
// FIXME
#include "qtest/qttestparser.h"
#include "quick/quicktestparser.h"
#include "gtest/gtestparser.h"
// end of FIXME
#include "testframeworkmanager.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/progressmanager/futureprogress.h>
......@@ -81,15 +76,6 @@ TestCodeParser::TestCodeParser(TestTreeModel *parent)
this, [this] (int index) {
emit testParseResultReady(m_futureWatcher.resultAt(index));
});
// REMOVE
auto p1 = new QtTestParser;
p1->setId("QtTest");
auto p2 = new QuickTestParser;
p2->setId("QtQuickTest");
auto p3 = new GTestParser;
p3->setId("GTest");
m_testCodeParsers.append( {p1, p2, p3} );
}
TestCodeParser::~TestCodeParser()
......@@ -128,6 +114,26 @@ void TestCodeParser::setState(State state)
}
}
void TestCodeParser::syncTestFrameworks(const QList<Core::Id> &frameworkIds)
{
if (m_parserState != Disabled && m_parserState != Idle) {
// there's a running parse
m_fullUpdatePostponed = m_partialUpdatePostponed = false;
m_postponedFiles.clear();
Core::ProgressManager::instance()->cancelTasks(Constants::TASK_PARSE);
}
m_testCodeParsers.clear();
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
qCDebug(LOG) << "Setting" << frameworkIds << "as current parsers";
foreach (const Core::Id &id, frameworkIds) {
ITestParser *testParser = frameworkManager->testParserForTestFramework(id);
QTC_ASSERT(testParser, continue);
m_testCodeParsers.append(testParser);
}
if (m_parserState != Disabled)
updateTestTree();
}
void TestCodeParser::emitUpdateTestTree()
{
if (m_singleShotScheduled) {
......
......@@ -55,6 +55,7 @@ public:
State state() const { return m_parserState; }
bool isParsing() const { return m_parserState == PartialParse || m_parserState == FullParse; }
void setDirty() { m_dirty = true; }
void syncTestFrameworks(const QList<Core::Id> &frameworkIds);
#ifdef WITH_TESTS
bool furtherParsingExpected() const
{ return m_singleShotScheduled || m_fullUpdatePostponed || m_partialUpdatePostponed; }
......
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "testframeworkmanager.h"
#include "autotestconstants.h"
#include "itestframework.h"
#include "itestparser.h"
#include "testrunner.h"
#include "testtreeitem.h"
#include "testtreemodel.h"
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <QLoggingCategory>
static Q_LOGGING_CATEGORY(LOG, "qtc.autotest.frameworkmanager")
namespace Autotest {
namespace Internal {
TestFrameworkManager *s_instance = 0;