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:
hjk
2020-04-17 17:04:35 +02:00
parent 90fd6870c5
commit 6285696091
6 changed files with 87 additions and 36 deletions

View File

@@ -40,7 +40,7 @@ add_qtc_plugin(AutoTest
gtest/gtesttreeitem.cpp gtest/gtesttreeitem.h gtest/gtesttreeitem.cpp gtest/gtesttreeitem.h
gtest/gtestvisitors.cpp gtest/gtestvisitors.h gtest/gtestvisitors.cpp gtest/gtestvisitors.h
iframeworksettings.h iframeworksettings.h
itestframework.h itestframework.cpp itestframework.h
itestparser.cpp itestparser.h itestparser.cpp itestparser.h
projectsettingswidget.cpp projectsettingswidget.h projectsettingswidget.cpp projectsettingswidget.h
qtest/qttest_utils.cpp qtest/qttest_utils.h qtest/qttest_utils.cpp qtest/qttest_utils.h

View File

@@ -7,6 +7,7 @@ DEFINES += AUTOTEST_LIBRARY
SOURCES += \ SOURCES += \
autotestplugin.cpp \ autotestplugin.cpp \
itestframework.cpp \
itestparser.cpp \ itestparser.cpp \
projectsettingswidget.cpp \ projectsettingswidget.cpp \
testcodeparser.cpp \ testcodeparser.cpp \

View File

@@ -76,6 +76,7 @@ QtcPlugin {
"testprojectsettings.h", "testprojectsettings.h",
"itestparser.cpp", "itestparser.cpp",
"itestparser.h", "itestparser.h",
"itestframework.cpp",
"itestframework.h", "itestframework.h",
"iframeworksettings.h", "iframeworksettings.h",
"testframeworkmanager.cpp", "testframeworkmanager.cpp",

View 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

View File

@@ -35,34 +35,19 @@ class IFrameworkSettings;
class ITestFramework class ITestFramework
{ {
public: public:
explicit ITestFramework(bool activeByDefault) : m_active(activeByDefault) {} explicit ITestFramework(bool activeByDefault);
virtual ~ITestFramework() virtual ~ITestFramework();
{
delete m_testParser;
}
virtual const char *name() const = 0; virtual const char *name() const = 0;
virtual unsigned priority() const = 0; // should this be modifyable? virtual unsigned priority() const = 0; // should this be modifyable?
virtual IFrameworkSettings *frameworkSettings() { return nullptr; } virtual IFrameworkSettings *frameworkSettings() { return nullptr; }
TestTreeItem *rootNode() TestTreeItem *rootNode();
{ if (!m_rootNode) ITestParser *testParser();
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;
}
Core::Id settingsId() const; Core::Id settingsId() const;
Core::Id id() const;
Core::Id id() const { return Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(name()); }
bool active() const { return m_active; } bool active() const { return m_active; }
void setActive(bool active) { m_active = 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 // framework specific tool tip to be displayed on the general settings page
virtual QString groupingToolTip() const { return QString(); } virtual QString groupingToolTip() const { return QString(); }
void resetRootNode() 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;
}
protected: protected:
virtual ITestParser *createTestParser() = 0; virtual ITestParser *createTestParser() = 0;

View File

@@ -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 } // namespace Autotest