forked from qt-creator/qt-creator
AutoTests: Some code cosmetics
QVector->QList, typedef->using... Change-Id: I563759015f146b6a32d664a8bcc5690e5bbe81f6 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -12,8 +12,7 @@
|
||||
|
||||
#include <QByteArray>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class BoostCodeParser
|
||||
{
|
||||
@@ -21,7 +20,9 @@ public:
|
||||
BoostCodeParser(const QByteArray &source, const CPlusPlus::LanguageFeatures &features,
|
||||
const CPlusPlus::Document::Ptr &doc, const CPlusPlus::Snapshot &snapshot);
|
||||
virtual ~BoostCodeParser() = default;
|
||||
|
||||
BoostTestCodeLocationList findTests();
|
||||
|
||||
private:
|
||||
enum class TestCaseType {Auto, Functions, Parameter, Fixture, Data};
|
||||
|
||||
@@ -50,11 +51,10 @@ private:
|
||||
CPlusPlus::Tokens m_tokens;
|
||||
int m_currentIndex = 0;
|
||||
BoostTestCodeLocationList m_testCases;
|
||||
QVector<BoostTestInfo> m_suites;
|
||||
QList<BoostTestInfo> m_suites;
|
||||
QString m_currentSuite;
|
||||
BoostTestTreeItem::TestStates m_currentState = BoostTestTreeItem::Enabled;
|
||||
int m_lineNo = 0;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
} // Autotest
|
||||
} // Autotest::Internal
|
||||
|
@@ -5,8 +5,7 @@
|
||||
|
||||
#include "../testtreeitem.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class BoostTestParseResult;
|
||||
|
||||
@@ -75,7 +74,7 @@ struct BoostTestInfo
|
||||
int line;
|
||||
};
|
||||
|
||||
typedef QVector<BoostTestInfo> BoostTestInfoList;
|
||||
using BoostTestInfoList = QList<BoostTestInfo>;
|
||||
|
||||
class BoostTestCodeLocationAndType : public TestCodeLocationAndType
|
||||
{
|
||||
@@ -84,8 +83,7 @@ public:
|
||||
BoostTestInfoList m_suitesState;
|
||||
};
|
||||
|
||||
typedef QVector<BoostTestCodeLocationAndType> BoostTestCodeLocationList;
|
||||
using BoostTestCodeLocationList = QList<BoostTestCodeLocationAndType>;
|
||||
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
} // namespace Autotest::Internal
|
||||
|
@@ -86,7 +86,7 @@ static bool hasCatchNames(const CPlusPlus::Document::Ptr &document)
|
||||
continue;
|
||||
|
||||
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)
|
||||
continue;
|
||||
return true;
|
||||
|
@@ -5,8 +5,7 @@
|
||||
|
||||
#include "../testtreeitem.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class CatchTreeItem : public TestTreeItem
|
||||
{
|
||||
@@ -58,7 +57,6 @@ public:
|
||||
QStringList tags; // TODO: use them for the item
|
||||
};
|
||||
|
||||
typedef QVector<CatchTestCodeLocationAndType> CatchTestCodeLocationList;
|
||||
using CatchTestCodeLocationList = QList<CatchTestCodeLocationAndType>;
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
} // namespace Autotest::Internal
|
||||
|
@@ -62,7 +62,7 @@ static bool hasGTestNames(const CPlusPlus::Document::Ptr &document)
|
||||
if (!macro.isFunctionLike())
|
||||
continue;
|
||||
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)
|
||||
continue;
|
||||
return true;
|
||||
|
@@ -496,7 +496,7 @@ QSet<QString> internalTargets(const TestTreeItem &item)
|
||||
if (!projectInfo)
|
||||
return {};
|
||||
const FilePath filePath = item.filePath();
|
||||
const QVector<CppEditor::ProjectPart::ConstPtr> projectParts = projectInfo->projectParts();
|
||||
const QList<CppEditor::ProjectPart::ConstPtr> projectParts = projectInfo->projectParts();
|
||||
if (projectParts.isEmpty())
|
||||
return CppEditor::CppModelManager::dependingInternalTargets(item.filePath());
|
||||
for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectParts) {
|
||||
|
@@ -5,8 +5,7 @@
|
||||
|
||||
#include "../testtreeitem.h"
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class GTestParseResult;
|
||||
|
||||
@@ -54,6 +53,7 @@ public:
|
||||
bool isGroupable() const override;
|
||||
TestTreeItem *applyFilters() override;
|
||||
bool shouldBeAddedAfterFiltering() const override;
|
||||
|
||||
private:
|
||||
bool modifyTestSetContent(const GTestParseResult *result);
|
||||
QList<ITestConfiguration *> getTestConfigurations(bool ignoreCheckState) const;
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
GTestTreeItem::TestStates m_state;
|
||||
};
|
||||
|
||||
typedef QVector<GTestCodeLocationAndType> GTestCodeLocationList;
|
||||
using GTestCodeLocationList = QList<GTestCodeLocationAndType>;
|
||||
|
||||
struct GTestCaseSpec
|
||||
{
|
||||
@@ -76,5 +76,4 @@ struct GTestCaseSpec
|
||||
bool disabled;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
} // namespace Autotest::Internal
|
||||
|
@@ -29,7 +29,7 @@ public:
|
||||
|
||||
virtual TestTreeItem *createTestTreeItem() const = 0;
|
||||
|
||||
QVector<TestParseResult *> children;
|
||||
QList<TestParseResult *> children;
|
||||
ITestFramework *framework;
|
||||
TestTreeItem::Type itemType = TestTreeItem::Root;
|
||||
QString displayName;
|
||||
|
@@ -51,6 +51,6 @@ public:
|
||||
bool m_inherited = false;
|
||||
};
|
||||
|
||||
typedef QVector<QtTestCodeLocationAndType> QtTestCodeLocationList;
|
||||
using QtTestCodeLocationList = QList<QtTestCodeLocationAndType>;
|
||||
|
||||
} // namespace Autotest::Internal
|
||||
|
@@ -212,7 +212,7 @@ static bool checkQmlDocumentForQuickTestCode(QPromise<TestParseResultPtr> &promi
|
||||
if (!qmlVisitor.isValid())
|
||||
return false;
|
||||
|
||||
const QVector<QuickTestCaseSpec> &testCases = qmlVisitor.testCases();
|
||||
const QList<QuickTestCaseSpec> &testCases = qmlVisitor.testCases();
|
||||
|
||||
for (const QuickTestCaseSpec &testCase : testCases) {
|
||||
const QString testCaseName = testCase.m_caseName;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "quicktesttreeitem.h"
|
||||
#include "../testtreeitem.h"
|
||||
|
||||
#include <cplusplus/ASTVisitor.h>
|
||||
#include <cplusplus/CppDocument.h>
|
||||
@@ -12,8 +12,7 @@
|
||||
|
||||
#include <QStack>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
namespace Autotest::Internal {
|
||||
|
||||
class QuickTestCaseSpec
|
||||
{
|
||||
@@ -40,14 +39,14 @@ public:
|
||||
|
||||
void throwRecursionDepthError() override;
|
||||
|
||||
QVector<QuickTestCaseSpec> testCases() const { return m_testCases; }
|
||||
QList<QuickTestCaseSpec> testCases() const { return m_testCases; }
|
||||
bool isValid() const { return !m_testCases.isEmpty(); }
|
||||
|
||||
private:
|
||||
QmlJS::Document::Ptr m_currentDoc;
|
||||
const QmlJS::Snapshot &m_snapshot;
|
||||
QStack<QuickTestCaseSpec> m_caseParseStack;
|
||||
QVector<QuickTestCaseSpec> m_testCases;
|
||||
QList<QuickTestCaseSpec> m_testCases;
|
||||
QStack<bool> m_objectIsTestStack;
|
||||
bool m_expectTestCaseName = false;
|
||||
bool m_checkForDerivedTest = false;
|
||||
@@ -66,5 +65,4 @@ private:
|
||||
CPlusPlus::Document::Ptr m_currentDoc;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
} // namespace Autotest::Internal
|
||||
|
@@ -707,7 +707,7 @@ void TestResultsPane::createMarks(const QModelIndex &parent)
|
||||
{
|
||||
const TestResult parentResult = m_model->testResult(parent);
|
||||
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) {
|
||||
const QModelIndex index = m_model->index(row, 0, parent);
|
||||
const TestResult result = m_model->testResult(index);
|
||||
|
@@ -124,7 +124,7 @@ private:
|
||||
bool m_autoScroll = false;
|
||||
bool m_atEnd = false;
|
||||
bool m_testRunning = false;
|
||||
QVector<TestEditorMark *> m_marks;
|
||||
QList<TestEditorMark *> m_marks;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -190,7 +190,7 @@ public:
|
||||
TestTreeItem::Type m_type = TestTreeItem::Root;
|
||||
};
|
||||
|
||||
typedef QVector<TestCodeLocationAndType> TestCodeLocationList;
|
||||
using TestCodeLocationList = QList<TestCodeLocationAndType>;
|
||||
|
||||
} // namespace Autotest
|
||||
|
||||
|
@@ -686,7 +686,7 @@ void TestTreeModel::onParseResultsReady(const QList<TestParseResultPtr> &results
|
||||
|
||||
void Autotest::TestTreeModel::onDataChanged(const QModelIndex &topLeft,
|
||||
const QModelIndex &bottomRight,
|
||||
const QVector<int> &roles)
|
||||
const QList<int> &roles)
|
||||
{
|
||||
const QModelIndex parent = topLeft.parent();
|
||||
QTC_ASSERT(parent == bottomRight.parent(), return);
|
||||
|
@@ -79,7 +79,7 @@ signals:
|
||||
private:
|
||||
void onParseResultsReady(const QList<TestParseResultPtr> &results);
|
||||
void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
|
||||
const QVector<int> &roles);
|
||||
const QList<int> &roles);
|
||||
void handleParseResult(const TestParseResult *result, TestTreeItem *rootNode);
|
||||
void removeAllTestItems();
|
||||
void removeAllTestToolItems();
|
||||
|
Reference in New Issue
Block a user