forked from qt-creator/qt-creator
AutoTest: Modernize code a bit
Change-Id: Ie56f6e5cb8a4f1962bd8df5e57214911ae609921 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -38,7 +38,7 @@ class TestUtils
|
|||||||
public:
|
public:
|
||||||
static QString getCMakeDisplayNameIfNecessary(const QString &filePath, const QString &proFile)
|
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))
|
if (!proFile.endsWith(CMAKE_LISTS))
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
|
@@ -48,9 +48,9 @@ public:
|
|||||||
|
|
||||||
QSharedPointer<TestSettings> settings() const;
|
QSharedPointer<TestSettings> settings() const;
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *errorString);
|
bool initialize(const QStringList &arguments, QString *errorString) override;
|
||||||
void extensionsInitialized();
|
void extensionsInitialized() override;
|
||||||
ShutdownFlag aboutToShutdown();
|
ShutdownFlag aboutToShutdown() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool checkLicense();
|
bool checkLicense();
|
||||||
@@ -58,7 +58,7 @@ private:
|
|||||||
void onRunAllTriggered();
|
void onRunAllTriggered();
|
||||||
void onRunSelectedTriggered();
|
void onRunSelectedTriggered();
|
||||||
void updateMenuItemsEnabledState();
|
void updateMenuItemsEnabledState();
|
||||||
QList<QObject *> createTestObjects() const;
|
QList<QObject *> createTestObjects() const override;
|
||||||
const QSharedPointer<TestSettings> m_settings;
|
const QSharedPointer<TestSettings> m_settings;
|
||||||
TestFrameworkManager *m_frameworkManager = 0;
|
TestFrameworkManager *m_frameworkManager = 0;
|
||||||
};
|
};
|
||||||
|
@@ -65,7 +65,7 @@ void AutoTestUnitTests::initTestCase()
|
|||||||
if (allKits.count() != 1)
|
if (allKits.count() != 1)
|
||||||
QSKIP("This test requires exactly one kit to be present");
|
QSKIP("This test requires exactly one kit to be present");
|
||||||
if (auto qtVersion = QtSupport::QtKitInformation::qtVersion(allKits.first()))
|
if (auto qtVersion = QtSupport::QtKitInformation::qtVersion(allKits.first()))
|
||||||
m_isQt4 = qtVersion->qtVersionString().startsWith(QLatin1Char('4'));
|
m_isQt4 = qtVersion->qtVersionString().startsWith('4');
|
||||||
else
|
else
|
||||||
QSKIP("Could not figure out which Qt version is used for default kit.");
|
QSKIP("Could not figure out which Qt version is used for default kit.");
|
||||||
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first(),
|
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(allKits.first(),
|
||||||
|
@@ -41,14 +41,14 @@ QStringList GTestConfiguration::argumentsForTestRunner(const TestSettings &setti
|
|||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
const QStringList &testSets = testCases();
|
const QStringList &testSets = testCases();
|
||||||
if (testSets.size())
|
if (testSets.size())
|
||||||
arguments << QLatin1String("--gtest_filter=") + testSets.join(QLatin1Char(':'));
|
arguments << "--gtest_filter=" + testSets.join(':');
|
||||||
if (settings.gTestSettings.runDisabled)
|
if (settings.gTestSettings.runDisabled)
|
||||||
arguments << QLatin1String("--gtest_also_run_disabled_tests");
|
arguments << "--gtest_also_run_disabled_tests";
|
||||||
if (settings.gTestSettings.repeat)
|
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) {
|
if (settings.gTestSettings.shuffle) {
|
||||||
arguments << QLatin1String("--gtest_shuffle")
|
arguments << "--gtest_shuffle"
|
||||||
<< QString::fromLatin1("--gtest_random_seed=%1").arg(settings.gTestSettings.seed);
|
<< QString("--gtest_random_seed=%1").arg(settings.gTestSettings.seed);
|
||||||
}
|
}
|
||||||
if (settings.gTestSettings.throwOnFailure)
|
if (settings.gTestSettings.throwOnFailure)
|
||||||
arguments << "--gtest_throw_on_failure";
|
arguments << "--gtest_throw_on_failure";
|
||||||
|
@@ -72,8 +72,8 @@ void GTestOutputReader::processOutput(const QByteArray &outputLine)
|
|||||||
if (line.trimmed().isEmpty())
|
if (line.trimmed().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!line.startsWith(QLatin1Char('['))) {
|
if (!line.startsWith('[')) {
|
||||||
m_description.append(line).append(QLatin1Char('\n'));
|
m_description.append(line).append('\n');
|
||||||
if (iterations.exactMatch(line)) {
|
if (iterations.exactMatch(line)) {
|
||||||
m_iteration = iterations.cap(1).toInt();
|
m_iteration = iterations.cap(1).toInt();
|
||||||
m_description.clear();
|
m_description.clear();
|
||||||
@@ -142,7 +142,7 @@ 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(QLatin1Char('\n'))) {
|
foreach (const QString &output, m_description.split('\n')) {
|
||||||
QRegExp *match = 0;
|
QRegExp *match = 0;
|
||||||
if (failureLocation.exactMatch(output))
|
if (failureLocation.exactMatch(output))
|
||||||
match = &failureLocation;
|
match = &failureLocation;
|
||||||
|
@@ -42,7 +42,7 @@ TestTreeItem *GTestParseResult::createTestTreeItem() const
|
|||||||
static bool includesGTest(const CPlusPlus::Document::Ptr &doc,
|
static bool includesGTest(const CPlusPlus::Document::Ptr &doc,
|
||||||
const CPlusPlus::Snapshot &snapshot)
|
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()) {
|
foreach (const CPlusPlus::Document::Include &inc, doc->resolvedIncludes()) {
|
||||||
if (inc.resolvedFileName().endsWith(gtestH))
|
if (inc.resolvedFileName().endsWith(gtestH))
|
||||||
return true;
|
return true;
|
||||||
|
@@ -42,12 +42,12 @@ const QString GTestResult::outputString(bool selected) const
|
|||||||
case Result::Fail:
|
case Result::Fail:
|
||||||
output = m_testSetName;
|
output = m_testSetName;
|
||||||
if (selected && !desc.isEmpty())
|
if (selected && !desc.isEmpty())
|
||||||
output.append(QLatin1Char('\n')).append(desc);
|
output.append('\n').append(desc);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
output = desc;
|
output = desc;
|
||||||
if (!selected)
|
if (!selected)
|
||||||
output = output.split(QLatin1Char('\n')).first();
|
output = output.split('\n').first();
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@@ -43,24 +43,24 @@ QString GTestSettings::name() const
|
|||||||
|
|
||||||
void GTestSettings::fromSettings(const QSettings *s)
|
void GTestSettings::fromSettings(const QSettings *s)
|
||||||
{
|
{
|
||||||
runDisabled = s->value(QLatin1String(runDisabledKey), false).toBool();
|
runDisabled = s->value(runDisabledKey, false).toBool();
|
||||||
repeat = s->value(QLatin1String(repeatKey), false).toBool();
|
repeat = s->value(repeatKey, false).toBool();
|
||||||
shuffle = s->value(QLatin1String(shuffleKey), false).toBool();
|
shuffle = s->value(shuffleKey, false).toBool();
|
||||||
iterations = s->value(QLatin1String(iterationsKey), 1).toInt();
|
iterations = s->value(iterationsKey, 1).toInt();
|
||||||
seed = s->value(QLatin1String(seedKey), 0).toInt();
|
seed = s->value(seedKey, 0).toInt();
|
||||||
breakOnFailure = s->value(QLatin1String(breakOnFailureKey), true).toBool();
|
breakOnFailure = s->value(breakOnFailureKey, true).toBool();
|
||||||
throwOnFailure = s->value(QLatin1String(throwOnFailureKey), false).toBool();
|
throwOnFailure = s->value(throwOnFailureKey, false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTestSettings::toSettings(QSettings *s) const
|
void GTestSettings::toSettings(QSettings *s) const
|
||||||
{
|
{
|
||||||
s->setValue(QLatin1String(runDisabledKey), runDisabled);
|
s->setValue(runDisabledKey, runDisabled);
|
||||||
s->setValue(QLatin1String(repeatKey), repeat);
|
s->setValue(repeatKey, repeat);
|
||||||
s->setValue(QLatin1String(shuffleKey), shuffle);
|
s->setValue(shuffleKey, shuffle);
|
||||||
s->setValue(QLatin1String(iterationsKey), iterations);
|
s->setValue(iterationsKey, iterations);
|
||||||
s->setValue(QLatin1String(seedKey), seed);
|
s->setValue(seedKey, seed);
|
||||||
s->setValue(QLatin1String(breakOnFailureKey), breakOnFailure);
|
s->setValue(breakOnFailureKey, breakOnFailure);
|
||||||
s->setValue(QLatin1String(throwOnFailureKey), throwOnFailure);
|
s->setValue(throwOnFailureKey, throwOnFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -101,7 +101,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const
|
|||||||
GTestConfiguration *config = 0;
|
GTestConfiguration *config = 0;
|
||||||
switch (type()) {
|
switch (type()) {
|
||||||
case TestCase: {
|
case TestCase: {
|
||||||
const QString &testSpecifier = gtestFilter(state()).arg(name()).arg(QLatin1Char('*'));
|
const QString &testSpecifier = gtestFilter(state()).arg(name()).arg('*');
|
||||||
if (int count = childCount()) {
|
if (int count = childCount()) {
|
||||||
config = new GTestConfiguration;
|
config = new GTestConfiguration;
|
||||||
config->setTestCases(QStringList(testSpecifier));
|
config->setTestCases(QStringList(testSpecifier));
|
||||||
@@ -339,7 +339,7 @@ QString GTestTreeItem::nameSuffix() const
|
|||||||
if (m_state & Typed)
|
if (m_state & Typed)
|
||||||
suffix += (suffix.isEmpty() ? QLatin1String(" [") : QLatin1String(", ")) + markups[1];
|
suffix += (suffix.isEmpty() ? QLatin1String(" [") : QLatin1String(", ")) + markups[1];
|
||||||
if (!suffix.isEmpty())
|
if (!suffix.isEmpty())
|
||||||
suffix += QLatin1Char(']');
|
suffix += ']';
|
||||||
return suffix;
|
return suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,8 +46,8 @@ public:
|
|||||||
Q_FLAGS(TestState)
|
Q_FLAGS(TestState)
|
||||||
Q_DECLARE_FLAGS(TestStates, 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) {}
|
Type type = Root) : TestTreeItem(name, filePath, type), m_state(Enabled) {}
|
||||||
|
|
||||||
static GTestTreeItem *createTestItem(const TestParseResult *result);
|
static GTestTreeItem *createTestItem(const TestParseResult *result);
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ inline bool operator<(const GTestCaseSpec &spec1, const GTestCaseSpec &spec2)
|
|||||||
class GTestVisitor : public CPlusPlus::ASTVisitor
|
class GTestVisitor : public CPlusPlus::ASTVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GTestVisitor(CPlusPlus::Document::Ptr doc);
|
explicit GTestVisitor(CPlusPlus::Document::Ptr doc);
|
||||||
bool visit(CPlusPlus::FunctionDefinitionAST *ast);
|
bool visit(CPlusPlus::FunctionDefinitionAST *ast);
|
||||||
|
|
||||||
QMap<GTestCaseSpec, GTestCodeLocationList> gtestFunctions() const { return m_gtestFunctions; }
|
QMap<GTestCaseSpec, GTestCodeLocationList> gtestFunctions() const { return m_gtestFunctions; }
|
||||||
|
@@ -34,7 +34,7 @@ namespace Internal {
|
|||||||
class ITestFramework
|
class ITestFramework
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ITestFramework(bool activeByDefault) : m_active(activeByDefault) {}
|
explicit ITestFramework(bool activeByDefault) : m_active(activeByDefault) {}
|
||||||
virtual ~ITestFramework()
|
virtual ~ITestFramework()
|
||||||
{
|
{
|
||||||
delete m_rootNode;
|
delete m_rootNode;
|
||||||
|
@@ -38,13 +38,13 @@ namespace Internal {
|
|||||||
static QString decode(const QString& original)
|
static QString decode(const QString& original)
|
||||||
{
|
{
|
||||||
QString result(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);
|
regex.setMinimal(true);
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while ((pos = regex.indexIn(original, pos)) != -1) {
|
while ((pos = regex.indexIn(original, pos)) != -1) {
|
||||||
const QString value = regex.cap(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)));
|
result.replace(regex.cap(0), QChar(value.midRef(1).toInt(0, 16)));
|
||||||
else
|
else
|
||||||
result.replace(regex.cap(0), QChar(value.toInt(0, 10)));
|
result.replace(regex.cap(0), QChar(value.toInt(0, 10)));
|
||||||
@@ -80,13 +80,13 @@ static QString formatResult(double value)
|
|||||||
|
|
||||||
beforeDecimalPoint.chop(beforeRemove);
|
beforeDecimalPoint.chop(beforeRemove);
|
||||||
for (int i = 0; i < beforeRemove; ++i)
|
for (int i = 0; i < beforeRemove; ++i)
|
||||||
beforeDecimalPoint.append(QLatin1Char('0'));
|
beforeDecimalPoint.append('0');
|
||||||
|
|
||||||
int afterUse = significantDigits - beforeUse;
|
int afterUse = significantDigits - beforeUse;
|
||||||
if (beforeDecimalPoint == QLatin1String("0") && !afterDecimalPoint.isEmpty()) {
|
if (beforeDecimalPoint == QLatin1String("0") && !afterDecimalPoint.isEmpty()) {
|
||||||
++afterUse;
|
++afterUse;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < afterDecimalPoint.count() && afterDecimalPoint.at(i) == QLatin1Char('0'))
|
while (i < afterDecimalPoint.count() && afterDecimalPoint.at(i) == '0')
|
||||||
++i;
|
++i;
|
||||||
afterUse += i;
|
afterUse += i;
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ static QString formatResult(double value)
|
|||||||
|
|
||||||
QString result = beforeDecimalPoint;
|
QString result = beforeDecimalPoint;
|
||||||
if (afterUse > 0)
|
if (afterUse > 0)
|
||||||
result.append(QLatin1Char('.'));
|
result.append('.');
|
||||||
result += afterDecimalPoint;
|
result += afterDecimalPoint;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -105,16 +105,16 @@ static QString formatResult(double value)
|
|||||||
static QString constructBenchmarkInformation(const QString &metric, double value, int iterations)
|
static QString constructBenchmarkInformation(const QString &metric, double value, int iterations)
|
||||||
{
|
{
|
||||||
QString metricsText;
|
QString metricsText;
|
||||||
if (metric == QLatin1String("WalltimeMilliseconds")) // default
|
if (metric == "WalltimeMilliseconds") // default
|
||||||
metricsText = QLatin1String("msecs");
|
metricsText = "msecs";
|
||||||
else if (metric == QLatin1String("CPUTicks")) // -tickcounter
|
else if (metric == "CPUTicks") // -tickcounter
|
||||||
metricsText = QLatin1String("CPU ticks");
|
metricsText = "CPU ticks";
|
||||||
else if (metric == QLatin1String("Events")) // -eventcounter
|
else if (metric == "Events") // -eventcounter
|
||||||
metricsText = QLatin1String("events");
|
metricsText = "events";
|
||||||
else if (metric == QLatin1String("InstructionReads")) // -callgrind
|
else if (metric == "InstructionReads") // -callgrind
|
||||||
metricsText = QLatin1String("instruction reads");
|
metricsText = "instruction reads";
|
||||||
else if (metric == QLatin1String("CPUCycles")) // -perf
|
else if (metric == "CPUCycles") // -perf
|
||||||
metricsText = QLatin1String("CPU cycles");
|
metricsText = "CPU cycles";
|
||||||
return QtTestOutputReader::tr("%1 %2 per iteration (total: %3, iterations: %4)")
|
return QtTestOutputReader::tr("%1 %2 per iteration (total: %3, iterations: %4)")
|
||||||
.arg(formatResult(value))
|
.arg(formatResult(value))
|
||||||
.arg(metricsText)
|
.arg(metricsText)
|
||||||
@@ -227,7 +227,7 @@ void QtTestOutputReader::processOutput(const QByteArray &outputLine)
|
|||||||
break;
|
break;
|
||||||
case Description:
|
case Description:
|
||||||
if (!m_description.isEmpty())
|
if (!m_description.isEmpty())
|
||||||
m_description.append(QLatin1Char('\n'));
|
m_description.append('\n');
|
||||||
m_description.append(text);
|
m_description.append(text);
|
||||||
break;
|
break;
|
||||||
case QtVersion:
|
case QtVersion:
|
||||||
|
@@ -43,8 +43,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus:
|
|||||||
{
|
{
|
||||||
static QStringList expectedHeaderPrefixes
|
static QStringList expectedHeaderPrefixes
|
||||||
= Utils::HostOsInfo::isMacHost()
|
= Utils::HostOsInfo::isMacHost()
|
||||||
? QStringList({ QLatin1String("QtTest.framework/Headers"), QLatin1String("QtTest") })
|
? QStringList({ "QtTest.framework/Headers", "QtTest" }) : QStringList({ "QtTest" });
|
||||||
: QStringList({ QLatin1String("QtTest") });
|
|
||||||
|
|
||||||
const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes();
|
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
|
// bad, as there could be much more different approaches
|
||||||
if (inc.unresolvedFileName() == QLatin1String("QtTest")) {
|
if (inc.unresolvedFileName() == QLatin1String("QtTest")) {
|
||||||
foreach (const QString &prefix, expectedHeaderPrefixes) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,7 +61,7 @@ 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) {
|
foreach (const QString &include, allIncludes) {
|
||||||
foreach (const QString &prefix, expectedHeaderPrefixes) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +140,7 @@ static QSet<QString> filesWithDataFunctionDefinitions(
|
|||||||
|
|
||||||
for ( ; it != end; ++it) {
|
for ( ; it != end; ++it) {
|
||||||
const QString &key = it.key();
|
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);
|
result.insert(it.value().m_name);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -209,7 +208,7 @@ static bool handleQtTest(QFutureInterface<TestParseResultPtr> futureInterface,
|
|||||||
const TestCodeLocationAndType &location = it.value();
|
const TestCodeLocationAndType &location = it.value();
|
||||||
QtTestParseResult *func = new QtTestParseResult(id);
|
QtTestParseResult *func = new QtTestParseResult(id);
|
||||||
func->itemType = location.m_type;
|
func->itemType = location.m_type;
|
||||||
func->name = testCaseName + QLatin1String("::") + it.key();
|
func->name = testCaseName + "::" + it.key();
|
||||||
func->displayName = it.key();
|
func->displayName = it.key();
|
||||||
func->fileName = location.m_name;
|
func->fileName = location.m_name;
|
||||||
func->line = location.m_line;
|
func->line = location.m_line;
|
||||||
@@ -220,7 +219,7 @@ static bool handleQtTest(QFutureInterface<TestParseResultPtr> futureInterface,
|
|||||||
dataTag->itemType = tag.m_type;
|
dataTag->itemType = tag.m_type;
|
||||||
dataTag->name = tag.m_name;
|
dataTag->name = tag.m_name;
|
||||||
dataTag->displayName = 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->line = tag.m_line;
|
||||||
dataTag->column = tag.m_column;
|
dataTag->column = tag.m_column;
|
||||||
|
|
||||||
|
@@ -45,28 +45,28 @@ const QString QtTestResult::outputString(bool selected) const
|
|||||||
case Result::UnexpectedPass:
|
case Result::UnexpectedPass:
|
||||||
case Result::BlacklistedFail:
|
case Result::BlacklistedFail:
|
||||||
case Result::BlacklistedPass:
|
case Result::BlacklistedPass:
|
||||||
output = className + QLatin1String("::") + m_function;
|
output = className + "::" + m_function;
|
||||||
if (!m_dataTag.isEmpty())
|
if (!m_dataTag.isEmpty())
|
||||||
output.append(QString::fromLatin1(" (%1)").arg(m_dataTag));
|
output.append(QString(" (%1)").arg(m_dataTag));
|
||||||
if (selected && !desc.isEmpty()) {
|
if (selected && !desc.isEmpty()) {
|
||||||
output.append(QLatin1Char('\n')).append(desc);
|
output.append('\n').append(desc);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Result::Benchmark:
|
case Result::Benchmark:
|
||||||
output = className + QLatin1String("::") + m_function;
|
output = className + "::" + m_function;
|
||||||
if (!m_dataTag.isEmpty())
|
if (!m_dataTag.isEmpty())
|
||||||
output.append(QString::fromLatin1(" (%1)").arg(m_dataTag));
|
output.append(QString(" (%1)").arg(m_dataTag));
|
||||||
if (!desc.isEmpty()) {
|
if (!desc.isEmpty()) {
|
||||||
int breakPos = desc.indexOf(QLatin1Char('('));
|
int breakPos = desc.indexOf('(');
|
||||||
output.append(QLatin1String(": ")).append(desc.left(breakPos));
|
output.append(": ").append(desc.left(breakPos));
|
||||||
if (selected)
|
if (selected)
|
||||||
output.append(QLatin1Char('\n')).append(desc.mid(breakPos));
|
output.append('\n').append(desc.mid(breakPos));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
output = desc;
|
output = desc;
|
||||||
if (!selected)
|
if (!selected)
|
||||||
output = output.split(QLatin1Char('\n')).first();
|
output = output.split('\n').first();
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@@ -56,14 +56,14 @@ QString QtTestSettings::name() const
|
|||||||
|
|
||||||
void QtTestSettings::fromSettings(const QSettings *s)
|
void QtTestSettings::fromSettings(const QSettings *s)
|
||||||
{
|
{
|
||||||
metrics = intToMetrics(s->value(QLatin1String(metricsKey), Walltime).toInt());
|
metrics = intToMetrics(s->value(metricsKey, Walltime).toInt());
|
||||||
noCrashHandler = s->value(QLatin1String(noCrashhandlerKey), true).toBool();
|
noCrashHandler = s->value(noCrashhandlerKey, true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtTestSettings::toSettings(QSettings *s) const
|
void QtTestSettings::toSettings(QSettings *s) const
|
||||||
{
|
{
|
||||||
s->setValue(QLatin1String(metricsKey), metrics);
|
s->setValue(metricsKey, metrics);
|
||||||
s->setValue(QLatin1String(noCrashhandlerKey), noCrashHandler);
|
s->setValue(noCrashhandlerKey, noCrashHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QtTestSettings::metricsTypeToOption(const MetricsType type)
|
QString QtTestSettings::metricsTypeToOption(const MetricsType type)
|
||||||
|
@@ -118,7 +118,7 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const
|
|||||||
const TestTreeItem *parent = function ? function->parentItem() : 0;
|
const TestTreeItem *parent = function ? function->parentItem() : 0;
|
||||||
if (!parent)
|
if (!parent)
|
||||||
return 0;
|
return 0;
|
||||||
const QString functionWithTag = function->name() + QLatin1Char(':') + name();
|
const QString functionWithTag = function->name() + ':' + name();
|
||||||
config = new QtTestConfiguration();
|
config = new QtTestConfiguration();
|
||||||
config->setTestCases(QStringList(functionWithTag));
|
config->setTestCases(QStringList(functionWithTag));
|
||||||
config->setProFile(parent->proFile());
|
config->setProFile(parent->proFile());
|
||||||
|
@@ -33,8 +33,8 @@ namespace Internal {
|
|||||||
class QtTestTreeItem : public TestTreeItem
|
class QtTestTreeItem : public TestTreeItem
|
||||||
{
|
{
|
||||||
public:
|
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) {}
|
Type type = Root) : TestTreeItem(name, filePath, type) {}
|
||||||
|
|
||||||
static QtTestTreeItem *createTestItem(const TestParseResult *result);
|
static QtTestTreeItem *createTestItem(const TestParseResult *result);
|
||||||
|
|
||||||
|
@@ -35,10 +35,7 @@
|
|||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static QStringList specialFunctions({ QLatin1String("initTestCase"),
|
static QStringList specialFunctions({ "initTestCase", "cleanupTestCase", "init", "cleanup" });
|
||||||
QLatin1String("cleanupTestCase"),
|
|
||||||
QLatin1String("init"),
|
|
||||||
QLatin1String("cleanup") });
|
|
||||||
|
|
||||||
/************************** Cpp Test Symbol Visitor ***************************/
|
/************************** Cpp Test Symbol Visitor ***************************/
|
||||||
|
|
||||||
@@ -82,7 +79,7 @@ bool TestVisitor::visit(CPlusPlus::Class *symbol)
|
|||||||
}
|
}
|
||||||
if (specialFunctions.contains(name))
|
if (specialFunctions.contains(name))
|
||||||
locationAndType.m_type = TestTreeItem::TestSpecialFunction;
|
locationAndType.m_type = TestTreeItem::TestSpecialFunction;
|
||||||
else if (name.endsWith(QLatin1String("_data")))
|
else if (name.endsWith("_data"))
|
||||||
locationAndType.m_type = TestTreeItem::TestDataFunction;
|
locationAndType.m_type = TestTreeItem::TestDataFunction;
|
||||||
else
|
else
|
||||||
locationAndType.m_type = TestTreeItem::TestFunctionOrSet;
|
locationAndType.m_type = TestTreeItem::TestFunctionOrSet;
|
||||||
@@ -111,7 +108,7 @@ bool TestAstVisitor::visit(CPlusPlus::CallAST *ast)
|
|||||||
if (const auto qualifiedNameAST = idExpressionAST->name->asQualifiedName()) {
|
if (const auto qualifiedNameAST = idExpressionAST->name->asQualifiedName()) {
|
||||||
const CPlusPlus::Overview o;
|
const CPlusPlus::Overview o;
|
||||||
const QString prettyName = o.prettyName(qualifiedNameAST->name);
|
const QString prettyName = o.prettyName(qualifiedNameAST->name);
|
||||||
if (prettyName == QLatin1String("QTest::qExec")) {
|
if (prettyName == "QTest::qExec") {
|
||||||
if (const auto expressionListAST = ast->expression_list) {
|
if (const auto expressionListAST = ast->expression_list) {
|
||||||
// first argument is the one we need
|
// first argument is the one we need
|
||||||
if (const auto argumentExpressionAST = expressionListAST->value) {
|
if (const auto argumentExpressionAST = expressionListAST->value) {
|
||||||
@@ -148,17 +145,14 @@ bool TestAstVisitor::visit(CPlusPlus::CompoundStatementAST *ast)
|
|||||||
|
|
||||||
TestDataFunctionVisitor::TestDataFunctionVisitor(CPlusPlus::Document::Ptr doc)
|
TestDataFunctionVisitor::TestDataFunctionVisitor(CPlusPlus::Document::Ptr doc)
|
||||||
: CPlusPlus::ASTVisitor(doc->translationUnit()),
|
: CPlusPlus::ASTVisitor(doc->translationUnit()),
|
||||||
m_currentDoc(doc),
|
m_currentDoc(doc)
|
||||||
m_currentAstDepth(0),
|
|
||||||
m_insideUsingQTestDepth(0),
|
|
||||||
m_insideUsingQTest(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestDataFunctionVisitor::visit(CPlusPlus::UsingDirectiveAST *ast)
|
bool TestDataFunctionVisitor::visit(CPlusPlus::UsingDirectiveAST *ast)
|
||||||
{
|
{
|
||||||
if (auto nameAST = ast->name) {
|
if (auto nameAST = ast->name) {
|
||||||
if (m_overview.prettyName(nameAST->name) == QLatin1String("QTest")) {
|
if (m_overview.prettyName(nameAST->name) == "QTest") {
|
||||||
m_insideUsingQTest = true;
|
m_insideUsingQTest = true;
|
||||||
// we need the surrounding AST depth as using directive is an AST itself
|
// we need the surrounding AST depth as using directive is an AST itself
|
||||||
m_insideUsingQTestDepth = m_currentAstDepth - 1;
|
m_insideUsingQTestDepth = m_currentAstDepth - 1;
|
||||||
@@ -177,7 +171,7 @@ bool TestDataFunctionVisitor::visit(CPlusPlus::FunctionDefinitionAST *ast)
|
|||||||
CPlusPlus::LookupContext lc;
|
CPlusPlus::LookupContext lc;
|
||||||
const QString prettyName = m_overview.prettyName(lc.fullyQualifiedName(ast->symbol));
|
const QString prettyName = m_overview.prettyName(lc.fullyQualifiedName(ast->symbol));
|
||||||
// do not handle functions that aren't real test data functions
|
// do not handle functions that aren't real test data functions
|
||||||
if (!prettyName.endsWith(QLatin1String("_data")))
|
if (!prettyName.endsWith("_data"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_currentFunction = prettyName.left(prettyName.size() - 5);
|
m_currentFunction = prettyName.left(prettyName.size() - 5);
|
||||||
@@ -275,10 +269,10 @@ bool TestDataFunctionVisitor::newRowCallFound(CPlusPlus::CallAST *ast, unsigned
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (const auto qualifiedNameAST = exp->name->asQualifiedName()) {
|
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();
|
*firstToken = qualifiedNameAST->firstToken();
|
||||||
} else if (m_insideUsingQTest) {
|
} 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();
|
*firstToken = exp->name->firstToken();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ namespace Internal {
|
|||||||
class TestVisitor : public CPlusPlus::SymbolVisitor
|
class TestVisitor : public CPlusPlus::SymbolVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestVisitor(const QString &fullQualifiedClassName);
|
explicit TestVisitor(const QString &fullQualifiedClassName);
|
||||||
|
|
||||||
QMap<QString, TestCodeLocationAndType> privateSlots() const { return m_privSlots; }
|
QMap<QString, TestCodeLocationAndType> privateSlots() const { return m_privSlots; }
|
||||||
bool resultValid() const { return m_valid; }
|
bool resultValid() const { return m_valid; }
|
||||||
@@ -59,7 +59,7 @@ private:
|
|||||||
class TestAstVisitor : public CPlusPlus::ASTVisitor
|
class TestAstVisitor : public CPlusPlus::ASTVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestAstVisitor(CPlusPlus::Document::Ptr doc);
|
explicit TestAstVisitor(CPlusPlus::Document::Ptr doc);
|
||||||
|
|
||||||
bool visit(CPlusPlus::CallAST *ast);
|
bool visit(CPlusPlus::CallAST *ast);
|
||||||
bool visit(CPlusPlus::CompoundStatementAST *ast);
|
bool visit(CPlusPlus::CompoundStatementAST *ast);
|
||||||
@@ -75,7 +75,7 @@ private:
|
|||||||
class TestDataFunctionVisitor : public CPlusPlus::ASTVisitor
|
class TestDataFunctionVisitor : public CPlusPlus::ASTVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestDataFunctionVisitor(CPlusPlus::Document::Ptr doc);
|
explicit TestDataFunctionVisitor(CPlusPlus::Document::Ptr doc);
|
||||||
|
|
||||||
bool visit(CPlusPlus::UsingDirectiveAST *ast);
|
bool visit(CPlusPlus::UsingDirectiveAST *ast);
|
||||||
bool visit(CPlusPlus::FunctionDefinitionAST *ast);
|
bool visit(CPlusPlus::FunctionDefinitionAST *ast);
|
||||||
@@ -93,9 +93,9 @@ private:
|
|||||||
QString m_currentFunction;
|
QString m_currentFunction;
|
||||||
QMap<QString, TestCodeLocationList> m_dataTags;
|
QMap<QString, TestCodeLocationList> m_dataTags;
|
||||||
TestCodeLocationList m_currentTags;
|
TestCodeLocationList m_currentTags;
|
||||||
unsigned m_currentAstDepth;
|
unsigned m_currentAstDepth = 0;
|
||||||
unsigned m_insideUsingQTestDepth;
|
unsigned m_insideUsingQTestDepth = 0;
|
||||||
bool m_insideUsingQTest;
|
bool m_insideUsingQTest = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -50,17 +50,16 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
|
|||||||
{
|
{
|
||||||
static QStringList expectedHeaderPrefixes
|
static QStringList expectedHeaderPrefixes
|
||||||
= Utils::HostOsInfo::isMacHost()
|
= Utils::HostOsInfo::isMacHost()
|
||||||
? QStringList({ QLatin1String("QtQuickTest.framework/Headers"),
|
? QStringList({ "QtQuickTest.framework/Headers", "QtQuickTest" })
|
||||||
QLatin1String("QtQuickTest") })
|
: QStringList({ "QtQuickTest" });
|
||||||
: QStringList({ QLatin1String("QtQuickTest") });
|
|
||||||
|
|
||||||
const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes();
|
const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes();
|
||||||
|
|
||||||
foreach (const CPlusPlus::Document::Include &inc, includes) {
|
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) {
|
foreach (const QString &prefix, expectedHeaderPrefixes) {
|
||||||
if (inc.resolvedFileName().endsWith(
|
if (inc.resolvedFileName().endsWith(
|
||||||
QString::fromLatin1("%1/quicktest.h").arg(prefix))) {
|
QString("%1/quicktest.h").arg(prefix))) {
|
||||||
return true;
|
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 &include, snapshot.allIncludesForDocument(doc->fileName())) {
|
||||||
foreach (const QString &prefix, expectedHeaderPrefixes) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,7 +139,7 @@ static QList<QmlJS::Document::Ptr> scanDirectoryForQuickTestQmlFiles(const QStri
|
|||||||
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) {
|
foreach (const QmlJS::Document::Ptr &doc, docs) {
|
||||||
const QString fileName(QFileInfo(doc->fileName()).fileName());
|
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;
|
foundDocs << doc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -131,7 +131,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const
|
|||||||
case TestCase: {
|
case TestCase: {
|
||||||
QStringList testFunctions;
|
QStringList testFunctions;
|
||||||
for (int row = 0, count = childCount(); row < count; ++row)
|
for (int row = 0, count = childCount(); row < count; ++row)
|
||||||
testFunctions << name() + QLatin1String("::") + childItem(row)->name();
|
testFunctions << name() + "::" + childItem(row)->name();
|
||||||
config = new QuickTestConfiguration;
|
config = new QuickTestConfiguration;
|
||||||
config->setTestCases(testFunctions);
|
config->setTestCases(testFunctions);
|
||||||
config->setProFile(proFile());
|
config->setProFile(proFile());
|
||||||
@@ -140,7 +140,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const
|
|||||||
}
|
}
|
||||||
case TestFunctionOrSet: {
|
case TestFunctionOrSet: {
|
||||||
TestTreeItem *parent = parentItem();
|
TestTreeItem *parent = parentItem();
|
||||||
QStringList testFunction(parent->name() + QLatin1String("::") + name());
|
QStringList testFunction(parent->name() + "::" + name());
|
||||||
config = new QuickTestConfiguration;
|
config = new QuickTestConfiguration;
|
||||||
config->setTestCases(testFunction);
|
config->setTestCases(testFunction);
|
||||||
config->setProFile(parent->proFile());
|
config->setProFile(parent->proFile());
|
||||||
@@ -239,7 +239,7 @@ QList<TestConfiguration *> QuickTestTreeItem::getSelectedTestConfigurations() co
|
|||||||
const TestTreeItem *grandChild = child->childItem(grandChildRow);
|
const TestTreeItem *grandChild = child->childItem(grandChildRow);
|
||||||
if (grandChild->type() != TestFunctionOrSet)
|
if (grandChild->type() != TestFunctionOrSet)
|
||||||
continue;
|
continue;
|
||||||
testFunctions << child->name() + QLatin1String("::") + grandChild->name();
|
testFunctions << child->name() + "::" + grandChild->name();
|
||||||
}
|
}
|
||||||
if (foundProFiles.contains(child->proFile())) {
|
if (foundProFiles.contains(child->proFile())) {
|
||||||
tc = foundProFiles[child->proFile()];
|
tc = foundProFiles[child->proFile()];
|
||||||
|
@@ -33,8 +33,8 @@ namespace Internal {
|
|||||||
class QuickTestTreeItem : public TestTreeItem
|
class QuickTestTreeItem : public TestTreeItem
|
||||||
{
|
{
|
||||||
public:
|
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) {}
|
Type type = Root) : TestTreeItem(name, filePath, type) {}
|
||||||
|
|
||||||
static QuickTestTreeItem *createTestItem(const TestParseResult *result);
|
static QuickTestTreeItem *createTestItem(const TestParseResult *result);
|
||||||
|
|
||||||
|
@@ -30,10 +30,7 @@
|
|||||||
namespace Autotest {
|
namespace Autotest {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static QStringList specialFunctions({ QLatin1String("initTestCase"),
|
static QStringList specialFunctions({ "initTestCase", "cleanupTestCase", "init", "cleanup" });
|
||||||
QLatin1String("cleanupTestCase"),
|
|
||||||
QLatin1String("init"),
|
|
||||||
QLatin1String("cleanup") });
|
|
||||||
|
|
||||||
TestQmlVisitor::TestQmlVisitor(QmlJS::Document::Ptr doc)
|
TestQmlVisitor::TestQmlVisitor(QmlJS::Document::Ptr doc)
|
||||||
: m_currentDoc(doc)
|
: m_currentDoc(doc)
|
||||||
@@ -43,7 +40,7 @@ TestQmlVisitor::TestQmlVisitor(QmlJS::Document::Ptr doc)
|
|||||||
bool TestQmlVisitor::visit(QmlJS::AST::UiObjectDefinition *ast)
|
bool TestQmlVisitor::visit(QmlJS::AST::UiObjectDefinition *ast)
|
||||||
{
|
{
|
||||||
const QStringRef name = ast->qualifiedTypeNameId->name;
|
const QStringRef name = ast->qualifiedTypeNameId->name;
|
||||||
if (name != QLatin1String("TestCase"))
|
if (name != "TestCase")
|
||||||
return true; // find nested TestCase items as well
|
return true; // find nested TestCase items as well
|
||||||
|
|
||||||
m_currentTestCaseName.clear();
|
m_currentTestCaseName.clear();
|
||||||
@@ -64,15 +61,15 @@ bool TestQmlVisitor::visit(QmlJS::AST::ExpressionStatement *ast)
|
|||||||
bool TestQmlVisitor::visit(QmlJS::AST::UiScriptBinding *ast)
|
bool TestQmlVisitor::visit(QmlJS::AST::UiScriptBinding *ast)
|
||||||
{
|
{
|
||||||
const QStringRef name = ast->qualifiedId->name;
|
const QStringRef name = ast->qualifiedId->name;
|
||||||
return name == QLatin1String("name");
|
return name == "name";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast)
|
bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast)
|
||||||
{
|
{
|
||||||
const QStringRef name = ast->name;
|
const QStringRef name = ast->name;
|
||||||
if (name.startsWith(QLatin1String("test_"))
|
if (name.startsWith("test_")
|
||||||
|| name.startsWith(QLatin1String("benchmark_"))
|
|| name.startsWith("benchmark_")
|
||||||
|| name.endsWith(QLatin1String("_data"))
|
|| name.endsWith("_data")
|
||||||
|| specialFunctions.contains(name.toString())) {
|
|| specialFunctions.contains(name.toString())) {
|
||||||
const auto sourceLocation = ast->firstSourceLocation();
|
const auto sourceLocation = ast->firstSourceLocation();
|
||||||
TestCodeLocationAndType locationAndType;
|
TestCodeLocationAndType locationAndType;
|
||||||
@@ -81,7 +78,7 @@ bool TestQmlVisitor::visit(QmlJS::AST::FunctionDeclaration *ast)
|
|||||||
locationAndType.m_column = sourceLocation.startColumn - 1;
|
locationAndType.m_column = sourceLocation.startColumn - 1;
|
||||||
if (specialFunctions.contains(name.toString()))
|
if (specialFunctions.contains(name.toString()))
|
||||||
locationAndType.m_type = TestTreeItem::TestSpecialFunction;
|
locationAndType.m_type = TestTreeItem::TestSpecialFunction;
|
||||||
else if (name.endsWith(QLatin1String("_data")))
|
else if (name.endsWith("_data"))
|
||||||
locationAndType.m_type = TestTreeItem::TestDataFunction;
|
locationAndType.m_type = TestTreeItem::TestDataFunction;
|
||||||
else
|
else
|
||||||
locationAndType.m_type = TestTreeItem::TestFunctionOrSet;
|
locationAndType.m_type = TestTreeItem::TestFunctionOrSet;
|
||||||
|
@@ -36,7 +36,7 @@ namespace Internal {
|
|||||||
class TestQmlVisitor : public QmlJS::AST::Visitor
|
class TestQmlVisitor : public QmlJS::AST::Visitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestQmlVisitor(QmlJS::Document::Ptr doc);
|
explicit TestQmlVisitor(QmlJS::Document::Ptr doc);
|
||||||
|
|
||||||
bool visit(QmlJS::AST::UiObjectDefinition *ast);
|
bool visit(QmlJS::AST::UiObjectDefinition *ast);
|
||||||
bool visit(QmlJS::AST::ExpressionStatement *ast);
|
bool visit(QmlJS::AST::ExpressionStatement *ast);
|
||||||
|
@@ -338,7 +338,7 @@ void TestCodeParser::scanForTests(const QStringList &fileList)
|
|||||||
if (isFullParse) {
|
if (isFullParse) {
|
||||||
// remove qml files as they will be found automatically by the referencing cpp file
|
// remove qml files as they will be found automatically by the referencing cpp file
|
||||||
list = Utils::filtered(list, [] (const QString &fn) {
|
list = Utils::filtered(list, [] (const QString &fn) {
|
||||||
return !fn.endsWith(QLatin1String(".qml"));
|
return !fn.endsWith(".qml");
|
||||||
});
|
});
|
||||||
m_model->markAllForRemoval();
|
m_model->markAllForRemoval();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -118,10 +118,8 @@ void TestConfiguration::completeTestInformation(int runMode)
|
|||||||
// some project manager store line/column information as well inside ProjectPart
|
// some project manager store line/column information as well inside ProjectPart
|
||||||
if (bti.isValid() && m_proFile.startsWith(bti.projectFilePath.toString())) {
|
if (bti.isValid() && m_proFile.startsWith(bti.projectFilePath.toString())) {
|
||||||
targetFile = bti.targetFilePath.toString();
|
targetFile = bti.targetFilePath.toString();
|
||||||
if (Utils::HostOsInfo::isWindowsHost()
|
if (Utils::HostOsInfo::isWindowsHost() && !targetFile.toLower().endsWith(".exe"))
|
||||||
&& !targetFile.toLower().endsWith(QLatin1String(".exe"))) {
|
|
||||||
targetFile = Utils::HostOsInfo::withExecutableSuffix(targetFile);
|
targetFile = Utils::HostOsInfo::withExecutableSuffix(targetFile);
|
||||||
}
|
|
||||||
targetName = bti.targetName;
|
targetName = bti.targetName;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -274,7 +272,7 @@ QString TestConfiguration::executableFilePath() const
|
|||||||
} else if (commandFileInfo.path() == "."){
|
} else if (commandFileInfo.path() == "."){
|
||||||
QString fullCommandFileName = m_targetFile;
|
QString fullCommandFileName = m_targetFile;
|
||||||
if (Utils::HostOsInfo::isWindowsHost() && !m_targetFile.endsWith(".exe"))
|
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
|
// TODO: check if we can use searchInPath() from Utils::Environment
|
||||||
const QStringList &pathList = m_environment.toProcessEnvironment().value("PATH").split(
|
const QStringList &pathList = m_environment.toProcessEnvironment().value("PATH").split(
|
||||||
Utils::HostOsInfo::pathListSeparator());
|
Utils::HostOsInfo::pathListSeparator());
|
||||||
|
@@ -60,7 +60,7 @@ class TestNavigationWidget : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit TestNavigationWidget(QWidget *parent = 0);
|
explicit TestNavigationWidget(QWidget *parent = 0);
|
||||||
~TestNavigationWidget();
|
~TestNavigationWidget();
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
||||||
QList<QToolButton *> createToolButtons();
|
QList<QToolButton *> createToolButtons();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -94,7 +94,7 @@ public:
|
|||||||
TestNavigationWidgetFactory();
|
TestNavigationWidgetFactory();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::NavigationView createWidget();
|
Core::NavigationView createWidget() override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -48,34 +48,34 @@ TestResult::TestResult(const QString &name)
|
|||||||
|
|
||||||
const QString TestResult::outputString(bool selected) const
|
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)
|
Result::Type TestResult::resultFromString(const QString &resultString)
|
||||||
{
|
{
|
||||||
if (resultString == QLatin1String("pass"))
|
if (resultString == "pass")
|
||||||
return Result::Pass;
|
return Result::Pass;
|
||||||
if (resultString == QLatin1String("fail"))
|
if (resultString == "fail")
|
||||||
return Result::Fail;
|
return Result::Fail;
|
||||||
if (resultString == QLatin1String("xfail"))
|
if (resultString == "xfail")
|
||||||
return Result::ExpectedFail;
|
return Result::ExpectedFail;
|
||||||
if (resultString == QLatin1String("xpass"))
|
if (resultString == "xpass")
|
||||||
return Result::UnexpectedPass;
|
return Result::UnexpectedPass;
|
||||||
if (resultString == QLatin1String("skip"))
|
if (resultString == "skip")
|
||||||
return Result::Skip;
|
return Result::Skip;
|
||||||
if (resultString == QLatin1String("qdebug"))
|
if (resultString == "qdebug")
|
||||||
return Result::MessageDebug;
|
return Result::MessageDebug;
|
||||||
if (resultString == QLatin1String("qinfo"))
|
if (resultString == "qinfo")
|
||||||
return Result::MessageInfo;
|
return Result::MessageInfo;
|
||||||
if (resultString == QLatin1String("warn") || resultString == QLatin1String("qwarn"))
|
if (resultString == "warn" || resultString == "qwarn")
|
||||||
return Result::MessageWarn;
|
return Result::MessageWarn;
|
||||||
if (resultString == QLatin1String("qfatal"))
|
if (resultString == "qfatal")
|
||||||
return Result::MessageFatal;
|
return Result::MessageFatal;
|
||||||
if (resultString == QLatin1String("system"))
|
if (resultString == "system")
|
||||||
return Result::MessageSystem;
|
return Result::MessageSystem;
|
||||||
if (resultString == QLatin1String("bpass"))
|
if (resultString == "bpass")
|
||||||
return Result::BlacklistedPass;
|
return Result::BlacklistedPass;
|
||||||
if (resultString == QLatin1String("bfail"))
|
if (resultString == "bfail")
|
||||||
return Result::BlacklistedFail;
|
return Result::BlacklistedFail;
|
||||||
qDebug("Unexpected test result: %s", qPrintable(resultString));
|
qDebug("Unexpected test result: %s", qPrintable(resultString));
|
||||||
return Result::Invalid;
|
return Result::Invalid;
|
||||||
|
@@ -98,11 +98,11 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||||||
QString output = testResult->outputString(selected);
|
QString output = testResult->outputString(selected);
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
output.replace(QLatin1Char('\n'), QChar::LineSeparator);
|
output.replace('\n', QChar::LineSeparator);
|
||||||
|
|
||||||
if (AutotestPlugin::instance()->settings()->limitResultOutput
|
if (AutotestPlugin::instance()->settings()->limitResultOutput
|
||||||
&& output.length() > outputLimit)
|
&& output.length() > outputLimit)
|
||||||
output = output.left(outputLimit).append(QLatin1String("..."));
|
output = output.left(outputLimit).append("...");
|
||||||
|
|
||||||
recalculateTextLayout(index, output, painter->font(), positions.textAreaWidth());
|
recalculateTextLayout(index, output, painter->font(), positions.textAreaWidth());
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString file = testResult->fileName();
|
QString file = testResult->fileName();
|
||||||
const int pos = file.lastIndexOf(QLatin1Char('/'));
|
const int pos = file.lastIndexOf('/');
|
||||||
if (pos != -1)
|
if (pos != -1)
|
||||||
file = file.mid(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);
|
const TestResult *testResult = resultFilterModel->testResult(index);
|
||||||
QTC_ASSERT(testResult, return QSize());
|
QTC_ASSERT(testResult, return QSize());
|
||||||
QString output = testResult->outputString(selected);
|
QString output = testResult->outputString(selected);
|
||||||
output.replace(QLatin1Char('\n'), QChar::LineSeparator);
|
output.replace('\n', QChar::LineSeparator);
|
||||||
|
|
||||||
if (AutotestPlugin::instance()->settings()->limitResultOutput
|
if (AutotestPlugin::instance()->settings()->limitResultOutput
|
||||||
&& output.length() > outputLimit)
|
&& output.length() > outputLimit)
|
||||||
output = output.left(outputLimit).append(QLatin1String("..."));
|
output = output.left(outputLimit).append("...");
|
||||||
|
|
||||||
recalculateTextLayout(index, output, opt.font, positions.textAreaWidth());
|
recalculateTextLayout(index, output, opt.font, positions.textAreaWidth());
|
||||||
|
|
||||||
|
@@ -39,8 +39,8 @@ class TestResultDelegate : public QStyledItemDelegate
|
|||||||
public:
|
public:
|
||||||
explicit TestResultDelegate(QObject *parent = 0);
|
explicit TestResultDelegate(QObject *parent = 0);
|
||||||
|
|
||||||
void paint(QPainter *painter, 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;
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -64,7 +64,7 @@ private:
|
|||||||
m_maxFileLength = srcModel->maxWidthOfFileName(options.font);
|
m_maxFileLength = srcModel->maxWidthOfFileName(options.font);
|
||||||
m_maxLineLength = srcModel->maxWidthOfLineNumber(options.font);
|
m_maxLineLength = srcModel->maxWidthOfLineNumber(options.font);
|
||||||
m_realFileLength = m_maxFileLength;
|
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(
|
m_indentation = options.widget ? options.widget->style()->pixelMetric(
|
||||||
QStyle::PM_TreeViewIndentation, &options) : 0;
|
QStyle::PM_TreeViewIndentation, &options) : 0;
|
||||||
m_level = filterModel->mapToSource(options.index).parent() == srcModel->rootItem()->index() ? 1 : 2;
|
m_level = filterModel->mapToSource(options.index).parent() == srcModel->rootItem()->index() ? 1 : 2;
|
||||||
|
@@ -128,10 +128,7 @@ void TestResultItem::updateResult()
|
|||||||
/********************************* TestResultModel *****************************************/
|
/********************************* TestResultModel *****************************************/
|
||||||
|
|
||||||
TestResultModel::TestResultModel(QObject *parent)
|
TestResultModel::TestResultModel(QObject *parent)
|
||||||
: Utils::TreeModel<>(parent),
|
: Utils::TreeModel<>(parent)
|
||||||
m_widthOfLineNumber(0),
|
|
||||||
m_maxWidthOfFileName(0),
|
|
||||||
m_disabled(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +241,7 @@ int TestResultModel::maxWidthOfFileName(const QFont &font)
|
|||||||
const TestResultItem *item = static_cast<TestResultItem *>(children.at(childRow));
|
const TestResultItem *item = static_cast<TestResultItem *>(children.at(childRow));
|
||||||
if (const TestResult *result = item->testResult()) {
|
if (const TestResult *result = item->testResult()) {
|
||||||
QString fileName = result->fileName();
|
QString fileName = result->fileName();
|
||||||
const int pos = fileName.lastIndexOf(QLatin1Char('/'));
|
const int pos = fileName.lastIndexOf('/');
|
||||||
if (pos != -1)
|
if (pos != -1)
|
||||||
fileName = fileName.mid(pos + 1);
|
fileName = fileName.mid(pos + 1);
|
||||||
m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.width(fileName));
|
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) {
|
if (m_widthOfLineNumber == 0 || font != m_measurementFont) {
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
m_measurementFont = font;
|
m_measurementFont = font;
|
||||||
m_widthOfLineNumber = fm.width(QLatin1String("88888"));
|
m_widthOfLineNumber = fm.width("88888");
|
||||||
}
|
}
|
||||||
return m_widthOfLineNumber;
|
return m_widthOfLineNumber;
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ class TestResultItem : public Utils::TreeItem
|
|||||||
public:
|
public:
|
||||||
explicit TestResultItem(const TestResultPtr &testResult);
|
explicit TestResultItem(const TestResultPtr &testResult);
|
||||||
~TestResultItem();
|
~TestResultItem();
|
||||||
QVariant data(int column, int role) const;
|
QVariant data(int column, int role) const override;
|
||||||
const TestResult *testResult() const { return m_testResult.data(); }
|
const TestResult *testResult() const { return m_testResult.data(); }
|
||||||
void updateDescription(const QString &description);
|
void updateDescription(const QString &description);
|
||||||
void updateResult();
|
void updateResult();
|
||||||
@@ -70,9 +70,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<Result::Type, int> m_testResultCount;
|
QMap<Result::Type, int> m_testResultCount;
|
||||||
int m_widthOfLineNumber;
|
int m_widthOfLineNumber = 0;
|
||||||
int m_maxWidthOfFileName;
|
int m_maxWidthOfFileName = 0;
|
||||||
int m_disabled;
|
int m_disabled = 0;
|
||||||
QList<int> m_processedIndices;
|
QList<int> m_processedIndices;
|
||||||
QFont m_measurementFont;
|
QFont m_measurementFont;
|
||||||
};
|
};
|
||||||
@@ -81,7 +81,7 @@ class TestResultFilterModel : public QSortFilterProxyModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TestResultFilterModel(TestResultModel *sourceModel, QObject *parent = 0);
|
explicit TestResultFilterModel(TestResultModel *sourceModel, QObject *parent = 0);
|
||||||
|
|
||||||
void enableAllResultTypes();
|
void enableAllResultTypes();
|
||||||
void toggleTestResultType(Result::Type type);
|
void toggleTestResultType(Result::Type type);
|
||||||
@@ -90,7 +90,7 @@ public:
|
|||||||
const TestResult *testResult(const QModelIndex &index) const;
|
const TestResult *testResult(const QModelIndex &index) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool acceptTestCaseResult(const QModelIndex &index) const;
|
bool acceptTestCaseResult(const QModelIndex &index) const;
|
||||||
|
@@ -77,10 +77,7 @@ void ResultsTreeView::keyPressEvent(QKeyEvent *event)
|
|||||||
|
|
||||||
TestResultsPane::TestResultsPane(QObject *parent) :
|
TestResultsPane::TestResultsPane(QObject *parent) :
|
||||||
Core::IOutputPane(parent),
|
Core::IOutputPane(parent),
|
||||||
m_context(new Core::IContext(this)),
|
m_context(new Core::IContext(this))
|
||||||
m_wasVisibleBefore(false),
|
|
||||||
m_autoScroll(false),
|
|
||||||
m_testRunning(false)
|
|
||||||
{
|
{
|
||||||
m_outputWidget = new QWidget;
|
m_outputWidget = new QWidget;
|
||||||
QVBoxLayout *outputLayout = new QVBoxLayout;
|
QVBoxLayout *outputLayout = new QVBoxLayout;
|
||||||
@@ -441,32 +438,28 @@ void TestResultsPane::initializeFilterMenu()
|
|||||||
|
|
||||||
void TestResultsPane::updateSummaryLabel()
|
void TestResultsPane::updateSummaryLabel()
|
||||||
{
|
{
|
||||||
QString labelText = QString::fromLatin1("<p>Test summary: %1 %2, %3 %4")
|
QString labelText = QString("<p>Test summary: %1 %2, %3 %4")
|
||||||
.arg(QString::number(m_model->resultTypeCount(Result::Pass)), tr("passes"),
|
.arg(QString::number(m_model->resultTypeCount(Result::Pass)), tr("passes"),
|
||||||
QString::number(m_model->resultTypeCount(Result::Fail)), tr("fails"));
|
QString::number(m_model->resultTypeCount(Result::Fail)), tr("fails"));
|
||||||
int count = m_model->resultTypeCount(Result::UnexpectedPass);
|
int count = m_model->resultTypeCount(Result::UnexpectedPass);
|
||||||
if (count)
|
if (count)
|
||||||
labelText.append(QString::fromLatin1(", %1 %2")
|
labelText.append(QString(", %1 %2").arg(QString::number(count), tr("unexpected passes")));
|
||||||
.arg(QString::number(count), tr("unexpected passes")));
|
|
||||||
count = m_model->resultTypeCount(Result::ExpectedFail);
|
count = m_model->resultTypeCount(Result::ExpectedFail);
|
||||||
if (count)
|
if (count)
|
||||||
labelText.append(QString::fromLatin1(", %1 %2")
|
labelText.append(QString(", %1 %2").arg(QString::number(count), tr("expected fails")));
|
||||||
.arg(QString::number(count), tr("expected fails")));
|
|
||||||
count = m_model->resultTypeCount(Result::MessageFatal);
|
count = m_model->resultTypeCount(Result::MessageFatal);
|
||||||
if (count)
|
if (count)
|
||||||
labelText.append(QString::fromLatin1(", %1 %2")
|
labelText.append(QString(", %1 %2").arg(QString::number(count), tr("fatals")));
|
||||||
.arg(QString::number(count), tr("fatals")));
|
|
||||||
count = m_model->resultTypeCount(Result::BlacklistedFail)
|
count = m_model->resultTypeCount(Result::BlacklistedFail)
|
||||||
+ m_model->resultTypeCount(Result::BlacklistedPass);
|
+ m_model->resultTypeCount(Result::BlacklistedPass);
|
||||||
if (count)
|
if (count)
|
||||||
labelText.append(QString::fromLatin1(", %1 %2")
|
labelText.append(QString(", %1 %2").arg(QString::number(count), tr("blacklisted")));
|
||||||
.arg(QString::number(count), tr("blacklisted")));
|
|
||||||
|
|
||||||
count = m_model->disabledTests();
|
count = m_model->disabledTests();
|
||||||
if (count)
|
if (count)
|
||||||
labelText.append(tr(", %1 disabled").arg(count));
|
labelText.append(tr(", %1 disabled").arg(count));
|
||||||
|
|
||||||
labelText.append(QLatin1String(".</p>"));
|
labelText.append(".</p>");
|
||||||
m_summaryLabel->setText(labelText);
|
m_summaryLabel->setText(labelText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,8 +579,8 @@ QString TestResultsPane::getWholeOutput(const QModelIndex &parent)
|
|||||||
QModelIndex current = m_model->index(row, 0, parent);
|
QModelIndex current = m_model->index(row, 0, parent);
|
||||||
const TestResult *result = m_model->testResult(current);
|
const TestResult *result = m_model->testResult(current);
|
||||||
QTC_ASSERT(result, continue);
|
QTC_ASSERT(result, continue);
|
||||||
output.append(TestResult::resultToString(result->result())).append(QLatin1Char('\t'));
|
output.append(TestResult::resultToString(result->result())).append('\t');
|
||||||
output.append(result->outputString(true)).append(QLatin1Char('\n'));
|
output.append(result->outputString(true)).append('\n');
|
||||||
output.append(getWholeOutput(current));
|
output.append(getWholeOutput(current));
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
|
@@ -55,7 +55,7 @@ class ResultsTreeView : public Utils::TreeView
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ResultsTreeView(QWidget *parent = 0);
|
explicit ResultsTreeView(QWidget *parent = 0);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void copyShortcutTriggered();
|
void copyShortcutTriggered();
|
||||||
@@ -72,20 +72,20 @@ public:
|
|||||||
static TestResultsPane *instance();
|
static TestResultsPane *instance();
|
||||||
|
|
||||||
// IOutputPane interface
|
// IOutputPane interface
|
||||||
QWidget *outputWidget(QWidget *parent);
|
QWidget *outputWidget(QWidget *parent) override;
|
||||||
QList<QWidget *> toolBarWidgets() const;
|
QList<QWidget *> toolBarWidgets() const override;
|
||||||
QString displayName() const;
|
QString displayName() const override;
|
||||||
int priorityInStatusBar() const;
|
int priorityInStatusBar() const override;
|
||||||
void clearContents();
|
void clearContents() override;
|
||||||
void visibilityChanged(bool visible);
|
void visibilityChanged(bool visible) override;
|
||||||
void setFocus();
|
void setFocus() override;
|
||||||
bool hasFocus() const;
|
bool hasFocus() const override;
|
||||||
bool canFocus() const;
|
bool canFocus() const override;
|
||||||
bool canNavigate() const;
|
bool canNavigate() const override;
|
||||||
bool canNext() const;
|
bool canNext() const override;
|
||||||
bool canPrevious() const;
|
bool canPrevious() const override;
|
||||||
void goToNext();
|
void goToNext() override;
|
||||||
void goToPrev();
|
void goToPrev() override;
|
||||||
|
|
||||||
void addTestResult(const TestResultPtr &result);
|
void addTestResult(const TestResultPtr &result);
|
||||||
|
|
||||||
@@ -124,10 +124,10 @@ private:
|
|||||||
QToolButton *m_stopTestRun;
|
QToolButton *m_stopTestRun;
|
||||||
QToolButton *m_filterButton;
|
QToolButton *m_filterButton;
|
||||||
QMenu *m_filterMenu;
|
QMenu *m_filterMenu;
|
||||||
bool m_wasVisibleBefore;
|
bool m_wasVisibleBefore = false;
|
||||||
bool m_autoScroll;
|
bool m_autoScroll = false;
|
||||||
bool m_atEnd;
|
bool m_atEnd = false;
|
||||||
bool m_testRunning;
|
bool m_testRunning = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -141,7 +141,7 @@ static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
|
|||||||
testProcess.setArguments(testConfiguration->argumentsForTestRunner(settings));
|
testProcess.setArguments(testConfiguration->argumentsForTestRunner(settings));
|
||||||
testProcess.setWorkingDirectory(testConfiguration->workingDirectory());
|
testProcess.setWorkingDirectory(testConfiguration->workingDirectory());
|
||||||
if (Utils::HostOsInfo::isWindowsHost())
|
if (Utils::HostOsInfo::isWindowsHost())
|
||||||
environment.insert(QLatin1String("QT_LOGGING_TO_CONSOLE"), QLatin1String("1"));
|
environment.insert("QT_LOGGING_TO_CONSOLE", "1");
|
||||||
testProcess.setProcessEnvironment(environment);
|
testProcess.setProcessEnvironment(environment);
|
||||||
testProcess.setProgram(commandFilePath);
|
testProcess.setProgram(commandFilePath);
|
||||||
testProcess.start();
|
testProcess.start();
|
||||||
|
@@ -50,13 +50,13 @@ TestSettings::TestSettings()
|
|||||||
|
|
||||||
void TestSettings::toSettings(QSettings *s) const
|
void TestSettings::toSettings(QSettings *s) const
|
||||||
{
|
{
|
||||||
s->beginGroup(QLatin1String(group));
|
s->beginGroup(group);
|
||||||
s->setValue(QLatin1String(timeoutKey), timeout);
|
s->setValue(timeoutKey, timeout);
|
||||||
s->setValue(QLatin1String(omitInternalKey), omitInternalMssg);
|
s->setValue(omitInternalKey, omitInternalMssg);
|
||||||
s->setValue(QLatin1String(omitRunConfigWarnKey), omitRunConfigWarn);
|
s->setValue(omitRunConfigWarnKey, omitRunConfigWarn);
|
||||||
s->setValue(QLatin1String(limitResultOutputKey), limitResultOutput);
|
s->setValue(limitResultOutputKey, limitResultOutput);
|
||||||
s->setValue(QLatin1String(autoScrollKey), autoScroll);
|
s->setValue(autoScrollKey, autoScroll);
|
||||||
s->setValue(QLatin1String(alwaysParseKey), alwaysParse);
|
s->setValue(alwaysParseKey, alwaysParse);
|
||||||
// store frameworks and their current active state
|
// store frameworks and their current active state
|
||||||
for (const Core::Id &id : frameworks.keys())
|
for (const Core::Id &id : frameworks.keys())
|
||||||
s->setValue(QLatin1String(id.name()), frameworks.value(id));
|
s->setValue(QLatin1String(id.name()), frameworks.value(id));
|
||||||
@@ -74,12 +74,12 @@ void TestSettings::toSettings(QSettings *s) const
|
|||||||
void TestSettings::fromSettings(QSettings *s)
|
void TestSettings::fromSettings(QSettings *s)
|
||||||
{
|
{
|
||||||
s->beginGroup(group);
|
s->beginGroup(group);
|
||||||
timeout = s->value(QLatin1String(timeoutKey), defaultTimeout).toInt();
|
timeout = s->value(timeoutKey, defaultTimeout).toInt();
|
||||||
omitInternalMssg = s->value(QLatin1String(omitInternalKey), true).toBool();
|
omitInternalMssg = s->value(omitInternalKey, true).toBool();
|
||||||
omitRunConfigWarn = s->value(QLatin1String(omitRunConfigWarnKey), false).toBool();
|
omitRunConfigWarn = s->value(omitRunConfigWarnKey, false).toBool();
|
||||||
limitResultOutput = s->value(QLatin1String(limitResultOutputKey), true).toBool();
|
limitResultOutput = s->value(limitResultOutputKey, true).toBool();
|
||||||
autoScroll = s->value(QLatin1String(autoScrollKey), true).toBool();
|
autoScroll = s->value(autoScrollKey, true).toBool();
|
||||||
alwaysParse = s->value(QLatin1String(alwaysParseKey), true).toBool();
|
alwaysParse = s->value(alwaysParseKey, true).toBool();
|
||||||
// try to get settings for registered frameworks
|
// try to get settings for registered frameworks
|
||||||
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
|
TestFrameworkManager *frameworkManager = TestFrameworkManager::instance();
|
||||||
const QList<Core::Id> ®istered = frameworkManager->registeredFrameworkIds();
|
const QList<Core::Id> ®istered = frameworkManager->registeredFrameworkIds();
|
||||||
|
@@ -60,9 +60,9 @@ public:
|
|||||||
explicit TestSettingsPage(const QSharedPointer<TestSettings> &settings);
|
explicit TestSettingsPage(const QSharedPointer<TestSettings> &settings);
|
||||||
~TestSettingsPage();
|
~TestSettingsPage();
|
||||||
|
|
||||||
QWidget *widget();
|
QWidget *widget() override;
|
||||||
void apply();
|
void apply() override;
|
||||||
void finish() { }
|
void finish() override { }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<TestSettings> m_settings;
|
QSharedPointer<TestSettings> m_settings;
|
||||||
|
@@ -40,9 +40,7 @@ namespace Internal {
|
|||||||
TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type type)
|
TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type type)
|
||||||
: m_name(name),
|
: m_name(name),
|
||||||
m_filePath(filePath),
|
m_filePath(filePath),
|
||||||
m_type(type),
|
m_type(type)
|
||||||
m_line(0),
|
|
||||||
m_status(NewlyAdded)
|
|
||||||
{
|
{
|
||||||
m_checked = (m_type == TestCase || m_type == TestFunctionOrSet) ? Qt::Checked : Qt::Unchecked;
|
m_checked = (m_type == TestCase || m_type == TestFunctionOrSet) ? Qt::Checked : Qt::Unchecked;
|
||||||
}
|
}
|
||||||
|
@@ -64,8 +64,8 @@ public:
|
|||||||
Naturally
|
Naturally
|
||||||
};
|
};
|
||||||
|
|
||||||
TestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
|
explicit TestTreeItem(const QString &name = QString(), const QString &filePath = QString(),
|
||||||
Type type = Root);
|
Type type = Root);
|
||||||
|
|
||||||
virtual QVariant data(int column, int role) const override;
|
virtual QVariant data(int column, int role) const override;
|
||||||
virtual bool setData(int column, const QVariant &data, int role) override;
|
virtual bool setData(int column, const QVariant &data, int role) override;
|
||||||
@@ -131,19 +131,19 @@ private:
|
|||||||
QString m_filePath;
|
QString m_filePath;
|
||||||
Qt::CheckState m_checked;
|
Qt::CheckState m_checked;
|
||||||
Type m_type;
|
Type m_type;
|
||||||
unsigned m_line;
|
unsigned m_line = 0;
|
||||||
unsigned m_column;
|
unsigned m_column = 0;
|
||||||
QString m_proFile;
|
QString m_proFile;
|
||||||
Status m_status;
|
Status m_status = NewlyAdded;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestCodeLocationAndType
|
class TestCodeLocationAndType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString m_name; // tag name for m_type == TEST_DATATAG, file name for other values
|
QString m_name; // tag name for m_type == TEST_DATATAG, file name for other values
|
||||||
unsigned m_line;
|
unsigned m_line = 0;
|
||||||
unsigned m_column;
|
unsigned m_column = 0;
|
||||||
TestTreeItem::Type m_type;
|
TestTreeItem::Type m_type = TestTreeItem::Root;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QVector<TestCodeLocationAndType> TestCodeLocationList;
|
typedef QVector<TestCodeLocationAndType> TestCodeLocationList;
|
||||||
|
@@ -34,11 +34,11 @@ class TestTreeItemDelegate : public QStyledItemDelegate
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TestTreeItemDelegate(QObject *parent = 0);
|
explicit TestTreeItemDelegate(QObject *parent = 0);
|
||||||
~TestTreeItemDelegate();
|
~TestTreeItemDelegate();
|
||||||
|
|
||||||
public:
|
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
|
} // namespace Internal
|
||||||
|
@@ -43,8 +43,7 @@ namespace Internal {
|
|||||||
|
|
||||||
TestTreeModel::TestTreeModel(QObject *parent) :
|
TestTreeModel::TestTreeModel(QObject *parent) :
|
||||||
TreeModel<>(parent),
|
TreeModel<>(parent),
|
||||||
m_parser(new TestCodeParser(this)),
|
m_parser(new TestCodeParser(this))
|
||||||
m_connectionsInitialized(false)
|
|
||||||
{
|
{
|
||||||
connect(m_parser, &TestCodeParser::aboutToPerformFullParse, this,
|
connect(m_parser, &TestCodeParser::aboutToPerformFullParse, this,
|
||||||
&TestTreeModel::removeAllTestItems, Qt::QueuedConnection);
|
&TestTreeModel::removeAllTestItems, Qt::QueuedConnection);
|
||||||
@@ -415,9 +414,7 @@ QMultiMap<QString, int> TestTreeModel::gtestNamesAndSets() const
|
|||||||
|
|
||||||
TestTreeSortFilterModel::TestTreeSortFilterModel(TestTreeModel *sourceModel, QObject *parent)
|
TestTreeSortFilterModel::TestTreeSortFilterModel(TestTreeModel *sourceModel, QObject *parent)
|
||||||
: QSortFilterProxyModel(parent),
|
: QSortFilterProxyModel(parent),
|
||||||
m_sourceModel(sourceModel),
|
m_sourceModel(sourceModel)
|
||||||
m_sortMode(TestTreeItem::Alphabetically),
|
|
||||||
m_filterMode(Basic)
|
|
||||||
{
|
{
|
||||||
setSourceModel(sourceModel);
|
setSourceModel(sourceModel);
|
||||||
}
|
}
|
||||||
|
@@ -94,7 +94,7 @@ private:
|
|||||||
void setupParsingConnections();
|
void setupParsingConnections();
|
||||||
|
|
||||||
TestCodeParser *m_parser;
|
TestCodeParser *m_parser;
|
||||||
bool m_connectionsInitialized;
|
bool m_connectionsInitialized = false;
|
||||||
QAtomicInt m_refCounter;
|
QAtomicInt m_refCounter;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ public:
|
|||||||
ShowAll = ShowInitAndCleanup | ShowTestData
|
ShowAll = ShowInitAndCleanup | ShowTestData
|
||||||
};
|
};
|
||||||
|
|
||||||
TestTreeSortFilterModel(TestTreeModel *sourceModel, QObject *parent = 0);
|
explicit TestTreeSortFilterModel(TestTreeModel *sourceModel, QObject *parent = 0);
|
||||||
void setSortMode(TestTreeItem::SortMode sortMode);
|
void setSortMode(TestTreeItem::SortMode sortMode);
|
||||||
void setFilterMode(FilterMode filterMode);
|
void setFilterMode(FilterMode filterMode);
|
||||||
void toggleFilter(FilterMode filterMode);
|
void toggleFilter(FilterMode filterMode);
|
||||||
@@ -121,8 +121,8 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
TestTreeModel *m_sourceModel;
|
TestTreeModel *m_sourceModel;
|
||||||
TestTreeItem::SortMode m_sortMode;
|
TestTreeItem::SortMode m_sortMode = TestTreeItem::Alphabetically;
|
||||||
FilterMode m_filterMode;
|
FilterMode m_filterMode = Basic;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -39,9 +39,9 @@ class TestTreeView : public Utils::NavigationTreeView
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestTreeView(QWidget *parent = 0);
|
explicit TestTreeView(QWidget *parent = 0);
|
||||||
|
|
||||||
void selectAll();
|
void selectAll() override;
|
||||||
void deselectAll();
|
void deselectAll();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user