diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index 27e433896a1..ae03dc91d1d 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -438,6 +438,24 @@ void AutotestPluginPrivate::onRunUnderCursorTriggered(TestRunMode mode) m_testRunner.runTests(mode, testsToRun); } +TestFrameworks AutotestPlugin::activeTestFrameworks() +{ + ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); + TestFrameworks sorted; + if (!project || projectSettings(project)->useGlobalSettings()) { + sorted = Utils::filtered(TestFrameworkManager::registeredFrameworks(), + &ITestFramework::active); + } else { // we've got custom project settings + const TestProjectSettings *settings = projectSettings(project); + const QHash active = settings->activeFrameworks(); + sorted = Utils::filtered(TestFrameworkManager::registeredFrameworks(), + [active](ITestFramework *framework) { + return active.value(framework, false); + }); + } + return sorted; +} + void AutotestPlugin::updateMenuItemsEnabledState() { const ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); diff --git a/src/plugins/autotest/autotestplugin.h b/src/plugins/autotest/autotestplugin.h index 71d6b8e5ee3..f6b8b337af5 100644 --- a/src/plugins/autotest/autotestplugin.h +++ b/src/plugins/autotest/autotestplugin.h @@ -3,7 +3,7 @@ #pragma once -#include "autotest_global.h" +#include "itestframework.h" #include @@ -45,6 +45,7 @@ public: static TestSettings *settings(); static TestProjectSettings *projectSettings(ProjectExplorer::Project *project); + static TestFrameworks activeTestFrameworks(); static void updateMenuItemsEnabledState(); static void cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice); static ChoicePair cachedChoiceFor(const QString &buildTargetKey); diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp index 5a619ffe532..8842734f0c5 100644 --- a/src/plugins/autotest/testtreemodel.cpp +++ b/src/plugins/autotest/testtreemodel.cpp @@ -299,21 +299,8 @@ QList TestTreeModel::testItemsByName(const QString &testName) void TestTreeModel::synchronizeTestFrameworks() { - ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); - TestFrameworks sorted; - if (!project || AutotestPlugin::projectSettings(project)->useGlobalSettings()) { - sorted = Utils::filtered(TestFrameworkManager::registeredFrameworks(), - &ITestFramework::active); - qCDebug(LOG) << "Active frameworks sorted by priority" << sorted; - } else { // we've got custom project settings - const TestProjectSettings *settings = AutotestPlugin::projectSettings(project); - const QHash active = settings->activeFrameworks(); - sorted = Utils::filtered(TestFrameworkManager::registeredFrameworks(), - [active](ITestFramework *framework) { - return active.value(framework, false); - }); - } - + const TestFrameworks sorted = AutotestPlugin::activeTestFrameworks(); + qCDebug(LOG) << "Active frameworks sorted by priority" << sorted; const auto sortedParsers = Utils::transform(sorted, &ITestFramework::testParser); // pre-check to avoid further processing when frameworks are unchanged TreeItem *invisibleRoot = rootItem();