diff --git a/src/plugins/autotest/CMakeLists.txt b/src/plugins/autotest/CMakeLists.txt index 619501af8ba..1ee331dc5f2 100644 --- a/src/plugins/autotest/CMakeLists.txt +++ b/src/plugins/autotest/CMakeLists.txt @@ -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 diff --git a/src/plugins/autotest/autotest.pro b/src/plugins/autotest/autotest.pro index 7082a385864..5d1db25e3ae 100644 --- a/src/plugins/autotest/autotest.pro +++ b/src/plugins/autotest/autotest.pro @@ -7,6 +7,7 @@ DEFINES += AUTOTEST_LIBRARY SOURCES += \ autotestplugin.cpp \ + itestframework.cpp \ itestparser.cpp \ projectsettingswidget.cpp \ testcodeparser.cpp \ diff --git a/src/plugins/autotest/autotest.qbs b/src/plugins/autotest/autotest.qbs index 5e7bee484b3..ea014bc06d9 100644 --- a/src/plugins/autotest/autotest.qbs +++ b/src/plugins/autotest/autotest.qbs @@ -76,6 +76,7 @@ QtcPlugin { "testprojectsettings.h", "itestparser.cpp", "itestparser.h", + "itestframework.cpp", "itestframework.h", "iframeworksettings.h", "testframeworkmanager.cpp", diff --git a/src/plugins/autotest/itestframework.cpp b/src/plugins/autotest/itestframework.cpp new file mode 100644 index 00000000000..b7a45a8ae19 --- /dev/null +++ b/src/plugins/autotest/itestframework.cpp @@ -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(m_rootNode->model())->takeItem(m_rootNode); + delete m_rootNode; + m_rootNode = nullptr; +} + +} // namespace Autotest diff --git a/src/plugins/autotest/itestframework.h b/src/plugins/autotest/itestframework.h index 27efbaaa606..960b9d8ad56 100644 --- a/src/plugins/autotest/itestframework.h +++ b/src/plugins/autotest/itestframework.h @@ -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(m_rootNode->model())->takeItem(m_rootNode); - delete m_rootNode; - m_rootNode = nullptr; - } + void resetRootNode(); protected: virtual ITestParser *createTestParser() = 0; diff --git a/src/plugins/autotest/testframeworkmanager.cpp b/src/plugins/autotest/testframeworkmanager.cpp index 3e800619654..d7f1354f30c 100644 --- a/src/plugins/autotest/testframeworkmanager.cpp +++ b/src/plugins/autotest/testframeworkmanager.cpp @@ -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