summaryrefslogtreecommitdiff
path: root/src/plugins/autotest/quick
diff options
context:
space:
mode:
authorBernhard Beschow <shentey@gmail.com>2021-01-01 19:19:43 +0100
committerBernhard Beschow <shentey@gmail.com>2021-04-12 06:42:49 +0000
commitac61bfdc906468b1437602b8c6b169b114061ab8 (patch)
tree04a12d9b83c54884df5cad83c620b19813a446d9 /src/plugins/autotest/quick
parent3f0f289b28efffa9bf1d0e68e84d01054ecdb3bb (diff)
downloadqt-creator-ac61bfdc906468b1437602b8c6b169b114061ab8.tar.gz
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>
Diffstat (limited to 'src/plugins/autotest/quick')
-rw-r--r--src/plugins/autotest/quick/quicktesttreeitem.cpp14
-rw-r--r--src/plugins/autotest/quick/quicktesttreeitem.h1
2 files changed, 8 insertions, 7 deletions
diff --git a/src/plugins/autotest/quick/quicktesttreeitem.cpp b/src/plugins/autotest/quick/quicktesttreeitem.cpp
index d93df66759..2e449cf93b 100644
--- a/src/plugins/autotest/quick/quicktesttreeitem.cpp
+++ b/src/plugins/autotest/quick/quicktesttreeitem.cpp
@@ -36,6 +36,8 @@
namespace Autotest {
namespace Internal {
+QSet<QString> internalTargets(const QString &proFile);
+
TestTreeItem *QuickTestTreeItem::copyWithoutChildren()
{
QuickTestTreeItem *copied = new QuickTestTreeItem(framework());
@@ -156,7 +158,7 @@ ITestConfiguration *QuickTestTreeItem::testConfiguration() const
return nullptr;
}
if (config)
- config->setInternalTargets(internalTargets());
+ config->setInternalTargets(internalTargets(proFile()));
return config;
}
@@ -189,7 +191,7 @@ static QList<ITestConfiguration *> testConfigurationsFor(
auto tc = new QuickTestConfiguration(treeItem->framework());
tc->setProjectFile(treeItem->proFile());
tc->setProject(ProjectExplorer::SessionManager::startupProject());
- tc->setInternalTargets(treeItem->internalTargets());
+ tc->setInternalTargets(internalTargets(treeItem->proFile()));
it = configurationForProFiles.insert(treeItem->proFile(), tc);
}
it.value()->setTestCases(it.value()->testCases() + functions);
@@ -216,7 +218,7 @@ struct Tests {
static void addTestsForItem(Tests &tests, const TestTreeItem *item)
{
tests.testCount += item->childCount();
- tests.internalTargets = item->internalTargets();
+ tests.internalTargets = internalTargets(item->proFile());
}
QList<ITestConfiguration *> QuickTestTreeItem::getAllTestConfigurations() const
@@ -234,7 +236,7 @@ QList<ITestConfiguration *> QuickTestTreeItem::getAllTestConfigurations() const
child->forFirstLevelChildItems([&testsForProfile](TestTreeItem *grandChild) {
const QString &proFile = grandChild->proFile();
++(testsForProfile[proFile].testCount);
- testsForProfile[proFile].internalTargets = grandChild->internalTargets();
+ testsForProfile[proFile].internalTargets = internalTargets(grandChild->proFile());
});
return;
}
@@ -384,7 +386,7 @@ bool QuickTestTreeItem::isGroupable() const
return type() == TestCase && !name().isEmpty() && !filePath().isEmpty();
}
-QSet<QString> QuickTestTreeItem::internalTargets() const
+QSet<QString> internalTargets(const QString &proFile)
{
QSet<QString> result;
const auto cppMM = CppTools::CppModelManager::instance();
@@ -392,7 +394,7 @@ QSet<QString> QuickTestTreeItem::internalTargets() const
for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo.projectParts()) {
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
continue;
- if (projectPart->projectFile == proFile())
+ if (projectPart->projectFile == proFile)
result.insert(projectPart->buildSystemTarget);
}
return result;
diff --git a/src/plugins/autotest/quick/quicktesttreeitem.h b/src/plugins/autotest/quick/quicktesttreeitem.h
index a599c6ceab..5397d01f77 100644
--- a/src/plugins/autotest/quick/quicktesttreeitem.h
+++ b/src/plugins/autotest/quick/quicktesttreeitem.h
@@ -59,7 +59,6 @@ public:
bool removeOnSweepIfEmpty() const override;
TestTreeItem *createParentGroupNode() const override;
bool isGroupable() const override;
- QSet<QString> internalTargets() const override;
void markForRemovalRecursively(const QString &filePath) override;
private:
TestTreeItem *findChildByFileNameAndType(const QString &filePath, const QString &name,