AutoTest: Modernize code a bit

Change-Id: Ie56f6e5cb8a4f1962bd8df5e57214911ae609921
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2016-09-29 12:15:43 +02:00
parent 8b579fca6a
commit b0bf07c64a
44 changed files with 207 additions and 235 deletions

View File

@@ -38,7 +38,7 @@ class TestUtils
public:
static QString getCMakeDisplayNameIfNecessary(const QString &filePath, const QString &proFile)
{
static const QString CMAKE_LISTS = QLatin1String("CMakeLists.txt");
static const QString CMAKE_LISTS("CMakeLists.txt");
if (!proFile.endsWith(CMAKE_LISTS))
return QString();

View File

@@ -48,9 +48,9 @@ public:
QSharedPointer<TestSettings> settings() const;
bool initialize(const QStringList &arguments, QString *errorString);
void extensionsInitialized();
ShutdownFlag aboutToShutdown();
bool initialize(const QStringList &arguments, QString *errorString) override;
void extensionsInitialized() override;
ShutdownFlag aboutToShutdown() override;
private:
bool checkLicense();
@@ -58,7 +58,7 @@ private:
void onRunAllTriggered();
void onRunSelectedTriggered();
void updateMenuItemsEnabledState();
QList<QObject *> createTestObjects() const;
QList<QObject *> createTestObjects() const override;
const QSharedPointer<TestSettings> m_settings;
TestFrameworkManager *m_frameworkManager = 0;
};

View File

@@ -65,7 +65,7 @@ void AutoTestUnitTests::initTestCase()
if (allKits.count() != 1)
QSKIP("This test requires exactly one kit to be present");
if (auto qtVersion = QtSupport::QtKitInformation::qtVersion(allKits.first()))
m_isQt4 = qtVersion->qtVersionString().startsWith(QLatin1Char('4'));
m_isQt4 = qtVersion->qtVersionString().startsWith('4');
else
QSKIP("Could not figure out which Qt version is used for default kit.");
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first(),

View File

@@ -41,14 +41,14 @@ QStringList GTestConfiguration::argumentsForTestRunner(const TestSettings &setti
QStringList arguments;
const QStringList &testSets = testCases();
if (testSets.size())
arguments << QLatin1String("--gtest_filter=") + testSets.join(QLatin1Char(':'));
arguments << "--gtest_filter=" + testSets.join(':');
if (settings.gTestSettings.runDisabled)
arguments << QLatin1String("--gtest_also_run_disabled_tests");
arguments << "--gtest_also_run_disabled_tests";
if (settings.gTestSettings.repeat)
arguments << QString::fromLatin1("--gtest_repeat=%1").arg(settings.gTestSettings.iterations);
arguments << QString("--gtest_repeat=%1").arg(settings.gTestSettings.iterations);
if (settings.gTestSettings.shuffle) {
arguments << QLatin1String("--gtest_shuffle")
<< QString::fromLatin1("--gtest_random_seed=%1").arg(settings.gTestSettings.seed);
arguments << "--gtest_shuffle"
<< QString("--gtest_random_seed=%1").arg(settings.gTestSettings.seed);
}
if (settings.gTestSettings.throwOnFailure)
arguments << "--gtest_throw_on_failure";

View File

@@ -72,8 +72,8 @@ void GTestOutputReader::processOutput(const QByteArray &outputLine)
if (line.trimmed().isEmpty())
return;
if (!line.startsWith(QLatin1Char('['))) {
m_description.append(line).append(QLatin1Char('\n'));
if (!line.startsWith('[')) {
m_description.append(line).append('\n');
if (iterations.exactMatch(line)) {
m_iteration = iterations.cap(1).toInt();
m_description.clear();
@@ -142,7 +142,7 @@ void GTestOutputReader::processOutput(const QByteArray &outputLine)
m_description.chop(1);
testResult->setDescription(m_description);
foreach (const QString &output, m_description.split(QLatin1Char('\n'))) {
foreach (const QString &output, m_description.split('\n')) {
QRegExp *match = 0;
if (failureLocation.exactMatch(output))
match = &failureLocation;

View File

@@ -42,7 +42,7 @@ TestTreeItem *GTestParseResult::createTestTreeItem() const
static bool includesGTest(const CPlusPlus::Document::Ptr &doc,
const CPlusPlus::Snapshot &snapshot)
{
const QString gtestH = QLatin1String("gtest/gtest.h");
static const QString gtestH("gtest/gtest.h");
foreach (const CPlusPlus::Document::Include &inc, doc->resolvedIncludes()) {
if (inc.resolvedFileName().endsWith(gtestH))
return true;

View File

@@ -42,12 +42,12 @@ const QString GTestResult::outputString(bool selected) const
case Result::Fail:
output = m_testSetName;
if (selected && !desc.isEmpty())
output.append(QLatin1Char('\n')).append(desc);
output.append('\n').append(desc);
break;
default:
output = desc;
if (!selected)
output = output.split(QLatin1Char('\n')).first();
output = output.split('\n').first();
}
return output;
}

View File

@@ -43,24 +43,24 @@ QString GTestSettings::name() const
void GTestSettings::fromSettings(const QSettings *s)
{
runDisabled = s->value(QLatin1String(runDisabledKey), false).toBool();
repeat = s->value(QLatin1String(repeatKey), false).toBool();
shuffle = s->value(QLatin1String(shuffleKey), false).toBool();
iterations = s->value(QLatin1String(iterationsKey), 1).toInt();
seed = s->value(QLatin1String(seedKey), 0).toInt();
breakOnFailure = s->value(QLatin1String(breakOnFailureKey), true).toBool();
throwOnFailure = s->value(QLatin1String(throwOnFailureKey), false).toBool();
runDisabled = s->value(runDisabledKey, false).toBool();
repeat = s->value(repeatKey, false).toBool();
shuffle = s->value(shuffleKey, false).toBool();
iterations = s->value(iterationsKey, 1).toInt();
seed = s->value(seedKey, 0).toInt();
breakOnFailure = s->value(breakOnFailureKey, true).toBool();
throwOnFailure = s->value(throwOnFailureKey, false).toBool();
}
void GTestSettings::toSettings(QSettings *s) const
{
s->setValue(QLatin1String(runDisabledKey), runDisabled);
s->setValue(QLatin1String(repeatKey), repeat);
s->setValue(QLatin1String(shuffleKey), shuffle);
s->setValue(QLatin1String(iterationsKey), iterations);
s->setValue(QLatin1String(seedKey), seed);
s->setValue(QLatin1String(breakOnFailureKey), breakOnFailure);
s->setValue(QLatin1String(throwOnFailureKey), throwOnFailure);
s->setValue(runDisabledKey, runDisabled);
s->setValue(repeatKey, repeat);
s->setValue(shuffleKey, shuffle);
s->setValue(iterationsKey, iterations);
s->setValue(seedKey, seed);
s->setValue(breakOnFailureKey, breakOnFailure);
s->setValue(throwOnFailureKey, throwOnFailure);
}
} // namespace Internal

View File

@@ -101,7 +101,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const
GTestConfiguration *config = 0;
switch (type()) {
case TestCase: {
const QString &testSpecifier = gtestFilter(state()).arg(name()).arg(QLatin1Char('*'));
const QString &testSpecifier = gtestFilter(state()).arg(name()).arg('*');
if (int count = childCount()) {
config = new GTestConfiguration;
config->setTestCases(QStringList(testSpecifier));
@@ -339,7 +339,7 @@ QString GTestTreeItem::nameSuffix() const
if (m_state & Typed)
suffix += (suffix.isEmpty() ? QLatin1String(" [") : QLatin1String(", ")) + markups[1];
if (!suffix.isEmpty())
suffix += QLatin1Char(']');
suffix += ']';
return suffix;
}

View File

@@ -46,7 +46,7 @@ public:
Q_FLAGS(TestState)
Q_DECLARE_FLAGS(TestStates, TestState)
GTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
explicit GTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
Type type = Root) : TestTreeItem(name, filePath, type), m_state(Enabled) {}
static GTestTreeItem *createTestItem(const TestParseResult *result);

View File

@@ -57,7 +57,7 @@ inline bool operator<(const GTestCaseSpec &spec1, const GTestCaseSpec &spec2)
class GTestVisitor : public CPlusPlus::ASTVisitor
{
public:
GTestVisitor(CPlusPlus::Document::Ptr doc);
explicit GTestVisitor(CPlusPlus::Document::Ptr doc);
bool visit(CPlusPlus::FunctionDefinitionAST *ast);
QMap<GTestCaseSpec, GTestCodeLocationList> gtestFunctions() const { return m_gtestFunctions; }

View File

@@ -34,7 +34,7 @@ namespace Internal {
class ITestFramework
{
public:
ITestFramework(bool activeByDefault) : m_active(activeByDefault) {}
explicit ITestFramework(bool activeByDefault) : m_active(activeByDefault) {}
virtual ~ITestFramework()
{
delete m_rootNode;

View File

@@ -38,13 +38,13 @@ namespace Internal {
static QString decode(const QString& original)
{
QString result(original);
static QRegExp regex(QLatin1String("&#((x[0-9A-F]+)|([0-9]+));"), Qt::CaseInsensitive);
static QRegExp regex("&#((x[0-9A-F]+)|([0-9]+));", Qt::CaseInsensitive);
regex.setMinimal(true);
int pos = 0;
while ((pos = regex.indexIn(original, pos)) != -1) {
const QString value = regex.cap(1);
if (value.startsWith(QLatin1Char('x')))
if (value.startsWith('x'))
result.replace(regex.cap(0), QChar(value.midRef(1).toInt(0, 16)));
else
result.replace(regex.cap(0), QChar(value.toInt(0, 10)));
@@ -80,13 +80,13 @@ static QString formatResult(double value)
beforeDecimalPoint.chop(beforeRemove);
for (int i = 0; i < beforeRemove; ++i)
beforeDecimalPoint.append(QLatin1Char('0'));
beforeDecimalPoint.append('0');
int afterUse = significantDigits - beforeUse;
if (beforeDecimalPoint == QLatin1String("0") && !afterDecimalPoint.isEmpty()) {
++afterUse;
int i = 0;
while (i < afterDecimalPoint.count() && afterDecimalPoint.at(i) == QLatin1Char('0'))
while (i < afterDecimalPoint.count() && afterDecimalPoint.at(i) == '0')
++i;
afterUse += i;
}
@@ -96,7 +96,7 @@ static QString formatResult(double value)
QString result = beforeDecimalPoint;
if (afterUse > 0)
result.append(QLatin1Char('.'));
result.append('.');
result += afterDecimalPoint;
return result;
@@ -105,16 +105,16 @@ static QString formatResult(double value)
static QString constructBenchmarkInformation(const QString &metric, double value, int iterations)
{
QString metricsText;
if (metric == QLatin1String("WalltimeMilliseconds")) // default
metricsText = QLatin1String("msecs");
else if (metric == QLatin1String("CPUTicks")) // -tickcounter
metricsText = QLatin1String("CPU ticks");
else if (metric == QLatin1String("Events")) // -eventcounter
metricsText = QLatin1String("events");
else if (metric == QLatin1String("InstructionReads")) // -callgrind
metricsText = QLatin1String("instruction reads");
else if (metric == QLatin1String("CPUCycles")) // -perf
metricsText = QLatin1String("CPU cycles");
if (metric == "WalltimeMilliseconds") // default
metricsText = "msecs";
else if (metric == "CPUTicks") // -tickcounter
metricsText = "CPU ticks";
else if (metric == "Events") // -eventcounter
metricsText = "events";
else if (metric == "InstructionReads") // -callgrind
metricsText = "instruction reads";
else if (metric == "CPUCycles") // -perf
metricsText = "CPU cycles";
return QtTestOutputReader::tr("%1 %2 per iteration (total: %3, iterations: %4)")
.arg(formatResult(value))
.arg(metricsText)
@@ -227,7 +227,7 @@ void QtTestOutputReader::processOutput(const QByteArray &outputLine)
break;
case Description:
if (!m_description.isEmpty())
m_description.append(QLatin1Char('\n'));
m_description.append('\n');
m_description.append(text);
break;
case QtVersion:

View File

@@ -43,8 +43,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus:
{
static QStringList expectedHeaderPrefixes
= Utils::HostOsInfo::isMacHost()
? QStringList({ QLatin1String("QtTest.framework/Headers"), QLatin1String("QtTest") })
: QStringList({ QLatin1String("QtTest") });
? QStringList({ "QtTest.framework/Headers", "QtTest" }) : QStringList({ "QtTest" });
const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes();
@@ -53,7 +52,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus:
// bad, as there could be much more different approaches
if (inc.unresolvedFileName() == QLatin1String("QtTest")) {
foreach (const QString &prefix, expectedHeaderPrefixes) {
if (inc.resolvedFileName().endsWith(QString::fromLatin1("%1/QtTest").arg(prefix)))
if (inc.resolvedFileName().endsWith(QString("%1/QtTest").arg(prefix)))
return true;
}
}
@@ -62,7 +61,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus:
const QSet<QString> allIncludes = snapshot.allIncludesForDocument(doc->fileName());
foreach (const QString &include, allIncludes) {
foreach (const QString &prefix, expectedHeaderPrefixes) {
if (include.endsWith(QString::fromLatin1("%1/qtest.h").arg(prefix)))
if (include.endsWith(QString("%1/qtest.h").arg(prefix)))
return true;
}
}
@@ -141,7 +140,7 @@ static QSet<QString> filesWithDataFunctionDefinitions(
for ( ; it != end; ++it) {
const QString &key = it.key();
if (key.endsWith(QLatin1String("_data")) && testFunctions.contains(key.left(key.size() - 5)))
if (key.endsWith("_data") && testFunctions.contains(key.left(key.size() - 5)))
result.insert(it.value().m_name);
}
return result;
@@ -209,7 +208,7 @@ static bool handleQtTest(QFutureInterface<TestParseResultPtr> futureInterface,
const TestCodeLocationAndType &location = it.value();
QtTestParseResult *func = new QtTestParseResult(id);
func->itemType = location.m_type;
func->name = testCaseName + QLatin1String("::") + it.key();
func->name = testCaseName + "::" + it.key();
func->displayName = it.key();
func->fileName = location.m_name;
func->line = location.m_line;
@@ -220,7 +219,7 @@ static bool handleQtTest(QFutureInterface<TestParseResultPtr> futureInterface,
dataTag->itemType = tag.m_type;
dataTag->name = tag.m_name;
dataTag->displayName = tag.m_name;
dataTag->fileName = testFunctions.value(it.key() + QLatin1String("_data")).m_name;
dataTag->fileName = testFunctions.value(it.key() + "_data").m_name;
dataTag->line = tag.m_line;
dataTag->column = tag.m_column;

View File

@@ -45,28 +45,28 @@ const QString QtTestResult::outputString(bool selected) const
case Result::UnexpectedPass:
case Result::BlacklistedFail:
case Result::BlacklistedPass:
output = className + QLatin1String("::") + m_function;
output = className + "::" + m_function;
if (!m_dataTag.isEmpty())
output.append(QString::fromLatin1(" (%1)").arg(m_dataTag));
output.append(QString(" (%1)").arg(m_dataTag));
if (selected && !desc.isEmpty()) {
output.append(QLatin1Char('\n')).append(desc);
output.append('\n').append(desc);
}
break;
case Result::Benchmark:
output = className + QLatin1String("::") + m_function;
output = className + "::" + m_function;
if (!m_dataTag.isEmpty())
output.append(QString::fromLatin1(" (%1)").arg(m_dataTag));
output.append(QString(" (%1)").arg(m_dataTag));
if (!desc.isEmpty()) {
int breakPos = desc.indexOf(QLatin1Char('('));
output.append(QLatin1String(": ")).append(desc.left(breakPos));
int breakPos = desc.indexOf('(');
output.append(": ").append(desc.left(breakPos));
if (selected)
output.append(QLatin1Char('\n')).append(desc.mid(breakPos));
output.append('\n').append(desc.mid(breakPos));
}
break;
default:
output = desc;
if (!selected)
output = output.split(QLatin1Char('\n')).first();
output = output.split('\n').first();
}
return output;
}

View File

@@ -56,14 +56,14 @@ QString QtTestSettings::name() const
void QtTestSettings::fromSettings(const QSettings *s)
{
metrics = intToMetrics(s->value(QLatin1String(metricsKey), Walltime).toInt());
noCrashHandler = s->value(QLatin1String(noCrashhandlerKey), true).toBool();
metrics = intToMetrics(s->value(metricsKey, Walltime).toInt());
noCrashHandler = s->value(noCrashhandlerKey, true).toBool();
}
void QtTestSettings::toSettings(QSettings *s) const
{
s->setValue(QLatin1String(metricsKey), metrics);
s->setValue(QLatin1String(noCrashhandlerKey), noCrashHandler);
s->setValue(metricsKey, metrics);
s->setValue(noCrashhandlerKey, noCrashHandler);
}
QString QtTestSettings::metricsTypeToOption(const MetricsType type)

View File

@@ -118,7 +118,7 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const
const TestTreeItem *parent = function ? function->parentItem() : 0;
if (!parent)
return 0;
const QString functionWithTag = function->name() + QLatin1Char(':') + name();
const QString functionWithTag = function->name() + ':' + name();
config = new QtTestConfiguration();
config->setTestCases(QStringList(functionWithTag));
config->setProFile(parent->proFile());

View File

@@ -33,7 +33,7 @@ namespace Internal {
class QtTestTreeItem : public TestTreeItem
{
public:
QtTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
explicit QtTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
Type type = Root) : TestTreeItem(name, filePath, type) {}
static QtTestTreeItem *createTestItem(const TestParseResult *result);

View File

@@ -35,10 +35,7 @@
namespace Autotest {
namespace Internal {
static QStringList specialFunctions({ QLatin1String("initTestCase"),
QLatin1String("cleanupTestCase"),
QLatin1String("init"),
QLatin1String("cleanup") });
static QStringList specialFunctions({ "initTestCase", "cleanupTestCase", "init", "cleanup" });
/************************** Cpp Test Symbol Visitor ***************************/
@@ -82,7 +79,7 @@ bool TestVisitor::visit(CPlusPlus::Class *symbol)
}
if (specialFunctions.contains(name))
locationAndType.m_type = TestTreeItem::TestSpecialFunction;
else if (name.endsWith(QLatin1String("_data")))
else if (name.endsWith("_data"))
locationAndType.m_type = TestTreeItem::TestDataFunction;
else
locationAndType.m_type = TestTreeItem::TestFunctionOrSet;
@@ -111,7 +108,7 @@ bool TestAstVisitor::visit(CPlusPlus::CallAST *ast)
if (const auto qualifiedNameAST = idExpressionAST->name->asQualifiedName()) {
const CPlusPlus::Overview o;
const QString prettyName = o.prettyName(qualifiedNameAST->name);
if (prettyName == QLatin1String("QTest::qExec")) {
if (prettyName == "QTest::qExec") {
if (const auto expressionListAST = ast->expression_list) {
// first argument is the one we need
if (const auto argumentExpressionAST = expressionListAST->value) {
@@ -148,17 +145,14 @@ bool TestAstVisitor::visit(CPlusPlus::CompoundStatementAST *ast)
TestDataFunctionVisitor::TestDataFunctionVisitor(CPlusPlus::Document::Ptr doc)
: CPlusPlus::ASTVisitor(doc->translationUnit()),
m_currentDoc(doc),
m_currentAstDepth(0),
m_insideUsingQTestDepth(0),
m_insideUsingQTest(false)
m_currentDoc(doc)
{
}
bool TestDataFunctionVisitor::visit(CPlusPlus::UsingDirectiveAST *ast)
{
if (auto nameAST = ast->name) {
if (m_overview.prettyName(nameAST->name) == QLatin1String("QTest")) {
if (m_overview.prettyName(nameAST->name) == "QTest") {
m_insideUsingQTest = true;
// we need the surrounding AST depth as using directive is an AST itself
m_insideUsingQTestDepth = m_currentAstDepth - 1;
@@ -177,7 +171,7 @@ bool TestDataFunctionVisitor::visit(CPlusPlus::FunctionDefinitionAST *ast)
CPlusPlus::LookupContext lc;
const QString prettyName = m_overview.prettyName(lc.fullyQualifiedName(ast->symbol));
// do not handle functions that aren't real test data functions
if (!prettyName.endsWith(QLatin1String("_data")))
if (!prettyName.endsWith("_data"))
return false;
m_currentFunction = prettyName.left(prettyName.size() - 5);
@@ -275,10 +269,10 @@ bool TestDataFunctionVisitor::newRowCallFound(CPlusPlus::CallAST *ast, unsigned
return false;
if (const auto qualifiedNameAST = exp->name->asQualifiedName()) {
found = m_overview.prettyName(qualifiedNameAST->name) == QLatin1String("QTest::newRow");
found = m_overview.prettyName(qualifiedNameAST->name) == "QTest::newRow";
*firstToken = qualifiedNameAST->firstToken();
} else if (m_insideUsingQTest) {
found = m_overview.prettyName(exp->name->name) == QLatin1String("newRow");
found = m_overview.prettyName(exp->name->name) == "newRow";
*firstToken = exp->name->firstToken();
}
}

View File

@@ -42,7 +42,7 @@ namespace Internal {
class TestVisitor : public CPlusPlus::SymbolVisitor
{
public:
TestVisitor(const QString &fullQualifiedClassName);
explicit TestVisitor(const QString &fullQualifiedClassName);
QMap<QString, TestCodeLocationAndType> privateSlots() const { return m_privSlots; }
bool resultValid() const { return m_valid; }
@@ -59,7 +59,7 @@ private:
class TestAstVisitor : public CPlusPlus::ASTVisitor
{
public:
TestAstVisitor(CPlusPlus::Document::Ptr doc);
explicit TestAstVisitor(CPlusPlus::Document::Ptr doc);
bool visit(CPlusPlus::CallAST *ast);
bool visit(CPlusPlus::CompoundStatementAST *ast);
@@ -75,7 +75,7 @@ private:
class TestDataFunctionVisitor : public CPlusPlus::ASTVisitor
{
public:
TestDataFunctionVisitor(CPlusPlus::Document::Ptr doc);
explicit TestDataFunctionVisitor(CPlusPlus::Document::Ptr doc);
bool visit(CPlusPlus::UsingDirectiveAST *ast);
bool visit(CPlusPlus::FunctionDefinitionAST *ast);
@@ -93,9 +93,9 @@ private:
QString m_currentFunction;
QMap<QString, TestCodeLocationList> m_dataTags;
TestCodeLocationList m_currentTags;
unsigned m_currentAstDepth;
unsigned m_insideUsingQTestDepth;
bool m_insideUsingQTest;
unsigned m_currentAstDepth = 0;
unsigned m_insideUsingQTestDepth = 0;
bool m_insideUsingQTest = false;
};
} // namespace Internal

View File

@@ -50,17 +50,16 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
{
static QStringList expectedHeaderPrefixes
= Utils::HostOsInfo::isMacHost()
? QStringList({ QLatin1String("QtQuickTest.framework/Headers"),
QLatin1String("QtQuickTest") })
: QStringList({ QLatin1String("QtQuickTest") });
? QStringList({ "QtQuickTest.framework/Headers", "QtQuickTest" })
: QStringList({ "QtQuickTest" });
const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes();
foreach (const CPlusPlus::Document::Include &inc, includes) {
if (inc.unresolvedFileName() == QLatin1String("QtQuickTest/quicktest.h")) {
if (inc.unresolvedFileName() == "QtQuickTest/quicktest.h") {
foreach (const QString &prefix, expectedHeaderPrefixes) {
if (inc.resolvedFileName().endsWith(
QString::fromLatin1("%1/quicktest.h").arg(prefix))) {
QString("%1/quicktest.h").arg(prefix))) {
return true;
}
}
@@ -69,7 +68,7 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
foreach (const QString &include, snapshot.allIncludesForDocument(doc->fileName())) {
foreach (const QString &prefix, expectedHeaderPrefixes) {
if (include.endsWith(QString::fromLatin1("%1/quicktest.h").arg(prefix)))
if (include.endsWith(QString("%1/quicktest.h").arg(prefix)))
return true;
}
}
@@ -140,7 +139,7 @@ static QList<QmlJS::Document::Ptr> scanDirectoryForQuickTestQmlFiles(const QStri
const QList<QmlJS::Document::Ptr> docs = snapshot.documentsInDirectory(path);
foreach (const QmlJS::Document::Ptr &doc, docs) {
const QString fileName(QFileInfo(doc->fileName()).fileName());
if (fileName.startsWith(QLatin1String("tst_")) && fileName.endsWith(QLatin1String(".qml")))
if (fileName.startsWith("tst_") && fileName.endsWith(".qml"))
foundDocs << doc;
}
}

View File

@@ -131,7 +131,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const
case TestCase: {
QStringList testFunctions;
for (int row = 0, count = childCount(); row < count; ++row)
testFunctions << name() + QLatin1String("::") + childItem(row)->name();
testFunctions << name() + "::" + childItem(row)->name();
config = new QuickTestConfiguration;
config->setTestCases(testFunctions);
config->setProFile(proFile());
@@ -140,7 +140,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const
}
case TestFunctionOrSet: {
TestTreeItem *parent = parentItem();
QStringList testFunction(parent->name() + QLatin1String("::") + name());
QStringList testFunction(parent->name() + "::" + name());
config = new QuickTestConfiguration;
config->setTestCases(testFunction);
config->setProFile(parent->proFile());
@@ -239,7 +239,7 @@ QList<TestConfiguration *> QuickTestTreeItem::getSelectedTestConfigurations() co
const TestTreeItem *grandChild = child->childItem(grandChildRow);
if (grandChild->type() != TestFunctionOrSet)
continue;
testFunctions << child->name() + QLatin1String("::") + grandChild->name();
testFunctions << child->name() + "::" + grandChild->name();
}
if (foundProFiles.contains(child->proFile())) {
tc = foundProFiles[child->proFile()];

View File

@@ -33,7 +33,7 @@ namespace Internal {
class QuickTestTreeItem : public TestTreeItem
{
public:
QuickTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
explicit QuickTestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
Type type = Root) : TestTreeItem(name, filePath, type) {}
static QuickTestTreeItem *createTestItem(const TestParseResult *result);

View File

@@ -30,10 +30,7 @@
namespace Autotest {
namespace Internal {
static QStringList specialFunctions({ QLatin1String("initTestCase"),
QLatin1String("cleanupTestCase"),
QLatin1String("init"),
QLatin1String("cleanup") });
static QStringList specialFunctions({ "initTestCase", "cleanupTestCase", "init", "cleanup" });
TestQmlVisitor::TestQmlVisitor(QmlJS::Document::Ptr doc)
: m_currentDoc(doc)
@@ -43,7 +40,7 @@ TestQmlVisitor::TestQmlVisitor(QmlJS::Document::Ptr doc)
bool TestQmlVisitor::visit(QmlJS::AST::UiObjectDefinition *ast)
{
const QStringRef name = ast->qualifiedTypeNameId->name;
if (name != QLatin1String("TestCase"))
if (name != "TestCase")
return true; // find nested TestCase items as well
m_currentTestCaseName.clear();
@@ -64,15 +61,15 @@ bool TestQmlVisitor::visit(QmlJS::AST::ExpressionStatement *ast)
bool TestQmlVisitor::visit(QmlJS::AST::UiScriptBinding *ast)
{
const QStringRef name = ast->qualifiedId->name;
return name == QLatin1String("name");
return name == "name";
}
bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast)
{
const QStringRef name = ast->name;
if (name.startsWith(QLatin1String("test_"))
|| name.startsWith(QLatin1String("benchmark_"))
|| name.endsWith(QLatin1String("_data"))
if (name.startsWith("test_")
|| name.startsWith("benchmark_")
|| name.endsWith("_data")
|| specialFunctions.contains(name.toString())) {
const auto sourceLocation = ast->firstSourceLocation();
TestCodeLocationAndType locationAndType;
@@ -81,7 +78,7 @@ bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast)
locationAndType.m_column = sourceLocation.startColumn - 1;
if (specialFunctions.contains(name.toString()))
locationAndType.m_type = TestTreeItem::TestSpecialFunction;
else if (name.endsWith(QLatin1String("_data")))
else if (name.endsWith("_data"))
locationAndType.m_type = TestTreeItem::TestDataFunction;
else
locationAndType.m_type = TestTreeItem::TestFunctionOrSet;

View File

@@ -36,7 +36,7 @@ namespace Internal {
class TestQmlVisitor : public QmlJS::AST::Visitor
{
public:
TestQmlVisitor(QmlJS::Document::Ptr doc);
explicit TestQmlVisitor(QmlJS::Document::Ptr doc);
bool visit(QmlJS::AST::UiObjectDefinition *ast);
bool visit(QmlJS::AST::ExpressionStatement *ast);

View File

@@ -338,7 +338,7 @@ void TestCodeParser::scanForTests(const QStringList &fileList)
if (isFullParse) {
// remove qml files as they will be found automatically by the referencing cpp file
list = Utils::filtered(list, [] (const QString &fn) {
return !fn.endsWith(QLatin1String(".qml"));
return !fn.endsWith(".qml");
});
m_model->markAllForRemoval();
} else {

View File

@@ -118,10 +118,8 @@ void TestConfiguration::completeTestInformation(int runMode)
// some project manager store line/column information as well inside ProjectPart
if (bti.isValid() && m_proFile.startsWith(bti.projectFilePath.toString())) {
targetFile = bti.targetFilePath.toString();
if (Utils::HostOsInfo::isWindowsHost()
&& !targetFile.toLower().endsWith(QLatin1String(".exe"))) {
if (Utils::HostOsInfo::isWindowsHost() && !targetFile.toLower().endsWith(".exe"))
targetFile = Utils::HostOsInfo::withExecutableSuffix(targetFile);
}
targetName = bti.targetName;
break;
}
@@ -274,7 +272,7 @@ QString TestConfiguration::executableFilePath() const
} else if (commandFileInfo.path() == "."){
QString fullCommandFileName = m_targetFile;
if (Utils::HostOsInfo::isWindowsHost() && !m_targetFile.endsWith(".exe"))
fullCommandFileName = m_targetFile + QLatin1String(".exe");
fullCommandFileName = m_targetFile + ".exe";
// TODO: check if we can use searchInPath() from Utils::Environment
const QStringList &pathList = m_environment.toProcessEnvironment().value("PATH").split(
Utils::HostOsInfo::pathListSeparator());

View File

@@ -60,7 +60,7 @@ class TestNavigationWidget : public QWidget
public:
explicit TestNavigationWidget(QWidget *parent = 0);
~TestNavigationWidget();
void contextMenuEvent(QContextMenuEvent *event);
void contextMenuEvent(QContextMenuEvent *event) override;
QList<QToolButton *> createToolButtons();
signals:
@@ -94,7 +94,7 @@ public:
TestNavigationWidgetFactory();
private:
Core::NavigationView createWidget();
Core::NavigationView createWidget() override;
};

View File

@@ -48,34 +48,34 @@ TestResult::TestResult(const QString &name)
const QString TestResult::outputString(bool selected) const
{
return selected ? m_description : m_description.split(QLatin1Char('\n')).first();
return selected ? m_description : m_description.split('\n').first();
}
Result::Type TestResult::resultFromString(const QString &resultString)
{
if (resultString == QLatin1String("pass"))
if (resultString == "pass")
return Result::Pass;
if (resultString == QLatin1String("fail"))
if (resultString == "fail")
return Result::Fail;
if (resultString == QLatin1String("xfail"))
if (resultString == "xfail")
return Result::ExpectedFail;
if (resultString == QLatin1String("xpass"))
if (resultString == "xpass")
return Result::UnexpectedPass;
if (resultString == QLatin1String("skip"))
if (resultString == "skip")
return Result::Skip;
if (resultString == QLatin1String("qdebug"))
if (resultString == "qdebug")
return Result::MessageDebug;
if (resultString == QLatin1String("qinfo"))
if (resultString == "qinfo")
return Result::MessageInfo;
if (resultString == QLatin1String("warn") || resultString == QLatin1String("qwarn"))
if (resultString == "warn" || resultString == "qwarn")
return Result::MessageWarn;
if (resultString == QLatin1String("qfatal"))
if (resultString == "qfatal")
return Result::MessageFatal;
if (resultString == QLatin1String("system"))
if (resultString == "system")
return Result::MessageSystem;
if (resultString == QLatin1String("bpass"))
if (resultString == "bpass")
return Result::BlacklistedPass;
if (resultString == QLatin1String("bfail"))
if (resultString == "bfail")
return Result::BlacklistedFail;
qDebug("Unexpected test result: %s", qPrintable(resultString));
return Result::Invalid;

View File

@@ -98,11 +98,11 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
QString output = testResult->outputString(selected);
if (selected) {
output.replace(QLatin1Char('\n'), QChar::LineSeparator);
output.replace('\n', QChar::LineSeparator);
if (AutotestPlugin::instance()->settings()->limitResultOutput
&& output.length() > outputLimit)
output = output.left(outputLimit).append(QLatin1String("..."));
output = output.left(outputLimit).append("...");
recalculateTextLayout(index, output, painter->font(), positions.textAreaWidth());
@@ -115,7 +115,7 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
}
QString file = testResult->fileName();
const int pos = file.lastIndexOf(QLatin1Char('/'));
const int pos = file.lastIndexOf('/');
if (pos != -1)
file = file.mid(pos + 1);
@@ -156,11 +156,11 @@ QSize TestResultDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo
const TestResult *testResult = resultFilterModel->testResult(index);
QTC_ASSERT(testResult, return QSize());
QString output = testResult->outputString(selected);
output.replace(QLatin1Char('\n'), QChar::LineSeparator);
output.replace('\n', QChar::LineSeparator);
if (AutotestPlugin::instance()->settings()->limitResultOutput
&& output.length() > outputLimit)
output = output.left(outputLimit).append(QLatin1String("..."));
output = output.left(outputLimit).append("...");
recalculateTextLayout(index, output, opt.font, positions.textAreaWidth());

View File

@@ -39,8 +39,8 @@ class TestResultDelegate : public QStyledItemDelegate
public:
explicit TestResultDelegate(QObject *parent = 0);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void currentChanged(const QModelIndex &current, const QModelIndex &previous);
private:
@@ -64,7 +64,7 @@ private:
m_maxFileLength = srcModel->maxWidthOfFileName(options.font);
m_maxLineLength = srcModel->maxWidthOfLineNumber(options.font);
m_realFileLength = m_maxFileLength;
m_typeAreaWidth = QFontMetrics(options.font).width(QLatin1String("XXXXXXXX"));
m_typeAreaWidth = QFontMetrics(options.font).width("XXXXXXXX");
m_indentation = options.widget ? options.widget->style()->pixelMetric(
QStyle::PM_TreeViewIndentation, &options) : 0;
m_level = filterModel->mapToSource(options.index).parent() == srcModel->rootItem()->index() ? 1 : 2;

View File

@@ -128,10 +128,7 @@ void TestResultItem::updateResult()
/********************************* TestResultModel *****************************************/
TestResultModel::TestResultModel(QObject *parent)
: Utils::TreeModel<>(parent),
m_widthOfLineNumber(0),
m_maxWidthOfFileName(0),
m_disabled(0)
: Utils::TreeModel<>(parent)
{
}
@@ -244,7 +241,7 @@ int TestResultModel::maxWidthOfFileName(const QFont &font)
const TestResultItem *item = static_cast<TestResultItem *>(children.at(childRow));
if (const TestResult *result = item->testResult()) {
QString fileName = result->fileName();
const int pos = fileName.lastIndexOf(QLatin1Char('/'));
const int pos = fileName.lastIndexOf('/');
if (pos != -1)
fileName = fileName.mid(pos + 1);
m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.width(fileName));
@@ -264,7 +261,7 @@ int TestResultModel::maxWidthOfLineNumber(const QFont &font)
if (m_widthOfLineNumber == 0 || font != m_measurementFont) {
QFontMetrics fm(font);
m_measurementFont = font;
m_widthOfLineNumber = fm.width(QLatin1String("88888"));
m_widthOfLineNumber = fm.width("88888");
}
return m_widthOfLineNumber;
}

View File

@@ -42,7 +42,7 @@ class TestResultItem : public Utils::TreeItem
public:
explicit TestResultItem(const TestResultPtr &testResult);
~TestResultItem();
QVariant data(int column, int role) const;
QVariant data(int column, int role) const override;
const TestResult *testResult() const { return m_testResult.data(); }
void updateDescription(const QString &description);
void updateResult();
@@ -70,9 +70,9 @@ public:
private:
QMap<Result::Type, int> m_testResultCount;
int m_widthOfLineNumber;
int m_maxWidthOfFileName;
int m_disabled;
int m_widthOfLineNumber = 0;
int m_maxWidthOfFileName = 0;
int m_disabled = 0;
QList<int> m_processedIndices;
QFont m_measurementFont;
};
@@ -81,7 +81,7 @@ class TestResultFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
TestResultFilterModel(TestResultModel *sourceModel, QObject *parent = 0);
explicit TestResultFilterModel(TestResultModel *sourceModel, QObject *parent = 0);
void enableAllResultTypes();
void toggleTestResultType(Result::Type type);
@@ -90,7 +90,7 @@ public:
const TestResult *testResult(const QModelIndex &index) const;
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
private:
bool acceptTestCaseResult(const QModelIndex &index) const;

View File

@@ -77,10 +77,7 @@ void ResultsTreeView::keyPressEvent(QKeyEvent *event)
TestResultsPane::TestResultsPane(QObject *parent) :
Core::IOutputPane(parent),
m_context(new Core::IContext(this)),
m_wasVisibleBefore(false),
m_autoScroll(false),
m_testRunning(false)
m_context(new Core::IContext(this))
{
m_outputWidget = new QWidget;
QVBoxLayout *outputLayout = new QVBoxLayout;
@@ -441,32 +438,28 @@ void TestResultsPane::initializeFilterMenu()
void TestResultsPane::updateSummaryLabel()
{
QString labelText = QString::fromLatin1("<p>Test summary:&nbsp;&nbsp; %1 %2, %3 %4")
QString labelText = QString("<p>Test summary:&nbsp;&nbsp; %1 %2, %3 %4")
.arg(QString::number(m_model->resultTypeCount(Result::Pass)), tr("passes"),
QString::number(m_model->resultTypeCount(Result::Fail)), tr("fails"));
int count = m_model->resultTypeCount(Result::UnexpectedPass);
if (count)
labelText.append(QString::fromLatin1(", %1 %2")
.arg(QString::number(count), tr("unexpected passes")));
labelText.append(QString(", %1 %2").arg(QString::number(count), tr("unexpected passes")));
count = m_model->resultTypeCount(Result::ExpectedFail);
if (count)
labelText.append(QString::fromLatin1(", %1 %2")
.arg(QString::number(count), tr("expected fails")));
labelText.append(QString(", %1 %2").arg(QString::number(count), tr("expected fails")));
count = m_model->resultTypeCount(Result::MessageFatal);
if (count)
labelText.append(QString::fromLatin1(", %1 %2")
.arg(QString::number(count), tr("fatals")));
labelText.append(QString(", %1 %2").arg(QString::number(count), tr("fatals")));
count = m_model->resultTypeCount(Result::BlacklistedFail)
+ m_model->resultTypeCount(Result::BlacklistedPass);
if (count)
labelText.append(QString::fromLatin1(", %1 %2")
.arg(QString::number(count), tr("blacklisted")));
labelText.append(QString(", %1 %2").arg(QString::number(count), tr("blacklisted")));
count = m_model->disabledTests();
if (count)
labelText.append(tr(", %1 disabled").arg(count));
labelText.append(QLatin1String(".</p>"));
labelText.append(".</p>");
m_summaryLabel->setText(labelText);
}
@@ -586,8 +579,8 @@ QString TestResultsPane::getWholeOutput(const QModelIndex &parent)
QModelIndex current = m_model->index(row, 0, parent);
const TestResult *result = m_model->testResult(current);
QTC_ASSERT(result, continue);
output.append(TestResult::resultToString(result->result())).append(QLatin1Char('\t'));
output.append(result->outputString(true)).append(QLatin1Char('\n'));
output.append(TestResult::resultToString(result->result())).append('\t');
output.append(result->outputString(true)).append('\n');
output.append(getWholeOutput(current));
}
return output;

View File

@@ -55,7 +55,7 @@ class ResultsTreeView : public Utils::TreeView
{
Q_OBJECT
public:
ResultsTreeView(QWidget *parent = 0);
explicit ResultsTreeView(QWidget *parent = 0);
signals:
void copyShortcutTriggered();
@@ -72,20 +72,20 @@ public:
static TestResultsPane *instance();
// IOutputPane interface
QWidget *outputWidget(QWidget *parent);
QList<QWidget *> toolBarWidgets() const;
QString displayName() const;
int priorityInStatusBar() const;
void clearContents();
void visibilityChanged(bool visible);
void setFocus();
bool hasFocus() const;
bool canFocus() const;
bool canNavigate() const;
bool canNext() const;
bool canPrevious() const;
void goToNext();
void goToPrev();
QWidget *outputWidget(QWidget *parent) override;
QList<QWidget *> toolBarWidgets() const override;
QString displayName() const override;
int priorityInStatusBar() const override;
void clearContents() override;
void visibilityChanged(bool visible) override;
void setFocus() override;
bool hasFocus() const override;
bool canFocus() const override;
bool canNavigate() const override;
bool canNext() const override;
bool canPrevious() const override;
void goToNext() override;
void goToPrev() override;
void addTestResult(const TestResultPtr &result);
@@ -124,10 +124,10 @@ private:
QToolButton *m_stopTestRun;
QToolButton *m_filterButton;
QMenu *m_filterMenu;
bool m_wasVisibleBefore;
bool m_autoScroll;
bool m_atEnd;
bool m_testRunning;
bool m_wasVisibleBefore = false;
bool m_autoScroll = false;
bool m_atEnd = false;
bool m_testRunning = false;
};
} // namespace Internal

View File

@@ -141,7 +141,7 @@ static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
testProcess.setArguments(testConfiguration->argumentsForTestRunner(settings));
testProcess.setWorkingDirectory(testConfiguration->workingDirectory());
if (Utils::HostOsInfo::isWindowsHost())
environment.insert(QLatin1String("QT_LOGGING_TO_CONSOLE"), QLatin1String("1"));
environment.insert("QT_LOGGING_TO_CONSOLE", "1");
testProcess.setProcessEnvironment(environment);
testProcess.setProgram(commandFilePath);
testProcess.start();

View File

@@ -50,13 +50,13 @@ TestSettings::TestSettings()
void TestSettings::toSettings(QSettings *s) const
{
s->beginGroup(QLatin1String(group));
s->setValue(QLatin1String(timeoutKey), timeout);
s->setValue(QLatin1String(omitInternalKey), omitInternalMssg);
s->setValue(QLatin1String(omitRunConfigWarnKey), omitRunConfigWarn);
s->setValue(QLatin1String(limitResultOutputKey), limitResultOutput);
s->setValue(QLatin1String(autoScrollKey), autoScroll);
s->setValue(QLatin1String(alwaysParseKey), alwaysParse);
s->beginGroup(group);
s->setValue(timeoutKey, timeout);
s->setValue(omitInternalKey, omitInternalMssg);
s->setValue(omitRunConfigWarnKey, omitRunConfigWarn);
s->setValue(limitResultOutputKey, limitResultOutput);
s->setValue(autoScrollKey, autoScroll);
s->setValue(alwaysParseKey, alwaysParse);
// store frameworks and their current active state
for (const Core::Id &id : frameworks.keys())
s->setValue(QLatin1String(id.name()), frameworks.value(id));
@@ -74,12 +74,12 @@ void TestSettings::toSettings(QSettings *s) const
void TestSettings::fromSettings(QSettings *s)
{
s->beginGroup(group);
timeout = s->value(QLatin1String(timeoutKey), defaultTimeout).toInt();
omitInternalMssg = s->value(QLatin1String(omitInternalKey), true).toBool();
omitRunConfigWarn = s->value(QLatin1String(omitRunConfigWarnKey), false).toBool();
limitResultOutput = s->value(QLatin1String(limitResultOutputKey), true).toBool();
autoScroll = s->value(QLatin1String(autoScrollKey), true).toBool();
alwaysParse = s->value(QLatin1String(alwaysParseKey), true).toBool();
timeout = s->value(timeoutKey, defaultTimeout).toInt();
omitInternalMssg = s->value(omitInternalKey, true).toBool();
omitRunConfigWarn = s->value(omitRunConfigWarnKey, false).toBool();
limitResultOutput = s->value(limitResultOutputKey, true).toBool();
autoScroll = s->value(autoScrollKey, true).toBool();
alwaysParse = s->value(alwaysParseKey, true).toBool();
// try to get settings for registered frameworks
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
const QList<Core::Id> &registered = frameworkManager->registeredFrameworkIds();

View File

@@ -60,9 +60,9 @@ public:
explicit TestSettingsPage(const QSharedPointer<TestSettings> &settings);
~TestSettingsPage();
QWidget *widget();
void apply();
void finish() { }
QWidget *widget() override;
void apply() override;
void finish() override { }
private:
QSharedPointer<TestSettings> m_settings;

View File

@@ -40,9 +40,7 @@ namespace Internal {
TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type type)
: m_name(name),
m_filePath(filePath),
m_type(type),
m_line(0),
m_status(NewlyAdded)
m_type(type)
{
m_checked = (m_type == TestCase || m_type == TestFunctionOrSet) ? Qt::Checked : Qt::Unchecked;
}

View File

@@ -64,7 +64,7 @@ public:
Naturally
};
TestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
explicit TestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
Type type = Root);
virtual QVariant data(int column, int role) const override;
@@ -131,19 +131,19 @@ private:
QString m_filePath;
Qt::CheckState m_checked;
Type m_type;
unsigned m_line;
unsigned m_column;
unsigned m_line = 0;
unsigned m_column = 0;
QString m_proFile;
Status m_status;
Status m_status = NewlyAdded;
};
class TestCodeLocationAndType
{
public:
QString m_name; // tag name for m_type == TEST_DATATAG, file name for other values
unsigned m_line;
unsigned m_column;
TestTreeItem::Type m_type;
unsigned m_line = 0;
unsigned m_column = 0;
TestTreeItem::Type m_type = TestTreeItem::Root;
};
typedef QVector<TestCodeLocationAndType> TestCodeLocationList;

View File

@@ -34,11 +34,11 @@ class TestTreeItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
TestTreeItemDelegate(QObject *parent = 0);
explicit TestTreeItemDelegate(QObject *parent = 0);
~TestTreeItemDelegate();
public:
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
};
} // namespace Internal

View File

@@ -43,8 +43,7 @@ namespace Internal {
TestTreeModel::TestTreeModel(QObject *parent) :
TreeModel<>(parent),
m_parser(new TestCodeParser(this)),
m_connectionsInitialized(false)
m_parser(new TestCodeParser(this))
{
connect(m_parser, &TestCodeParser::aboutToPerformFullParse, this,
&TestTreeModel::removeAllTestItems, Qt::QueuedConnection);
@@ -415,9 +414,7 @@ QMultiMap<QString, int> TestTreeModel::gtestNamesAndSets() const
TestTreeSortFilterModel::TestTreeSortFilterModel(TestTreeModel *sourceModel, QObject *parent)
: QSortFilterProxyModel(parent),
m_sourceModel(sourceModel),
m_sortMode(TestTreeItem::Alphabetically),
m_filterMode(Basic)
m_sourceModel(sourceModel)
{
setSourceModel(sourceModel);
}

View File

@@ -94,7 +94,7 @@ private:
void setupParsingConnections();
TestCodeParser *m_parser;
bool m_connectionsInitialized;
bool m_connectionsInitialized = false;
QAtomicInt m_refCounter;
};
@@ -109,7 +109,7 @@ public:
ShowAll = ShowInitAndCleanup | ShowTestData
};
TestTreeSortFilterModel(TestTreeModel *sourceModel, QObject *parent = 0);
explicit TestTreeSortFilterModel(TestTreeModel *sourceModel, QObject *parent = 0);
void setSortMode(TestTreeItem::SortMode sortMode);
void setFilterMode(FilterMode filterMode);
void toggleFilter(FilterMode filterMode);
@@ -121,8 +121,8 @@ protected:
private:
TestTreeModel *m_sourceModel;
TestTreeItem::SortMode m_sortMode;
FilterMode m_filterMode;
TestTreeItem::SortMode m_sortMode = TestTreeItem::Alphabetically;
FilterMode m_filterMode = Basic;
};

View File

@@ -39,9 +39,9 @@ class TestTreeView : public Utils::NavigationTreeView
Q_OBJECT
public:
TestTreeView(QWidget *parent = 0);
explicit TestTreeView(QWidget *parent = 0);
void selectAll();
void selectAll() override;
void deselectAll();
private: