AutoTest: Modernize code

* remove unnecessary QLatin1String where possible
* foreach
* nullptr
* bad naming of static members

Change-Id: If0f7c6839be4d2efbfef6f7f0775d2034775bd90
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2017-02-13 10:05:06 +01:00
parent 085ac718d5
commit 23398229e9
26 changed files with 147 additions and 147 deletions

View File

@@ -31,12 +31,12 @@ namespace Autotest {
namespace Icons { namespace Icons {
const Utils::Icon SORT_ALPHABETICALLY({ const Utils::Icon SORT_ALPHABETICALLY({
{QLatin1String(":/images/sort.png"), Utils::Theme::IconsBaseColor}}); {":/images/sort.png", Utils::Theme::IconsBaseColor}});
const Utils::Icon SORT_NATURALLY({ const Utils::Icon SORT_NATURALLY({
{QLatin1String(":/images/leafsort.png"), Utils::Theme::IconsBaseColor}}); {":/images/leafsort.png", Utils::Theme::IconsBaseColor}});
const Utils::Icon RUN_SELECTED_OVERLAY({ const Utils::Icon RUN_SELECTED_OVERLAY({
{QLatin1String(":/images/runselected_boxes.png"), Utils::Theme::BackgroundColorDark}, {":/images/runselected_boxes.png", Utils::Theme::BackgroundColorDark},
{QLatin1String(":/images/runselected_tickmarks.png"), Utils::Theme::IconsBaseColor}}); {":/images/runselected_tickmarks.png", Utils::Theme::IconsBaseColor}});
const Utils::Icon RESULT_PASS({ const Utils::Icon RESULT_PASS({
{":/utils/images/filledcircle.png", Utils::Theme::OutputPanes_TestPassTextColor}}, {":/utils/images/filledcircle.png", Utils::Theme::OutputPanes_TestPassTextColor}},

View File

@@ -63,7 +63,7 @@
using namespace Autotest::Internal; using namespace Autotest::Internal;
using namespace Core; using namespace Core;
static AutotestPlugin *m_instance = 0; static AutotestPlugin *s_instance = nullptr;
AutotestPlugin::AutotestPlugin() AutotestPlugin::AutotestPlugin()
: m_settings(new TestSettings) : m_settings(new TestSettings)
@@ -73,7 +73,7 @@ AutotestPlugin::AutotestPlugin()
qRegisterMetaType<TestTreeItem *>(); qRegisterMetaType<TestTreeItem *>();
qRegisterMetaType<TestCodeLocationAndType>(); qRegisterMetaType<TestCodeLocationAndType>();
m_instance = this; s_instance = this;
} }
AutotestPlugin::~AutotestPlugin() AutotestPlugin::~AutotestPlugin()
@@ -83,7 +83,7 @@ AutotestPlugin::~AutotestPlugin()
AutotestPlugin *AutotestPlugin::instance() AutotestPlugin *AutotestPlugin::instance()
{ {
return m_instance; return s_instance;
} }
QSharedPointer<TestSettings> AutotestPlugin::settings() const QSharedPointer<TestSettings> AutotestPlugin::settings() const

View File

@@ -73,7 +73,7 @@ void AutoTestUnitTests::initTestCase()
if (!toolchain) if (!toolchain)
QSKIP("This test requires that there is a kit with a toolchain."); QSKIP("This test requires that there is a kit with a toolchain.");
m_tmpDir = new CppTools::Tests::TemporaryCopiedDir(QLatin1String(":/unit_test")); m_tmpDir = new CppTools::Tests::TemporaryCopiedDir(":/unit_test");
} }
void AutoTestUnitTests::cleanupTestCase() void AutoTestUnitTests::cleanupTestCase()
@@ -117,16 +117,16 @@ void AutoTestUnitTests::testCodeParser_data()
QTest::newRow("plainAutoTest") QTest::newRow("plainAutoTest")
<< QString(m_tmpDir->path() + QLatin1String("/plain/plain.pro")) << QString(m_tmpDir->path() + "/plain/plain.pro")
<< 1 << 0 << 0 << 0; << 1 << 0 << 0 << 0;
QTest::newRow("mixedAutoTestAndQuickTests") QTest::newRow("mixedAutoTestAndQuickTests")
<< QString(m_tmpDir->path() + QLatin1String("/mixed_atp/mixed_atp.pro")) << QString(m_tmpDir->path() + "/mixed_atp/mixed_atp.pro")
<< 4 << 5 << 3 << 10; << 4 << 5 << 3 << 10;
QTest::newRow("plainAutoTestQbs") QTest::newRow("plainAutoTestQbs")
<< QString(m_tmpDir->path() + QLatin1String("/plain/plain.qbs")) << QString(m_tmpDir->path() + "/plain/plain.qbs")
<< 1 << 0 << 0 << 0; << 1 << 0 << 0 << 0;
QTest::newRow("mixedAutoTestAndQuickTestsQbs") QTest::newRow("mixedAutoTestAndQuickTestsQbs")
<< QString(m_tmpDir->path() + QLatin1String("/mixed_atp/mixed_atp.qbs")) << QString(m_tmpDir->path() + "/mixed_atp/mixed_atp.qbs")
<< 4 << 5 << 3 << 10; << 4 << 5 << 3 << 10;
} }
@@ -210,7 +210,7 @@ void AutoTestUnitTests::testCodeParserGTest()
QMultiMap<QString, int> foundNamesAndSets = m_model->gtestNamesAndSets(); QMultiMap<QString, int> foundNamesAndSets = m_model->gtestNamesAndSets();
QCOMPARE(expectedNamesAndSets.size(), foundNamesAndSets.size()); QCOMPARE(expectedNamesAndSets.size(), foundNamesAndSets.size());
foreach (const QString &name, expectedNamesAndSets.keys()) for (const QString &name : expectedNamesAndSets.keys())
QCOMPARE(expectedNamesAndSets.values(name), foundNamesAndSets.values(name)); QCOMPARE(expectedNamesAndSets.values(name), foundNamesAndSets.values(name));
// check also that no Qt related tests have been found // check also that no Qt related tests have been found
@@ -224,9 +224,9 @@ void AutoTestUnitTests::testCodeParserGTest_data()
{ {
QTest::addColumn<QString>("projectFilePath"); QTest::addColumn<QString>("projectFilePath");
QTest::newRow("simpleGoogletest") QTest::newRow("simpleGoogletest")
<< QString(m_tmpDir->path() + QLatin1String("/simple_gt/simple_gt.pro")); << QString(m_tmpDir->path() + "/simple_gt/simple_gt.pro");
QTest::newRow("simpleGoogletestQbs") QTest::newRow("simpleGoogletestQbs")
<< QString(m_tmpDir->path() + QLatin1String("/simple_gt/simple_gt.qbs")); << QString(m_tmpDir->path() + "/simple_gt/simple_gt.qbs");
} }
} // namespace Internal } // namespace Internal

View File

@@ -140,8 +140,8 @@ void GTestOutputReader::processOutput(const QByteArray &outputLine)
m_description.chop(1); m_description.chop(1);
testResult->setDescription(m_description); testResult->setDescription(m_description);
foreach (const QString &output, m_description.split('\n')) { for (const QString &output : m_description.split('\n')) {
QRegExp *match = 0; QRegExp *match = nullptr;
if (failureLocation.exactMatch(output)) if (failureLocation.exactMatch(output))
match = &failureLocation; match = &failureLocation;
else if (errorLocation.exactMatch(output)) else if (errorLocation.exactMatch(output))

View File

@@ -47,7 +47,7 @@ TestTreeItem *GTestParseResult::createTestTreeItem() const
item->setState(GTestTreeItem::Typed); item->setState(GTestTreeItem::Typed);
if (disabled) if (disabled)
item->setState(GTestTreeItem::Disabled); item->setState(GTestTreeItem::Disabled);
foreach (const TestParseResult *testSet, children) for (const TestParseResult *testSet : children)
item->appendChild(testSet->createTestTreeItem()); item->appendChild(testSet->createTestTreeItem());
return item; return item;
} }
@@ -56,12 +56,12 @@ static bool includesGTest(const CPlusPlus::Document::Ptr &doc,
const CPlusPlus::Snapshot &snapshot) const CPlusPlus::Snapshot &snapshot)
{ {
static const QString gtestH("gtest/gtest.h"); static const QString gtestH("gtest/gtest.h");
foreach (const CPlusPlus::Document::Include &inc, doc->resolvedIncludes()) { for (const CPlusPlus::Document::Include &inc : doc->resolvedIncludes()) {
if (inc.resolvedFileName().endsWith(gtestH)) if (inc.resolvedFileName().endsWith(gtestH))
return true; return true;
} }
foreach (const QString &include, snapshot.allIncludesForDocument(doc->fileName())) { for (const QString &include : snapshot.allIncludesForDocument(doc->fileName())) {
if (include.endsWith(gtestH)) if (include.endsWith(gtestH))
return true; return true;
} }
@@ -71,7 +71,7 @@ static bool includesGTest(const CPlusPlus::Document::Ptr &doc,
static bool hasGTestNames(const CPlusPlus::Document::Ptr &document) static bool hasGTestNames(const CPlusPlus::Document::Ptr &document)
{ {
foreach (const CPlusPlus::Document::MacroUse &macro, document->macroUses()) { for (const CPlusPlus::Document::MacroUse &macro : document->macroUses()) {
if (!macro.isFunctionLike()) if (!macro.isFunctionLike())
continue; continue;
if (GTestUtils::isGTestMacro(QLatin1String(macro.macro().name()))) { if (GTestUtils::isGTestMacro(QLatin1String(macro.macro().name()))) {
@@ -106,7 +106,7 @@ static bool handleGTest(QFutureInterface<TestParseResultPtr> futureInterface,
else else
return false; // happens if shutting down while parsing return false; // happens if shutting down while parsing
foreach (const GTestCaseSpec &testSpec, result.keys()) { for (const GTestCaseSpec &testSpec : result.keys()) {
GTestParseResult *parseResult = new GTestParseResult(id); GTestParseResult *parseResult = new GTestParseResult(id);
parseResult->itemType = TestTreeItem::TestCase; parseResult->itemType = TestTreeItem::TestCase;
parseResult->fileName = filePath; parseResult->fileName = filePath;
@@ -116,7 +116,7 @@ static bool handleGTest(QFutureInterface<TestParseResultPtr> futureInterface,
parseResult->disabled = testSpec.disabled; parseResult->disabled = testSpec.disabled;
parseResult->proFile = proFile; parseResult->proFile = proFile;
foreach (const GTestCodeLocationAndType &location, result.value(testSpec)) { for (const GTestCodeLocationAndType &location : result.value(testSpec)) {
GTestParseResult *testSet = new GTestParseResult(id); GTestParseResult *testSet = new GTestParseResult(id);
testSet->name = location.m_name; testSet->name = location.m_name;
testSet->fileName = filePath; testSet->fileName = filePath;

View File

@@ -37,12 +37,12 @@ namespace Internal {
static QString gtestFilter(GTestTreeItem::TestStates states) static QString gtestFilter(GTestTreeItem::TestStates states)
{ {
if ((states & GTestTreeItem::Parameterized) && (states & GTestTreeItem::Typed)) if ((states & GTestTreeItem::Parameterized) && (states & GTestTreeItem::Typed))
return QLatin1String("*/%1/*.%2"); return QString("*/%1/*.%2");
if (states & GTestTreeItem::Parameterized) if (states & GTestTreeItem::Parameterized)
return QLatin1String("*/%1.%2/*"); return QString("*/%1.%2/*");
if (states & GTestTreeItem::Typed) if (states & GTestTreeItem::Typed)
return QLatin1String("%1/*.%2"); return QString("%1/*.%2");
return QLatin1String("%1.%2"); return QString("%1.%2");
} }
QVariant GTestTreeItem::data(int column, int role) const QVariant GTestTreeItem::data(int column, int role) const
@@ -76,9 +76,9 @@ QVariant GTestTreeItem::data(int column, int role) const
TestConfiguration *GTestTreeItem::testConfiguration() const TestConfiguration *GTestTreeItem::testConfiguration() const
{ {
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
QTC_ASSERT(project, return 0); QTC_ASSERT(project, return nullptr);
GTestConfiguration *config = 0; GTestConfiguration *config = nullptr;
switch (type()) { switch (type()) {
case TestCase: { case TestCase: {
const QString &testSpecifier = gtestFilter(state()).arg(name()).arg('*'); const QString &testSpecifier = gtestFilter(state()).arg(name()).arg('*');
@@ -97,7 +97,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const
case TestFunctionOrSet: { case TestFunctionOrSet: {
GTestTreeItem *parent = static_cast<GTestTreeItem *>(parentItem()); GTestTreeItem *parent = static_cast<GTestTreeItem *>(parentItem());
if (!parent) if (!parent)
return 0; return nullptr;
const QString &testSpecifier = gtestFilter(parent->state()).arg(parent->name()).arg(name()); const QString &testSpecifier = gtestFilter(parent->state()).arg(parent->name()).arg(name());
config = new GTestConfiguration; config = new GTestConfiguration;
config->setTestCases(QStringList(testSpecifier)); config->setTestCases(QStringList(testSpecifier));
@@ -108,7 +108,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const
break; break;
} }
default: default:
return 0; return nullptr;
} }
return config; return config;
} }
@@ -254,7 +254,7 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
TestTreeItem *GTestTreeItem::find(const TestParseResult *result) TestTreeItem *GTestTreeItem::find(const TestParseResult *result)
{ {
QTC_ASSERT(result, return 0); QTC_ASSERT(result, return nullptr);
const GTestParseResult *parseResult = static_cast<const GTestParseResult *>(result); const GTestParseResult *parseResult = static_cast<const GTestParseResult *>(result);
GTestTreeItem::TestStates states = parseResult->disabled ? GTestTreeItem::Disabled GTestTreeItem::TestStates states = parseResult->disabled ? GTestTreeItem::Disabled
@@ -269,7 +269,7 @@ TestTreeItem *GTestTreeItem::find(const TestParseResult *result)
case TestCase: case TestCase:
return findChildByNameAndFile(result->name, result->fileName); return findChildByNameAndFile(result->name, result->fileName);
default: default:
return 0; return nullptr;
} }
} }
@@ -315,9 +315,9 @@ QString GTestTreeItem::nameSuffix() const
QCoreApplication::translate("GTestTreeItem", "typed") }; QCoreApplication::translate("GTestTreeItem", "typed") };
QString suffix; QString suffix;
if (m_state & Parameterized) if (m_state & Parameterized)
suffix = QLatin1String(" [") + markups[0]; suffix = QString(" [") + markups[0];
if (m_state & Typed) if (m_state & Typed)
suffix += (suffix.isEmpty() ? QLatin1String(" [") : QLatin1String(", ")) + markups[1]; suffix += (suffix.isEmpty() ? QString(" [") : QString(", ")) + markups[1];
if (!suffix.isEmpty()) if (!suffix.isEmpty())
suffix += ']'; suffix += ']';
return suffix; return suffix;

View File

@@ -40,7 +40,7 @@ GTestVisitor::GTestVisitor(CPlusPlus::Document::Ptr doc)
bool GTestVisitor::visit(CPlusPlus::FunctionDefinitionAST *ast) bool GTestVisitor::visit(CPlusPlus::FunctionDefinitionAST *ast)
{ {
static QString disabledPrefix = QString::fromLatin1("DISABLED_"); static const QString disabledPrefix("DISABLED_");
if (!ast || !ast->declarator || !ast->declarator->core_declarator) if (!ast || !ast->declarator || !ast->declarator->core_declarator)
return false; return false;

View File

@@ -32,7 +32,7 @@
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
static CppParser *s_parserInstance = 0; static CppParser *s_parserInstance = nullptr;
CppParser::CppParser() CppParser::CppParser()
{ {

View File

@@ -59,9 +59,9 @@ static QString formatResult(double value)
{ {
//NAN is not supported with visual studio 2010 //NAN is not supported with visual studio 2010
if (value < 0)// || value == NAN) if (value < 0)// || value == NAN)
return QLatin1String("NAN"); return QString("NAN");
if (value == 0) if (value == 0)
return QLatin1String("0"); return QString("0");
int significantDigits = 0; int significantDigits = 0;
qreal divisor = 1; qreal divisor = 1;
@@ -83,7 +83,7 @@ static QString formatResult(double value)
beforeDecimalPoint.append('0'); beforeDecimalPoint.append('0');
int afterUse = significantDigits - beforeUse; int afterUse = significantDigits - beforeUse;
if (beforeDecimalPoint == QLatin1String("0") && !afterDecimalPoint.isEmpty()) { if (beforeDecimalPoint == QString("0") && !afterDecimalPoint.isEmpty()) {
++afterUse; ++afterUse;
int i = 0; int i = 0;
while (i < afterDecimalPoint.count() && afterDecimalPoint.at(i) == '0') while (i < afterDecimalPoint.count() && afterDecimalPoint.at(i) == '0')

View File

@@ -46,7 +46,7 @@ TestTreeItem *QtTestParseResult::createTestTreeItem() const
item->setColumn(column); item->setColumn(column);
item->setInherited(m_inherited); item->setInherited(m_inherited);
foreach (const TestParseResult *funcParseResult, children) for (const TestParseResult *funcParseResult : children)
item->appendChild(funcParseResult->createTestTreeItem()); item->appendChild(funcParseResult->createTestTreeItem());
return item; return item;
} }
@@ -59,11 +59,11 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus:
const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes(); const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes();
foreach (const CPlusPlus::Document::Include &inc, includes) { for (const CPlusPlus::Document::Include &inc : includes) {
// TODO this short cut works only for #include <QtTest> // TODO this short cut works only for #include <QtTest>
// bad, as there could be much more different approaches // bad, as there could be much more different approaches
if (inc.unresolvedFileName() == QLatin1String("QtTest")) { if (inc.unresolvedFileName() == QString("QtTest")) {
foreach (const QString &prefix, expectedHeaderPrefixes) { for (const QString &prefix : expectedHeaderPrefixes) {
if (inc.resolvedFileName().endsWith(QString("%1/QtTest").arg(prefix))) if (inc.resolvedFileName().endsWith(QString("%1/QtTest").arg(prefix)))
return true; return true;
} }
@@ -71,8 +71,8 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus:
} }
const QSet<QString> allIncludes = snapshot.allIncludesForDocument(doc->fileName()); const QSet<QString> allIncludes = snapshot.allIncludesForDocument(doc->fileName());
foreach (const QString &include, allIncludes) { for (const QString &include : allIncludes) {
foreach (const QString &prefix, expectedHeaderPrefixes) { for (const QString &prefix : expectedHeaderPrefixes) {
if (include.endsWith(QString("%1/qtest.h").arg(prefix))) if (include.endsWith(QString("%1/qtest.h").arg(prefix)))
return true; return true;
} }
@@ -99,7 +99,7 @@ static QString testClass(const CppTools::CppModelManager *modelManager,
const QList<CPlusPlus::Document::MacroUse> macros = document->macroUses(); const QList<CPlusPlus::Document::MacroUse> macros = document->macroUses();
foreach (const CPlusPlus::Document::MacroUse &macro, macros) { for (const CPlusPlus::Document::MacroUse &macro : macros) {
if (!macro.isFunctionLike()) if (!macro.isFunctionLike())
continue; continue;
const QByteArray name = macro.macro().name(); const QByteArray name = macro.macro().name();
@@ -303,7 +303,7 @@ static bool handleQtTest(QFutureInterface<TestParseResultPtr> futureInterface,
// TODO: change to QHash<> // TODO: change to QHash<>
QMap<QString, QtTestCodeLocationList> dataTags; QMap<QString, QtTestCodeLocationList> dataTags;
foreach (const QString &file, files) for (const QString &file : files)
dataTags.unite(checkForDataTags(file, snapshot)); dataTags.unite(checkForDataTags(file, snapshot));
QtTestParseResult *parseResult = new QtTestParseResult(id); QtTestParseResult *parseResult = new QtTestParseResult(id);
@@ -333,7 +333,7 @@ static bool handleQtTest(QFutureInterface<TestParseResultPtr> futureInterface,
func->setInherited(location.m_inherited); func->setInherited(location.m_inherited);
const QtTestCodeLocationList &tagLocations = tagLocationsFor(func, dataTags); const QtTestCodeLocationList &tagLocations = tagLocationsFor(func, dataTags);
foreach (const QtTestCodeLocationAndType &tag, tagLocations) { for (const QtTestCodeLocationAndType &tag : tagLocations) {
QtTestParseResult *dataTag = new QtTestParseResult(id); QtTestParseResult *dataTag = new QtTestParseResult(id);
dataTag->itemType = tag.m_type; dataTag->itemType = tag.m_type;
dataTag->name = tag.m_name; dataTag->name = tag.m_name;

View File

@@ -106,7 +106,7 @@ bool QtTestResult::isIntermediateFor(const TestResult *other) const
TestResult *QtTestResult::createIntermediateResultFor(const TestResult *other) TestResult *QtTestResult::createIntermediateResultFor(const TestResult *other)
{ {
QTC_ASSERT(other, return 0); QTC_ASSERT(other, return nullptr);
const QtTestResult *qtOther = static_cast<const QtTestResult *>(other); const QtTestResult *qtOther = static_cast<const QtTestResult *>(other);
QtTestResult *intermediate = new QtTestResult(qtOther->name()); QtTestResult *intermediate = new QtTestResult(qtOther->name());
intermediate->m_function = qtOther->m_function; intermediate->m_function = qtOther->m_function;

View File

@@ -72,13 +72,13 @@ QString QtTestSettings::metricsTypeToOption(const MetricsType type)
case MetricsType::Walltime: case MetricsType::Walltime:
return QString(); return QString();
case MetricsType::TickCounter: case MetricsType::TickCounter:
return QLatin1String("-tickcounter"); return QString("-tickcounter");
case MetricsType::EventCounter: case MetricsType::EventCounter:
return QLatin1String("-eventcounter"); return QString("-eventcounter");
case MetricsType::CallGrind: case MetricsType::CallGrind:
return QLatin1String("-callgrind"); return QString("-callgrind");
case MetricsType::Perf: case MetricsType::Perf:
return QLatin1String("-perf"); return QString("-perf");
default: default:
return QString(); return QString();
} }

View File

@@ -102,9 +102,9 @@ bool QtTestTreeItem::canProvideDebugConfiguration() const
TestConfiguration *QtTestTreeItem::testConfiguration() const TestConfiguration *QtTestTreeItem::testConfiguration() const
{ {
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
QTC_ASSERT(project, return 0); QTC_ASSERT(project, return nullptr);
QtTestConfiguration *config = 0; QtTestConfiguration *config = nullptr;
switch (type()) { switch (type()) {
case TestCase: case TestCase:
config = new QtTestConfiguration; config = new QtTestConfiguration;
@@ -125,9 +125,9 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const
} }
case TestDataTag: { case TestDataTag: {
const TestTreeItem *function = parentItem(); const TestTreeItem *function = parentItem();
const TestTreeItem *parent = function ? function->parentItem() : 0; const TestTreeItem *parent = function ? function->parentItem() : nullptr;
if (!parent) if (!parent)
return 0; return nullptr;
const QString functionWithTag = function->name() + ':' + name(); const QString functionWithTag = function->name() + ':' + name();
config = new QtTestConfiguration(); config = new QtTestConfiguration();
config->setTestCases(QStringList(functionWithTag)); config->setTestCases(QStringList(functionWithTag));
@@ -138,7 +138,7 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const
break; break;
} }
default: default:
return 0; return nullptr;
} }
return config; return config;
} }
@@ -180,7 +180,7 @@ QList<TestConfiguration *> QtTestTreeItem::getSelectedTestConfigurations() const
if (!project || type() != Root) if (!project || type() != Root)
return result; return result;
QtTestConfiguration *testConfiguration = 0; QtTestConfiguration *testConfiguration = nullptr;
for (int row = 0, count = childCount(); row < count; ++row) { for (int row = 0, count = childCount(); row < count; ++row) {
const TestTreeItem *child = childItem(row); const TestTreeItem *child = childItem(row);
@@ -231,7 +231,7 @@ QList<TestConfiguration *> QtTestTreeItem::getSelectedTestConfigurations() const
TestTreeItem *QtTestTreeItem::find(const TestParseResult *result) TestTreeItem *QtTestTreeItem::find(const TestParseResult *result)
{ {
QTC_ASSERT(result, return 0); QTC_ASSERT(result, return nullptr);
switch (type()) { switch (type()) {
case Root: case Root:
@@ -245,7 +245,7 @@ TestTreeItem *QtTestTreeItem::find(const TestParseResult *result)
case TestSpecialFunction: case TestSpecialFunction:
return findChildByName(result->name); return findChildByName(result->name);
default: default:
return 0; return nullptr;
} }
} }
@@ -277,9 +277,9 @@ TestTreeItem *QtTestTreeItem::findChildByNameAndInheritance(const QString &name,
QString QtTestTreeItem::nameSuffix() const QString QtTestTreeItem::nameSuffix() const
{ {
static QString inheritedSuffix = QLatin1String(" [") static QString inheritedSuffix = QString(" [")
+ QCoreApplication::translate("QtTestTreeItem", "inherited") + QCoreApplication::translate("QtTestTreeItem", "inherited")
+ QLatin1String("]"); + QString("]");
return m_inherited ? inheritedSuffix : QString(); return m_inherited ? inheritedSuffix : QString();
} }

View File

@@ -142,7 +142,7 @@ bool TestAstVisitor::visit(CPlusPlus::CallAST *ast)
bool TestAstVisitor::visit(CPlusPlus::CompoundStatementAST *ast) bool TestAstVisitor::visit(CPlusPlus::CompoundStatementAST *ast)
{ {
if (!ast || !ast->symbol) { if (!ast || !ast->symbol) {
m_currentScope = 0; m_currentScope = nullptr;
return false; return false;
} }
m_currentScope = ast->symbol->asScope(); m_currentScope = ast->symbol->asScope();

View File

@@ -74,7 +74,7 @@ public:
private: private:
QString m_className; QString m_className;
CPlusPlus::Scope *m_currentScope = 0; CPlusPlus::Scope *m_currentScope = nullptr;
CPlusPlus::Document::Ptr m_currentDoc; CPlusPlus::Document::Ptr m_currentDoc;
CPlusPlus::Snapshot m_snapshot; CPlusPlus::Snapshot m_snapshot;
}; };

View File

@@ -47,7 +47,7 @@ TestTreeItem *QuickTestParseResult::createTestTreeItem() const
item->setProFile(proFile); item->setProFile(proFile);
item->setLine(line); item->setLine(line);
item->setColumn(column); item->setColumn(column);
foreach (const TestParseResult *funcResult, children) for (const TestParseResult *funcResult : children)
item->appendChild(funcResult->createTestTreeItem()); item->appendChild(funcResult->createTestTreeItem());
return item; return item;
} }
@@ -62,9 +62,9 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes(); const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes();
foreach (const CPlusPlus::Document::Include &inc, includes) { for (const CPlusPlus::Document::Include &inc : includes) {
if (inc.unresolvedFileName() == "QtQuickTest/quicktest.h") { if (inc.unresolvedFileName() == "QtQuickTest/quicktest.h") {
foreach (const QString &prefix, expectedHeaderPrefixes) { for (const QString &prefix : expectedHeaderPrefixes) {
if (inc.resolvedFileName().endsWith( if (inc.resolvedFileName().endsWith(
QString("%1/quicktest.h").arg(prefix))) { QString("%1/quicktest.h").arg(prefix))) {
return true; return true;
@@ -73,8 +73,8 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
} }
} }
foreach (const QString &include, snapshot.allIncludesForDocument(doc->fileName())) { for (const QString &include : snapshot.allIncludesForDocument(doc->fileName())) {
foreach (const QString &prefix, expectedHeaderPrefixes) { for (const QString &prefix : expectedHeaderPrefixes) {
if (include.endsWith(QString("%1/quicktest.h").arg(prefix))) if (include.endsWith(QString("%1/quicktest.h").arg(prefix)))
return true; return true;
} }
@@ -89,7 +89,7 @@ static QString quickTestSrcDir(const CppTools::CppModelManager *cppMM,
const QList<CppTools::ProjectPart::Ptr> parts = cppMM->projectPart(fileName); const QList<CppTools::ProjectPart::Ptr> parts = cppMM->projectPart(fileName);
if (parts.size() > 0) { if (parts.size() > 0) {
QByteArray projDefines(parts.at(0)->projectDefines); QByteArray projDefines(parts.at(0)->projectDefines);
foreach (const QByteArray &line, projDefines.split('\n')) { for (const QByteArray &line : projDefines.split('\n')) {
if (line.contains(qtsd)) { if (line.contains(qtsd)) {
QByteArray result = line.mid(line.indexOf(qtsd) + qtsd.length()); QByteArray result = line.mid(line.indexOf(qtsd) + qtsd.length());
if (result.startsWith('"')) if (result.startsWith('"'))
@@ -107,7 +107,7 @@ static QString quickTestName(const CPlusPlus::Document::Ptr &doc)
{ {
const QList<CPlusPlus::Document::MacroUse> macros = doc->macroUses(); const QList<CPlusPlus::Document::MacroUse> macros = doc->macroUses();
foreach (const CPlusPlus::Document::MacroUse &macro, macros) { for (const CPlusPlus::Document::MacroUse &macro : macros) {
if (!macro.isFunctionLike()) if (!macro.isFunctionLike())
continue; continue;
const QByteArray name = macro.macro().name(); const QByteArray name = macro.macro().name();
@@ -142,9 +142,9 @@ static QList<QmlJS::Document::Ptr> scanDirectoryForQuickTestQmlFiles(const QStri
} }
QList<QmlJS::Document::Ptr> foundDocs; QList<QmlJS::Document::Ptr> foundDocs;
foreach (const QString &path, dirs) { for (const QString &path : dirs) {
const QList<QmlJS::Document::Ptr> docs = snapshot.documentsInDirectory(path); const QList<QmlJS::Document::Ptr> docs = snapshot.documentsInDirectory(path);
foreach (const QmlJS::Document::Ptr &doc, docs) { for (const QmlJS::Document::Ptr &doc : docs) {
const QString fileName(QFileInfo(doc->fileName()).fileName()); const QString fileName(QFileInfo(doc->fileName()).fileName());
if (fileName.startsWith("tst_") && fileName.endsWith(".qml")) if (fileName.startsWith("tst_") && fileName.endsWith(".qml"))
foundDocs << doc; foundDocs << doc;
@@ -218,7 +218,7 @@ static bool handleQtQuickTest(QFutureInterface<TestParseResultPtr> futureInterfa
const QList<QmlJS::Document::Ptr> qmlDocs = scanDirectoryForQuickTestQmlFiles(srcDir); const QList<QmlJS::Document::Ptr> qmlDocs = scanDirectoryForQuickTestQmlFiles(srcDir);
bool result = false; bool result = false;
foreach (const QmlJS::Document::Ptr &qmlJSDoc, qmlDocs) for (const QmlJS::Document::Ptr &qmlJSDoc : qmlDocs)
result |= checkQmlDocumentForQuickTestCode(futureInterface, qmlJSDoc, id, proFile); result |= checkQmlDocumentForQuickTestCode(futureInterface, qmlJSDoc, id, proFile);
return result; return result;
} }

View File

@@ -112,9 +112,9 @@ bool QuickTestTreeItem::canProvideTestConfiguration() const
TestConfiguration *QuickTestTreeItem::testConfiguration() const TestConfiguration *QuickTestTreeItem::testConfiguration() const
{ {
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject();
QTC_ASSERT(project, return 0); QTC_ASSERT(project, return nullptr);
QuickTestConfiguration *config = 0; QuickTestConfiguration *config = nullptr;
switch (type()) { switch (type()) {
case TestCase: { case TestCase: {
QStringList testFunctions; QStringList testFunctions;
@@ -136,7 +136,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const
break; break;
} }
default: default:
return 0; return nullptr;
} }
return config; return config;
} }
@@ -185,7 +185,7 @@ QList<TestConfiguration *> QuickTestTreeItem::getSelectedTestConfigurations() co
if (!project || type() != Root) if (!project || type() != Root)
return result; return result;
QuickTestConfiguration *tc = 0; QuickTestConfiguration *tc = nullptr;
QHash<QString, QuickTestConfiguration *> foundProFiles; QHash<QString, QuickTestConfiguration *> foundProFiles;
// unnamed Quick Tests must be handled first // unnamed Quick Tests must be handled first
if (TestTreeItem *unnamed = unnamedQuickTests()) { if (TestTreeItem *unnamed = unnamedQuickTests()) {
@@ -266,7 +266,7 @@ QList<TestConfiguration *> QuickTestTreeItem::getSelectedTestConfigurations() co
TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result) TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result)
{ {
QTC_ASSERT(result, return 0); QTC_ASSERT(result, return nullptr);
switch (type()) { switch (type()) {
case Root: case Root:
@@ -275,7 +275,7 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result)
return name().isEmpty() ? findChildByNameAndFile(result->name, result->fileName) return name().isEmpty() ? findChildByNameAndFile(result->name, result->fileName)
: findChildByName(result->name); : findChildByName(result->name);
default: default:
return 0; return nullptr;
} }
} }
@@ -310,14 +310,14 @@ bool QuickTestTreeItem::lessThan(const TestTreeItem *other, TestTreeItem::SortMo
TestTreeItem *QuickTestTreeItem::unnamedQuickTests() const TestTreeItem *QuickTestTreeItem::unnamedQuickTests() const
{ {
if (type() != Root) if (type() != Root)
return 0; return nullptr;
for (int row = 0, count = childCount(); row < count; ++row) { for (int row = 0, count = childCount(); row < count; ++row) {
TestTreeItem *child = childItem(row); TestTreeItem *child = childItem(row);
if (child->name().isEmpty()) if (child->name().isEmpty())
return child; return child;
} }
return 0; return nullptr;
} }
} // namespace Internal } // namespace Internal

View File

@@ -123,7 +123,7 @@ void TestCodeParser::syncTestFrameworks(const QVector<Core::Id> &frameworkIds)
m_testCodeParsers.clear(); m_testCodeParsers.clear();
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance(); TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
qCDebug(LOG) << "Setting" << frameworkIds << "as current parsers"; qCDebug(LOG) << "Setting" << frameworkIds << "as current parsers";
foreach (const Core::Id &id, frameworkIds) { for (const Core::Id &id : frameworkIds) {
ITestParser *testParser = frameworkManager->testParserForTestFramework(id); ITestParser *testParser = frameworkManager->testParserForTestFramework(id);
QTC_ASSERT(testParser, continue); QTC_ASSERT(testParser, continue);
m_testCodeParsers.append(testParser); m_testCodeParsers.append(testParser);
@@ -292,7 +292,7 @@ bool TestCodeParser::postponed(const QStringList &fileList)
if (m_fullUpdatePostponed) if (m_fullUpdatePostponed)
return true; return true;
// partial parse triggered, postpone or add current files to already postponed partial // partial parse triggered, postpone or add current files to already postponed partial
foreach (const QString &file, fileList) for (const QString &file : fileList)
m_postponedFiles.insert(file); m_postponedFiles.insert(file);
m_partialUpdatePostponed = true; m_partialUpdatePostponed = true;
} }
@@ -307,7 +307,7 @@ static void parseFileForTests(const QVector<ITestParser *> &parsers,
QFutureInterface<TestParseResultPtr> &futureInterface, QFutureInterface<TestParseResultPtr> &futureInterface,
const QString &fileName) const QString &fileName)
{ {
foreach (ITestParser *parser, parsers) { for (ITestParser *parser : parsers) {
if (futureInterface.isCanceled()) if (futureInterface.isCanceled())
return; return;
if (parser->processDocument(futureInterface, fileName)) if (parser->processDocument(futureInterface, fileName))
@@ -357,7 +357,7 @@ void TestCodeParser::scanForTests(const QStringList &fileList)
}); });
m_model->markAllForRemoval(); m_model->markAllForRemoval();
} else { } else {
foreach (const QString &filePath, list) for (const QString &filePath : list)
m_model->markForRemoval(filePath); m_model->markForRemoval(filePath);
} }
@@ -373,7 +373,7 @@ void TestCodeParser::scanForTests(const QStringList &fileList)
return; return;
} }
qCDebug(LOG) << QDateTime::currentDateTime().toString("hh:mm:ss.zzz") << "StartParsing"; qCDebug(LOG) << QDateTime::currentDateTime().toString("hh:mm:ss.zzz") << "StartParsing";
foreach (ITestParser *parser, m_testCodeParsers) for (ITestParser *parser : m_testCodeParsers)
parser->init(list); parser->init(list);
QFuture<TestParseResultPtr> future = Utils::map(list, QFuture<TestParseResultPtr> future = Utils::map(list,

View File

@@ -46,7 +46,7 @@ static Q_LOGGING_CATEGORY(LOG, "qtc.autotest.frameworkmanager")
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
TestFrameworkManager *s_instance = 0; TestFrameworkManager *s_instance = nullptr;
TestFrameworkManager::TestFrameworkManager() TestFrameworkManager::TestFrameworkManager()
{ {
@@ -100,7 +100,7 @@ void TestFrameworkManager::activateFrameworksFromSettings(QSharedPointer<TestSet
QString TestFrameworkManager::frameworkNameForId(const Core::Id &id) const QString TestFrameworkManager::frameworkNameForId(const Core::Id &id) const
{ {
ITestFramework *framework = m_registeredFrameworks.value(id, 0); ITestFramework *framework = m_registeredFrameworks.value(id, nullptr);
return framework ? QString::fromLatin1(framework->name()) : QString(); return framework ? QString::fromLatin1(framework->name()) : QString();
} }
@@ -143,15 +143,15 @@ QVector<Core::Id> TestFrameworkManager::sortedActiveFrameworkIds() const
TestTreeItem *TestFrameworkManager::rootNodeForTestFramework(const Core::Id &frameworkId) const TestTreeItem *TestFrameworkManager::rootNodeForTestFramework(const Core::Id &frameworkId) const
{ {
ITestFramework *framework = m_registeredFrameworks.value(frameworkId, 0); ITestFramework *framework = m_registeredFrameworks.value(frameworkId, nullptr);
return framework ? framework->rootNode() : 0; return framework ? framework->rootNode() : nullptr;
} }
ITestParser *TestFrameworkManager::testParserForTestFramework(const Core::Id &frameworkId) const ITestParser *TestFrameworkManager::testParserForTestFramework(const Core::Id &frameworkId) const
{ {
ITestFramework *framework = m_registeredFrameworks.value(frameworkId, 0); ITestFramework *framework = m_registeredFrameworks.value(frameworkId, nullptr);
if (!framework) if (!framework)
return 0; return nullptr;
ITestParser *testParser = framework->testParser(); ITestParser *testParser = framework->testParser();
qCDebug(LOG) << "Setting" << frameworkId << "as Id for test parser"; qCDebug(LOG) << "Setting" << frameworkId << "as Id for test parser";
testParser->setId(frameworkId); testParser->setId(frameworkId);

View File

@@ -118,10 +118,10 @@ void TestNavigationWidget::contextMenuEvent(QContextMenuEvent *event)
const bool hasTests = m_model->hasTests(); const bool hasTests = m_model->hasTests();
QMenu menu; QMenu menu;
QAction *runThisTest = 0; QAction *runThisTest = nullptr;
QAction *runWithoutDeploy = 0; QAction *runWithoutDeploy = nullptr;
QAction *debugThisTest = 0; QAction *debugThisTest = nullptr;
QAction *debugWithoutDeploy = 0; QAction *debugWithoutDeploy = nullptr;
const QModelIndexList list = m_view->selectionModel()->selectedIndexes(); const QModelIndexList list = m_view->selectionModel()->selectedIndexes();
if (list.size() == 1) { if (list.size() == 1) {
const QModelIndex index = list.first(); const QModelIndex index = list.first();
@@ -312,7 +312,7 @@ void TestNavigationWidget::onRunThisTestTriggered(TestRunner::Mode runMode)
configuration = item->debugConfiguration(); configuration = item->debugConfiguration();
break; break;
default: default:
configuration = 0; configuration = nullptr;
} }
if (configuration) { if (configuration) {

View File

@@ -95,37 +95,37 @@ QString TestResult::resultToString(const Result::Type type)
switch (type) { switch (type) {
case Result::Pass: case Result::Pass:
case Result::MessageTestCaseSuccess: case Result::MessageTestCaseSuccess:
return QLatin1String("PASS"); return QString("PASS");
case Result::Fail: case Result::Fail:
case Result::MessageTestCaseFail: case Result::MessageTestCaseFail:
return QLatin1String("FAIL"); return QString("FAIL");
case Result::ExpectedFail: case Result::ExpectedFail:
return QLatin1String("XFAIL"); return QString("XFAIL");
case Result::UnexpectedPass: case Result::UnexpectedPass:
return QLatin1String("XPASS"); return QString("XPASS");
case Result::Skip: case Result::Skip:
return QLatin1String("SKIP"); return QString("SKIP");
case Result::Benchmark: case Result::Benchmark:
return QLatin1String("BENCH"); return QString("BENCH");
case Result::MessageDebug: case Result::MessageDebug:
return QLatin1String("DEBUG"); return QString("DEBUG");
case Result::MessageInfo: case Result::MessageInfo:
return QLatin1String("INFO"); return QString("INFO");
case Result::MessageWarn: case Result::MessageWarn:
case Result::MessageTestCaseWarn: case Result::MessageTestCaseWarn:
return QLatin1String("WARN"); return QString("WARN");
case Result::MessageFatal: case Result::MessageFatal:
return QLatin1String("FATAL"); return QString("FATAL");
case Result::MessageSystem: case Result::MessageSystem:
return QLatin1String("SYSTEM"); return QString("SYSTEM");
case Result::BlacklistedPass: case Result::BlacklistedPass:
return QLatin1String("BPASS"); return QString("BPASS");
case Result::BlacklistedFail: case Result::BlacklistedFail:
return QLatin1String("BFAIL"); return QString("BFAIL");
default: default:
if (type >= Result::INTERNAL_MESSAGES_BEGIN && type <= Result::INTERNAL_MESSAGES_END) if (type >= Result::INTERNAL_MESSAGES_BEGIN && type <= Result::INTERNAL_MESSAGES_END)
return QString(); return QString();
return QLatin1String("UNKNOWN"); return QString("UNKNOWN");
} }
} }
@@ -182,7 +182,7 @@ bool TestResult::isIntermediateFor(const TestResult *other) const
TestResult *TestResult::createIntermediateResultFor(const TestResult *other) TestResult *TestResult::createIntermediateResultFor(const TestResult *other)
{ {
QTC_ASSERT(other, return 0); QTC_ASSERT(other, return nullptr);
TestResult *intermediate = new TestResult(other->m_name); TestResult *intermediate = new TestResult(other->m_name);
return intermediate; return intermediate;
} }

View File

@@ -149,13 +149,13 @@ TestResultItem *TestResultItem::intermediateFor(const TestResultItem *item) cons
if (testResult->isIntermediateFor(otherResult)) if (testResult->isIntermediateFor(otherResult))
return child; return child;
} }
return 0; return nullptr;
} }
TestResultItem *TestResultItem::createAndAddIntermediateFor(const TestResultItem *child) TestResultItem *TestResultItem::createAndAddIntermediateFor(const TestResultItem *child)
{ {
TestResultPtr result(m_testResult->createIntermediateResultFor(child->testResult())); TestResultPtr result(m_testResult->createIntermediateResultFor(child->testResult()));
QTC_ASSERT(!result.isNull(), return 0); QTC_ASSERT(!result.isNull(), return nullptr);
result->setResult(Result::MessageIntermediate); result->setResult(Result::MessageIntermediate);
TestResultItem *intermediate = new TestResultItem(result); TestResultItem *intermediate = new TestResultItem(result);
appendChild(intermediate); appendChild(intermediate);

View File

@@ -165,7 +165,7 @@ void TestResultsPane::createToolButtons()
m_runSelected = new QToolButton(m_treeView); m_runSelected = new QToolButton(m_treeView);
Utils::Icon runSelectedIcon = Utils::Icons::RUN_SMALL_TOOLBAR; Utils::Icon runSelectedIcon = Utils::Icons::RUN_SMALL_TOOLBAR;
foreach (const Utils::IconMaskAndColor &maskAndColor, Icons::RUN_SELECTED_OVERLAY) for (const Utils::IconMaskAndColor &maskAndColor : Icons::RUN_SELECTED_OVERLAY)
runSelectedIcon.append(maskAndColor); runSelectedIcon.append(maskAndColor);
m_runSelected->setIcon(runSelectedIcon.icon()); m_runSelected->setIcon(runSelectedIcon.icon());
m_runSelected->setToolTip(tr("Run Selected Tests")); m_runSelected->setToolTip(tr("Run Selected Tests"));
@@ -190,19 +190,19 @@ void TestResultsPane::createToolButtons()
m_filterButton->setMenu(m_filterMenu); m_filterButton->setMenu(m_filterMenu);
} }
static TestResultsPane *m_instance = 0; static TestResultsPane *s_instance = nullptr;
TestResultsPane *TestResultsPane::instance() TestResultsPane *TestResultsPane::instance()
{ {
if (!m_instance) if (!s_instance)
m_instance = new TestResultsPane; s_instance = new TestResultsPane;
return m_instance; return s_instance;
} }
TestResultsPane::~TestResultsPane() TestResultsPane::~TestResultsPane()
{ {
delete m_treeView; delete m_treeView;
m_instance = 0; s_instance = nullptr;
} }
void TestResultsPane::addTestResult(const TestResultPtr &result) void TestResultsPane::addTestResult(const TestResultPtr &result)
@@ -419,7 +419,7 @@ void TestResultsPane::initializeFilterMenu()
textAndType.insert(Result::MessageDebug, tr("Debug Messages")); textAndType.insert(Result::MessageDebug, tr("Debug Messages"));
textAndType.insert(Result::MessageWarn, tr("Warning Messages")); textAndType.insert(Result::MessageWarn, tr("Warning Messages"));
textAndType.insert(Result::MessageInternal, tr("Internal Messages")); textAndType.insert(Result::MessageInternal, tr("Internal Messages"));
foreach (Result::Type result, textAndType.keys()) { for (Result::Type result : textAndType.keys()) {
QAction *action = new QAction(m_filterMenu); QAction *action = new QAction(m_filterMenu);
action->setText(textAndType.value(result)); action->setText(textAndType.value(result));
action->setCheckable(true); action->setCheckable(true);
@@ -464,7 +464,7 @@ void TestResultsPane::updateSummaryLabel()
void TestResultsPane::enableAllFilter() void TestResultsPane::enableAllFilter()
{ {
foreach (QAction *action, m_filterMenu->actions()) { for (QAction *action : m_filterMenu->actions()) {
if (action->isCheckable()) if (action->isCheckable())
action->setChecked(true); action->setChecked(true);
} }

View File

@@ -54,13 +54,13 @@
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
static TestRunner *m_instance = 0; static TestRunner *s_instance = nullptr;
TestRunner *TestRunner::instance() TestRunner *TestRunner::instance()
{ {
if (!m_instance) if (!s_instance)
m_instance = new TestRunner; s_instance = new TestRunner;
return m_instance; return s_instance;
} }
TestRunner::TestRunner(QObject *parent) : TestRunner::TestRunner(QObject *parent) :
@@ -85,7 +85,7 @@ TestRunner::~TestRunner()
{ {
qDeleteAll(m_selectedTests); qDeleteAll(m_selectedTests);
m_selectedTests.clear(); m_selectedTests.clear();
m_instance = 0; s_instance = nullptr;
} }
void TestRunner::setSelectedTests(const QList<TestConfiguration *> &selected) void TestRunner::setSelectedTests(const QList<TestConfiguration *> &selected)
@@ -102,7 +102,7 @@ static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
const int timeout = settings.timeout; const int timeout = settings.timeout;
QEventLoop eventLoop; QEventLoop eventLoop;
int testCaseCount = 0; int testCaseCount = 0;
foreach (TestConfiguration *config, selectedTests) { for (TestConfiguration *config : selectedTests) {
config->completeTestInformation(TestRunner::Run); config->completeTestInformation(TestRunner::Run);
if (config->project()) { if (config->project()) {
testCaseCount += config->testCaseCount(); testCaseCount += config->testCaseCount();
@@ -119,7 +119,7 @@ static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
futureInterface.setProgressRange(0, testCaseCount); futureInterface.setProgressRange(0, testCaseCount);
futureInterface.setProgressValue(0); futureInterface.setProgressValue(0);
foreach (const TestConfiguration *testConfiguration, selectedTests) { for (const TestConfiguration *testConfiguration : selectedTests) {
QScopedPointer<TestOutputReader> outputReader; QScopedPointer<TestOutputReader> outputReader;
outputReader.reset(testConfiguration->outputReader(futureInterface, &testProcess)); outputReader.reset(testConfiguration->outputReader(futureInterface, &testProcess));
QTC_ASSERT(outputReader, continue); QTC_ASSERT(outputReader, continue);
@@ -166,11 +166,11 @@ static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
} }
} else { } else {
futureInterface.reportResult(TestResultPtr(new FaultyTestResult(Result::MessageFatal, futureInterface.reportResult(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
QString::fromLatin1("Failed to start test for project \"%1\".").arg(testConfiguration->displayName())))); QString("Failed to start test for project \"%1\".").arg(testConfiguration->displayName()))));
} }
if (testProcess.exitStatus() == QProcess::CrashExit) { if (testProcess.exitStatus() == QProcess::CrashExit) {
futureInterface.reportResult(TestResultPtr(new FaultyTestResult(Result::MessageFatal, futureInterface.reportResult(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
QString::fromLatin1("Test for project \"%1\" crashed.").arg(testConfiguration->displayName())))); QString("Test for project \"%1\" crashed.").arg(testConfiguration->displayName()))));
} }
if (canceledByTimeout) { if (canceledByTimeout) {
@@ -204,7 +204,7 @@ void TestRunner::prepareToRunTests(Mode mode)
// clear old log and output pane // clear old log and output pane
TestResultsPane::instance()->clearContents(); TestResultsPane::instance()->clearContents();
foreach (TestConfiguration *config, m_selectedTests) { for (TestConfiguration *config : m_selectedTests) {
if (!omitRunConfigWarnings && config->guessedConfiguration()) { if (!omitRunConfigWarnings && config->guessedConfiguration()) {
emit testResultReady(TestResultPtr(new FaultyTestResult(Result::MessageWarn, emit testResultReady(TestResultPtr(new FaultyTestResult(Result::MessageWarn,
tr("Project's run configuration was guessed for \"%1\".\n" tr("Project's run configuration was guessed for \"%1\".\n"

View File

@@ -51,7 +51,7 @@ static QIcon testTreeIcon(TestTreeItem::Type type)
QIcon(), QIcon(),
CPlusPlus::Icons::iconForType(CPlusPlus::Icons::ClassIconType), CPlusPlus::Icons::iconForType(CPlusPlus::Icons::ClassIconType),
CPlusPlus::Icons::iconForType(CPlusPlus::Icons::SlotPrivateIconType), CPlusPlus::Icons::iconForType(CPlusPlus::Icons::SlotPrivateIconType),
QIcon(QLatin1String(":/images/data.png")) QIcon(":/images/data.png")
}; };
if (int(type) >= int(sizeof icons / sizeof *icons)) if (int(type) >= int(sizeof icons / sizeof *icons))
@@ -344,7 +344,7 @@ TestTreeItem *TestTreeItem::findChildBy(CompareFunction compare) const
if (compare(child)) if (compare(child))
return child; return child;
} }
return 0; return nullptr;
} }
} // namespace Internal } // namespace Internal

View File

@@ -56,13 +56,13 @@ TestTreeModel::TestTreeModel(QObject *parent) :
setupParsingConnections(); setupParsingConnections();
} }
static TestTreeModel *m_instance = 0; static TestTreeModel *s_instance = nullptr;
TestTreeModel *TestTreeModel::instance() TestTreeModel *TestTreeModel::instance()
{ {
if (!m_instance) if (!s_instance)
m_instance = new TestTreeModel; s_instance = new TestTreeModel;
return m_instance; return s_instance;
} }
TestTreeModel::~TestTreeModel() TestTreeModel::~TestTreeModel()
@@ -75,7 +75,7 @@ TestTreeModel::~TestTreeModel()
takeItem(item); // do NOT delete the item as it's still a ptr hold by TestFrameworkManager takeItem(item); // do NOT delete the item as it's still a ptr hold by TestFrameworkManager
} }
m_instance = 0; s_instance = nullptr;
} }
void TestTreeModel::setupParsingConnections() void TestTreeModel::setupParsingConnections()
@@ -177,7 +177,7 @@ void TestTreeModel::syncTestFrameworks()
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance(); TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
QVector<Core::Id> sortedIds = frameworkManager->sortedActiveFrameworkIds(); QVector<Core::Id> sortedIds = frameworkManager->sortedActiveFrameworkIds();
foreach (const Core::Id &id, sortedIds) for (const Core::Id &id : sortedIds)
rootItem()->appendChild(frameworkManager->rootNodeForTestFramework(id)); rootItem()->appendChild(frameworkManager->rootNodeForTestFramework(id));
m_parser->syncTestFrameworks(sortedIds); m_parser->syncTestFrameworks(sortedIds);
@@ -186,7 +186,7 @@ void TestTreeModel::syncTestFrameworks()
void TestTreeModel::removeFiles(const QStringList &files) void TestTreeModel::removeFiles(const QStringList &files)
{ {
foreach (const QString &file, files) for (const QString &file : files)
markForRemoval(file); markForRemoval(file);
sweep(); sweep();
} }
@@ -268,7 +268,7 @@ void TestTreeModel::handleParseResult(const TestParseResult *result, TestTreeIte
emit dataChanged(idx, idx); emit dataChanged(idx, idx);
} }
// recursively handle children of this item // recursively handle children of this item
foreach (const TestParseResult *child, result->children) for (const TestParseResult *child : result->children)
handleParseResult(child, toBeModified); handleParseResult(child, toBeModified);
return; return;
} }
@@ -324,14 +324,14 @@ TestTreeItem *TestTreeModel::unnamedQuickTests() const
{ {
TestTreeItem *rootNode = quickRootNode(); TestTreeItem *rootNode = quickRootNode();
if (!rootNode) if (!rootNode)
return 0; return nullptr;
for (int row = 0, count = rootNode->childCount(); row < count; ++row) { for (int row = 0, count = rootNode->childCount(); row < count; ++row) {
TestTreeItem *child = rootNode->childItem(row); TestTreeItem *child = rootNode->childItem(row);
if (child->name().isEmpty()) if (child->name().isEmpty())
return child; return child;
} }
return 0; return nullptr;
} }
int TestTreeModel::namedQuickTestsCount() const int TestTreeModel::namedQuickTestsCount() const