diff --git a/src/plugins/autotest/boost/boosttestconfiguration.cpp b/src/plugins/autotest/boost/boosttestconfiguration.cpp index cdae7a40f8c..8bd90f78fed 100644 --- a/src/plugins/autotest/boost/boosttestconfiguration.cpp +++ b/src/plugins/autotest/boost/boosttestconfiguration.cpp @@ -29,24 +29,16 @@ #include "boosttestsettings.h" #include "../autotestplugin.h" -#include "../testframeworkmanager.h" +#include "../itestframework.h" #include "../testsettings.h" namespace Autotest { namespace Internal { -static BoostTestSettings *getBoostSettings() -{ - const Core::Id id = Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix( - BoostTest::Constants::FRAMEWORK_NAME); - TestFrameworkManager *manager = TestFrameworkManager::instance(); - return dynamic_cast(manager->settingsForTestFramework(id)); -} - TestOutputReader *BoostTestConfiguration::outputReader(const QFutureInterface &fi, QProcess *app) const { - auto settings = getBoostSettings(); + auto settings = dynamic_cast(framework()->frameworkSettings()); return new BoostTestOutputReader(fi, app, buildDirectory(), projectFile(), settings->logLevel, settings->reportLevel); } @@ -113,7 +105,7 @@ static QStringList filterInterfering(const QStringList &provided, QStringList *o QStringList BoostTestConfiguration::argumentsForTestRunner(QStringList *omitted) const { - auto boostSettings = getBoostSettings(); + auto boostSettings = dynamic_cast(framework()->frameworkSettings()); QStringList arguments; arguments << "-l" << BoostTestSettings::logLevelToOption(boostSettings->logLevel); arguments << "-r" << BoostTestSettings::reportLevelToOption(boostSettings->reportLevel); diff --git a/src/plugins/autotest/boost/boosttestconfiguration.h b/src/plugins/autotest/boost/boosttestconfiguration.h index e792fe21d51..2259eca5137 100644 --- a/src/plugins/autotest/boost/boosttestconfiguration.h +++ b/src/plugins/autotest/boost/boosttestconfiguration.h @@ -33,7 +33,8 @@ namespace Internal { class BoostTestConfiguration : public DebuggableTestConfiguration { public: - BoostTestConfiguration() {} + explicit BoostTestConfiguration(ITestFramework *framework) + : DebuggableTestConfiguration(framework) {} TestOutputReader *outputReader(const QFutureInterface &fi, QProcess *app) const override; QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override; diff --git a/src/plugins/autotest/boost/boosttestframework.cpp b/src/plugins/autotest/boost/boosttestframework.cpp index fc4f76a1258..a1448e33ccd 100644 --- a/src/plugins/autotest/boost/boosttestframework.cpp +++ b/src/plugins/autotest/boost/boosttestframework.cpp @@ -37,9 +37,10 @@ ITestParser *BoostTestFramework::createTestParser() return new BoostTestParser(this); } -TestTreeItem *BoostTestFramework::createRootNode() const +TestTreeItem *BoostTestFramework::createRootNode() { return new BoostTestTreeItem( + this, QCoreApplication::translate("BoostTestFramework", BoostTest::Constants::FRAMEWORK_SETTINGS_CATEGORY), QString(), TestTreeItem::Root); diff --git a/src/plugins/autotest/boost/boosttestframework.h b/src/plugins/autotest/boost/boosttestframework.h index ac011c422a9..2d112ae0773 100644 --- a/src/plugins/autotest/boost/boosttestframework.h +++ b/src/plugins/autotest/boost/boosttestframework.h @@ -43,7 +43,7 @@ private: unsigned priority() const override; IFrameworkSettings *frameworkSettings() override { return &m_settings; } ITestParser *createTestParser() override; - TestTreeItem *createRootNode() const override; + TestTreeItem *createRootNode() override; BoostTestSettings m_settings; BoostTestSettingsPage m_settingsPage{&m_settings, settingsId()}; diff --git a/src/plugins/autotest/boost/boosttestparser.cpp b/src/plugins/autotest/boost/boosttestparser.cpp index e6f85ce2d35..db49187d376 100644 --- a/src/plugins/autotest/boost/boosttestparser.cpp +++ b/src/plugins/autotest/boost/boosttestparser.cpp @@ -56,7 +56,7 @@ TestTreeItem *BoostTestParseResult::createTestTreeItem() const if (itemType == TestTreeItem::Root) return nullptr; - BoostTestTreeItem *item = new BoostTestTreeItem(displayName, fileName, itemType); + BoostTestTreeItem *item = new BoostTestTreeItem(framework, displayName, fileName, itemType); item->setProFile(proFile); item->setLine(line); item->setColumn(column); diff --git a/src/plugins/autotest/boost/boosttesttreeitem.cpp b/src/plugins/autotest/boost/boosttesttreeitem.cpp index d85fa439cf8..faf50624941 100644 --- a/src/plugins/autotest/boost/boosttesttreeitem.cpp +++ b/src/plugins/autotest/boost/boosttesttreeitem.cpp @@ -40,7 +40,7 @@ namespace Internal { TestTreeItem *BoostTestTreeItem::copyWithoutChildren() { - BoostTestTreeItem *copied = new BoostTestTreeItem; + BoostTestTreeItem *copied = new BoostTestTreeItem(framework()); copied->copyBasicDataFrom(this); copied->m_state = m_state; copied->m_fullName = m_fullName; @@ -146,7 +146,7 @@ TestTreeItem *BoostTestTreeItem::createParentGroupNode() const { const QFileInfo fileInfo(filePath()); const QFileInfo base(fileInfo.absolutePath()); - return new BoostTestTreeItem(base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); + return new BoostTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); } QString BoostTestTreeItem::prependWithParentsSuitePaths(const QString &testName) const @@ -204,7 +204,7 @@ QList BoostTestTreeItem::getAllTestConfigurations() const for (auto it = testsPerProjectfile.begin(), end = testsPerProjectfile.end(); it != end; ++it) { for (const QString &target : qAsConst(it.value().internalTargets)) { - BoostTestConfiguration *config = new BoostTestConfiguration; + BoostTestConfiguration *config = new BoostTestConfiguration(framework()); config->setProject(project); config->setProjectFile(it.key()); config->setTestCaseCount(it.value().testCases); @@ -250,7 +250,7 @@ QList BoostTestTreeItem::getSelectedTestConfigurations() co auto end = testCasesForProjectFile.cend(); for (auto it = testCasesForProjectFile.cbegin(); it != end; ++it) { for (const QString &target : it.value().internalTargets) { - BoostTestConfiguration *config = new BoostTestConfiguration; + BoostTestConfiguration *config = new BoostTestConfiguration(framework()); config->setProject(project); config->setProjectFile(it.key()); config->setTestCases(it.value().testCases); @@ -294,7 +294,7 @@ TestConfiguration *BoostTestTreeItem::testConfiguration() const testCases.append(prependWithParentsSuitePaths(handleSpecialFunctionNames(tcName))); } - BoostTestConfiguration *config = new BoostTestConfiguration; + BoostTestConfiguration *config = new BoostTestConfiguration(framework()); config->setProjectFile(proFile()); config->setProject(project); config->setTestCases(testCases); diff --git a/src/plugins/autotest/boost/boosttesttreeitem.h b/src/plugins/autotest/boost/boosttesttreeitem.h index a3676c39de4..f9dc154a562 100644 --- a/src/plugins/autotest/boost/boosttesttreeitem.h +++ b/src/plugins/autotest/boost/boosttesttreeitem.h @@ -48,8 +48,12 @@ public: Q_FLAGS(TestState) Q_DECLARE_FLAGS(TestStates, TestState) - explicit BoostTestTreeItem(const QString &name = QString(), const QString &filePath = QString(), - Type type = Root) : TestTreeItem(name, filePath, type) {} + explicit BoostTestTreeItem(ITestFramework *framework, + const QString &name = QString(), + const QString &filePath = QString(), + Type type = Root) + : TestTreeItem(framework, name, filePath, type) + {} public: TestTreeItem *copyWithoutChildren() override; diff --git a/src/plugins/autotest/gtest/gtestconfiguration.cpp b/src/plugins/autotest/gtest/gtestconfiguration.cpp index eb5a8299599..615ddcd3da0 100644 --- a/src/plugins/autotest/gtest/gtestconfiguration.cpp +++ b/src/plugins/autotest/gtest/gtestconfiguration.cpp @@ -28,7 +28,7 @@ #include "gtestoutputreader.h" #include "gtestsettings.h" #include "../autotestplugin.h" -#include "../testframeworkmanager.h" +#include "../itestframework.h" #include "../testsettings.h" #include @@ -73,9 +73,6 @@ QStringList filterInterfering(const QStringList &provided, QStringList *omitted) QStringList GTestConfiguration::argumentsForTestRunner(QStringList *omitted) const { - static const Core::Id id - = Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(GTest::Constants::FRAMEWORK_NAME); - QStringList arguments; if (AutotestPlugin::settings()->processArgs) { arguments << filterInterfering(runnable().commandLineArguments.split( @@ -86,8 +83,7 @@ QStringList GTestConfiguration::argumentsForTestRunner(QStringList *omitted) con if (!testSets.isEmpty()) arguments << "--gtest_filter=" + testSets.join(':'); - TestFrameworkManager *manager = TestFrameworkManager::instance(); - auto gSettings = dynamic_cast(manager->settingsForTestFramework(id)); + auto gSettings = dynamic_cast(framework()->frameworkSettings()); if (!gSettings) return arguments; diff --git a/src/plugins/autotest/gtest/gtestconfiguration.h b/src/plugins/autotest/gtest/gtestconfiguration.h index 51f88293ec2..822ad99fd1b 100644 --- a/src/plugins/autotest/gtest/gtestconfiguration.h +++ b/src/plugins/autotest/gtest/gtestconfiguration.h @@ -33,7 +33,9 @@ namespace Internal { class GTestConfiguration : public DebuggableTestConfiguration { public: - explicit GTestConfiguration() {} + explicit GTestConfiguration(ITestFramework *framework) + : DebuggableTestConfiguration(framework) {} + TestOutputReader *outputReader(const QFutureInterface &fi, QProcess *app) const override; QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override; diff --git a/src/plugins/autotest/gtest/gtestframework.cpp b/src/plugins/autotest/gtest/gtestframework.cpp index ed46d7e4b79..c97f209b6c7 100644 --- a/src/plugins/autotest/gtest/gtestframework.cpp +++ b/src/plugins/autotest/gtest/gtestframework.cpp @@ -44,9 +44,10 @@ ITestParser *GTestFramework::createTestParser() return new GTestParser(this); } -TestTreeItem *GTestFramework::createRootNode() const +TestTreeItem *GTestFramework::createRootNode() { return new GTestTreeItem( + this, QCoreApplication::translate("GTestFramework", GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY), QString(), TestTreeItem::Root); diff --git a/src/plugins/autotest/gtest/gtestframework.h b/src/plugins/autotest/gtest/gtestframework.h index b1f196419cd..25c43918c2a 100644 --- a/src/plugins/autotest/gtest/gtestframework.h +++ b/src/plugins/autotest/gtest/gtestframework.h @@ -47,7 +47,7 @@ private: QString groupingToolTip() const override; IFrameworkSettings *frameworkSettings() override { return &m_settings; } ITestParser *createTestParser() override; - TestTreeItem *createRootNode() const override; + TestTreeItem *createRootNode() override; GTestSettings m_settings; GTestSettingsPage m_settingsPage{&m_settings, settingsId()}; diff --git a/src/plugins/autotest/gtest/gtestoutputreader.h b/src/plugins/autotest/gtest/gtestoutputreader.h index 2cf13a2b95f..9bed450971a 100644 --- a/src/plugins/autotest/gtest/gtestoutputreader.h +++ b/src/plugins/autotest/gtest/gtestoutputreader.h @@ -32,8 +32,6 @@ namespace Autotest { namespace Internal { -class GTestResult; - class GTestOutputReader : public TestOutputReader { Q_DECLARE_TR_FUNCTIONS(Autotest::Internal::GTestOutputReader) diff --git a/src/plugins/autotest/gtest/gtestparser.cpp b/src/plugins/autotest/gtest/gtestparser.cpp index e60a9a7d9d1..194c5a4b308 100644 --- a/src/plugins/autotest/gtest/gtestparser.cpp +++ b/src/plugins/autotest/gtest/gtestparser.cpp @@ -38,7 +38,7 @@ TestTreeItem *GTestParseResult::createTestTreeItem() const { if (itemType != TestTreeItem::TestSuite && itemType != TestTreeItem::TestCase) return nullptr; - GTestTreeItem *item = new GTestTreeItem(name, fileName, itemType); + GTestTreeItem *item = new GTestTreeItem(framework, name, fileName, itemType); item->setProFile(proFile); item->setLine(line); item->setColumn(column); diff --git a/src/plugins/autotest/gtest/gtesttreeitem.cpp b/src/plugins/autotest/gtest/gtesttreeitem.cpp index 49d1138b8ae..f2821ca1bff 100644 --- a/src/plugins/autotest/gtest/gtesttreeitem.cpp +++ b/src/plugins/autotest/gtest/gtesttreeitem.cpp @@ -65,7 +65,7 @@ static QString gtestFilter(GTestTreeItem::TestStates states) TestTreeItem *GTestTreeItem::copyWithoutChildren() { - GTestTreeItem *copied = new GTestTreeItem; + GTestTreeItem *copied = new GTestTreeItem(framework()); copied->copyBasicDataFrom(this); copied->m_state = m_state; return copied; @@ -170,7 +170,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const case TestSuite: { const QString &testSpecifier = gtestFilter(state()).arg(name()).arg('*'); if (int count = childCount()) { - config = new GTestConfiguration; + config = new GTestConfiguration(framework()); config->setTestCases(QStringList(testSpecifier)); config->setTestCaseCount(count); config->setProjectFile(proFile()); @@ -183,7 +183,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const if (!parent) return nullptr; const QString &testSpecifier = gtestFilter(parent->state()).arg(parent->name()).arg(name()); - config = new GTestConfiguration; + config = new GTestConfiguration(framework()); config->setTestCases(QStringList(testSpecifier)); config->setProjectFile(proFile()); config->setProject(project); @@ -261,7 +261,7 @@ QList GTestTreeItem::getTestConfigurations(bool ignoreCheck for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) { for (const QString &target : qAsConst(it.value().internalTargets)) { - GTestConfiguration *tc = new GTestConfiguration; + GTestConfiguration *tc = new GTestConfiguration(framework()); if (!ignoreCheckState) tc->setTestCases(it.value().filters); tc->setTestCaseCount(tc->testCaseCount() + it.value().testSetCount); @@ -307,7 +307,7 @@ QList GTestTreeItem::getTestConfigurationsForFile(const Uti }); for (auto it = testCases.begin(), end = testCases.end(); it != end; ++it) { for (const QString &target : qAsConst(it.value().internalTargets)) { - GTestConfiguration *tc = new GTestConfiguration; + GTestConfiguration *tc = new GTestConfiguration(framework()); tc->setTestCases(it.value().filters); tc->setProjectFile(it.key()); tc->setProject(project); @@ -420,7 +420,7 @@ TestTreeItem *GTestTreeItem::createParentGroupNode() const if (GTestFramework::groupMode() == GTest::Constants::Directory) { const QFileInfo fileInfo(filePath()); const QFileInfo base(fileInfo.absolutePath()); - return new GTestTreeItem(base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); + return new GTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); } else { // GTestFilter QTC_ASSERT(childCount(), return nullptr); // paranoia const TestTreeItem *firstChild = childAt(0); @@ -428,7 +428,7 @@ TestTreeItem *GTestTreeItem::createParentGroupNode() const const QString fullTestName = name() + '.' + firstChild->name(); const QString groupNodeName = matchesFilter(activeFilter, fullTestName) ? matchingString() : notMatchingString(); - auto groupNode = new GTestTreeItem(groupNodeName, activeFilter, TestTreeItem::GroupNode); + auto groupNode = new GTestTreeItem(framework(), groupNodeName, activeFilter, TestTreeItem::GroupNode); if (groupNodeName == notMatchingString()) groupNode->setData(0, Qt::Unchecked, Qt::CheckStateRole); return groupNode; diff --git a/src/plugins/autotest/gtest/gtesttreeitem.h b/src/plugins/autotest/gtest/gtesttreeitem.h index 3b93116ffc5..3e5c1620a10 100644 --- a/src/plugins/autotest/gtest/gtesttreeitem.h +++ b/src/plugins/autotest/gtest/gtesttreeitem.h @@ -46,8 +46,12 @@ public: Q_FLAGS(TestState) Q_DECLARE_FLAGS(TestStates, TestState) - explicit GTestTreeItem(const QString &name = QString(), const QString &filePath = QString(), - Type type = Root) : TestTreeItem(name, filePath, type), m_state(Enabled) {} + explicit GTestTreeItem(ITestFramework *framework, + const QString &name = QString(), + const QString &filePath = QString(), + Type type = Root) + : TestTreeItem(framework, name, filePath, type), m_state(Enabled) + {} TestTreeItem *copyWithoutChildren() override; QVariant data(int column, int role) const override; diff --git a/src/plugins/autotest/itestframework.h b/src/plugins/autotest/itestframework.h index 8d81b28289a..27efbaaa606 100644 --- a/src/plugins/autotest/itestframework.h +++ b/src/plugins/autotest/itestframework.h @@ -83,7 +83,7 @@ public: protected: virtual ITestParser *createTestParser() = 0; - virtual TestTreeItem *createRootNode() const = 0; + virtual TestTreeItem *createRootNode() = 0; private: TestTreeItem *m_rootNode = nullptr; diff --git a/src/plugins/autotest/qtest/qttestconfiguration.cpp b/src/plugins/autotest/qtest/qttestconfiguration.cpp index 81618dfb14f..a3bc92c67c4 100644 --- a/src/plugins/autotest/qtest/qttestconfiguration.cpp +++ b/src/plugins/autotest/qtest/qttestconfiguration.cpp @@ -29,7 +29,7 @@ #include "qttestsettings.h" #include "qttest_utils.h" #include "../autotestplugin.h" -#include "../testframeworkmanager.h" +#include "../itestframework.h" #include "../testsettings.h" namespace Autotest { @@ -38,10 +38,7 @@ namespace Internal { TestOutputReader *QtTestConfiguration::outputReader(const QFutureInterface &fi, QProcess *app) const { - static const Core::Id id - = Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME); - TestFrameworkManager *manager = TestFrameworkManager::instance(); - auto qtSettings = dynamic_cast(manager->settingsForTestFramework(id)); + auto qtSettings = dynamic_cast(framework()->frameworkSettings()); const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput ? QtTestOutputReader::XML : QtTestOutputReader::PlainText; @@ -50,17 +47,13 @@ TestOutputReader *QtTestConfiguration::outputReader(const QFutureInterfaceprocessArgs) { arguments.append(QTestUtils::filterInterfering( runnable().commandLineArguments.split(' ', QString::SkipEmptyParts), omitted, false)); } - TestFrameworkManager *manager = TestFrameworkManager::instance(); - auto qtSettings = dynamic_cast(manager->settingsForTestFramework(id)); + auto qtSettings = dynamic_cast(framework()->frameworkSettings()); if (!qtSettings) return arguments; if (qtSettings->useXMLOutput) diff --git a/src/plugins/autotest/qtest/qttestconfiguration.h b/src/plugins/autotest/qtest/qttestconfiguration.h index f38ad7f847b..8196665679c 100644 --- a/src/plugins/autotest/qtest/qttestconfiguration.h +++ b/src/plugins/autotest/qtest/qttestconfiguration.h @@ -33,7 +33,8 @@ namespace Internal { class QtTestConfiguration : public DebuggableTestConfiguration { public: - explicit QtTestConfiguration() {} + explicit QtTestConfiguration(ITestFramework *framework) + : DebuggableTestConfiguration(framework) {} TestOutputReader *outputReader(const QFutureInterface &fi, QProcess *app) const override; QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override; diff --git a/src/plugins/autotest/qtest/qttestframework.cpp b/src/plugins/autotest/qtest/qttestframework.cpp index 02484079671..c606c53f32e 100644 --- a/src/plugins/autotest/qtest/qttestframework.cpp +++ b/src/plugins/autotest/qtest/qttestframework.cpp @@ -36,9 +36,10 @@ ITestParser *QtTestFramework::createTestParser() return new QtTestParser(this); } -TestTreeItem *QtTestFramework::createRootNode() const +TestTreeItem *QtTestFramework::createRootNode() { return new QtTestTreeItem( + this, QCoreApplication::translate("QtTestFramework", QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY), QString(), TestTreeItem::Root); diff --git a/src/plugins/autotest/qtest/qttestframework.h b/src/plugins/autotest/qtest/qttestframework.h index 803079f5937..6cfa70a2117 100644 --- a/src/plugins/autotest/qtest/qttestframework.h +++ b/src/plugins/autotest/qtest/qttestframework.h @@ -42,7 +42,7 @@ private: const char *name() const override; unsigned priority() const override; ITestParser *createTestParser() override; - TestTreeItem *createRootNode() const override; + TestTreeItem *createRootNode() override; IFrameworkSettings *frameworkSettings() override { return &m_settings; } QtTestSettings m_settings; diff --git a/src/plugins/autotest/qtest/qttestparser.cpp b/src/plugins/autotest/qtest/qttestparser.cpp index 41a8463cc6c..5367d89a551 100644 --- a/src/plugins/autotest/qtest/qttestparser.cpp +++ b/src/plugins/autotest/qtest/qttestparser.cpp @@ -41,7 +41,7 @@ TestTreeItem *QtTestParseResult::createTestTreeItem() const if (itemType == TestTreeItem::Root) return nullptr; - QtTestTreeItem *item = new QtTestTreeItem(displayName, fileName, itemType); + QtTestTreeItem *item = new QtTestTreeItem(framework, displayName, fileName, itemType); item->setProFile(proFile); item->setLine(line); item->setColumn(column); diff --git a/src/plugins/autotest/qtest/qttesttreeitem.cpp b/src/plugins/autotest/qtest/qttesttreeitem.cpp index df15f385580..a128a809416 100644 --- a/src/plugins/autotest/qtest/qttesttreeitem.cpp +++ b/src/plugins/autotest/qtest/qttesttreeitem.cpp @@ -34,8 +34,9 @@ namespace Autotest { namespace Internal { -QtTestTreeItem::QtTestTreeItem(const QString &name, const QString &filePath, TestTreeItem::Type type) - : TestTreeItem(name, filePath, type) +QtTestTreeItem::QtTestTreeItem(ITestFramework *framework, const QString &name, + const QString &filePath, TestTreeItem::Type type) + : TestTreeItem(framework, name, filePath, type) { if (type == TestDataTag) setData(0, Qt::Checked, Qt::CheckStateRole); @@ -43,7 +44,7 @@ QtTestTreeItem::QtTestTreeItem(const QString &name, const QString &filePath, Tes TestTreeItem *QtTestTreeItem::copyWithoutChildren() { - QtTestTreeItem *copied = new QtTestTreeItem; + QtTestTreeItem *copied = new QtTestTreeItem(framework()); copied->copyBasicDataFrom(this); copied->m_inherited = m_inherited; return copied; @@ -114,14 +115,14 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const QtTestConfiguration *config = nullptr; switch (type()) { case TestCase: - config = new QtTestConfiguration; + config = new QtTestConfiguration(framework()); config->setTestCaseCount(childCount()); config->setProjectFile(proFile()); config->setProject(project); break; case TestFunction: { TestTreeItem *parent = parentItem(); - config = new QtTestConfiguration(); + config = new QtTestConfiguration(framework()); config->setTestCases(QStringList(name())); config->setProjectFile(parent->proFile()); config->setProject(project); @@ -133,7 +134,7 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const if (!parent) return nullptr; const QString functionWithTag = function->name() + ':' + name(); - config = new QtTestConfiguration(); + config = new QtTestConfiguration(framework()); config->setTestCases(QStringList(functionWithTag)); config->setProjectFile(parent->proFile()); config->setProject(project); @@ -180,7 +181,7 @@ static void fillTestConfigurationsFromCheckState(const TestTreeItem *item, } }); - testConfig = new QtTestConfiguration(); + testConfig = new QtTestConfiguration(item->framework()); testConfig->setTestCases(testCases); testConfig->setProjectFile(item->proFile()); testConfig->setProject(ProjectExplorer::SessionManager::startupProject()); @@ -342,7 +343,7 @@ TestTreeItem *QtTestTreeItem::createParentGroupNode() const { const QFileInfo fileInfo(filePath()); const QFileInfo base(fileInfo.absolutePath()); - return new QtTestTreeItem(base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); + return new QtTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); } bool QtTestTreeItem::isGroupable() const diff --git a/src/plugins/autotest/qtest/qttesttreeitem.h b/src/plugins/autotest/qtest/qttesttreeitem.h index 97ad8535805..9b803ee92eb 100644 --- a/src/plugins/autotest/qtest/qttesttreeitem.h +++ b/src/plugins/autotest/qtest/qttesttreeitem.h @@ -33,7 +33,7 @@ namespace Internal { class QtTestTreeItem : public TestTreeItem { public: - explicit QtTestTreeItem(const QString &name = QString(), const QString &filePath = QString(), + explicit QtTestTreeItem(ITestFramework *framework, const QString &name = QString(), const QString &filePath = QString(), Type type = Root); TestTreeItem *copyWithoutChildren() override; diff --git a/src/plugins/autotest/quick/quicktestconfiguration.cpp b/src/plugins/autotest/quick/quicktestconfiguration.cpp index c2ae540b43c..e61c4f12d8e 100644 --- a/src/plugins/autotest/quick/quicktestconfiguration.cpp +++ b/src/plugins/autotest/quick/quicktestconfiguration.cpp @@ -29,13 +29,14 @@ #include "../qtest/qttestsettings.h" #include "../qtest/qttest_utils.h" #include "../autotestplugin.h" -#include "../testframeworkmanager.h" +#include "../itestframework.h" #include "../testsettings.h" namespace Autotest { namespace Internal { -QuickTestConfiguration::QuickTestConfiguration() +QuickTestConfiguration::QuickTestConfiguration(ITestFramework *framework) + : DebuggableTestConfiguration(framework) { setMixedDebugging(true); } @@ -43,10 +44,7 @@ QuickTestConfiguration::QuickTestConfiguration() TestOutputReader *QuickTestConfiguration::outputReader(const QFutureInterface &fi, QProcess *app) const { - static const Core::Id id - = Core::Id(Constants::FRAMEWORK_PREFIX).withSuffix(QtTest::Constants::FRAMEWORK_NAME); - TestFrameworkManager *manager = TestFrameworkManager::instance(); - auto qtSettings = dynamic_cast(manager->settingsForTestFramework(id)); + auto qtSettings = dynamic_cast(framework()->frameworkSettings()); const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput ? QtTestOutputReader::XML : QtTestOutputReader::PlainText; @@ -56,9 +54,6 @@ TestOutputReader *QuickTestConfiguration::outputReader(const QFutureInterfaceprocessArgs) { arguments.append(QTestUtils::filterInterfering @@ -66,8 +61,7 @@ QStringList QuickTestConfiguration::argumentsForTestRunner(QStringList *omitted) omitted, true)); } - TestFrameworkManager *manager = TestFrameworkManager::instance(); - auto qtSettings = dynamic_cast(manager->settingsForTestFramework(id)); + auto qtSettings = dynamic_cast(framework()->frameworkSettings()); if (!qtSettings) return arguments; if (qtSettings->useXMLOutput) diff --git a/src/plugins/autotest/quick/quicktestconfiguration.h b/src/plugins/autotest/quick/quicktestconfiguration.h index 286b891741c..ae1e46797c2 100644 --- a/src/plugins/autotest/quick/quicktestconfiguration.h +++ b/src/plugins/autotest/quick/quicktestconfiguration.h @@ -33,7 +33,7 @@ namespace Internal { class QuickTestConfiguration : public DebuggableTestConfiguration { public: - QuickTestConfiguration(); + explicit QuickTestConfiguration(ITestFramework *framework); TestOutputReader *outputReader(const QFutureInterface &fi, QProcess *app) const override; QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override; diff --git a/src/plugins/autotest/quick/quicktestframework.cpp b/src/plugins/autotest/quick/quicktestframework.cpp index 69dd5eb7c75..fc6b1e34d11 100644 --- a/src/plugins/autotest/quick/quicktestframework.cpp +++ b/src/plugins/autotest/quick/quicktestframework.cpp @@ -35,9 +35,9 @@ ITestParser *QuickTestFramework::createTestParser() return new QuickTestParser(this); } -TestTreeItem *QuickTestFramework::createRootNode() const +TestTreeItem *QuickTestFramework::createRootNode() { - return new QuickTestTreeItem(QCoreApplication::translate("QuickTestFramework", "Quick Test"), + return new QuickTestTreeItem(this, QCoreApplication::translate("QuickTestFramework", "Quick Test"), QString(), TestTreeItem::Root); } diff --git a/src/plugins/autotest/quick/quicktestframework.h b/src/plugins/autotest/quick/quicktestframework.h index 27982e8a2a8..d42e9ff46e3 100644 --- a/src/plugins/autotest/quick/quicktestframework.h +++ b/src/plugins/autotest/quick/quicktestframework.h @@ -47,7 +47,7 @@ public: protected: ITestParser *createTestParser() override; - TestTreeItem *createRootNode() const override; + TestTreeItem *createRootNode() override; }; } // namespace Internal diff --git a/src/plugins/autotest/quick/quicktestparser.cpp b/src/plugins/autotest/quick/quicktestparser.cpp index 053e9c88b1e..923ead8c2fc 100644 --- a/src/plugins/autotest/quick/quicktestparser.cpp +++ b/src/plugins/autotest/quick/quicktestparser.cpp @@ -49,7 +49,7 @@ TestTreeItem *QuickTestParseResult::createTestTreeItem() const if (itemType == TestTreeItem::Root || itemType == TestTreeItem::TestDataTag) return nullptr; - QuickTestTreeItem *item = new QuickTestTreeItem(name, fileName, itemType); + QuickTestTreeItem *item = new QuickTestTreeItem(framework, name, fileName, itemType); item->setProFile(proFile); item->setLine(line); item->setColumn(column); diff --git a/src/plugins/autotest/quick/quicktesttreeitem.cpp b/src/plugins/autotest/quick/quicktesttreeitem.cpp index 9675b057197..66a95c106e9 100644 --- a/src/plugins/autotest/quick/quicktesttreeitem.cpp +++ b/src/plugins/autotest/quick/quicktesttreeitem.cpp @@ -38,7 +38,7 @@ namespace Internal { TestTreeItem *QuickTestTreeItem::copyWithoutChildren() { - QuickTestTreeItem *copied = new QuickTestTreeItem; + QuickTestTreeItem *copied = new QuickTestTreeItem(framework()); copied->copyBasicDataFrom(this); return copied; } @@ -137,7 +137,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const if (child->type() == TestTreeItem::TestFunction) testFunctions << testName + "::" + child->name(); }); - config = new QuickTestConfiguration; + config = new QuickTestConfiguration(framework()); config->setTestCases(testFunctions); config->setProjectFile(proFile()); config->setProject(project); @@ -146,7 +146,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const case TestFunction: { TestTreeItem *parent = parentItem(); QStringList testFunction(parent->name() + "::" + name()); - config = new QuickTestConfiguration; + config = new QuickTestConfiguration(framework()); config->setTestCases(testFunction); config->setProjectFile(parent->proFile()); config->setProject(project); @@ -186,7 +186,7 @@ static void testConfigurationFromCheckState(const TestTreeItem *item, oldFunctions << testFunctions; tc->setTestCases(oldFunctions); } else { - tc = new QuickTestConfiguration; + tc = new QuickTestConfiguration(item->framework()); tc->setTestCases(testFunctions); tc->setProjectFile(item->proFile()); tc->setProject(ProjectExplorer::SessionManager::startupProject()); @@ -244,7 +244,7 @@ QList QuickTestTreeItem::getAllTestConfigurations() const }); // create TestConfiguration for each project file for (auto it = testsForProfile.begin(), end = testsForProfile.end(); it != end; ++it) { - QuickTestConfiguration *tc = new QuickTestConfiguration; + QuickTestConfiguration *tc = new QuickTestConfiguration(framework()); tc->setTestCaseCount(it.value().testCount); tc->setProjectFile(it.key()); tc->setProject(project); @@ -404,7 +404,7 @@ TestTreeItem *QuickTestTreeItem::createParentGroupNode() const { const QFileInfo fileInfo(filePath()); const QFileInfo base(fileInfo.absolutePath()); - return new QuickTestTreeItem(base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); + return new QuickTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); } bool QuickTestTreeItem::isGroupable() const diff --git a/src/plugins/autotest/quick/quicktesttreeitem.h b/src/plugins/autotest/quick/quicktesttreeitem.h index f99db4ce544..050c7c4dd14 100644 --- a/src/plugins/autotest/quick/quicktesttreeitem.h +++ b/src/plugins/autotest/quick/quicktesttreeitem.h @@ -33,8 +33,12 @@ namespace Internal { class QuickTestTreeItem : public TestTreeItem { public: - explicit QuickTestTreeItem(const QString &name = QString(), const QString &filePath = QString(), - Type type = Root) : TestTreeItem(name, filePath, type) {} + explicit QuickTestTreeItem(ITestFramework *framework, + const QString &name = QString(), + const QString &filePath = QString(), + Type type = Root) + : TestTreeItem(framework, name, filePath, type) + {} TestTreeItem *copyWithoutChildren() override; QVariant data(int column, int role) const override; diff --git a/src/plugins/autotest/testconfiguration.cpp b/src/plugins/autotest/testconfiguration.cpp index 1735f3d65d6..96a5a842dbf 100644 --- a/src/plugins/autotest/testconfiguration.cpp +++ b/src/plugins/autotest/testconfiguration.cpp @@ -49,6 +49,11 @@ using namespace Utils; namespace Autotest { +TestConfiguration::TestConfiguration(ITestFramework *framework) + : m_framework(framework) +{ +} + TestConfiguration::~TestConfiguration() { m_testCases.clear(); @@ -351,4 +356,9 @@ bool TestConfiguration::hasExecutable() const return !m_runnable.executable.isEmpty(); } +ITestFramework *TestConfiguration::framework() const +{ + return m_framework; +} + } // namespace Autotest diff --git a/src/plugins/autotest/testconfiguration.h b/src/plugins/autotest/testconfiguration.h index 56533f8a520..2c8d4046a71 100644 --- a/src/plugins/autotest/testconfiguration.h +++ b/src/plugins/autotest/testconfiguration.h @@ -45,6 +45,7 @@ namespace Internal { class TestRunConfiguration; } // namespace Internal +class ITestFramework; class TestOutputReader; class TestResult; enum class TestRunMode; @@ -54,7 +55,7 @@ using TestResultPtr = QSharedPointer; class TestConfiguration { public: - explicit TestConfiguration() = default; + explicit TestConfiguration(ITestFramework *framework); virtual ~TestConfiguration(); void completeTestInformation(TestRunMode runMode); @@ -73,6 +74,7 @@ public: void setInternalTargets(const QSet &targets); void setOriginalRunConfiguration(ProjectExplorer::RunConfiguration *runConfig); + ITestFramework *framework() const; QStringList testCases() const { return m_testCases; } int testCaseCount() const { return m_testCaseCount; } QString executableFilePath() const; @@ -95,7 +97,9 @@ public: QProcess *app) const = 0; virtual QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const = 0; virtual Utils::Environment filteredEnvironment(const Utils::Environment &original) const = 0; + private: + ITestFramework *m_framework; QStringList m_testCases; int m_testCaseCount = 0; QString m_projectFile; @@ -113,8 +117,8 @@ private: class DebuggableTestConfiguration : public TestConfiguration { public: - explicit DebuggableTestConfiguration(TestRunMode runMode = TestRunMode::Run) - : m_runMode(runMode) {} + explicit DebuggableTestConfiguration(ITestFramework *framework, TestRunMode runMode = TestRunMode::Run) + : TestConfiguration(framework), m_runMode(runMode) {} void setRunMode(TestRunMode mode) { m_runMode = mode; } TestRunMode runMode() const { return m_runMode; } diff --git a/src/plugins/autotest/testframeworkmanager.cpp b/src/plugins/autotest/testframeworkmanager.cpp index 6531a2b8ae7..c6684259a58 100644 --- a/src/plugins/autotest/testframeworkmanager.cpp +++ b/src/plugins/autotest/testframeworkmanager.cpp @@ -120,14 +120,6 @@ ITestFramework *TestFrameworkManager::frameworkForId(Id frameworkId) }); } -IFrameworkSettings *TestFrameworkManager::settingsForTestFramework( - const Id &frameworkId) const -{ - ITestFramework *framework = frameworkForId(frameworkId); - QTC_ASSERT(framework, return nullptr); - return framework->frameworkSettings(); -} - void TestFrameworkManager::synchronizeSettings(QSettings *s) { Internal::AutotestPlugin::settings()->fromSettings(s); diff --git a/src/plugins/autotest/testframeworkmanager.h b/src/plugins/autotest/testframeworkmanager.h index 549d772c570..59145f28b52 100644 --- a/src/plugins/autotest/testframeworkmanager.h +++ b/src/plugins/autotest/testframeworkmanager.h @@ -61,7 +61,6 @@ public: TestFrameworks sortedRegisteredFrameworks() const; TestFrameworks sortedActiveFrameworks() const; - IFrameworkSettings *settingsForTestFramework(const Core::Id &frameworkId) const; void synchronizeSettings(QSettings *s); bool hasActiveFrameworks() const; diff --git a/src/plugins/autotest/testtreeitem.cpp b/src/plugins/autotest/testtreeitem.cpp index fee361e25e5..5debb983d64 100644 --- a/src/plugins/autotest/testtreeitem.cpp +++ b/src/plugins/autotest/testtreeitem.cpp @@ -38,8 +38,10 @@ namespace Autotest { -TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type type) - : m_name(name), +TestTreeItem::TestTreeItem(ITestFramework *framework, const QString &name, + const QString &filePath, Type type) + : m_framework(framework), + m_name(name), m_filePath(filePath), m_type(type) { @@ -355,6 +357,11 @@ inline bool TestTreeItem::modifyName(const QString &name) return false; } +ITestFramework *TestTreeItem::framework() const +{ + return m_framework; +} + /* * try to find build system target that depends on the given file - if the file is no header * try to find the corresponding header and use this instead to find the respective target diff --git a/src/plugins/autotest/testtreeitem.h b/src/plugins/autotest/testtreeitem.h index ad86dcb8425..8d77ba0a6c5 100644 --- a/src/plugins/autotest/testtreeitem.h +++ b/src/plugins/autotest/testtreeitem.h @@ -46,6 +46,7 @@ namespace Utils { class FilePath; } namespace Autotest { +class ITestFramework; class TestConfiguration; class TestParseResult; enum class TestRunMode; @@ -71,7 +72,9 @@ public: Naturally }; - explicit TestTreeItem(const QString &name = QString(), const QString &filePath = QString(), + explicit TestTreeItem(ITestFramework *framework, + const QString &name = QString(), + const QString &filePath = QString(), Type type = Root); virtual TestTreeItem *copyWithoutChildren() = 0; @@ -83,6 +86,7 @@ public: bool modifyDataTagContent(const TestParseResult *result); bool modifyLineAndColumn(const TestParseResult *result); + ITestFramework *framework() const; const QString name() const { return m_name; } void setName(const QString &name) { m_name = name; } const QString filePath() const { return m_filePath; } @@ -129,6 +133,7 @@ public: // decide whether an item should still be added to the treemodel virtual bool shouldBeAddedAfterFiltering() const { return true; } virtual QSet internalTargets() const; + protected: void copyBasicDataFrom(const TestTreeItem *other); typedef std::function CompareFunction; @@ -146,6 +151,7 @@ private: Cleared }; + ITestFramework *m_framework = nullptr; QString m_name; QString m_filePath; Qt::CheckState m_checked;