AutoTest: Free TestTreeItem from CppTools dependency

Makes TestTreeItem programming language agnostic.

By moving the "query" methods to CppTools, the cohesion within these
methods is improved, i.e. information crosses the AutoTest <-> CppTools
border fewer times. Furthermore, it allows the CppTools plugin to see
how its data is being used, allowing it to optimize its queries
behind the scenes.

Change-Id: I0a60140abaca1193d500605dfa2812b4d937d94c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Bernhard Beschow
2021-01-01 19:19:43 +01:00
parent 3f0f289b28
commit ac61bfdc90
11 changed files with 96 additions and 76 deletions

View File

@@ -30,6 +30,7 @@
#include "boosttestparser.h"
#include "../testframeworkmanager.h"
#include <cpptools/cppmodelmanager.h>
#include <projectexplorer/session.h>
#include <utils/qtcassert.h>
@@ -197,8 +198,10 @@ QList<ITestConfiguration *> BoostTestTreeItem::getAllTestConfigurations() const
++funcChildren;
});
if (funcChildren) {
const auto cppMM = CppTools::CppModelManager::instance();
QTC_ASSERT(cppMM, return);
testsPerProjectfile[item->proFile()].testCases += funcChildren;
testsPerProjectfile[item->proFile()].internalTargets.unite(item->internalTargets());
testsPerProjectfile[item->proFile()].internalTargets.unite(cppMM->internalTargets(item->filePath()));
}
});
@@ -236,6 +239,8 @@ QList<ITestConfiguration *> BoostTestTreeItem::getTestConfigurations(
if (!item->enabled()) // ignore child tests known to be disabled when using run selected
return;
if (predicate(item)) {
const auto cppMM = CppTools::CppModelManager::instance();
QTC_ASSERT(cppMM, return);
QString tcName = item->name();
if (item->state().testFlag(BoostTestTreeItem::Templated))
tcName.append("<*");
@@ -244,7 +249,7 @@ QList<ITestConfiguration *> BoostTestTreeItem::getTestConfigurations(
tcName = handleSpecialFunctionNames(tcName);
testCasesForProjectFile[item->proFile()].testCases.append(
item->prependWithParentsSuitePaths(tcName));
testCasesForProjectFile[item->proFile()].internalTargets.unite(item->internalTargets());
testCasesForProjectFile[item->proFile()].internalTargets.unite(cppMM->internalTargets(item->filePath()));
}
});
@@ -280,6 +285,8 @@ ITestConfiguration *BoostTestTreeItem::testConfiguration() const
{
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
QTC_ASSERT(project, return nullptr);
const auto cppMM = CppTools::CppModelManager::instance();
QTC_ASSERT(cppMM, return nullptr);
const Type itemType = type();
if (itemType == TestSuite || itemType == TestCase) {
@@ -313,7 +320,7 @@ ITestConfiguration *BoostTestTreeItem::testConfiguration() const
config->setProjectFile(proFile());
config->setProject(project);
config->setTestCases(testCases);
config->setInternalTargets(internalTargets());
config->setInternalTargets(cppMM->internalTargets(filePath()));
return config;
}
return nullptr;