diff options
41 files changed, 343 insertions, 310 deletions
diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index 3f8c2ff819..27e433896a 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -66,6 +66,7 @@ #endif using namespace Core; +using namespace Utils; namespace Autotest { namespace Internal { @@ -361,7 +362,7 @@ void AutotestPluginPrivate::onRunFileTriggered() if (!document) return; - const Utils::FilePath &fileName = document->filePath(); + const FilePath &fileName = document->filePath(); if (fileName.isEmpty()) return; @@ -398,7 +399,7 @@ void AutotestPluginPrivate::onRunUnderCursorTriggered(TestRunMode mode) // check whether we have been triggered on a test function definition const int line = currentEditor->currentLine(); - const Utils::FilePath &filePath = currentEditor->textDocument()->filePath(); + const FilePath &filePath = currentEditor->textDocument()->filePath(); QList<ITestTreeItem *> filteredItems = Utils::filtered(testsItems, [&](ITestTreeItem *it){ return it->line() == line && it->filePath() == filePath; }); diff --git a/src/plugins/autotest/autotestunittests.cpp b/src/plugins/autotest/autotestunittests.cpp index d655280d30..e72cc0cbbb 100644 --- a/src/plugins/autotest/autotestunittests.cpp +++ b/src/plugins/autotest/autotestunittests.cpp @@ -68,7 +68,7 @@ void AutoTestUnitTests::initTestCase() if (!qtcEnvironmentVariableIsEmpty("BOOST_INCLUDE_DIR")) { m_checkBoost = true; } else { - if (Utils::HostOsInfo::isLinuxHost() + if (HostOsInfo::isLinuxHost() && (QFileInfo::exists("/usr/include/boost/version.hpp") || QFileInfo::exists("/usr/local/include/boost/version.hpp"))) { qDebug() << "Found boost at system level - will run boost parser test."; @@ -77,7 +77,7 @@ void AutoTestUnitTests::initTestCase() } // Enable quick check for derived tests - static const Utils::Id id = Utils::Id("AutoTest.Framework.QtTest"); + static const Id id = Id("AutoTest.Framework.QtTest"); static_cast<Autotest::Internal::QtTestSettings *>( TestFrameworkManager::frameworkForId(id)->testSettings()) ->quickCheckForDerivedTests.setValue(true); @@ -257,7 +257,7 @@ void AutoTestUnitTests::testCodeParserBoostTest() QCOMPARE(m_model->boostTestNamesCount(), 5); - const Utils::FilePath basePath = projectInfo->projectRoot(); + const FilePath basePath = projectInfo->projectRoot(); QVERIFY(!basePath.isEmpty()); QMap<QString, int> expectedSuitesAndTests; diff --git a/src/plugins/autotest/boost/boosttestconfiguration.cpp b/src/plugins/autotest/boost/boosttestconfiguration.cpp index b3db3b8bcc..50d8a863f4 100644 --- a/src/plugins/autotest/boost/boosttestconfiguration.cpp +++ b/src/plugins/autotest/boost/boosttestconfiguration.cpp @@ -13,11 +13,13 @@ #include <utils/algorithm.h> #include <utils/stringutils.h> +using namespace Utils; + namespace Autotest { namespace Internal { TestOutputReader *BoostTestConfiguration::createOutputReader( - const QFutureInterface<TestResult> &fi, Utils::QtcProcess *app) const + const QFutureInterface<TestResult> &fi, QtcProcess *app) const { auto settings = static_cast<BoostTestSettings *>(framework()->testSettings()); return new BoostTestOutputReader(fi, app, buildDirectory(), projectFile(), @@ -113,11 +115,11 @@ QStringList BoostTestConfiguration::argumentsForTestRunner(QStringList *omitted) return arguments; } -Utils::Environment BoostTestConfiguration::filteredEnvironment(const Utils::Environment &original) const +Environment BoostTestConfiguration::filteredEnvironment(const Environment &original) const { const QStringList interferingEnv = interfering(InterferingType::EnvironmentVariables); - Utils::Environment result = original; + Environment result = original; if (!result.hasKey("BOOST_TEST_COLOR_OUTPUT")) result.set("BOOST_TEST_COLOR_OUTPUT", "1"); // use colored output by default for (const QString &key : interferingEnv) diff --git a/src/plugins/autotest/boost/boosttestoutputreader.cpp b/src/plugins/autotest/boost/boosttestoutputreader.cpp index 3847419b75..57d8503d27 100644 --- a/src/plugins/autotest/boost/boosttestoutputreader.cpp +++ b/src/plugins/autotest/boost/boosttestoutputreader.cpp @@ -14,15 +14,17 @@ #include <QLoggingCategory> #include <QRegularExpression> +using namespace Utils; + namespace Autotest { namespace Internal { static Q_LOGGING_CATEGORY(orLog, "qtc.autotest.boost.outputreader", QtWarningMsg) BoostTestOutputReader::BoostTestOutputReader(const QFutureInterface<TestResult> &futureInterface, - Utils::QtcProcess *testApplication, - const Utils::FilePath &buildDirectory, - const Utils::FilePath &projectFile, + QtcProcess *testApplication, + const FilePath &buildDirectory, + const FilePath &projectFile, LogLevel log, ReportLevel report) : TestOutputReader(futureInterface, testApplication, buildDirectory) , m_projectFile(projectFile) @@ -30,7 +32,7 @@ BoostTestOutputReader::BoostTestOutputReader(const QFutureInterface<TestResult> , m_reportLevel(report) { if (m_testApplication) - connect(m_testApplication, &Utils::QtcProcess::done, this, &BoostTestOutputReader::onDone); + connect(m_testApplication, &QtcProcess::done, this, &BoostTestOutputReader::onDone); } // content of "error:..." / "info:..." / ... messages diff --git a/src/plugins/autotest/boost/boosttestparser.cpp b/src/plugins/autotest/boost/boosttestparser.cpp index 4d261a4ca5..bbf6dfd56c 100644 --- a/src/plugins/autotest/boost/boosttestparser.cpp +++ b/src/plugins/autotest/boost/boosttestparser.cpp @@ -78,8 +78,8 @@ static bool hasBoostTestMacros(const CPlusPlus::Document::Ptr &doc) return false; } -static BoostTestParseResult *createParseResult(const QString &name, const Utils::FilePath &filePath, - const Utils::FilePath &projectFile, +static BoostTestParseResult *createParseResult(const QString &name, const FilePath &filePath, + const FilePath &projectFile, ITestFramework *framework, TestTreeItem::Type type, const BoostTestInfo &info) { @@ -97,7 +97,7 @@ static BoostTestParseResult *createParseResult(const QString &name, const Utils: } bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface, - const Utils::FilePath &fileName) + const FilePath &fileName) { CPlusPlus::Document::Ptr doc = document(fileName); if (doc.isNull() || !includesBoostTest(doc, m_cppSnapshot) || !hasBoostTestMacros(doc)) @@ -109,7 +109,7 @@ bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futu if (projectParts.isEmpty()) // happens if shutting down while parsing return false; const CppEditor::ProjectPart::ConstPtr projectPart = projectParts.first(); - const auto projectFile = Utils::FilePath::fromString(projectPart->projectFile); + const auto projectFile = FilePath::fromString(projectPart->projectFile); const QByteArray &fileContent = getFileContent(fileName); BoostCodeParser codeParser(fileContent, projectPart->languageFeatures, doc, m_cppSnapshot); diff --git a/src/plugins/autotest/boost/boosttestsettings.cpp b/src/plugins/autotest/boost/boosttestsettings.cpp index 1c5ee68e3a..c995cab9b6 100644 --- a/src/plugins/autotest/boost/boosttestsettings.cpp +++ b/src/plugins/autotest/boost/boosttestsettings.cpp @@ -81,7 +81,7 @@ BoostTestSettings::BoostTestSettings() memLeaks.setToolTip(Tr::tr("Enable memory leak detection.")); } -BoostTestSettingsPage::BoostTestSettingsPage(BoostTestSettings *settings, Utils::Id settingsId) +BoostTestSettingsPage::BoostTestSettingsPage(BoostTestSettings *settings, Id settingsId) { setId(settingsId); setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); diff --git a/src/plugins/autotest/boost/boosttesttreeitem.cpp b/src/plugins/autotest/boost/boosttesttreeitem.cpp index 41e203c592..4b53d92754 100644 --- a/src/plugins/autotest/boost/boosttesttreeitem.cpp +++ b/src/plugins/autotest/boost/boosttesttreeitem.cpp @@ -16,6 +16,8 @@ #include <QRegularExpression> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -123,7 +125,7 @@ bool BoostTestTreeItem::modify(const TestParseResult *result) TestTreeItem *BoostTestTreeItem::createParentGroupNode() const { - const Utils::FilePath &absPath = filePath().absolutePath(); + const FilePath &absPath = filePath().absolutePath(); return new BoostTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode); } @@ -164,7 +166,7 @@ QList<ITestConfiguration *> BoostTestTreeItem::getAllTestConfigurations() const }; // we only need the unique project files (and number of test cases for the progress indicator) - QHash<Utils::FilePath, BoostTestCases> testsPerProjectfile; + QHash<FilePath, BoostTestCases> testsPerProjectfile; forAllChildItems([&testsPerProjectfile](TestTreeItem *item){ if (item->type() != TestSuite) return; @@ -207,7 +209,7 @@ QList<ITestConfiguration *> BoostTestTreeItem::getTestConfigurations( QSet<QString> internalTargets; }; - QHash<Utils::FilePath, BoostTestCases> testCasesForProjectFile; + QHash<FilePath, BoostTestCases> testCasesForProjectFile; forAllChildren([&testCasesForProjectFile, &predicate](TreeItem *it){ auto item = static_cast<BoostTestTreeItem *>(it); if (item->type() != TestCase) @@ -346,10 +348,10 @@ bool BoostTestTreeItem::enabled() const TestTreeItem *BoostTestTreeItem::findChildByNameStateAndFile(const QString &name, BoostTestTreeItem::TestStates state, - const Utils::FilePath &proFile) const + const FilePath &proFile) const { return static_cast<TestTreeItem *>( - findAnyChild([name, state, proFile](const Utils::TreeItem *other){ + findAnyChild([name, state, proFile](const TreeItem *other){ const BoostTestTreeItem *boostItem = static_cast<const BoostTestTreeItem *>(other); return boostItem->proFile() == proFile && boostItem->fullName() == name && boostItem->state() == state; diff --git a/src/plugins/autotest/catch/catchconfiguration.cpp b/src/plugins/autotest/catch/catchconfiguration.cpp index b043b4e36e..c08f7ac82b 100644 --- a/src/plugins/autotest/catch/catchconfiguration.cpp +++ b/src/plugins/autotest/catch/catchconfiguration.cpp @@ -11,11 +11,13 @@ #include <utils/stringutils.h> +using namespace Utils; + namespace Autotest { namespace Internal { TestOutputReader *CatchConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi, - Utils::QtcProcess *app) const + QtcProcess *app) const { return new CatchOutputReader(fi, app, buildDirectory(), projectFile()); } @@ -115,7 +117,7 @@ QStringList CatchConfiguration::argumentsForTestRunner(QStringList *omitted) con return arguments; } -Utils::Environment CatchConfiguration::filteredEnvironment(const Utils::Environment &original) const +Environment CatchConfiguration::filteredEnvironment(const Environment &original) const { return original; } diff --git a/src/plugins/autotest/catch/catchoutputreader.cpp b/src/plugins/autotest/catch/catchoutputreader.cpp index fbc3ed0587..95e437fdc4 100644 --- a/src/plugins/autotest/catch/catchoutputreader.cpp +++ b/src/plugins/autotest/catch/catchoutputreader.cpp @@ -9,6 +9,8 @@ #include <utils/fileutils.h> #include <utils/qtcassert.h> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -30,9 +32,9 @@ namespace CatchXml { } CatchOutputReader::CatchOutputReader(const QFutureInterface<TestResult> &futureInterface, - Utils::QtcProcess *testApplication, - const Utils::FilePath &buildDirectory, - const Utils::FilePath &projectFile) + QtcProcess *testApplication, + const FilePath &buildDirectory, + const FilePath &projectFile) : TestOutputReader (futureInterface, testApplication, buildDirectory) , m_projectFile(projectFile) { diff --git a/src/plugins/autotest/catch/catchtestparser.cpp b/src/plugins/autotest/catch/catchtestparser.cpp index a3e9f5e01b..dd01c01c90 100644 --- a/src/plugins/autotest/catch/catchtestparser.cpp +++ b/src/plugins/autotest/catch/catchtestparser.cpp @@ -92,7 +92,7 @@ static bool hasCatchNames(const CPlusPlus::Document::Ptr &document) } bool CatchTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface, - const Utils::FilePath &fileName) + const FilePath &fileName) { CPlusPlus::Document::Ptr doc = document(fileName); if (doc.isNull() || !includesCatchHeader(doc, m_cppSnapshot)) @@ -117,9 +117,9 @@ bool CatchTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futu const QList<CppEditor::ProjectPart::ConstPtr> projectParts = modelManager->projectPart(fileName); if (projectParts.isEmpty()) // happens if shutting down while parsing return false; - Utils::FilePath proFile; + FilePath proFile; const CppEditor::ProjectPart::ConstPtr projectPart = projectParts.first(); - proFile = Utils::FilePath::fromString(projectPart->projectFile); + proFile = FilePath::fromString(projectPart->projectFile); CatchCodeParser codeParser(fileContent, projectPart->languageFeatures); const CatchTestCodeLocationList foundTests = codeParser.findTests(); diff --git a/src/plugins/autotest/catch/catchtestsettings.cpp b/src/plugins/autotest/catch/catchtestsettings.cpp index 5dace57f69..6fd0cde16d 100644 --- a/src/plugins/autotest/catch/catchtestsettings.cpp +++ b/src/plugins/autotest/catch/catchtestsettings.cpp @@ -114,7 +114,7 @@ CatchTestSettings::CatchTestSettings() }); } -CatchTestSettingsPage::CatchTestSettingsPage(CatchTestSettings *settings, Utils::Id settingsId) +CatchTestSettingsPage::CatchTestSettingsPage(CatchTestSettings *settings, Id settingsId) { setId(settingsId); setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); diff --git a/src/plugins/autotest/catch/catchtreeitem.cpp b/src/plugins/autotest/catch/catchtreeitem.cpp index 2df21bdd84..fe69fece87 100644 --- a/src/plugins/autotest/catch/catchtreeitem.cpp +++ b/src/plugins/autotest/catch/catchtreeitem.cpp @@ -14,6 +14,8 @@ #include <projectexplorer/session.h> #include <utils/qtcassert.h> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -72,7 +74,7 @@ TestTreeItem *CatchTreeItem::find(const TestParseResult *result) switch (type()) { case Root: if (result->framework->grouping()) { - const Utils::FilePath path = result->fileName.absolutePath(); + const FilePath path = result->fileName.absolutePath(); for (int row = 0; row < childCount(); ++row) { TestTreeItem *group = childItem(row); if (group->filePath() != path) @@ -123,7 +125,7 @@ bool CatchTreeItem::modify(const TestParseResult *result) TestTreeItem *CatchTreeItem::createParentGroupNode() const { - const Utils::FilePath absPath = filePath().absolutePath(); + const FilePath absPath = filePath().absolutePath(); return new CatchTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode); } @@ -172,7 +174,7 @@ struct CatchTestCases }; static void collectTestInfo(const TestTreeItem *item, - QHash<Utils::FilePath, CatchTestCases> &testCasesForProfile, + QHash<FilePath, CatchTestCases> &testCasesForProfile, bool ignoreCheckState) { QTC_ASSERT(item, return); @@ -189,7 +191,7 @@ 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 Utils::FilePath &projectFile = item->childItem(0)->proFile(); + const FilePath &projectFile = item->childItem(0)->proFile(); item->forAllChildItems([&testCasesForProfile, &projectFile](TestTreeItem *it) { CatchTreeItem *current = static_cast<CatchTreeItem *>(it); testCasesForProfile[projectFile].names.append(current->testCasesString()); @@ -210,7 +212,7 @@ static void collectTestInfo(const TestTreeItem *item, } static void collectFailedTestInfo(const CatchTreeItem *item, - QHash<Utils::FilePath, CatchTestCases> &testCasesForProfile) + QHash<FilePath, CatchTestCases> &testCasesForProfile) { QTC_ASSERT(item, return); QTC_ASSERT(item->type() == TestTreeItem::Root, return); @@ -246,7 +248,7 @@ QList<ITestConfiguration *> CatchTreeItem::getFailedTestConfigurations() const if (!project || type() != Root) return result; - QHash<Utils::FilePath, CatchTestCases> testCasesForProFile; + QHash<FilePath, CatchTestCases> testCasesForProFile; collectFailedTestInfo(this, testCasesForProFile); for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) { @@ -263,7 +265,7 @@ QList<ITestConfiguration *> CatchTreeItem::getFailedTestConfigurations() const return result; } -QList<ITestConfiguration *> CatchTreeItem::getTestConfigurationsForFile(const Utils::FilePath &fileName) const +QList<ITestConfiguration *> CatchTreeItem::getTestConfigurationsForFile(const FilePath &fileName) const { QList<ITestConfiguration *> result; const auto cppMM = CppEditor::CppModelManager::instance(); @@ -316,7 +318,7 @@ QList<ITestConfiguration *> CatchTreeItem::getTestConfigurations(bool ignoreChec if (!project || type() != Root) return result; - QHash<Utils::FilePath, CatchTestCases> testCasesForProfile; + QHash<FilePath, CatchTestCases> testCasesForProfile; for (int row = 0, end = childCount(); row < end; ++row) collectTestInfo(childItem(row), testCasesForProfile, ignoreCheckState); diff --git a/src/plugins/autotest/ctest/ctestoutputreader.cpp b/src/plugins/autotest/ctest/ctestoutputreader.cpp index 9676d85b8e..70ec5f0659 100644 --- a/src/plugins/autotest/ctest/ctestoutputreader.cpp +++ b/src/plugins/autotest/ctest/ctestoutputreader.cpp @@ -53,8 +53,8 @@ public: }; CTestOutputReader::CTestOutputReader(const QFutureInterface<TestResult> &futureInterface, - Utils::QtcProcess *testApplication, - const Utils::FilePath &buildDirectory) + QtcProcess *testApplication, + const FilePath &buildDirectory) : TestOutputReader(futureInterface, testApplication, buildDirectory) { } diff --git a/src/plugins/autotest/ctest/ctesttreeitem.cpp b/src/plugins/autotest/ctest/ctesttreeitem.cpp index 186b5e5852..3e59c2db81 100644 --- a/src/plugins/autotest/ctest/ctesttreeitem.cpp +++ b/src/plugins/autotest/ctest/ctesttreeitem.cpp @@ -20,11 +20,13 @@ #include <utils/link.h> #include <utils/qtcassert.h> +using namespace Utils; + namespace Autotest { namespace Internal { CTestTreeItem::CTestTreeItem(ITestBase *testBase, const QString &name, - const Utils::FilePath &filepath, Type type) + const FilePath &filepath, Type type) : ITestTreeItem(testBase, name, filepath, type) { } @@ -69,7 +71,7 @@ QVariant CTestTreeItem::data(int column, int role) const return checked(); if (role == LinkRole) { QVariant itemLink; - itemLink.setValue(Utils::Link(filePath(), line())); + itemLink.setValue(Link(filePath(), line())); return itemLink; } return ITestTreeItem::data(column, role); @@ -89,7 +91,7 @@ QList<ITestConfiguration *> CTestTreeItem::testConfigurationsFor(const QStringLi QStringList options{"--timeout", QString::number(AutotestPlugin::settings()->timeout / 1000)}; auto ctestSettings = static_cast<CTestSettings *>(testBase()->testSettings()); options << ctestSettings->activeSettingsAsOptions(); - Utils::CommandLine command = buildSystem->commandLineForTests(selected, options); + CommandLine command = buildSystem->commandLineForTests(selected, options); if (command.executable().isEmpty()) return {}; @@ -97,12 +99,12 @@ QList<ITestConfiguration *> CTestTreeItem::testConfigurationsFor(const QStringLi config->setProject(project); config->setCommandLine(command); const ProjectExplorer::RunConfiguration *runConfig = target->activeRunConfiguration(); - Utils::Environment env = Utils::Environment::systemEnvironment(); + Environment env = Environment::systemEnvironment(); if (QTC_GUARD(runConfig)) { if (auto envAspect = runConfig->aspect<ProjectExplorer::EnvironmentAspect>()) env = envAspect->environment(); } - if (Utils::HostOsInfo::isWindowsHost()) { + if (HostOsInfo::isWindowsHost()) { env.set("QT_FORCE_STDERR_LOGGING", "1"); env.set("QT_LOGGING_TO_CONSOLE", "1"); } diff --git a/src/plugins/autotest/gtest/gtestconfiguration.cpp b/src/plugins/autotest/gtest/gtestconfiguration.cpp index 500db0615a..d2f869d764 100644 --- a/src/plugins/autotest/gtest/gtestconfiguration.cpp +++ b/src/plugins/autotest/gtest/gtestconfiguration.cpp @@ -12,11 +12,13 @@ #include <utils/algorithm.h> #include <utils/stringutils.h> +using namespace Utils; + namespace Autotest { namespace Internal { TestOutputReader *GTestConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi, - Utils::QtcProcess *app) const + QtcProcess *app) const { return new GTestOutputReader(fi, app, buildDirectory(), projectFile()); } @@ -88,13 +90,13 @@ QStringList GTestConfiguration::argumentsForTestRunner(QStringList *omitted) con return arguments; } -Utils::Environment GTestConfiguration::filteredEnvironment(const Utils::Environment &original) const +Environment GTestConfiguration::filteredEnvironment(const Environment &original) const { const QStringList interfering{"GTEST_FILTER", "GTEST_ALSO_RUN_DISABLED_TESTS", "GTEST_REPEAT", "GTEST_SHUFFLE", "GTEST_RANDOM_SEED", "GTEST_OUTPUT", "GTEST_BREAK_ON_FAILURE", "GTEST_PRINT_TIME", "GTEST_CATCH_EXCEPTIONS"}; - Utils::Environment result = original; + Environment result = original; if (!result.hasKey("GTEST_COLOR")) result.set("GTEST_COLOR", "1"); // use colored output by default for (const QString &key : interfering) diff --git a/src/plugins/autotest/gtest/gtestoutputreader.cpp b/src/plugins/autotest/gtest/gtestoutputreader.cpp index f32f2fe99f..2d08cfa62f 100644 --- a/src/plugins/autotest/gtest/gtestoutputreader.cpp +++ b/src/plugins/autotest/gtest/gtestoutputreader.cpp @@ -12,25 +12,27 @@ #include <QRegularExpression> +using namespace Utils; + namespace Autotest { namespace Internal { GTestOutputReader::GTestOutputReader(const QFutureInterface<TestResult> &futureInterface, - Utils::QtcProcess *testApplication, - const Utils::FilePath &buildDirectory, - const Utils::FilePath &projectFile) + QtcProcess *testApplication, + const FilePath &buildDirectory, + const FilePath &projectFile) : TestOutputReader(futureInterface, testApplication, buildDirectory) , m_projectFile(projectFile) { if (m_testApplication) { - connect(m_testApplication, &Utils::QtcProcess::done, this, [this] { + connect(m_testApplication, &QtcProcess::done, this, [this] { const int exitCode = m_testApplication->exitCode(); if (exitCode == 1 && !m_description.isEmpty()) { createAndReportResult(Tr::tr("Running tests failed.\n %1\nExecutable: %2") .arg(m_description).arg(id()), ResultType::MessageFatal); } // on Windows abort() will result in normal termination, but exit code will be set to 3 - if (Utils::HostOsInfo::isWindowsHost() && exitCode == 3) + if (HostOsInfo::isWindowsHost() && exitCode == 3) reportCrash(); }); } @@ -156,7 +158,7 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine) TestResult testResult = createDefaultResult(); testResult.setResult(type); testResult.setLine(match.captured(3).toInt()); - const Utils::FilePath file = constructSourceFilePath(m_buildDir, match.captured(2)); + const FilePath file = constructSourceFilePath(m_buildDir, match.captured(2)); if (file.exists()) testResult.setFileName(file); testResult.setDescription(match.captured(4)); @@ -219,7 +221,7 @@ void GTestOutputReader::handleDescriptionAndReportResult(const TestResult &testR result = createDefaultResult(); result.setResult(ResultType::MessageLocation); result.setLine(innerMatch.captured(2).toInt()); - const Utils::FilePath file = constructSourceFilePath(m_buildDir, innerMatch.captured(1)); + const FilePath file = constructSourceFilePath(m_buildDir, innerMatch.captured(1)); if (file.exists()) result.setFileName(file); resultDescription << output; diff --git a/src/plugins/autotest/gtest/gtestparser.cpp b/src/plugins/autotest/gtest/gtestparser.cpp index 5c0d308c91..aa59bb94c2 100644 --- a/src/plugins/autotest/gtest/gtestparser.cpp +++ b/src/plugins/autotest/gtest/gtestparser.cpp @@ -71,7 +71,7 @@ static bool hasGTestNames(const CPlusPlus::Document::Ptr &document) } bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface, - const Utils::FilePath &fileName) + const FilePath &fileName) { CPlusPlus::Document::Ptr doc = document(fileName); if (doc.isNull() || !includesGTest(doc, m_cppSnapshot)) @@ -93,10 +93,10 @@ bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureIn visitor.accept(ast); const QMap<GTestCaseSpec, GTestCodeLocationList> result = visitor.gtestFunctions(); - Utils::FilePath proFile; + FilePath proFile; const QList<CppEditor::ProjectPart::ConstPtr> &ppList = modelManager->projectPart(filePath); if (!ppList.isEmpty()) - proFile = Utils::FilePath::fromString(ppList.first()->projectFile); + proFile = FilePath::fromString(ppList.first()->projectFile); else return false; // happens if shutting down while parsing diff --git a/src/plugins/autotest/gtest/gtestsettings.cpp b/src/plugins/autotest/gtest/gtestsettings.cpp index 97f3efad26..babea83f78 100644 --- a/src/plugins/autotest/gtest/gtestsettings.cpp +++ b/src/plugins/autotest/gtest/gtestsettings.cpp @@ -106,7 +106,7 @@ GTestSettings::GTestSettings() }); } -GTestSettingsPage::GTestSettingsPage(GTestSettings *settings, Utils::Id settingsId) +GTestSettingsPage::GTestSettingsPage(GTestSettings *settings, Id settingsId) { setId(settingsId); setCategory(Constants::AUTOTEST_SETTINGS_CATEGORY); diff --git a/src/plugins/autotest/gtest/gtesttreeitem.cpp b/src/plugins/autotest/gtest/gtesttreeitem.cpp index b6cdb714fe..c79ae93d1b 100644 --- a/src/plugins/autotest/gtest/gtesttreeitem.cpp +++ b/src/plugins/autotest/gtest/gtesttreeitem.cpp @@ -20,6 +20,8 @@ #include <QRegularExpression> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -110,8 +112,8 @@ QVariant GTestTreeItem::data(int column, int role) const case Qt::DecorationRole: if (type() == GroupNode && GTestFramework::groupMode() == GTest::Constants::GTestFilter) { - static const QIcon filterIcon = Utils::Icon({{":/utils/images/filtericon.png", - Utils::Theme::PanelTextColorMid}}).icon(); + static const QIcon filterIcon = Icon({{":/utils/images/filtericon.png", + Theme::PanelTextColorMid}}).icon(); return filterIcon; } break; @@ -195,7 +197,7 @@ struct GTestCases }; static void collectTestInfo(const GTestTreeItem *item, - QHash<Utils::FilePath, GTestCases> &testCasesForProFile, + QHash<FilePath, GTestCases> &testCasesForProFile, bool ignoreCheckState) { QTC_ASSERT(item, return); @@ -210,7 +212,7 @@ static void collectTestInfo(const GTestTreeItem *item, QTC_ASSERT(childCount != 0, return); QTC_ASSERT(item->type() == TestTreeItem::TestSuite, return); if (ignoreCheckState || item->checked() == Qt::Checked) { - const Utils::FilePath &projectFile = item->childItem(0)->proFile(); + const FilePath &projectFile = item->childItem(0)->proFile(); testCasesForProFile[projectFile].filters.append( gtestFilter(item->state()).arg(item->name()).arg('*')); testCasesForProFile[projectFile].testSetCount += childCount - 1; @@ -229,7 +231,7 @@ static void collectTestInfo(const GTestTreeItem *item, } static void collectFailedTestInfo(const GTestTreeItem *item, - QHash<Utils::FilePath, GTestCases> &testCasesForProfile) + QHash<FilePath, GTestCases> &testCasesForProfile) { QTC_ASSERT(item, return); QTC_ASSERT(item->type() == TestTreeItem::Root, return); @@ -254,7 +256,7 @@ QList<ITestConfiguration *> GTestTreeItem::getTestConfigurations(bool ignoreChec if (!project || type() != Root) return result; - QHash<Utils::FilePath, GTestCases> testCasesForProFile; + QHash<FilePath, GTestCases> testCasesForProFile; for (int row = 0, count = childCount(); row < count; ++row) { auto child = static_cast<const GTestTreeItem *>(childAt(row)); collectTestInfo(child, testCasesForProFile, ignoreCheckState); @@ -293,7 +295,7 @@ QList<ITestConfiguration *> GTestTreeItem::getFailedTestConfigurations() const if (!project || type() != Root) return result; - QHash<Utils::FilePath, GTestCases> testCasesForProFile; + QHash<FilePath, GTestCases> testCasesForProFile; collectFailedTestInfo(this, testCasesForProFile); for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) { @@ -311,14 +313,14 @@ QList<ITestConfiguration *> GTestTreeItem::getFailedTestConfigurations() const return result; } -QList<ITestConfiguration *> GTestTreeItem::getTestConfigurationsForFile(const Utils::FilePath &fileName) const +QList<ITestConfiguration *> GTestTreeItem::getTestConfigurationsForFile(const FilePath &fileName) const { QList<ITestConfiguration *> result; ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); if (!project || type() != Root) return result; - QHash<Utils::FilePath, GTestCases> testCases; + QHash<FilePath, GTestCases> testCases; forAllChildItems([&testCases, &fileName](TestTreeItem *node) { if (node->type() == Type::TestCase && node->filePath() == fileName) { QTC_ASSERT(node->parentItem(), return); @@ -358,7 +360,7 @@ TestTreeItem *GTestTreeItem::find(const TestParseResult *result) case Root: if (result->framework->grouping()) { if (GTestFramework::groupMode() == GTest::Constants::Directory) { - const Utils::FilePath base = parseResult->fileName.absolutePath(); + const FilePath base = parseResult->fileName.absolutePath(); for (int row = 0; row < childCount(); ++row) { GTestTreeItem *group = static_cast<GTestTreeItem *>(childAt(row)); if (group->filePath() != base.absoluteFilePath()) @@ -442,7 +444,7 @@ bool GTestTreeItem::modify(const TestParseResult *result) TestTreeItem *GTestTreeItem::createParentGroupNode() const { if (GTestFramework::groupMode() == GTest::Constants::Directory) { - const Utils::FilePath &absPath = filePath().absolutePath(); + const FilePath &absPath = filePath().absolutePath(); return new GTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode); } else { // GTestFilter QTC_ASSERT(childCount(), return nullptr); // paranoia @@ -453,7 +455,7 @@ TestTreeItem *GTestTreeItem::createParentGroupNode() const matchesFilter(activeFilter, fullTestName) ? matchingString() : notMatchingString(); // FIXME activeFilter is not a FilePath auto groupNode = new GTestTreeItem(framework(), groupNodeName, - Utils::FilePath::fromString(activeFilter), + FilePath::fromString(activeFilter), TestTreeItem::GroupNode); if (groupNodeName == notMatchingString()) groupNode->setData(0, Qt::Unchecked, Qt::CheckStateRole); @@ -475,7 +477,7 @@ bool GTestTreeItem::modifyTestSetContent(const GTestParseResult *result) TestTreeItem *GTestTreeItem::findChildByNameStateAndFile(const QString &name, GTestTreeItem::TestStates state, - const Utils::FilePath &proFile) const + const FilePath &proFile) const { return findFirstLevelChildItem([name, state, proFile](const TestTreeItem *other) { const GTestTreeItem *gtestItem = static_cast<const GTestTreeItem *>(other); @@ -504,13 +506,13 @@ QSet<QString> internalTargets(const TestTreeItem &item) const auto projectInfo = cppMM->projectInfo(ProjectExplorer::SessionManager::startupProject()); if (!projectInfo) return {}; - const Utils::FilePath filePath = item.filePath(); + const FilePath filePath = item.filePath(); const QVector<CppEditor::ProjectPart::ConstPtr> projectParts = projectInfo->projectParts(); if (projectParts.isEmpty()) return cppMM->dependingInternalTargets(item.filePath()); for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectParts) { - if (Utils::FilePath::fromString(projectPart->projectFile) == item.proFile() - && Utils::anyOf(projectPart->files, [&filePath] (const CppEditor::ProjectFile &pf) { + if (FilePath::fromString(projectPart->projectFile) == item.proFile() + && Utils::anyOf(projectPart->files, [&filePath](const CppEditor::ProjectFile &pf) { return pf.path == filePath; })) { result.insert(projectPart->buildSystemTarget); diff --git a/src/plugins/autotest/itestframework.cpp b/src/plugins/autotest/itestframework.cpp index bc4c98e998..093bb42aaa 100644 --- a/src/plugins/autotest/itestframework.cpp +++ b/src/plugins/autotest/itestframework.cpp @@ -8,6 +8,8 @@ #include "testtreeitem.h" #include "testtreemodel.h" +using namespace Utils; + namespace Autotest { ITestBase::ITestBase(bool activeByDefault, const ITestBase::TestBaseType type) @@ -15,15 +17,15 @@ ITestBase::ITestBase(bool activeByDefault, const ITestBase::TestBaseType type) , m_type(type) {} -Utils::Id ITestBase::settingsId() const +Id ITestBase::settingsId() const { - return Utils::Id(Constants::SETTINGSPAGE_PREFIX) + return Id(Constants::SETTINGSPAGE_PREFIX) .withSuffix(QString("%1.%2").arg(priority()).arg(QLatin1String(name()))); } -Utils::Id ITestBase::id() const +Id ITestBase::id() const { - return Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix(name()); + return Id(Constants::FRAMEWORK_PREFIX).withSuffix(name()); } void ITestBase::resetRootNode() diff --git a/src/plugins/autotest/itestparser.cpp b/src/plugins/autotest/itestparser.cpp index 9e9f8f17d6..d8f1d6953b 100644 --- a/src/plugins/autotest/itestparser.cpp +++ b/src/plugins/autotest/itestparser.cpp @@ -24,7 +24,7 @@ CppParser::CppParser(ITestFramework *framework) { } -void CppParser::init(const Utils::FilePaths &filesToParse, bool fullParse) +void CppParser::init(const FilePaths &filesToParse, bool fullParse) { Q_UNUSED(filesToParse) Q_UNUSED(fullParse) @@ -32,7 +32,7 @@ void CppParser::init(const Utils::FilePaths &filesToParse, bool fullParse) m_workingCopy = CppEditor::CppModelManager::instance()->workingCopy(); } -bool CppParser::selectedForBuilding(const Utils::FilePath &fileName) +bool CppParser::selectedForBuilding(const FilePath &fileName) { QList<CppEditor::ProjectPart::ConstPtr> projParts = CppEditor::CppModelManager::instance()->projectPart(fileName); @@ -40,7 +40,7 @@ bool CppParser::selectedForBuilding(const Utils::FilePath &fileName) return !projParts.isEmpty() && projParts.at(0)->selectedForBuilding; } -QByteArray CppParser::getFileContent(const Utils::FilePath &filePath) const +QByteArray CppParser::getFileContent(const FilePath &filePath) const { QByteArray fileContent; if (m_workingCopy.contains(filePath)) { @@ -48,8 +48,8 @@ QByteArray CppParser::getFileContent(const Utils::FilePath &filePath) const } else { QString error; const QTextCodec *codec = Core::EditorManager::defaultTextCodec(); - if (Utils::TextFileFormat::readFileUTF8(filePath, codec, &fileContent, &error) - != Utils::TextFileFormat::ReadSuccess) { + if (TextFileFormat::readFileUTF8(filePath, codec, &fileContent, &error) + != TextFileFormat::ReadSuccess) { qDebug() << "Failed to read file" << filePath << ":" << error; } } @@ -58,7 +58,7 @@ QByteArray CppParser::getFileContent(const Utils::FilePath &filePath) const } bool precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot, - const Utils::FilePath &filePath, + const FilePath &filePath, const QString &cacheString, const std::function<bool(const FilePath &)> &checker) { @@ -82,7 +82,7 @@ bool precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot, } bool CppParser::precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot, - const Utils::FilePath &filePath, + const FilePath &filePath, const QString &headerFilePath) { return Autotest::precompiledHeaderContains(snapshot, @@ -94,7 +94,7 @@ bool CppParser::precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot, } bool CppParser::precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot, - const Utils::FilePath &filePath, + const FilePath &filePath, const QRegularExpression &headerFileRegex) { return Autotest::precompiledHeaderContains(snapshot, @@ -113,7 +113,7 @@ void CppParser::release() s_pchLookupCache.clear(); } -CPlusPlus::Document::Ptr CppParser::document(const Utils::FilePath &fileName) +CPlusPlus::Document::Ptr CppParser::document(const FilePath &fileName) { return selectedForBuilding(fileName) ? m_cppSnapshot.document(fileName) : nullptr; } diff --git a/src/plugins/autotest/qtest/qttest_utils.cpp b/src/plugins/autotest/qtest/qttest_utils.cpp index 5f16776b2e..1069280bee 100644 --- a/src/plugins/autotest/qtest/qttest_utils.cpp +++ b/src/plugins/autotest/qtest/qttest_utils.cpp @@ -14,6 +14,8 @@ #include <QByteArrayList> #include <QSet> +using namespace Utils; + namespace Autotest { namespace Internal { namespace QTestUtils { @@ -25,10 +27,9 @@ bool isQTestMacro(const QByteArray ¯o) return valid.contains(macro); } -QHash<Utils::FilePath, TestCases> testCaseNamesForFiles(ITestFramework *framework, - const Utils::FilePaths &files) +QHash<FilePath, TestCases> testCaseNamesForFiles(ITestFramework *framework, const FilePaths &files) { - QHash<Utils::FilePath, TestCases> result; + QHash<FilePath, TestCases> result; TestTreeItem *rootNode = framework->rootNode(); QTC_ASSERT(rootNode, return result); @@ -48,18 +49,17 @@ QHash<Utils::FilePath, TestCases> testCaseNamesForFiles(ITestFramework *framewor return result; } -QMultiHash<Utils::FilePath, Utils::FilePath> alternativeFiles(ITestFramework *framework, - const Utils::FilePaths &files) +QMultiHash<FilePath, FilePath> alternativeFiles(ITestFramework *framework, const FilePaths &files) { - QMultiHash<Utils::FilePath, Utils::FilePath> result; + QMultiHash<FilePath, FilePath> result; TestTreeItem *rootNode = framework->rootNode(); QTC_ASSERT(rootNode, return result); rootNode->forFirstLevelChildren([&result, &files](ITestTreeItem *child) { - const Utils::FilePath &baseFilePath = child->filePath(); + const FilePath &baseFilePath = child->filePath(); for (int childRow = 0, count = child->childCount(); childRow < count; ++childRow) { auto grandChild = static_cast<const QtTestTreeItem *>(child->childAt(childRow)); - const Utils::FilePath &filePath = grandChild->filePath(); + const FilePath &filePath = grandChild->filePath(); if (grandChild->inherited() && baseFilePath != filePath && files.contains(filePath)) { if (!result.contains(filePath, baseFilePath)) result.insert(filePath, baseFilePath); @@ -128,10 +128,10 @@ QStringList filterInterfering(const QStringList &provided, QStringList *omitted, return allowed; } -Utils::Environment prepareBasicEnvironment(const Utils::Environment &env) +Environment prepareBasicEnvironment(const Environment &env) { - Utils::Environment result(env); - if (Utils::HostOsInfo::isWindowsHost()) { + Environment result(env); + if (HostOsInfo::isWindowsHost()) { result.set("QT_FORCE_STDERR_LOGGING", "1"); result.set("QT_LOGGING_TO_CONSOLE", "1"); } diff --git a/src/plugins/autotest/qtest/qttestconfiguration.cpp b/src/plugins/autotest/qtest/qttestconfiguration.cpp index 4ba792265f..8a77f305e3 100644 --- a/src/plugins/autotest/qtest/qttestconfiguration.cpp +++ b/src/plugins/autotest/qtest/qttestconfiguration.cpp @@ -13,6 +13,8 @@ #include <utils/algorithm.h> #include <utils/stringutils.h> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -27,7 +29,7 @@ static QStringList quoteIfNeeded(const QStringList &testCases, bool debugMode) } TestOutputReader *QtTestConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi, - Utils::QtcProcess *app) const + QtcProcess *app) const { auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings()); const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput.value() @@ -71,7 +73,7 @@ QStringList QtTestConfiguration::argumentsForTestRunner(QStringList *omitted) co return arguments; } -Utils::Environment QtTestConfiguration::filteredEnvironment(const Utils::Environment &original) const +Environment QtTestConfiguration::filteredEnvironment(const Environment &original) const { return QTestUtils::prepareBasicEnvironment(original); } diff --git a/src/plugins/autotest/qtest/qttestoutputreader.cpp b/src/plugins/autotest/qtest/qttestoutputreader.cpp index 027a1d3b39..a93e74eea4 100644 --- a/src/plugins/autotest/qtest/qttestoutputreader.cpp +++ b/src/plugins/autotest/qtest/qttestoutputreader.cpp @@ -14,6 +14,8 @@ #include <cctype> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -104,9 +106,9 @@ static QString constructBenchmarkInformation(const QString &metric, double value } QtTestOutputReader::QtTestOutputReader(const QFutureInterface<TestResult> &futureInterface, - Utils::QtcProcess *testApplication, - const Utils::FilePath &buildDirectory, - const Utils::FilePath &projectFile, + QtcProcess *testApplication, + const FilePath &buildDirectory, + const FilePath &projectFile, OutputMode mode, TestType type) : TestOutputReader(futureInterface, testApplication, buildDirectory) , m_projectFile(projectFile) diff --git a/src/plugins/autotest/qtest/qttestparser.cpp b/src/plugins/autotest/qtest/qttestparser.cpp index 637d571fd9..2b13133f03 100644 --- a/src/plugins/autotest/qtest/qttestparser.cpp +++ b/src/plugins/autotest/qtest/qttestparser.cpp @@ -36,8 +36,7 @@ TestTreeItem *QtTestParseResult::createTestTreeItem() const static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus::Snapshot &snapshot) { - static QStringList expectedHeaderPrefixes - = Utils::HostOsInfo::isMacHost() + static QStringList expectedHeaderPrefixes = HostOsInfo::isMacHost() ? QStringList({"QtTest.framework/Headers", "QtTest"}) : QStringList({"QtTest"}); const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes(); @@ -71,7 +70,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus: return false; } -static bool qtTestLibDefined(const Utils::FilePath &fileName) +static bool qtTestLibDefined(const FilePath &fileName) { const QList<CppEditor::ProjectPart::ConstPtr> parts = CppEditor::CppModelManager::instance()->projectPart(fileName); @@ -84,7 +83,7 @@ static bool qtTestLibDefined(const Utils::FilePath &fileName) } TestCases QtTestParser::testCases(const CppEditor::CppModelManager *modelManager, - const Utils::FilePath &filePath) const + const FilePath &filePath) const { const QByteArray &fileContent = getFileContent(filePath); CPlusPlus::Document::Ptr document = modelManager->document(filePath); @@ -141,7 +140,7 @@ TestCases QtTestParser::testCases(const CppEditor::CppModelManager *modelManager static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc, const CPlusPlus::Snapshot &snapshot, const QString &testCaseName, - const Utils::FilePaths &alternativeFiles = {}, + const FilePaths &alternativeFiles = {}, int *line = nullptr, int *column = nullptr) { @@ -153,7 +152,7 @@ static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc, doc->globalNamespace()); // fallback for inherited functions if (lookupItems.size() == 0 && !alternativeFiles.isEmpty()) { - for (const Utils::FilePath &alternativeFile : alternativeFiles) { + for (const FilePath &alternativeFile : alternativeFiles) { if (snapshot.contains(alternativeFile)) { CPlusPlus::Document::Ptr document = snapshot.document(alternativeFile); CPlusPlus::TypeOfExpression typeOfExpr; // we need a new one with no bindings @@ -179,10 +178,10 @@ static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc, return declaringDoc; } -static QSet<Utils::FilePath> filesWithDataFunctionDefinitions( +static QSet<FilePath> filesWithDataFunctionDefinitions( const QMap<QString, QtTestCodeLocationAndType> &testFunctions) { - QSet<Utils::FilePath> result; + QSet<FilePath> result; QMap<QString, QtTestCodeLocationAndType>::ConstIterator it = testFunctions.begin(); const QMap<QString, QtTestCodeLocationAndType>::ConstIterator end = testFunctions.end(); @@ -195,7 +194,7 @@ static QSet<Utils::FilePath> filesWithDataFunctionDefinitions( } QHash<QString, QtTestCodeLocationList> QtTestParser::checkForDataTags( - const Utils::FilePath &fileName) const + const FilePath &fileName) const { const QByteArray fileContent = getFileContent(fileName); CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, fileName); @@ -289,12 +288,12 @@ static QtTestCodeLocationList tagLocationsFor(const QtTestParseResult *func, static bool isQObject(const CPlusPlus::Document::Ptr &declaringDoc) { const FilePath file = declaringDoc->filePath(); - return (Utils::HostOsInfo::isMacHost() && file.endsWith("QtCore.framework/Headers/qobject.h")) + return (HostOsInfo::isMacHost() && file.endsWith("QtCore.framework/Headers/qobject.h")) || file.endsWith("QtCore/qobject.h") || file.endsWith("kernel/qobject.h"); } bool QtTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface, - const Utils::FilePath &fileName) + const FilePath &fileName) { CPlusPlus::Document::Ptr doc = document(fileName); if (doc.isNull()) @@ -359,8 +358,8 @@ std::optional<bool> QtTestParser::fillTestCaseData( if (data.testFunctions.isEmpty() && testCaseName == "QObject" && isQObject(declaringDoc)) return true; // we did not handle it, but we do not expect any test defined there either - const QSet<Utils::FilePath> &files = filesWithDataFunctionDefinitions(data.testFunctions); - for (const Utils::FilePath &file : files) + const QSet<FilePath> &files = filesWithDataFunctionDefinitions(data.testFunctions); + for (const FilePath &file : files) Utils::addToHash(&(data.dataTags), checkForDataTags(file)); data.fileName = declaringDoc->filePath(); @@ -378,7 +377,7 @@ QtTestParseResult *QtTestParser::createParseResult( parseResult->displayName = testCaseName; parseResult->line = data.line; parseResult->column = data.column; - parseResult->proFile = Utils::FilePath::fromString(projectFile); + parseResult->proFile = FilePath::fromString(projectFile); parseResult->setRunsMultipleTestcases(data.multipleTestCases); QMap<QString, QtTestCodeLocationAndType>::ConstIterator it = data.testFunctions.begin(); const QMap<QString, QtTestCodeLocationAndType>::ConstIterator end = data.testFunctions.end(); @@ -414,7 +413,7 @@ QtTestParseResult *QtTestParser::createParseResult( return parseResult; } -void QtTestParser::init(const Utils::FilePaths &filesToParse, bool fullParse) +void QtTestParser::init(const FilePaths &filesToParse, bool fullParse) { if (!fullParse) { // in a full parse cached information might lead to wrong results m_testCases = QTestUtils::testCaseNamesForFiles(framework(), filesToParse); diff --git a/src/plugins/autotest/qtest/qttesttreeitem.cpp b/src/plugins/autotest/qtest/qttesttreeitem.cpp index 1b4e4d21d2..2f84637282 100644 --- a/src/plugins/autotest/qtest/qttesttreeitem.cpp +++ b/src/plugins/autotest/qtest/qttesttreeitem.cpp @@ -12,11 +12,13 @@ #include <projectexplorer/session.h> #include <utils/qtcassert.h> +using namespace Utils; + namespace Autotest { namespace Internal { QtTestTreeItem::QtTestTreeItem(ITestFramework *testFramework, const QString &name, - const Utils::FilePath &filePath, TestTreeItem::Type type) + const FilePath &filePath, TestTreeItem::Type type) : TestTreeItem(testFramework, name, filePath, type) { if (type == TestDataTag) @@ -286,7 +288,7 @@ QList<ITestConfiguration *> QtTestTreeItem::getFailedTestConfigurations() const return result; } -QList<ITestConfiguration *> QtTestTreeItem::getTestConfigurationsForFile(const Utils::FilePath &fileName) const +QList<ITestConfiguration *> QtTestTreeItem::getTestConfigurationsForFile(const FilePath &fileName) const { QList<ITestConfiguration *> result; @@ -321,7 +323,7 @@ TestTreeItem *QtTestTreeItem::find(const TestParseResult *result) switch (type()) { case Root: if (result->framework->grouping()) { - const Utils::FilePath path = result->fileName.absolutePath(); + const FilePath path = result->fileName.absolutePath(); for (int row = 0; row < childCount(); ++row) { TestTreeItem *group = childItem(row); if (group->filePath() != path) @@ -394,7 +396,7 @@ bool QtTestTreeItem::modify(const TestParseResult *result) TestTreeItem *QtTestTreeItem::createParentGroupNode() const { - const Utils::FilePath &absPath = filePath().absolutePath(); + const FilePath &absPath = filePath().absolutePath(); return new QtTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode); } @@ -403,7 +405,7 @@ bool QtTestTreeItem::isGroupable() const return type() == TestCase; } -TestTreeItem *QtTestTreeItem::findChildByFileNameAndType(const Utils::FilePath &file, +TestTreeItem *QtTestTreeItem::findChildByFileNameAndType(const FilePath &file, const QString &name, Type type) const { return findFirstLevelChildItem([file, name, type](const TestTreeItem *other) { diff --git a/src/plugins/autotest/qtest/qttestvisitors.cpp b/src/plugins/autotest/qtest/qttestvisitors.cpp index 6680fc93a1..6f615c9932 100644 --- a/src/plugins/autotest/qtest/qttestvisitors.cpp +++ b/src/plugins/autotest/qtest/qttestvisitors.cpp @@ -12,6 +12,7 @@ #include <utils/qtcassert.h> using namespace CPlusPlus; +using namespace Utils; namespace Autotest { namespace Internal { @@ -36,7 +37,7 @@ bool TestVisitor::visit(Class *symbol) Symbol *member = symbol->memberAt(i); Type *type = member->type().type(); - const QString className = o.prettyName(CPlusPlus::LookupContext::fullyQualifiedName( + const QString className = o.prettyName(LookupContext::fullyQualifiedName( member->enclosingClass())); if (className != m_className) continue; @@ -51,12 +52,12 @@ bool TestVisitor::visit(Class *symbol) Function *functionDefinition = m_symbolFinder.findMatchingDefinition( func, m_snapshot, true); if (functionDefinition && functionDefinition->fileId()) { - locationAndType.m_filePath = Utils::FilePath::fromString( + locationAndType.m_filePath = FilePath::fromString( QString::fromUtf8(functionDefinition->fileName())); locationAndType.m_line = functionDefinition->line(); locationAndType.m_column = functionDefinition->column() - 1; } else { // if we cannot find the definition use declaration as fallback - locationAndType.m_filePath = Utils::FilePath::fromString( + locationAndType.m_filePath = FilePath::fromString( QString::fromUtf8(member->fileName())); locationAndType.m_line = member->line(); locationAndType.m_column = member->column() - 1; @@ -74,7 +75,7 @@ bool TestVisitor::visit(Class *symbol) } for (int counter = 0, end = symbol->baseClassCount(); counter < end; ++counter) { if (BaseClass *base = symbol->baseClassAt(counter)) { - const QString &baseClassName = o.prettyName(CPlusPlus::LookupContext::fullyQualifiedName(base)); + const QString &baseClassName = o.prettyName(LookupContext::fullyQualifiedName(base)); if (baseClassName != "QObject") m_baseClasses.insert(baseClassName); } @@ -171,7 +172,7 @@ bool TestDataFunctionVisitor::visit(FunctionDefinitionAST *ast) LookupContext lc; const QString prettyName = - m_overview.prettyName(CPlusPlus::LookupContext::fullyQualifiedName(ast->symbol)); + m_overview.prettyName(LookupContext::fullyQualifiedName(ast->symbol)); // do not handle functions that aren't real test data functions if (!prettyName.endsWith("_data")) return false; diff --git a/src/plugins/autotest/quick/quicktest_utils.cpp b/src/plugins/autotest/quick/quicktest_utils.cpp index 17202b538a..09d2453c96 100644 --- a/src/plugins/autotest/quick/quicktest_utils.cpp +++ b/src/plugins/autotest/quick/quicktest_utils.cpp @@ -9,6 +9,8 @@ #include <QByteArrayList> +using namespace Utils; + namespace Autotest { namespace Internal { namespace QuickTestUtils { @@ -20,10 +22,9 @@ bool isQuickTestMacro(const QByteArray ¯o) return valid.contains(macro); } -QHash<Utils::FilePath, Utils::FilePath> proFilesForQmlFiles(ITestFramework *framework, - const Utils::FilePaths &files) +QHash<FilePath, FilePath> proFilesForQmlFiles(ITestFramework *framework, const FilePaths &files) { - QHash<Utils::FilePath, Utils::FilePath> result; + QHash<FilePath, FilePath> result; TestTreeItem *rootNode = framework->rootNode(); QTC_ASSERT(rootNode, return result); @@ -31,16 +32,16 @@ QHash<Utils::FilePath, Utils::FilePath> proFilesForQmlFiles(ITestFramework *fram return result; rootNode->forFirstLevelChildItems([&result, &files](TestTreeItem *child) { - const Utils::FilePath &file = child->filePath(); + const FilePath &file = child->filePath(); if (!file.isEmpty() && files.contains(file)) { - const Utils::FilePath &proFile = child->proFile(); + const FilePath &proFile = child->proFile(); if (!proFile.isEmpty()) result.insert(file, proFile); } child->forFirstLevelChildItems([&result, &files](TestTreeItem *grandChild) { - const Utils::FilePath &file = grandChild->filePath(); + const FilePath &file = grandChild->filePath(); if (!file.isEmpty() && files.contains(file)) { - const Utils::FilePath &proFile = grandChild->proFile(); + const FilePath &proFile = grandChild->proFile(); if (!proFile.isEmpty()) result.insert(file, proFile); } diff --git a/src/plugins/autotest/quick/quicktestconfiguration.cpp b/src/plugins/autotest/quick/quicktestconfiguration.cpp index 8114c54884..c7cce31acf 100644 --- a/src/plugins/autotest/quick/quicktestconfiguration.cpp +++ b/src/plugins/autotest/quick/quicktestconfiguration.cpp @@ -12,6 +12,8 @@ #include <utils/stringutils.h> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -22,7 +24,7 @@ QuickTestConfiguration::QuickTestConfiguration(ITestFramework *framework) } TestOutputReader *QuickTestConfiguration::createOutputReader( - const QFutureInterface<TestResult> &fi, Utils::QtcProcess *app) const + const QFutureInterface<TestResult> &fi, QtcProcess *app) const { auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings()); const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput.value() @@ -64,7 +66,7 @@ QStringList QuickTestConfiguration::argumentsForTestRunner(QStringList *omitted) return arguments; } -Utils::Environment QuickTestConfiguration::filteredEnvironment(const Utils::Environment &original) const +Environment QuickTestConfiguration::filteredEnvironment(const Environment &original) const { return QTestUtils::prepareBasicEnvironment(original); } diff --git a/src/plugins/autotest/quick/quicktestparser.cpp b/src/plugins/autotest/quick/quicktestparser.cpp index b88e34b57b..2c72cdf3f1 100644 --- a/src/plugins/autotest/quick/quicktestparser.cpp +++ b/src/plugins/autotest/quick/quicktestparser.cpp @@ -43,8 +43,7 @@ TestTreeItem *QuickTestParseResult::createTestTreeItem() const static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus::Snapshot &snapshot) { - static QStringList expectedHeaderPrefixes - = Utils::HostOsInfo::isMacHost() + static QStringList expectedHeaderPrefixes = HostOsInfo::isMacHost() ? QStringList({"QtQuickTest.framework/Headers", "QtQuickTest"}) : QStringList({"QtQuickTest"}); @@ -78,8 +77,7 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc, return false; } -static QString quickTestSrcDir(const CppEditor::CppModelManager *cppMM, - const Utils::FilePath &fileName) +static QString quickTestSrcDir(const CppEditor::CppModelManager *cppMM, const FilePath &fileName) { const QList<CppEditor::ProjectPart::ConstPtr> parts = cppMM->projectPart(fileName); if (parts.size() > 0) { @@ -103,7 +101,7 @@ static QString quickTestSrcDir(const CppEditor::CppModelManager *cppMM, QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) const { const QList<CPlusPlus::Document::MacroUse> macros = doc->macroUses(); - const Utils::FilePath filePath = doc->filePath(); + const FilePath filePath = doc->filePath(); for (const CPlusPlus::Document::MacroUse ¯o : macros) { if (!macro.isFunctionLike() || macro.arguments().isEmpty()) @@ -130,8 +128,7 @@ QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) cons return astVisitor.testBaseName(); // check for precompiled headers - static QStringList expectedHeaderPrefixes - = Utils::HostOsInfo::isMacHost() + static QStringList expectedHeaderPrefixes = HostOsInfo::isMacHost() ? QStringList({"QtQuickTest.framework/Headers", "QtQuickTest"}) : QStringList({"QtQuickTest"}); bool pchIncludes = false; @@ -152,9 +149,9 @@ QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) cons return {}; } -QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const Utils::FilePath &srcDir) +QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const FilePath &srcDir) { - Utils::FilePaths dirs({srcDir}); + FilePaths dirs({srcDir}); QStringList dirsStr({srcDir.toString()}); ModelManagerInterface *qmlJsMM = QmlJSTools::Internal::ModelManager::instance(); // make sure even files not listed in pro file are available inside the snapshot @@ -171,7 +168,7 @@ QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const Ut QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); - auto subDir = Utils::FilePath::fromFileInfo(it.fileInfo()).canonicalPath(); + auto subDir = FilePath::fromFileInfo(it.fileInfo()).canonicalPath(); dirs.append(subDir); dirsStr.append(subDir.toString()); } @@ -182,10 +179,10 @@ QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const Ut QList<Document::Ptr> foundDocs; - for (const Utils::FilePath &path : std::as_const(dirs)) { + for (const FilePath &path : std::as_const(dirs)) { const QList<Document::Ptr> docs = snapshot.documentsInDirectory(path); for (const Document::Ptr &doc : docs) { - Utils::FilePath fi = doc->fileName(); + const FilePath fi = doc->fileName(); //const QFileInfo fi(doc->fileName()); // using working copy above might provide no more existing files if (!fi.exists()) @@ -202,7 +199,7 @@ QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const Ut static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr> &futureInterface, const Document::Ptr &qmlJSDoc, ITestFramework *framework, - const Utils::FilePath &proFile = {}, + const FilePath &proFile = {}, bool checkForDerivedTest = false) { if (qmlJSDoc.isNull()) @@ -260,10 +257,9 @@ bool QuickTestParser::handleQtQuickTest(QFutureInterface<TestParseResultPtr> &fu if (ppList.isEmpty()) // happens if shutting down while parsing return false; const FilePath cppFileName = document->filePath(); - const FilePath proFile = Utils::FilePath::fromString(ppList.at(0)->projectFile); + const FilePath proFile = FilePath::fromString(ppList.at(0)->projectFile); m_mainCppFiles.insert(cppFileName, proFile); - const Utils::FilePath srcDir = Utils::FilePath::fromString( - quickTestSrcDir(modelManager, cppFileName)); + const FilePath srcDir = FilePath::fromString(quickTestSrcDir(modelManager, cppFileName)); if (srcDir.isEmpty()) return false; @@ -308,7 +304,7 @@ void QuickTestParser::handleDirectoryChanged(const QString &directory) if (timestampChanged) { m_watchedFiles[directory] = filesAndDates; PathsAndLanguages paths; - paths.maybeInsert(Utils::FilePath::fromString(directory), Dialect::Qml); + paths.maybeInsert(FilePath::fromString(directory), Dialect::Qml); QFutureInterface<void> future; ModelManagerInterface *qmlJsMM = ModelManagerInterface::instance(); ModelManagerInterface::importScan(future, ModelManagerInterface::workingCopy(), paths, @@ -342,14 +338,14 @@ QuickTestParser::QuickTestParser(ITestFramework *framework) this, &QuickTestParser::handleDirectoryChanged); } -void QuickTestParser::init(const Utils::FilePaths &filesToParse, bool fullParse) +void QuickTestParser::init(const FilePaths &filesToParse, bool fullParse) { m_qmlSnapshot = QmlJSTools::Internal::ModelManager::instance()->snapshot(); if (!fullParse) { // in a full parse we get the correct entry points by the respective main m_proFilesForQmlFiles = QuickTestUtils::proFilesForQmlFiles(framework(), filesToParse); // get rid of cached main cpp files that are going to get processed anyhow - for (const Utils::FilePath &file : filesToParse) { + for (const FilePath &file : filesToParse) { if (m_mainCppFiles.contains(file)) { m_mainCppFiles.remove(file); if (m_mainCppFiles.isEmpty()) @@ -375,10 +371,10 @@ void QuickTestParser::release() } bool QuickTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureInterface, - const Utils::FilePath &fileName) + const FilePath &fileName) { if (fileName.endsWith(".qml")) { - const Utils::FilePath &proFile = m_proFilesForQmlFiles.value(fileName); + const FilePath &proFile = m_proFilesForQmlFiles.value(fileName); if (proFile.isEmpty()) return false; Document::Ptr qmlJSDoc = m_qmlSnapshot.document(fileName); @@ -396,9 +392,9 @@ bool QuickTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futu return handleQtQuickTest(futureInterface, cppdoc, framework()); } -Utils::FilePath QuickTestParser::projectFileForMainCppFile(const Utils::FilePath &fileName) const +FilePath QuickTestParser::projectFileForMainCppFile(const FilePath &fileName) const { - return m_mainCppFiles.contains(fileName) ? m_mainCppFiles.value(fileName) : Utils::FilePath(); + return m_mainCppFiles.contains(fileName) ? m_mainCppFiles.value(fileName) : FilePath(); } } // namespace Internal diff --git a/src/plugins/autotest/quick/quicktesttreeitem.cpp b/src/plugins/autotest/quick/quicktesttreeitem.cpp index d07c14628e..49358f49eb 100644 --- a/src/plugins/autotest/quick/quicktesttreeitem.cpp +++ b/src/plugins/autotest/quick/quicktesttreeitem.cpp @@ -12,10 +12,12 @@ #include <projectexplorer/session.h> #include <utils/qtcassert.h> +using namespace Utils; + namespace Autotest { namespace Internal { -static QSet<QString> internalTargets(const Utils::FilePath &proFile); +static QSet<QString> internalTargets(const FilePath &proFile); TestTreeItem *QuickTestTreeItem::copyWithoutChildren() { @@ -149,8 +151,8 @@ static QList<ITestConfiguration *> testConfigurationsFor( if (!project || rootNode->type() != TestTreeItem::Root) return {}; - QHash<Utils::FilePath, QuickTestConfiguration *> configurationForProFiles; - rootNode->forSelectedChildren([&predicate, &configurationForProFiles](Utils::TreeItem *it) { + QHash<FilePath, QuickTestConfiguration *> configurationForProFiles; + rootNode->forSelectedChildren([&predicate, &configurationForProFiles](TreeItem *it) { auto treeItem = static_cast<TestTreeItem *>(it); if (treeItem->type() == TestTreeItem::Root || treeItem->type() == TestTreeItem::GroupNode) return true; @@ -208,12 +210,12 @@ QList<ITestConfiguration *> QuickTestTreeItem::getAllTestConfigurations() const if (!project || type() != Root) return result; - QHash<Utils::FilePath, Tests> testsForProfile; + QHash<FilePath, Tests> testsForProfile; forFirstLevelChildItems([&testsForProfile](TestTreeItem *child) { // unnamed Quick Tests must be handled separately if (child->name().isEmpty()) { child->forFirstLevelChildItems([&testsForProfile](TestTreeItem *grandChild) { - const Utils::FilePath &proFile = grandChild->proFile(); + const FilePath &proFile = grandChild->proFile(); ++(testsForProfile[proFile].testCount); testsForProfile[proFile].internalTargets = internalTargets(grandChild->proFile()); }); @@ -255,7 +257,7 @@ QList<ITestConfiguration *> QuickTestTreeItem::getFailedTestConfigurations() con } QList<ITestConfiguration *> QuickTestTreeItem::getTestConfigurationsForFile( - const Utils::FilePath &fileName) const + const FilePath &fileName) const { return testConfigurationsFor(this, [&fileName](TestTreeItem *it) { return it->filePath() == fileName; @@ -271,7 +273,7 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result) if (result->name.isEmpty()) return unnamedQuickTests(); if (result->framework->grouping()) { - const Utils::FilePath path = result->fileName.absolutePath(); + const FilePath path = result->fileName.absolutePath(); TestTreeItem *group = findFirstLevelChildItem([path](TestTreeItem *group) { return group->filePath() == path; }); @@ -354,7 +356,7 @@ bool QuickTestTreeItem::removeOnSweepIfEmpty() const TestTreeItem *QuickTestTreeItem::createParentGroupNode() const { - const Utils::FilePath &absPath = filePath().absolutePath(); + const FilePath &absPath = filePath().absolutePath(); return new QuickTestTreeItem(framework(), absPath.baseName(), absPath, TestTreeItem::GroupNode); } @@ -363,7 +365,7 @@ bool QuickTestTreeItem::isGroupable() const return type() == TestCase && !name().isEmpty() && !filePath().isEmpty(); } -QSet<QString> internalTargets(const Utils::FilePath &proFile) +QSet<QString> internalTargets(const FilePath &proFile) { QSet<QString> result; const auto cppMM = CppEditor::CppModelManager::instance(); @@ -379,11 +381,11 @@ QSet<QString> internalTargets(const Utils::FilePath &proFile) return result; } -void QuickTestTreeItem::markForRemovalRecursively(const Utils::FilePath &filePath) +void QuickTestTreeItem::markForRemovalRecursively(const FilePath &filePath) { TestTreeItem::markForRemovalRecursively(filePath); auto parser = static_cast<QuickTestParser *>(framework()->testParser()); - const Utils::FilePath proFile = parser->projectFileForMainCppFile(filePath); + const FilePath proFile = parser->projectFileForMainCppFile(filePath); if (!proFile.isEmpty()) { TestTreeItem *root = framework()->rootNode(); root->forAllChildItems([proFile](TestTreeItem *it) { @@ -393,7 +395,7 @@ void QuickTestTreeItem::markForRemovalRecursively(const Utils::FilePath &filePat } } -TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const Utils::FilePath &filePath, +TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const FilePath &filePath, const QString &name, TestTreeItem::Type tType) @@ -404,7 +406,7 @@ TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const Utils::FilePat } TestTreeItem *QuickTestTreeItem::findChildByNameFileAndLine(const QString &name, - const Utils::FilePath &filePath, + const FilePath &filePath, int line) { return findFirstLevelChildItem([name, filePath, line](const TestTreeItem *other) { diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index c5dbcd6d51..edf126f8d4 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -26,6 +26,8 @@ #include <QFutureInterface> #include <QLoggingCategory> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -146,12 +148,12 @@ void TestCodeParser::updateTestTree(const QSet<ITestParser *> &parsers) [](const ITestParser *lhs, const ITestParser *rhs) { return lhs->framework()->priority() < rhs->framework()->priority(); }); - scanForTests(Utils::FilePaths(), sortedParsers); + scanForTests({}, sortedParsers); } /****** threaded parsing stuff *******/ -void TestCodeParser::onDocumentUpdated(const Utils::FilePath &fileName, bool isQmlFile) +void TestCodeParser::onDocumentUpdated(const FilePath &fileName, bool isQmlFile) { if (isProjectParsing() || m_codeModelParsing || m_postponedUpdateType == UpdateType::FullUpdate) return; @@ -163,7 +165,7 @@ void TestCodeParser::onDocumentUpdated(const Utils::FilePath &fileName, bool isQ if (!isQmlFile && !project->isKnownFile(fileName)) return; - scanForTests(Utils::FilePaths{fileName}); + scanForTests({fileName}); } void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &document) @@ -174,7 +176,7 @@ void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &docume void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document) { static const QStringList ignoredSuffixes{ "qbs", "ui.qml" }; - const Utils::FilePath fileName = document->fileName(); + const FilePath fileName = document->fileName(); if (!ignoredSuffixes.contains(fileName.suffix())) onDocumentUpdated(fileName, true); } @@ -211,7 +213,7 @@ void TestCodeParser::aboutToShutdown() } } -bool TestCodeParser::postponed(const Utils::FilePaths &fileList) +bool TestCodeParser::postponed(const FilePaths &fileList) { switch (m_parserState) { case Idle: @@ -253,7 +255,7 @@ bool TestCodeParser::postponed(const Utils::FilePaths &fileList) if (m_postponedUpdateType == UpdateType::FullUpdate) return true; // partial parse triggered, postpone or add current files to already postponed partial - for (const Utils::FilePath &file : fileList) + for (const FilePath &file : fileList) m_postponedFiles.insert(file); m_postponedUpdateType = UpdateType::PartialUpdate; } @@ -266,7 +268,7 @@ bool TestCodeParser::postponed(const Utils::FilePaths &fileList) static void parseFileForTests(const QList<ITestParser *> &parsers, QFutureInterface<TestParseResultPtr> &futureInterface, - const Utils::FilePath &fileName) + const FilePath &fileName) { for (ITestParser *parser : parsers) { if (futureInterface.isCanceled()) @@ -276,8 +278,7 @@ static void parseFileForTests(const QList<ITestParser *> &parsers, } } -void TestCodeParser::scanForTests(const Utils::FilePaths &fileList, - const QList<ITestParser *> &parsers) +void TestCodeParser::scanForTests(const FilePaths &fileList, const QList<ITestParser *> &parsers) { if (m_parserState == Shutdown || m_testCodeParsers.isEmpty()) return; @@ -292,7 +293,7 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList, Project *project = SessionManager::startupProject(); if (!project) return; - Utils::FilePaths list; + FilePaths list; if (isFullParse) { list = project->files(Project::SourceFiles); if (list.isEmpty()) { @@ -318,7 +319,7 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList, TestTreeModel::instance()->updateCheckStateCache(); if (isFullParse) { // remove qml files as they will be found automatically by the referencing cpp file - list = Utils::filtered(list, [](const Utils::FilePath &fn) { + list = Utils::filtered(list, [](const FilePath &fn) { return !fn.endsWith(".qml"); }); if (!parsers.isEmpty()) { @@ -330,11 +331,11 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList, } } else if (!parsers.isEmpty()) { for (ITestParser *parser: parsers) { - for (const Utils::FilePath &filePath : std::as_const(list)) + for (const FilePath &filePath : std::as_const(list)) parser->framework()->rootNode()->markForRemovalRecursively(filePath); } } else { - for (const Utils::FilePath &filePath : std::as_const(list)) + for (const FilePath &filePath : std::as_const(list)) emit requestRemoval(filePath); } @@ -353,8 +354,8 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList, } // We are only interested in files that have been either parsed by the c++ parser, // or have an extension that one of the parsers is specifically interested in. - const Utils::FilePaths filteredList - = Utils::filtered(list, [&extensions, &cppSnapshot](const Utils::FilePath &fn) { + const FilePaths filteredList + = Utils::filtered(list, [&extensions, &cppSnapshot](const FilePath &fn) { const bool isSupportedExtension = Utils::anyOf(extensions, [&fn](const QString &ext) { return fn.suffix() == ext; }); @@ -366,12 +367,11 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList, qCDebug(LOG) << "Starting scan of" << filteredList.size() << "(" << list.size() << ")" << "files with" << codeParsers.size() << "parsers"; - QFuture<TestParseResultPtr> future = Utils::map( - filteredList, - [codeParsers](QFutureInterface<TestParseResultPtr> &fi, const Utils::FilePath &file) { + QFuture<TestParseResultPtr> future = Utils::map(filteredList, + [codeParsers](QFutureInterface<TestParseResultPtr> &fi, const FilePath &file) { parseFileForTests(codeParsers, fi, file); }, - Utils::MapReduceOption::Unordered, + MapReduceOption::Unordered, m_threadPool, QThread::LowestPriority); m_futureWatcher.setFuture(future); @@ -381,7 +381,7 @@ void TestCodeParser::scanForTests(const Utils::FilePaths &fileList, } } -void TestCodeParser::onTaskStarted(Utils::Id type) +void TestCodeParser::onTaskStarted(Id type) { if (type == CppEditor::Constants::TASK_INDEX) { m_codeModelParsing = true; @@ -395,7 +395,7 @@ void TestCodeParser::onTaskStarted(Utils::Id type) } } -void TestCodeParser::onAllTasksFinished(Utils::Id type) +void TestCodeParser::onAllTasksFinished(Id type) { // if we cancel parsing ensure that progress animation is canceled as well if (type == Constants::TASK_PARSE && m_parsingHasFailed) diff --git a/src/plugins/autotest/testnavigationwidget.cpp b/src/plugins/autotest/testnavigationwidget.cpp index 8e81068cc9..100eed89ed 100644 --- a/src/plugins/autotest/testnavigationwidget.cpp +++ b/src/plugins/autotest/testnavigationwidget.cpp @@ -32,6 +32,8 @@ #include <QToolButton> #include <QVBoxLayout> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -48,10 +50,8 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) : m_view->setItemDelegate(new TestTreeItemDelegate(this)); QPalette pal; - pal.setColor(QPalette::Window, - Utils::creatorTheme()->color(Utils::Theme::InfoBarBackground)); - pal.setColor(QPalette::WindowText, - Utils::creatorTheme()->color(Utils::Theme::InfoBarText)); + pal.setColor(QPalette::Window, creatorTheme()->color(Theme::InfoBarBackground)); + pal.setColor(QPalette::WindowText, creatorTheme()->color(Theme::InfoBarText)); m_missingFrameworksWidget = new QFrame; m_missingFrameworksWidget->setPalette(pal); m_missingFrameworksWidget->setAutoFillBackground(true); @@ -70,7 +70,7 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) : connect(m_view, &TestTreeView::activated, this, &TestNavigationWidget::onItemActivated); - m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicatorSize::Medium, this); + m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Medium, this); m_progressIndicator->attachToWidget(m_view); m_progressIndicator->hide(); @@ -94,8 +94,7 @@ TestNavigationWidget::TestNavigationWidget(QWidget *parent) : }); connect(m_model, &TestTreeModel::testTreeModelChanged, this, &TestNavigationWidget::reapplyCachedExpandedState); - connect(m_progressTimer, &QTimer::timeout, - m_progressIndicator, &Utils::ProgressIndicator::show); + connect(m_progressTimer, &QTimer::timeout, m_progressIndicator, &ProgressIndicator::show); connect(m_view, &TestTreeView::expanded, this, &TestNavigationWidget::updateExpandedStateCache); connect(m_view, &TestTreeView::collapsed, this, &TestNavigationWidget::updateExpandedStateCache); } @@ -233,8 +232,8 @@ void TestNavigationWidget::updateExpandedStateCache() { m_expandedStateCache.evolve(ITestBase::Framework); - for (Utils::TreeItem *rootNode : *m_model->rootItem()) { - rootNode->forAllChildren([this](Utils::TreeItem *child) { + for (TreeItem *rootNode : *m_model->rootItem()) { + rootNode->forAllChildren([this](TreeItem *child) { m_expandedStateCache.insert(static_cast<ITestTreeItem *>(child), m_view->isExpanded(child->index())); }); @@ -243,7 +242,7 @@ void TestNavigationWidget::updateExpandedStateCache() void TestNavigationWidget::onItemActivated(const QModelIndex &index) { - const Utils::Link link = index.data(LinkRole).value<Utils::Link>(); + const Link link = index.data(LinkRole).value<Link>(); if (link.hasValidTarget()) Core::EditorManager::openEditorAt(link); } diff --git a/src/plugins/autotest/testoutputreader.cpp b/src/plugins/autotest/testoutputreader.cpp index bb48667ae6..6c9e4781bd 100644 --- a/src/plugins/autotest/testoutputreader.cpp +++ b/src/plugins/autotest/testoutputreader.cpp @@ -16,18 +16,18 @@ #include <QFileInfo> #include <QProcess> +using namespace Utils; + namespace Autotest { -Utils::FilePath TestOutputReader::constructSourceFilePath(const Utils::FilePath &path, - const QString &file) +FilePath TestOutputReader::constructSourceFilePath(const FilePath &path, const QString &file) { - const Utils::FilePath filePath = path.resolvePath(file); - return filePath.isReadableFile() ? filePath : Utils::FilePath(); + const FilePath filePath = path.resolvePath(file); + return filePath.isReadableFile() ? filePath : FilePath(); } TestOutputReader::TestOutputReader(const QFutureInterface<TestResult> &futureInterface, - Utils::QtcProcess *testApplication, - const Utils::FilePath &buildDirectory) + QtcProcess *testApplication, const FilePath &buildDirectory) : m_futureInterface(futureInterface) , m_testApplication(testApplication) , m_buildDir(buildDirectory) @@ -149,10 +149,10 @@ void TestOutputReader::checkForSanitizerOutput(const QByteArray &line) m_sanitizerLines.append("Sanitizer Issue"); m_sanitizerLines.append(lineStr); if (m_sanitizerOutputMode == SanitizerOutputMode::Ubsan) { - const Utils::FilePath path = constructSourceFilePath(m_buildDir, match.captured(1)); + const FilePath path = constructSourceFilePath(m_buildDir, match.captured(1)); // path may be empty if not existing - so, provide at least what we have m_sanitizerResult.setFileName( - path.exists() ? path : Utils::FilePath::fromString(match.captured(1))); + path.exists() ? path : FilePath::fromString(match.captured(1))); m_sanitizerResult.setLine(match.captured(2).toInt()); } } diff --git a/src/plugins/autotest/testprojectsettings.cpp b/src/plugins/autotest/testprojectsettings.cpp index 67ae9ddb00..862fc8a24f 100644 --- a/src/plugins/autotest/testprojectsettings.cpp +++ b/src/plugins/autotest/testprojectsettings.cpp @@ -12,6 +12,8 @@ #include <QLoggingCategory> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -43,7 +45,7 @@ void TestProjectSettings::setUseGlobalSettings(bool useGlobal) m_useGlobalSettings = useGlobal; } -void TestProjectSettings::activateFramework(const Utils::Id &id, bool activate) +void TestProjectSettings::activateFramework(const Id &id, bool activate) { ITestFramework *framework = TestFrameworkManager::frameworkForId(id); m_activeTestFrameworks[framework] = activate; @@ -51,7 +53,7 @@ void TestProjectSettings::activateFramework(const Utils::Id &id, bool activate) framework->resetRootNode(); } -void TestProjectSettings::activateTestTool(const Utils::Id &id, bool activate) +void TestProjectSettings::activateTestTool(const Id &id, bool activate) { ITestTool *testTool = TestFrameworkManager::testToolForId(id); m_activeTestTools[testTool] = activate; @@ -74,12 +76,12 @@ void TestProjectSettings::load() if (activeFrameworks.isValid()) { const QMap<QString, QVariant> frameworksMap = activeFrameworks.toMap(); for (ITestFramework *framework : registeredFrameworks) { - const Utils::Id id = framework->id(); + const Id id = framework->id(); bool active = frameworksMap.value(id.toString(), framework->active()).toBool(); m_activeTestFrameworks.insert(framework, active); } for (ITestTool *testTool : registeredTestTools) { - const Utils::Id id = testTool->id(); + const Id id = testTool->id(); bool active = frameworksMap.value(id.toString(), testTool->active()).toBool(); m_activeTestTools.insert(testTool, active); } diff --git a/src/plugins/autotest/testresult.cpp b/src/plugins/autotest/testresult.cpp index a2d20d88f6..ae885d6b48 100644 --- a/src/plugins/autotest/testresult.cpp +++ b/src/plugins/autotest/testresult.cpp @@ -6,6 +6,8 @@ #include <utils/qtcassert.h> #include <utils/theme/theme.h> +using namespace Utils; + namespace Autotest { TestResult::TestResult(const QString &id, const QString &name, const ResultHooks &hooks) @@ -131,33 +133,33 @@ QColor TestResult::colorForType(const ResultType type) if (type >= ResultType::INTERNAL_MESSAGES_BEGIN && type <= ResultType::INTERNAL_MESSAGES_END) return QColor("transparent"); - Utils::Theme *creatorTheme = Utils::creatorTheme(); + const Theme *theme = creatorTheme(); switch (type) { case ResultType::Pass: - return creatorTheme->color(Utils::Theme::OutputPanes_TestPassTextColor); + return theme->color(Theme::OutputPanes_TestPassTextColor); case ResultType::Fail: - return creatorTheme->color(Utils::Theme::OutputPanes_TestFailTextColor); + return theme->color(Theme::OutputPanes_TestFailTextColor); case ResultType::ExpectedFail: - return creatorTheme->color(Utils::Theme::OutputPanes_TestXFailTextColor); + return theme->color(Theme::OutputPanes_TestXFailTextColor); case ResultType::UnexpectedPass: - return creatorTheme->color(Utils::Theme::OutputPanes_TestXPassTextColor); + return theme->color(Theme::OutputPanes_TestXPassTextColor); case ResultType::Skip: - return creatorTheme->color(Utils::Theme::OutputPanes_TestSkipTextColor); + return theme->color(Theme::OutputPanes_TestSkipTextColor); case ResultType::MessageDebug: case ResultType::MessageInfo: - return creatorTheme->color(Utils::Theme::OutputPanes_TestDebugTextColor); + return theme->color(Theme::OutputPanes_TestDebugTextColor); case ResultType::MessageWarn: - return creatorTheme->color(Utils::Theme::OutputPanes_TestWarnTextColor); + return theme->color(Theme::OutputPanes_TestWarnTextColor); case ResultType::MessageFatal: case ResultType::MessageSystem: case ResultType::MessageError: - return creatorTheme->color(Utils::Theme::OutputPanes_TestFatalTextColor); + return theme->color(Theme::OutputPanes_TestFatalTextColor); case ResultType::BlacklistedPass: case ResultType::BlacklistedFail: case ResultType::BlacklistedXPass: case ResultType::BlacklistedXFail: default: - return creatorTheme->color(Utils::Theme::OutputPanes_StdOutTextColor); + return theme->color(Theme::OutputPanes_StdOutTextColor); } } diff --git a/src/plugins/autotest/testresultmodel.cpp b/src/plugins/autotest/testresultmodel.cpp index 3f8c678d5b..8a65a377da 100644 --- a/src/plugins/autotest/testresultmodel.cpp +++ b/src/plugins/autotest/testresultmodel.cpp @@ -16,6 +16,8 @@ #include <QFontMetrics> #include <QIcon> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -83,7 +85,7 @@ QVariant TestResultItem::data(int column, int role) const case Qt::DisplayRole: return m_testResult.isValid() ? m_testResult.outputString(true) : QVariant(); default: - return Utils::TreeItem::data(column, role); + return TreeItem::data(column, role); } } @@ -198,7 +200,7 @@ QString TestResultItem::resultString() const /********************************* TestResultModel *****************************************/ TestResultModel::TestResultModel(QObject *parent) - : Utils::TreeModel<TestResultItem>(new TestResultItem({}), parent) + : TreeModel<TestResultItem>(new TestResultItem({}), parent) { connect(TestRunner::instance(), &TestRunner::reportSummary, this, [this](const QString &id, const QHash<ResultType, int> &summary){ @@ -281,7 +283,7 @@ void TestResultModel::addTestResult(const TestResult &testResult, bool autoExpan if (autoExpand) { parentItem->expand(); newItem->expand(); - newItem->forAllChildren([](Utils::TreeItem *it) { it->expand(); }); + newItem->forAllChildren([](TreeItem *it) { it->expand(); }); } updateParent(newItem); } else { @@ -399,7 +401,7 @@ TestResultItem *TestResultModel::findParentItemFor(const TestResultItem *item, return root; bool needsIntermediate = false; - auto predicate = [result, &needsIntermediate](Utils::TreeItem *it) { + auto predicate = [result, &needsIntermediate](TreeItem *it) { TestResultItem *currentItem = static_cast<TestResultItem *>(it); return currentItem->testResult().isDirectParentOf(result, &needsIntermediate); }; diff --git a/src/plugins/autotest/testresultspane.cpp b/src/plugins/autotest/testresultspane.cpp index fee588f4e5..aacd12adcf 100644 --- a/src/plugins/autotest/testresultspane.cpp +++ b/src/plugins/autotest/testresultspane.cpp @@ -56,7 +56,7 @@ namespace Autotest { namespace Internal { ResultsTreeView::ResultsTreeView(QWidget *parent) - : Utils::TreeView(parent) + : TreeView(parent) { setAttribute(Qt::WA_MacShowFocusRect, false); setFrameStyle(NoFrame); @@ -84,10 +84,8 @@ TestResultsPane::TestResultsPane(QObject *parent) : visualOutputWidget->setLayout(outputLayout); QPalette pal; - pal.setColor(QPalette::Window, - Utils::creatorTheme()->color(Utils::Theme::InfoBarBackground)); - pal.setColor(QPalette::WindowText, - Utils::creatorTheme()->color(Utils::Theme::InfoBarText)); + pal.setColor(QPalette::Window, creatorTheme()->color(Theme::InfoBarBackground)); + pal.setColor(QPalette::WindowText, creatorTheme()->color(Theme::InfoBarText)); m_summaryWidget = new QFrame; m_summaryWidget->setPalette(pal); m_summaryWidget->setAutoFillBackground(true); @@ -130,10 +128,10 @@ TestResultsPane::TestResultsPane(QObject *parent) : createToolButtons(); - connect(m_treeView, &Utils::TreeView::activated, this, &TestResultsPane::onItemActivated); + connect(m_treeView, &TreeView::activated, this, &TestResultsPane::onItemActivated); connect(m_treeView->selectionModel(), &QItemSelectionModel::currentChanged, trd, &TestResultDelegate::currentChanged); - connect(m_treeView, &Utils::TreeView::customContextMenuRequested, + connect(m_treeView, &TreeView::customContextMenuRequested, this, &TestResultsPane::onCustomContextMenuRequested); connect(m_treeView, &ResultsTreeView::copyShortcutTriggered, this, [this] { onCopyItemTriggered(getTestResult(m_treeView->currentIndex())); @@ -167,25 +165,21 @@ void TestResultsPane::createToolButtons() }); m_runAll = new QToolButton(m_treeView); - m_runAll->setDefaultAction( - Utils::ProxyAction::proxyActionWithIcon( + m_runAll->setDefaultAction(ProxyAction::proxyActionWithIcon( ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action(), Utils::Icons::RUN_SMALL_TOOLBAR.icon())); m_runSelected = new QToolButton(m_treeView); - m_runSelected->setDefaultAction( - Utils::ProxyAction::proxyActionWithIcon( + m_runSelected->setDefaultAction(ProxyAction::proxyActionWithIcon( ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action(), Utils::Icons::RUN_SELECTED_TOOLBAR.icon())); m_runFailed = new QToolButton(m_treeView); - m_runFailed->setDefaultAction( - Utils::ProxyAction::proxyActionWithIcon( + m_runFailed->setDefaultAction(ProxyAction::proxyActionWithIcon( ActionManager::command(Constants::ACTION_RUN_FAILED_ID)->action(), Icons::RUN_FAILED_TOOLBAR.icon())); m_runFile = new QToolButton(m_treeView); - m_runFile->setDefaultAction( - Utils::ProxyAction::proxyActionWithIcon( + m_runFile->setDefaultAction(ProxyAction::proxyActionWithIcon( ActionManager::command(Constants::ACTION_RUN_FILE_ID)->action(), Utils::Icons::RUN_FILE_TOOLBAR.icon())); @@ -248,22 +242,22 @@ static void checkAndFineTuneColors(QTextCharFormat *format) const QColor bgColor = format->background().color(); QColor fgColor = format->foreground().color(); - if (Utils::StyleHelper::isReadableOn(bgColor, fgColor)) + if (StyleHelper::isReadableOn(bgColor, fgColor)) return; int h, s, v; fgColor.getHsv(&h, &s, &v); // adjust the color value to ensure better readability - if (Utils::StyleHelper::luminance(bgColor) < .5) + if (StyleHelper::luminance(bgColor) < .5) v = v + 64; else v = v - 64; fgColor.setHsv(h, s, v); - if (!Utils::StyleHelper::isReadableOn(bgColor, fgColor)) { + if (!StyleHelper::isReadableOn(bgColor, fgColor)) { s = (s + 128) % 255; // adjust the saturation to ensure better readability fgColor.setHsv(h, s, v); - if (!Utils::StyleHelper::isReadableOn(bgColor, fgColor)) + if (!StyleHelper::isReadableOn(bgColor, fgColor)) return; } @@ -278,9 +272,9 @@ void TestResultsPane::addOutputLine(const QByteArray &outputLine, OutputChannel return; } - const Utils::FormattedText formattedText - = Utils::FormattedText{QString::fromUtf8(outputLine), m_defaultFormat}; - const QList<Utils::FormattedText> formatted = channel == OutputChannel::StdOut + const FormattedText formattedText + = FormattedText{QString::fromUtf8(outputLine), m_defaultFormat}; + const QList<FormattedText> formatted = channel == OutputChannel::StdOut ? m_stdOutHandler.parseText(formattedText) : m_stdErrHandler.parseText(formattedText); @@ -332,9 +326,9 @@ void TestResultsPane::clearContents() connect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged, this, &TestResultsPane::onScrollBarRangeChanged, Qt::UniqueConnection); m_textOutput->clear(); - m_defaultFormat.setBackground(Utils::creatorTheme()->palette().color( + m_defaultFormat.setBackground(creatorTheme()->palette().color( m_textOutput->backgroundRole())); - m_defaultFormat.setForeground(Utils::creatorTheme()->palette().color( + m_defaultFormat.setForeground(creatorTheme()->palette().color( m_textOutput->foregroundRole())); // in case they had been forgotten to reset @@ -402,7 +396,7 @@ void TestResultsPane::goToNext() // if we have no current or could not find a next one, use the first item of the whole tree if (!nextCurrentIndex.isValid()) { - Utils::TreeItem *rootItem = m_model->itemForIndex(QModelIndex()); + TreeItem *rootItem = m_model->itemForIndex(QModelIndex()); // if the tree does not contain any item - don't do anything if (!rootItem || !rootItem->childCount()) return; @@ -459,7 +453,7 @@ void TestResultsPane::onItemActivated(const QModelIndex &index) const TestResult testResult = m_filterModel->testResult(index); if (testResult.isValid() && !testResult.fileName().isEmpty()) - EditorManager::openEditorAt(Utils::Link{testResult.fileName(), testResult.line(), 0}); + EditorManager::openEditorAt(Link{testResult.fileName(), testResult.line(), 0}); } void TestResultsPane::onRunAllTriggered() @@ -754,7 +748,7 @@ void TestResultsPane::createMarks(const QModelIndex &parent) || (isLocationItem && interested.contains(parentType))) { TestEditorMark *mark = new TestEditorMark(index, result.fileName(), result.line()); mark->setIcon(index.data(Qt::DecorationRole).value<QIcon>()); - mark->setColor(Utils::Theme::OutputPanes_TestFailTextColor); + mark->setColor(Theme::OutputPanes_TestFailTextColor); mark->setPriority(TextEditor::TextMark::NormalPriority); mark->setToolTip(result.description()); m_marks << mark; diff --git a/src/plugins/autotest/testsettingspage.cpp b/src/plugins/autotest/testsettingspage.cpp index 588a58f778..1cd6e2d1ae 100644 --- a/src/plugins/autotest/testsettingspage.cpp +++ b/src/plugins/autotest/testsettingspage.cpp @@ -29,6 +29,8 @@ #include <QTreeWidget> #include <QWidget> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -41,8 +43,8 @@ public: TestSettings settings() const; private: - void populateFrameworksListWidget(const QHash<Utils::Id, bool> &frameworks, - const QHash<Utils::Id, bool> &testTools); + void populateFrameworksListWidget(const QHash<Id, bool> &frameworks, + const QHash<Id, bool> &testTools); void testSettings(TestSettings &settings) const; void testToolsSettings(TestSettings &settings) const; void onFrameworkItemChanged(); @@ -61,7 +63,7 @@ private: QComboBox *m_runAfterBuildCB; QSpinBox *m_timeoutSpin; QTreeWidget *m_frameworkTreeWidget; - Utils::InfoLabel *m_frameworksWarn; + InfoLabel *m_frameworksWarn; }; TestSettingsWidget::TestSettingsWidget(QWidget *parent) @@ -146,12 +148,12 @@ TestSettingsWidget::TestSettingsWidget(QWidget *parent) item->setText(1, Tr::tr("Group")); item->setToolTip(1, Tr::tr("Enables grouping of test cases.")); - m_frameworksWarn = new Utils::InfoLabel; + m_frameworksWarn = new InfoLabel; m_frameworksWarn->setVisible(false); m_frameworksWarn->setElideMode(Qt::ElideNone); - m_frameworksWarn->setType(Utils::InfoLabel::Warning); + m_frameworksWarn->setType(InfoLabel::Warning); - using namespace Utils::Layouting; + using namespace Layouting; PushButton resetChoicesButton { text(Tr::tr("Reset Cached Choices")), @@ -249,13 +251,13 @@ enum TestBaseInfo BaseType }; -void TestSettingsWidget::populateFrameworksListWidget(const QHash<Utils::Id, bool> &frameworks, - const QHash<Utils::Id, bool> &testTools) +void TestSettingsWidget::populateFrameworksListWidget(const QHash<Id, bool> &frameworks, + const QHash<Id, bool> &testTools) { const TestFrameworks ®istered = TestFrameworkManager::registeredFrameworks(); m_frameworkTreeWidget->clear(); for (const ITestFramework *framework : registered) { - const Utils::Id id = framework->id(); + const Id id = framework->id(); auto item = new QTreeWidgetItem(m_frameworkTreeWidget, {framework->displayName()}); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable); item->setCheckState(0, frameworks.value(id) ? Qt::Checked : Qt::Unchecked); @@ -272,7 +274,7 @@ void TestSettingsWidget::populateFrameworksListWidget(const QHash<Utils::Id, boo // ...and now the test tools const TestTools ®isteredTools = TestFrameworkManager::registeredTestTools(); for (const ITestTool *testTool : registeredTools) { - const Utils::Id id = testTool->id(); + const Id id = testTool->id(); auto item = new QTreeWidgetItem(m_frameworkTreeWidget, {testTool->displayName()}); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable); item->setCheckState(0, testTools.value(id) ? Qt::Checked : Qt::Unchecked); @@ -289,7 +291,7 @@ void TestSettingsWidget::testSettings(TestSettings &settings) const QTC_ASSERT(itemCount <= model->rowCount(), return); for (int row = 0; row < itemCount; ++row) { QModelIndex idx = model->index(row, 0); - const Utils::Id id = Utils::Id::fromSetting(idx.data(BaseId)); + const Id id = Id::fromSetting(idx.data(BaseId)); settings.frameworks.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked); idx = model->index(row, 1); settings.frameworksGrouping.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked); @@ -306,7 +308,7 @@ void TestSettingsWidget::testToolsSettings(TestSettings &settings) const QTC_ASSERT(row <= end, return); for ( ; row < end; ++row) { const QModelIndex idx = model->index(row, 0); - const Utils::Id id = Utils::Id::fromSetting(idx.data(BaseId)); + const Id id = Id::fromSetting(idx.data(BaseId)); settings.tools.insert(id, idx.data(Qt::CheckStateRole) == Qt::Checked); } } @@ -365,8 +367,8 @@ void TestSettingsPage::apply() if (!m_widget) // page was not shown at all return; const TestSettings newSettings = m_widget->settings(); - const QList<Utils::Id> changedIds = Utils::filtered(newSettings.frameworksGrouping.keys(), - [newSettings, this](const Utils::Id &id) { + const QList<Id> changedIds = Utils::filtered(newSettings.frameworksGrouping.keys(), + [newSettings, this](const Id &id) { return newSettings.frameworksGrouping[id] != m_settings->frameworksGrouping[id]; }); *m_settings = newSettings; diff --git a/src/plugins/autotest/testtreeitem.cpp b/src/plugins/autotest/testtreeitem.cpp index 9196b2c6d4..bd6a4a1482 100644 --- a/src/plugins/autotest/testtreeitem.cpp +++ b/src/plugins/autotest/testtreeitem.cpp @@ -14,16 +14,18 @@ #include <QIcon> +using namespace Utils; + namespace Autotest { static QIcon testTreeIcon(TestTreeItem::Type type) { static QIcon icons[] = { QIcon(), - Utils::Icons::OPENFILE.icon(), + Icons::OPENFILE.icon(), QIcon(":/autotest/images/suite.png"), - Utils::CodeModelIcon::iconForType(Utils::CodeModelIcon::Class), - Utils::CodeModelIcon::iconForType(Utils::CodeModelIcon::SlotPrivate), + CodeModelIcon::iconForType(CodeModelIcon::Class), + CodeModelIcon::iconForType(CodeModelIcon::SlotPrivate), QIcon(":/autotest/images/data.png") }; @@ -33,7 +35,7 @@ static QIcon testTreeIcon(TestTreeItem::Type type) } ITestTreeItem::ITestTreeItem(ITestBase *testBase, const QString &name, - const Utils::FilePath &filePath, Type type) + const FilePath &filePath, Type type) : m_testBase(testBase) , m_name(name) , m_filePath(filePath) @@ -115,8 +117,8 @@ bool ITestTreeItem::lessThan(const ITestTreeItem *other, ITestTreeItem::SortMode Qt::CaseInsensitive) > 0; } - const Utils::Link &leftLink = data(0, LinkRole).value<Utils::Link>(); - const Utils::Link &rightLink = other->data(0, LinkRole).value<Utils::Link>(); + const Link &leftLink = data(0, LinkRole).value<Link>(); + const Link &rightLink = other->data(0, LinkRole).value<Link>(); const int comparison = leftLink.targetFilePath.toString().compare( rightLink.targetFilePath.toString(), Qt::CaseInsensitive); if (comparison == 0) { @@ -144,7 +146,7 @@ ITestConfiguration *ITestTreeItem::asConfiguration(TestRunMode mode) const /****************************** TestTreeItem ********************************************/ TestTreeItem::TestTreeItem(ITestFramework *testFramework, const QString &name, - const Utils::FilePath &filePath, Type type) + const FilePath &filePath, Type type) : ITestTreeItem(testFramework, name, filePath, type) { switch (type) { @@ -168,7 +170,7 @@ QVariant TestTreeItem::data(int column, int role) const return QVariant(); QVariant itemLink; itemLink.setValue( - Utils::Link(filePath(), line(), int(m_column))); + Link(filePath(), line(), int(m_column))); return itemLink; } return ITestTreeItem::data(column, role); @@ -222,7 +224,7 @@ void TestTreeItem::markForRemovalRecursively(bool mark) childItem(row)->markForRemovalRecursively(mark); } -void TestTreeItem::markForRemovalRecursively(const Utils::FilePath &filepath) +void TestTreeItem::markForRemovalRecursively(const FilePath &filepath) { bool mark = filePath() == filepath; forFirstLevelChildItems([&mark, &filepath](TestTreeItem *child) { @@ -249,20 +251,20 @@ TestTreeItem *TestTreeItem::findChildByName(const QString &name) }); } -TestTreeItem *TestTreeItem::findChildByFile(const Utils::FilePath &filePath) +TestTreeItem *TestTreeItem::findChildByFile(const FilePath &filePath) { return findFirstLevelChildItem([filePath](const TestTreeItem *other) { return other->filePath() == filePath; }); } -TestTreeItem *TestTreeItem::findChildByFileAndType(const Utils::FilePath &filePath, Type tType) +TestTreeItem *TestTreeItem::findChildByFileAndType(const FilePath &filePath, Type tType) { return findFirstLevelChildItem([filePath, tType](const TestTreeItem *other) { return other->type() == tType && other->filePath() == filePath; });} -TestTreeItem *TestTreeItem::findChildByNameAndFile(const QString &name, const Utils::FilePath &filePath) +TestTreeItem *TestTreeItem::findChildByNameAndFile(const QString &name, const FilePath &filePath) { return findFirstLevelChildItem([name, filePath](const TestTreeItem *other) { return other->filePath() == filePath && other->name() == name; @@ -280,7 +282,7 @@ ITestConfiguration *TestTreeItem::asConfiguration(TestRunMode mode) const } } -QList<ITestConfiguration *> TestTreeItem::getTestConfigurationsForFile(const Utils::FilePath &) const +QList<ITestConfiguration *> TestTreeItem::getTestConfigurationsForFile(const FilePath &) const { return QList<ITestConfiguration *>(); } @@ -342,7 +344,7 @@ void TestTreeItem::copyBasicDataFrom(const TestTreeItem *other) m_status = other->m_status; } -inline bool TestTreeItem::modifyFilePath(const Utils::FilePath &filepath) +inline bool TestTreeItem::modifyFilePath(const FilePath &filepath) { if (filePath() != filepath) { setFilePath(filepath); diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp index 0500fd90ca..5a619ffe53 100644 --- a/src/plugins/autotest/testtreemodel.cpp +++ b/src/plugins/autotest/testtreemodel.cpp @@ -20,8 +20,9 @@ #include <utils/fileutils.h> #include <utils/qtcassert.h> -using namespace ProjectExplorer; using namespace Autotest::Internal; +using namespace ProjectExplorer; +using namespace Utils; namespace Autotest { @@ -95,8 +96,7 @@ void TestTreeModel::setupParsingConnections() m_parser, &TestCodeParser::onCppDocumentUpdated, Qt::QueuedConnection); connect(cppMM, &CppEditor::CppModelManager::aboutToRemoveFiles, this, [this](const QStringList &files) { - const Utils::FilePaths filesToRemove - = Utils::FileUtils::toFilePathList(files); + const FilePaths filesToRemove = FileUtils::toFilePathList(files); removeFiles(filesToRemove); }, Qt::QueuedConnection); connect(cppMM, &CppEditor::CppModelManager::projectPartsUpdated, @@ -125,7 +125,7 @@ bool TestTreeModel::setData(const QModelIndex &index, const QVariant &value, int Qt::CheckState checked = item->checked(); if (item->hasChildren() && checked != Qt::PartiallyChecked) { // handle the new checkstate for children as well... - for (Utils::TreeItem *child : *item) { + for (TreeItem *child : *item) { const QModelIndex &idx = indexForItem(child); setData(idx, checked ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); } @@ -155,7 +155,7 @@ Qt::ItemFlags TestTreeModel::flags(const QModelIndex &index) const bool TestTreeModel::hasTests() const { - for (Utils::TreeItem *frameworkRoot : *rootItem()) { + for (TreeItem *frameworkRoot : *rootItem()) { if (frameworkRoot->hasChildren()) return true; } @@ -189,7 +189,7 @@ QList<ITestConfiguration *> TestTreeModel::getFailedTests() const return result; } -QList<ITestConfiguration *> TestTreeModel::getTestsForFile(const Utils::FilePath &fileName) const +QList<ITestConfiguration *> TestTreeModel::getTestsForFile(const FilePath &fileName) const { QList<ITestConfiguration *> result; forItemsAtLevel<1>([&result, &fileName](ITestTreeItem *testRoot) { @@ -316,10 +316,10 @@ void TestTreeModel::synchronizeTestFrameworks() const auto sortedParsers = Utils::transform(sorted, &ITestFramework::testParser); // pre-check to avoid further processing when frameworks are unchanged - Utils::TreeItem *invisibleRoot = rootItem(); + TreeItem *invisibleRoot = rootItem(); QSet<ITestParser *> newlyAdded; QList<ITestTreeItem *> oldFrameworkRoots; - for (Utils::TreeItem *oldFrameworkRoot : *invisibleRoot) + for (TreeItem *oldFrameworkRoot : *invisibleRoot) oldFrameworkRoots.append(static_cast<ITestTreeItem *>(oldFrameworkRoot)); for (ITestTreeItem *oldFrameworkRoot : oldFrameworkRoots) @@ -362,10 +362,10 @@ void TestTreeModel::synchronizeTestTools() } // pre-check to avoid further processing when test tools are unchanged - Utils::TreeItem *invisibleRoot = rootItem(); + TreeItem *invisibleRoot = rootItem(); QSet<ITestTool *> newlyAdded; QList<ITestTreeItem *> oldFrameworkRoots; - for (Utils::TreeItem *oldFrameworkRoot : *invisibleRoot) { + for (TreeItem *oldFrameworkRoot : *invisibleRoot) { auto item = static_cast<ITestTreeItem *>(oldFrameworkRoot); if (item->testBase()->type() == ITestBase::Tool) oldFrameworkRoots.append(item); @@ -416,9 +416,9 @@ void TestTreeModel::filterAndInsert(TestTreeItem *item, TestTreeItem *root, bool insertItemInParent(filtered, root, groupingEnabled); } -void TestTreeModel::rebuild(const QList<Utils::Id> &frameworkIds) +void TestTreeModel::rebuild(const QList<Id> &frameworkIds) { - for (const Utils::Id &id : frameworkIds) { + for (const Id &id : frameworkIds) { ITestFramework *framework = TestFrameworkManager::frameworkForId(id); TestTreeItem *frameworkRoot = framework->rootNode(); const bool groupingEnabled = framework->grouping(); @@ -456,7 +456,7 @@ void TestTreeModel::updateCheckStateCache() bool TestTreeModel::hasFailedTests() const { - auto failedItem = rootItem()->findAnyChild([](Utils::TreeItem *it) { + auto failedItem = rootItem()->findAnyChild([](TreeItem *it) { return it->data(0, FailedRole).toBool(); }); return failedItem != nullptr; @@ -464,17 +464,17 @@ bool TestTreeModel::hasFailedTests() const void TestTreeModel::clearFailedMarks() { - for (Utils::TreeItem *rootNode : *rootItem()) { - rootNode->forAllChildren([](Utils::TreeItem *child) { + for (TreeItem *rootNode : *rootItem()) { + rootNode->forAllChildren([](TreeItem *child) { child->setData(0, false, FailedRole); }); } m_failedStateCache.clear(); } -void TestTreeModel::removeFiles(const Utils::FilePaths &files) +void TestTreeModel::removeFiles(const FilePaths &files) { - for (const Utils::FilePath &file : files) + for (const FilePath &file : files) markForRemoval(file); sweep(); } @@ -488,7 +488,7 @@ void TestTreeModel::markAllFrameworkItemsForRemoval() } } -void TestTreeModel::markForRemoval(const Utils::FilePath &filePath) +void TestTreeModel::markForRemoval(const FilePath &filePath) { if (filePath.isEmpty()) return; @@ -558,7 +558,7 @@ static void applyParentCheckState(ITestTreeItem *parent, ITestTreeItem *newItem) const Qt::CheckState checkState = parent->checked() == Qt::Unchecked ? Qt::Unchecked : Qt::Checked; newItem->setData(0, checkState, Qt::CheckStateRole); - newItem->forAllChildren([checkState](Utils::TreeItem *it) { + newItem->forAllChildren([checkState](TreeItem *it) { it->setData(0, checkState, Qt::CheckStateRole); }); } @@ -752,25 +752,25 @@ void TestTreeModel::removeAllTestToolItems() // we're inside tests - so use some internal knowledge to make testing easier static TestTreeItem *qtRootNode() { - auto id = Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix("QtTest"); + const Id id = Id(Constants::FRAMEWORK_PREFIX).withSuffix("QtTest"); return TestFrameworkManager::frameworkForId(id)->rootNode(); } static TestTreeItem *quickRootNode() { - auto id = Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix("QtQuickTest"); + const Id id = Id(Constants::FRAMEWORK_PREFIX).withSuffix("QtQuickTest"); return TestFrameworkManager::frameworkForId(id)->rootNode(); } static TestTreeItem *gtestRootNode() { - auto id = Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix("GTest"); + const Id id = Id(Constants::FRAMEWORK_PREFIX).withSuffix("GTest"); return TestFrameworkManager::frameworkForId(id)->rootNode(); } static TestTreeItem *boostTestRootNode() { - auto id = Utils::Id(Constants::FRAMEWORK_PREFIX).withSuffix("Boost"); + const Id id = Id(Constants::FRAMEWORK_PREFIX).withSuffix("Boost"); return TestFrameworkManager::frameworkForId(id)->rootNode(); } |