forked from qt-creator/qt-creator
AutoTest: Add a itestframework.cpp
To get a few things out-of-line in itestframework.h. Change-Id: Iae6f702b789c98b17a4d255008736377030e3b6c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -40,7 +40,7 @@ add_qtc_plugin(AutoTest
|
||||
gtest/gtesttreeitem.cpp gtest/gtesttreeitem.h
|
||||
gtest/gtestvisitors.cpp gtest/gtestvisitors.h
|
||||
iframeworksettings.h
|
||||
itestframework.h
|
||||
itestframework.cpp itestframework.h
|
||||
itestparser.cpp itestparser.h
|
||||
projectsettingswidget.cpp projectsettingswidget.h
|
||||
qtest/qttest_utils.cpp qtest/qttest_utils.h
|
||||
|
@@ -7,6 +7,7 @@ DEFINES += AUTOTEST_LIBRARY
|
||||
|
||||
SOURCES += \
|
||||
autotestplugin.cpp \
|
||||
itestframework.cpp \
|
||||
itestparser.cpp \
|
||||
projectsettingswidget.cpp \
|
||||
testcodeparser.cpp \
|
||||
|
@@ -76,6 +76,7 @@ QtcPlugin {
|
||||
"testprojectsettings.h",
|
||||
"itestparser.cpp",
|
||||
"itestparser.h",
|
||||
"itestframework.cpp",
|
||||
"itestframework.h",
|
||||
"iframeworksettings.h",
|
||||
"testframeworkmanager.cpp",
|
||||
|
78
src/plugins/autotest/itestframework.cpp
Normal file
78
src/plugins/autotest/itestframework.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 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"
|
||||
#include "itestparser.h"
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
ITestFramework::ITestFramework(bool activeByDefault)
|
||||
: m_active(activeByDefault)
|
||||
{}
|
||||
|
||||
ITestFramework::~ITestFramework()
|
||||
{
|
||||
delete m_testParser;
|
||||
}
|
||||
|
||||
TestTreeItem *ITestFramework::rootNode()
|
||||
{
|
||||
if (!m_rootNode)
|
||||
m_rootNode = createRootNode();
|
||||
// These are stored in the TestTreeModel and destroyed on shutdown there.
|
||||
return m_rootNode;
|
||||
}
|
||||
|
||||
ITestParser *ITestFramework::testParser()
|
||||
{
|
||||
if (!m_testParser)
|
||||
m_testParser = createTestParser();
|
||||
return m_testParser;
|
||||
}
|
||||
|
||||
Core::Id ITestFramework::settingsId() const
|
||||
{
|
||||
return Core::Id(Constants::SETTINGSPAGE_PREFIX)
|
||||
.withSuffix(QString("%1.%2").arg(priority()).arg(QLatin1String(name())));
|
||||
}
|
||||
|
||||
Core::Id ITestFramework::id() const
|
||||
{
|
||||
return Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(name());
|
||||
}
|
||||
|
||||
void ITestFramework::resetRootNode()
|
||||
{
|
||||
if (!m_rootNode)
|
||||
return;
|
||||
if (m_rootNode->model())
|
||||
static_cast<TestTreeModel *>(m_rootNode->model())->takeItem(m_rootNode);
|
||||
delete m_rootNode;
|
||||
m_rootNode = nullptr;
|
||||
}
|
||||
|
||||
} // namespace Autotest
|
@@ -35,34 +35,19 @@ class IFrameworkSettings;
|
||||
class ITestFramework
|
||||
{
|
||||
public:
|
||||
explicit ITestFramework(bool activeByDefault) : m_active(activeByDefault) {}
|
||||
virtual ~ITestFramework()
|
||||
{
|
||||
delete m_testParser;
|
||||
}
|
||||
explicit ITestFramework(bool activeByDefault);
|
||||
virtual ~ITestFramework();
|
||||
|
||||
virtual const char *name() const = 0;
|
||||
virtual unsigned priority() const = 0; // should this be modifyable?
|
||||
|
||||
virtual IFrameworkSettings *frameworkSettings() { return nullptr; }
|
||||
|
||||
TestTreeItem *rootNode()
|
||||
{ if (!m_rootNode)
|
||||
m_rootNode = createRootNode();
|
||||
// These are stored in the TestTreeModel and destroyed on shutdown there.
|
||||
return m_rootNode;
|
||||
}
|
||||
|
||||
ITestParser *testParser()
|
||||
{
|
||||
if (!m_testParser)
|
||||
m_testParser = createTestParser();
|
||||
return m_testParser;
|
||||
}
|
||||
TestTreeItem *rootNode();
|
||||
ITestParser *testParser();
|
||||
|
||||
Core::Id settingsId() const;
|
||||
|
||||
Core::Id id() const { return Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(name()); }
|
||||
Core::Id id() const;
|
||||
|
||||
bool active() const { return m_active; }
|
||||
void setActive(bool active) { m_active = active; }
|
||||
@@ -71,15 +56,7 @@ public:
|
||||
// framework specific tool tip to be displayed on the general settings page
|
||||
virtual QString groupingToolTip() const { return QString(); }
|
||||
|
||||
void resetRootNode()
|
||||
{
|
||||
if (!m_rootNode)
|
||||
return;
|
||||
if (m_rootNode->model())
|
||||
static_cast<TestTreeModel *>(m_rootNode->model())->takeItem(m_rootNode);
|
||||
delete m_rootNode;
|
||||
m_rootNode = nullptr;
|
||||
}
|
||||
void resetRootNode();
|
||||
|
||||
protected:
|
||||
virtual ITestParser *createTestParser() = 0;
|
||||
|
@@ -91,10 +91,4 @@ void TestFrameworkManager::synchronizeSettings(QSettings *s)
|
||||
}
|
||||
}
|
||||
|
||||
Id ITestFramework::settingsId() const
|
||||
{
|
||||
return Core::Id(Constants::SETTINGSPAGE_PREFIX)
|
||||
.withSuffix(QString("%1.%2").arg(priority()).arg(QLatin1String(name())));
|
||||
}
|
||||
|
||||
} // namespace Autotest
|
||||
|
Reference in New Issue
Block a user