forked from qt-creator/qt-creator
AutoTest: Refactor TestResult
* use enum class * remove superfluous enum value * remove superfluous subclass * remove superfluous constructors * simplify handling Change-Id: Iecf11e62eb842c9d455d9238939244496f6b66f4 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -221,7 +221,7 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine)
|
||||
m_description.clear();
|
||||
m_duration.clear();
|
||||
m_file.clear();
|
||||
m_result = Result::Invalid;
|
||||
m_result = ResultType::Invalid;
|
||||
m_lineNumber = 0;
|
||||
const QXmlStreamAttributes &attributes = m_xmlReader.attributes();
|
||||
m_result = TestResult::resultFromString(
|
||||
@@ -237,19 +237,19 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine)
|
||||
const int iterations = attributes.value(QStringLiteral("iterations")).toInt();
|
||||
m_dataTag = attributes.value(QStringLiteral("tag")).toString();
|
||||
m_description = constructBenchmarkInformation(metric, value, iterations);
|
||||
m_result = Result::Benchmark;
|
||||
m_result = ResultType::Benchmark;
|
||||
} else if (currentTag == QStringLiteral("DataTag")) {
|
||||
m_cdataMode = DataTag;
|
||||
} else if (currentTag == QStringLiteral("Description")) {
|
||||
m_cdataMode = Description;
|
||||
} else if (currentTag == QStringLiteral("QtVersion")) {
|
||||
m_result = Result::MessageInternal;
|
||||
m_result = ResultType::MessageInternal;
|
||||
m_cdataMode = QtVersion;
|
||||
} else if (currentTag == QStringLiteral("QtBuild")) {
|
||||
m_result = Result::MessageInternal;
|
||||
m_result = ResultType::MessageInternal;
|
||||
m_cdataMode = QtBuild;
|
||||
} else if (currentTag == QStringLiteral("QTestVersion")) {
|
||||
m_result = Result::MessageInternal;
|
||||
m_result = ResultType::MessageInternal;
|
||||
m_cdataMode = QTestVersion;
|
||||
}
|
||||
break;
|
||||
@@ -308,7 +308,7 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine)
|
||||
&& m_xmlReader.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
|
||||
createAndReportResult(tr("XML parsing failed.")
|
||||
+ QString(" (%1) ").arg(m_xmlReader.error())
|
||||
+ m_xmlReader.errorString(), Result::MessageFatal);
|
||||
+ m_xmlReader.errorString(), ResultType::MessageFatal);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -317,7 +317,7 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine)
|
||||
|
||||
static QStringList extractFunctionInformation(const QString &testClassName,
|
||||
const QString &lineWithoutResultType,
|
||||
Result::Type resultType)
|
||||
ResultType resultType)
|
||||
{
|
||||
static QRegularExpression classInformation("^(.+?)\\((.*?)\\)(.*)$");
|
||||
QStringList result;
|
||||
@@ -327,7 +327,7 @@ static QStringList extractFunctionInformation(const QString &testClassName,
|
||||
QTC_ASSERT(fullQualifiedFunc.startsWith(testClassName + "::"), return result);
|
||||
fullQualifiedFunc = fullQualifiedFunc.mid(testClassName.length() + 2);
|
||||
result.append(fullQualifiedFunc);
|
||||
if (resultType == Result::Benchmark) { // tag is displayed differently
|
||||
if (resultType == ResultType::Benchmark) { // tag is displayed differently
|
||||
QString possiblyTag = match.captured(3);
|
||||
if (!possiblyTag.isEmpty())
|
||||
possiblyTag = possiblyTag.mid(2, possiblyTag.length() - 4);
|
||||
@@ -452,7 +452,7 @@ void QtTestOutputReader::processSummaryFinishOutput()
|
||||
sendFinishMessage(false);
|
||||
m_className.clear();
|
||||
m_description.clear();
|
||||
m_result = Result::Invalid;
|
||||
m_result = ResultType::Invalid;
|
||||
m_file.clear();
|
||||
m_lineNumber = 0;
|
||||
}
|
||||
@@ -478,16 +478,16 @@ void QtTestOutputReader::sendCompleteInformation()
|
||||
|
||||
void QtTestOutputReader::sendMessageCurrentTest()
|
||||
{
|
||||
TestResultPtr testResult = TestResultPtr(new QtTestResult(m_projectFile, m_testType));
|
||||
testResult->setResult(Result::MessageCurrentTest);
|
||||
QtTestResult *testResult = new QtTestResult(QString(), m_projectFile, m_testType, QString());
|
||||
testResult->setResult(ResultType::MessageCurrentTest);
|
||||
testResult->setDescription(tr("Entering test function %1::%2").arg(m_className, m_testCase));
|
||||
reportResult(testResult);
|
||||
reportResult(TestResultPtr(testResult));
|
||||
}
|
||||
|
||||
void QtTestOutputReader::sendStartMessage(bool isFunction)
|
||||
{
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(Result::MessageTestCaseStart);
|
||||
testResult->setResult(ResultType::TestStart);
|
||||
testResult->setDescription(isFunction ? tr("Executing test function %1").arg(m_testCase)
|
||||
: tr("Executing test case %1").arg(m_className));
|
||||
const TestTreeItem *testItem = testResult->findTestTreeItem();
|
||||
@@ -501,7 +501,7 @@ void QtTestOutputReader::sendStartMessage(bool isFunction)
|
||||
void QtTestOutputReader::sendFinishMessage(bool isFunction)
|
||||
{
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(Result::MessageTestCaseEnd);
|
||||
testResult->setResult(ResultType::TestEnd);
|
||||
if (!m_duration.isEmpty()) {
|
||||
testResult->setDescription(isFunction ? tr("Execution took %1 ms.").arg(m_duration)
|
||||
: tr("Test execution took %1 ms.").arg(m_duration));
|
||||
@@ -515,15 +515,15 @@ void QtTestOutputReader::sendFinishMessage(bool isFunction)
|
||||
void QtTestOutputReader::handleAndSendConfigMessage(const QRegularExpressionMatch &config)
|
||||
{
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(Result::MessageInternal);
|
||||
testResult->setResult(ResultType::MessageInternal);
|
||||
testResult->setDescription(trQtVersion(config.captured(3)));
|
||||
reportResult(testResult);
|
||||
testResult = createDefaultResult();
|
||||
testResult->setResult(Result::MessageInternal);
|
||||
testResult->setResult(ResultType::MessageInternal);
|
||||
testResult->setDescription(trQtBuild(config.captured(2)));
|
||||
reportResult(testResult);
|
||||
testResult = createDefaultResult();
|
||||
testResult->setResult(Result::MessageInternal);
|
||||
testResult->setResult(ResultType::MessageInternal);
|
||||
testResult->setDescription(trQtestVersion(config.captured(1)));
|
||||
reportResult(testResult);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user