diff options
Diffstat (limited to 'src/plugins/autotest/catch/catchtreeitem.cpp')
-rw-r--r-- | src/plugins/autotest/catch/catchtreeitem.cpp | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/plugins/autotest/catch/catchtreeitem.cpp b/src/plugins/autotest/catch/catchtreeitem.cpp index e0fbb145a9..96ee881653 100644 --- a/src/plugins/autotest/catch/catchtreeitem.cpp +++ b/src/plugins/autotest/catch/catchtreeitem.cpp @@ -27,6 +27,7 @@ #include "catchconfiguration.h" #include "catchframework.h" +#include <cpptools/cppmodelmanager.h> #include <projectexplorer/project.h> #include <projectexplorer/session.h> #include <utils/qtcassert.h> @@ -48,7 +49,7 @@ static QString nonRootDisplayName(const CatchTreeItem *it) return it->name(); TestTreeItem *parent = it->parentItem(); int baseDirSize = (parent->type() == TestTreeItem::GroupNode) - ? parent->filePath().size() : project->projectDirectory().toString().size(); + ? parent->filePath().toString().size() : project->projectDirectory().toString().size(); return it->name().mid(baseDirSize + 1); } @@ -87,7 +88,7 @@ TestTreeItem *CatchTreeItem::find(const TestParseResult *result) switch (type()) { case Root: if (result->framework->grouping()) { - const QString path = QFileInfo(result->fileName).absolutePath(); + const Utils::FilePath path = result->fileName.absolutePath(); for (int row = 0; row < childCount(); ++row) { TestTreeItem *group = childItem(row); if (group->filePath() != path) @@ -138,9 +139,8 @@ bool CatchTreeItem::modify(const TestParseResult *result) TestTreeItem *CatchTreeItem::createParentGroupNode() const { - const QFileInfo fileInfo(filePath()); - const QFileInfo base(fileInfo.absolutePath()); - return new CatchTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); + const QFileInfo base(filePath().toFileInfo().absolutePath()); + return new CatchTreeItem(framework(), base.baseName(), filePath(), TestTreeItem::GroupNode); } bool CatchTreeItem::canProvideTestConfiguration() const @@ -157,6 +157,8 @@ ITestConfiguration *CatchTreeItem::testConfiguration() const { ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); QTC_ASSERT(project, return nullptr); + const auto cppMM = CppTools::CppModelManager::instance(); + QTC_ASSERT(cppMM, return nullptr); if (type() != TestCase) return nullptr; @@ -167,7 +169,7 @@ ITestConfiguration *CatchTreeItem::testConfiguration() const config->setProjectFile(proFile()); config->setProject(project); config->setTestCases(QStringList(testCasesString())); - config->setInternalTargets(internalTargets()); + config->setInternalTargets(cppMM->internalTargets(filePath())); return config; } @@ -186,10 +188,12 @@ struct CatchTestCases }; static void collectTestInfo(const TestTreeItem *item, - QHash<QString, CatchTestCases> &testCasesForProfile, + QHash<Utils::FilePath, CatchTestCases> &testCasesForProfile, bool ignoreCheckState) { QTC_ASSERT(item, return); + const auto cppMM = CppTools::CppModelManager::instance(); + QTC_ASSERT(cppMM, return); const int childCount = item->childCount(); if (item->type() == TestTreeItem::GroupNode) { item->forFirstLevelChildItems([&testCasesForProfile, ignoreCheckState](TestTreeItem *it) { @@ -201,20 +205,20 @@ static void collectTestInfo(const TestTreeItem *item, QTC_ASSERT(childCount != 0, return); QTC_ASSERT(item->type() == TestTreeItem::TestSuite, return); if (ignoreCheckState || item->checked() == Qt::Checked) { - const QString &projectFile = item->childItem(0)->proFile(); + const Utils::FilePath &projectFile = item->childItem(0)->proFile(); item->forAllChildItems([&testCasesForProfile, &projectFile](TestTreeItem *it) { CatchTreeItem *current = static_cast<CatchTreeItem *>(it); testCasesForProfile[projectFile].names.append(current->testCasesString()); }); - testCasesForProfile[projectFile].internalTargets.unite(item->internalTargets()); + testCasesForProfile[projectFile].internalTargets.unite(cppMM->internalTargets(item->filePath())); } else if (item->checked() == Qt::PartiallyChecked) { - item->forFirstLevelChildItems([&testCasesForProfile](TestTreeItem *child) { + item->forFirstLevelChildItems([&testCasesForProfile, cppMM](TestTreeItem *child) { QTC_ASSERT(child->type() == TestTreeItem::TestCase, return); if (child->checked() == Qt::Checked) { CatchTreeItem *current = static_cast<CatchTreeItem *>(child); testCasesForProfile[child->proFile()].names.append(current->testCasesString()); testCasesForProfile[child->proFile()].internalTargets.unite( - child->internalTargets()); + cppMM->internalTargets(child->filePath())); } }); @@ -222,7 +226,7 @@ static void collectTestInfo(const TestTreeItem *item, } static void collectFailedTestInfo(const CatchTreeItem *item, - QHash<QString, CatchTestCases> &testCasesForProfile) + QHash<Utils::FilePath, CatchTestCases> &testCasesForProfile) { QTC_ASSERT(item, return); QTC_ASSERT(item->type() == TestTreeItem::Root, return); @@ -230,11 +234,13 @@ static void collectFailedTestInfo(const CatchTreeItem *item, item->forAllChildItems([&testCasesForProfile](TestTreeItem *it) { QTC_ASSERT(it, return); QTC_ASSERT(it->parentItem(), return); + const auto cppMM = CppTools::CppModelManager::instance(); + QTC_ASSERT(cppMM, return); if (it->type() == TestTreeItem::TestCase && it->data(0, FailedRole).toBool()) { CatchTreeItem *current = static_cast<CatchTreeItem *>(it); testCasesForProfile[it->proFile()].names.append(current->testCasesString()); testCasesForProfile[it->proFile()].internalTargets.unite( - it->internalTargets()); + cppMM->internalTargets(it->filePath())); } }); } @@ -256,7 +262,7 @@ QList<ITestConfiguration *> CatchTreeItem::getFailedTestConfigurations() const if (!project || type() != Root) return result; - QHash<QString, CatchTestCases> testCasesForProFile; + QHash<Utils::FilePath, CatchTestCases> testCasesForProFile; collectFailedTestInfo(this, testCasesForProFile); for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) { @@ -276,6 +282,9 @@ QList<ITestConfiguration *> CatchTreeItem::getFailedTestConfigurations() const QList<ITestConfiguration *> CatchTreeItem::getTestConfigurationsForFile(const Utils::FilePath &fileName) const { QList<ITestConfiguration *> result; + const auto cppMM = CppTools::CppModelManager::instance(); + QTC_ASSERT(cppMM, return result); + ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); if (!project || type() != Root) return result; @@ -300,7 +309,7 @@ QList<ITestConfiguration *> CatchTreeItem::getTestConfigurationsForFile(const Ut testConfig->setTestCases(testCases); testConfig->setProjectFile(item->proFile()); testConfig->setProject(ProjectExplorer::SessionManager::startupProject()); - testConfig->setInternalTargets(item->internalTargets()); + testConfig->setInternalTargets(cppMM->internalTargets(item->filePath())); result << testConfig; } @@ -324,7 +333,7 @@ QList<ITestConfiguration *> CatchTreeItem::getTestConfigurations(bool ignoreChec if (!project || type() != Root) return result; - QHash<QString, CatchTestCases> testCasesForProfile; + QHash<Utils::FilePath, CatchTestCases> testCasesForProfile; for (int row = 0, end = childCount(); row < end; ++row) collectTestInfo(childItem(row), testCasesForProfile, ignoreCheckState); |