AutoTests: Some code cosmetics

QVector->QList, typedef->using...

Change-Id: I563759015f146b6a32d664a8bcc5690e5bbe81f6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2025-04-09 09:40:20 +02:00
parent 6e6a8448c1
commit 5d1144c819
16 changed files with 32 additions and 39 deletions

View File

@@ -12,8 +12,7 @@
#include <QByteArray> #include <QByteArray>
namespace Autotest { namespace Autotest::Internal {
namespace Internal {
class BoostCodeParser class BoostCodeParser
{ {
@@ -21,7 +20,9 @@ public:
BoostCodeParser(const QByteArray &source, const CPlusPlus::LanguageFeatures &features, BoostCodeParser(const QByteArray &source, const CPlusPlus::LanguageFeatures &features,
const CPlusPlus::Document::Ptr &doc, const CPlusPlus::Snapshot &snapshot); const CPlusPlus::Document::Ptr &doc, const CPlusPlus::Snapshot &snapshot);
virtual ~BoostCodeParser() = default; virtual ~BoostCodeParser() = default;
BoostTestCodeLocationList findTests(); BoostTestCodeLocationList findTests();
private: private:
enum class TestCaseType {Auto, Functions, Parameter, Fixture, Data}; enum class TestCaseType {Auto, Functions, Parameter, Fixture, Data};
@@ -50,11 +51,10 @@ private:
CPlusPlus::Tokens m_tokens; CPlusPlus::Tokens m_tokens;
int m_currentIndex = 0; int m_currentIndex = 0;
BoostTestCodeLocationList m_testCases; BoostTestCodeLocationList m_testCases;
QVector<BoostTestInfo> m_suites; QList<BoostTestInfo> m_suites;
QString m_currentSuite; QString m_currentSuite;
BoostTestTreeItem::TestStates m_currentState = BoostTestTreeItem::Enabled; BoostTestTreeItem::TestStates m_currentState = BoostTestTreeItem::Enabled;
int m_lineNo = 0; int m_lineNo = 0;
}; };
} // Internal } // Autotest::Internal
} // Autotest

View File

@@ -5,8 +5,7 @@
#include "../testtreeitem.h" #include "../testtreeitem.h"
namespace Autotest { namespace Autotest::Internal {
namespace Internal {
class BoostTestParseResult; class BoostTestParseResult;
@@ -75,7 +74,7 @@ struct BoostTestInfo
int line; int line;
}; };
typedef QVector<BoostTestInfo> BoostTestInfoList; using BoostTestInfoList = QList<BoostTestInfo>;
class BoostTestCodeLocationAndType : public TestCodeLocationAndType class BoostTestCodeLocationAndType : public TestCodeLocationAndType
{ {
@@ -84,8 +83,7 @@ public:
BoostTestInfoList m_suitesState; BoostTestInfoList m_suitesState;
}; };
typedef QVector<BoostTestCodeLocationAndType> BoostTestCodeLocationList; using BoostTestCodeLocationList = QList<BoostTestCodeLocationAndType>;
} // namespace Internal } // namespace Autotest::Internal
} // namespace Autotest

View File

@@ -86,7 +86,7 @@ static bool hasCatchNames(const CPlusPlus::Document::Ptr &document)
continue; continue;
if (isCatchMacro(QLatin1String(macro.macro().name()))) { if (isCatchMacro(QLatin1String(macro.macro().name()))) {
const QVector<CPlusPlus::Document::Block> args = macro.arguments(); const QList<CPlusPlus::Document::Block> args = macro.arguments();
if (args.size() < 1) if (args.size() < 1)
continue; continue;
return true; return true;

View File

@@ -5,8 +5,7 @@
#include "../testtreeitem.h" #include "../testtreeitem.h"
namespace Autotest { namespace Autotest::Internal {
namespace Internal {
class CatchTreeItem : public TestTreeItem class CatchTreeItem : public TestTreeItem
{ {
@@ -58,7 +57,6 @@ public:
QStringList tags; // TODO: use them for the item QStringList tags; // TODO: use them for the item
}; };
typedef QVector<CatchTestCodeLocationAndType> CatchTestCodeLocationList; using CatchTestCodeLocationList = QList<CatchTestCodeLocationAndType>;
} // namespace Internal } // namespace Autotest::Internal
} // namespace Autotest

View File

@@ -62,7 +62,7 @@ static bool hasGTestNames(const CPlusPlus::Document::Ptr &document)
if (!macro.isFunctionLike()) if (!macro.isFunctionLike())
continue; continue;
if (GTestUtils::isGTestMacro(QLatin1String(macro.macro().name()))) { if (GTestUtils::isGTestMacro(QLatin1String(macro.macro().name()))) {
const QVector<CPlusPlus::Document::Block> args = macro.arguments(); const QList<CPlusPlus::Document::Block> args = macro.arguments();
if (args.size() != 2) if (args.size() != 2)
continue; continue;
return true; return true;

View File

@@ -496,7 +496,7 @@ QSet<QString> internalTargets(const TestTreeItem &item)
if (!projectInfo) if (!projectInfo)
return {}; return {};
const FilePath filePath = item.filePath(); const FilePath filePath = item.filePath();
const QVector<CppEditor::ProjectPart::ConstPtr> projectParts = projectInfo->projectParts(); const QList<CppEditor::ProjectPart::ConstPtr> projectParts = projectInfo->projectParts();
if (projectParts.isEmpty()) if (projectParts.isEmpty())
return CppEditor::CppModelManager::dependingInternalTargets(item.filePath()); return CppEditor::CppModelManager::dependingInternalTargets(item.filePath());
for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectParts) { for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectParts) {

View File

@@ -5,8 +5,7 @@
#include "../testtreeitem.h" #include "../testtreeitem.h"
namespace Autotest { namespace Autotest::Internal {
namespace Internal {
class GTestParseResult; class GTestParseResult;
@@ -54,6 +53,7 @@ public:
bool isGroupable() const override; bool isGroupable() const override;
TestTreeItem *applyFilters() override; TestTreeItem *applyFilters() override;
bool shouldBeAddedAfterFiltering() const override; bool shouldBeAddedAfterFiltering() const override;
private: private:
bool modifyTestSetContent(const GTestParseResult *result); bool modifyTestSetContent(const GTestParseResult *result);
QList<ITestConfiguration *> getTestConfigurations(bool ignoreCheckState) const; QList<ITestConfiguration *> getTestConfigurations(bool ignoreCheckState) const;
@@ -66,7 +66,7 @@ public:
GTestTreeItem::TestStates m_state; GTestTreeItem::TestStates m_state;
}; };
typedef QVector<GTestCodeLocationAndType> GTestCodeLocationList; using GTestCodeLocationList = QList<GTestCodeLocationAndType>;
struct GTestCaseSpec struct GTestCaseSpec
{ {
@@ -76,5 +76,4 @@ struct GTestCaseSpec
bool disabled; bool disabled;
}; };
} // namespace Internal } // namespace Autotest::Internal
} // namespace Autotest

View File

@@ -29,7 +29,7 @@ public:
virtual TestTreeItem *createTestTreeItem() const = 0; virtual TestTreeItem *createTestTreeItem() const = 0;
QVector<TestParseResult *> children; QList<TestParseResult *> children;
ITestFramework *framework; ITestFramework *framework;
TestTreeItem::Type itemType = TestTreeItem::Root; TestTreeItem::Type itemType = TestTreeItem::Root;
QString displayName; QString displayName;

View File

@@ -51,6 +51,6 @@ public:
bool m_inherited = false; bool m_inherited = false;
}; };
typedef QVector<QtTestCodeLocationAndType> QtTestCodeLocationList; using QtTestCodeLocationList = QList<QtTestCodeLocationAndType>;
} // namespace Autotest::Internal } // namespace Autotest::Internal

View File

@@ -212,7 +212,7 @@ static bool checkQmlDocumentForQuickTestCode(QPromise<TestParseResultPtr> &promi
if (!qmlVisitor.isValid()) if (!qmlVisitor.isValid())
return false; return false;
const QVector<QuickTestCaseSpec> &testCases = qmlVisitor.testCases(); const QList<QuickTestCaseSpec> &testCases = qmlVisitor.testCases();
for (const QuickTestCaseSpec &testCase : testCases) { for (const QuickTestCaseSpec &testCase : testCases) {
const QString testCaseName = testCase.m_caseName; const QString testCaseName = testCase.m_caseName;

View File

@@ -3,7 +3,7 @@
#pragma once #pragma once
#include "quicktesttreeitem.h" #include "../testtreeitem.h"
#include <cplusplus/ASTVisitor.h> #include <cplusplus/ASTVisitor.h>
#include <cplusplus/CppDocument.h> #include <cplusplus/CppDocument.h>
@@ -12,8 +12,7 @@
#include <QStack> #include <QStack>
namespace Autotest { namespace Autotest::Internal {
namespace Internal {
class QuickTestCaseSpec class QuickTestCaseSpec
{ {
@@ -40,14 +39,14 @@ public:
void throwRecursionDepthError() override; void throwRecursionDepthError() override;
QVector<QuickTestCaseSpec> testCases() const { return m_testCases; } QList<QuickTestCaseSpec> testCases() const { return m_testCases; }
bool isValid() const { return !m_testCases.isEmpty(); } bool isValid() const { return !m_testCases.isEmpty(); }
private: private:
QmlJS::Document::Ptr m_currentDoc; QmlJS::Document::Ptr m_currentDoc;
const QmlJS::Snapshot &m_snapshot; const QmlJS::Snapshot &m_snapshot;
QStack<QuickTestCaseSpec> m_caseParseStack; QStack<QuickTestCaseSpec> m_caseParseStack;
QVector<QuickTestCaseSpec> m_testCases; QList<QuickTestCaseSpec> m_testCases;
QStack<bool> m_objectIsTestStack; QStack<bool> m_objectIsTestStack;
bool m_expectTestCaseName = false; bool m_expectTestCaseName = false;
bool m_checkForDerivedTest = false; bool m_checkForDerivedTest = false;
@@ -66,5 +65,4 @@ private:
CPlusPlus::Document::Ptr m_currentDoc; CPlusPlus::Document::Ptr m_currentDoc;
}; };
} // namespace Internal } // namespace Autotest::Internal
} // namespace Autotest

View File

@@ -707,7 +707,7 @@ void TestResultsPane::createMarks(const QModelIndex &parent)
{ {
const TestResult parentResult = m_model->testResult(parent); const TestResult parentResult = m_model->testResult(parent);
const ResultType parentType = parentResult.isValid() ? parentResult.result() : ResultType::Invalid; const ResultType parentType = parentResult.isValid() ? parentResult.result() : ResultType::Invalid;
const QVector<ResultType> interested{ResultType::Fail, ResultType::UnexpectedPass}; const QList<ResultType> interested{ResultType::Fail, ResultType::UnexpectedPass};
for (int row = 0, count = m_model->rowCount(parent); row < count; ++row) { for (int row = 0, count = m_model->rowCount(parent); row < count; ++row) {
const QModelIndex index = m_model->index(row, 0, parent); const QModelIndex index = m_model->index(row, 0, parent);
const TestResult result = m_model->testResult(index); const TestResult result = m_model->testResult(index);

View File

@@ -124,7 +124,7 @@ private:
bool m_autoScroll = false; bool m_autoScroll = false;
bool m_atEnd = false; bool m_atEnd = false;
bool m_testRunning = false; bool m_testRunning = false;
QVector<TestEditorMark *> m_marks; QList<TestEditorMark *> m_marks;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -190,7 +190,7 @@ public:
TestTreeItem::Type m_type = TestTreeItem::Root; TestTreeItem::Type m_type = TestTreeItem::Root;
}; };
typedef QVector<TestCodeLocationAndType> TestCodeLocationList; using TestCodeLocationList = QList<TestCodeLocationAndType>;
} // namespace Autotest } // namespace Autotest

View File

@@ -686,7 +686,7 @@ void TestTreeModel::onParseResultsReady(const QList<TestParseResultPtr> &results
void Autotest::TestTreeModel::onDataChanged(const QModelIndex &topLeft, void Autotest::TestTreeModel::onDataChanged(const QModelIndex &topLeft,
const QModelIndex &bottomRight, const QModelIndex &bottomRight,
const QVector<int> &roles) const QList<int> &roles)
{ {
const QModelIndex parent = topLeft.parent(); const QModelIndex parent = topLeft.parent();
QTC_ASSERT(parent == bottomRight.parent(), return); QTC_ASSERT(parent == bottomRight.parent(), return);

View File

@@ -79,7 +79,7 @@ signals:
private: private:
void onParseResultsReady(const QList<TestParseResultPtr> &results); void onParseResultsReady(const QList<TestParseResultPtr> &results);
void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
const QVector<int> &roles); const QList<int> &roles);
void handleParseResult(const TestParseResult *result, TestTreeItem *rootNode); void handleParseResult(const TestParseResult *result, TestTreeItem *rootNode);
void removeAllTestItems(); void removeAllTestItems();
void removeAllTestToolItems(); void removeAllTestToolItems();