forked from qt-creator/qt-creator
Simplify conversion from/to Result::Type
Additionally rename enum value UNKNOWN to INVALID. Change-Id: I08dc4e371afb576db10716eda00ff6368f9d2311 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
@@ -61,56 +61,23 @@ Result::Type TestResult::resultFromString(const QString &resultString)
|
|||||||
if (resultString == QLatin1String("bfail"))
|
if (resultString == QLatin1String("bfail"))
|
||||||
return Result::BLACKLISTED_FAIL;
|
return Result::BLACKLISTED_FAIL;
|
||||||
qDebug("Unexpected test result: %s", qPrintable(resultString));
|
qDebug("Unexpected test result: %s", qPrintable(resultString));
|
||||||
return Result::UNKNOWN;
|
return Result::INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result::Type TestResult::toResultType(int rt)
|
Result::Type TestResult::toResultType(int rt)
|
||||||
{
|
{
|
||||||
switch(rt) {
|
if (rt < Result::FIRST_TYPE || rt > Result::LAST_TYPE)
|
||||||
case Result::PASS:
|
return Result::INVALID;
|
||||||
return Result::PASS;
|
|
||||||
case Result::FAIL:
|
return (Result::Type)rt;
|
||||||
return Result::FAIL;
|
|
||||||
case Result::EXPECTED_FAIL:
|
|
||||||
return Result::EXPECTED_FAIL;
|
|
||||||
case Result::UNEXPECTED_PASS:
|
|
||||||
return Result::UNEXPECTED_PASS;
|
|
||||||
case Result::SKIP:
|
|
||||||
return Result::SKIP;
|
|
||||||
case Result::BLACKLISTED_PASS:
|
|
||||||
return Result::BLACKLISTED_PASS;
|
|
||||||
case Result::BLACKLISTED_FAIL:
|
|
||||||
return Result::BLACKLISTED_FAIL;
|
|
||||||
case Result::BENCHMARK:
|
|
||||||
return Result::BENCHMARK;
|
|
||||||
case Result::MESSAGE_DEBUG:
|
|
||||||
return Result::MESSAGE_DEBUG;
|
|
||||||
case Result::MESSAGE_WARN:
|
|
||||||
return Result::MESSAGE_WARN;
|
|
||||||
case Result::MESSAGE_FATAL:
|
|
||||||
return Result::MESSAGE_FATAL;
|
|
||||||
case Result::MESSAGE_INTERNAL:
|
|
||||||
return Result::MESSAGE_INTERNAL;
|
|
||||||
case Result::MESSAGE_TEST_CASE_START:
|
|
||||||
return Result::MESSAGE_TEST_CASE_START;
|
|
||||||
case Result::MESSAGE_TEST_CASE_SUCCESS:
|
|
||||||
return Result::MESSAGE_TEST_CASE_SUCCESS;
|
|
||||||
case Result::MESSAGE_TEST_CASE_WARN:
|
|
||||||
return Result::MESSAGE_TEST_CASE_WARN;
|
|
||||||
case Result::MESSAGE_TEST_CASE_FAIL:
|
|
||||||
return Result::MESSAGE_TEST_CASE_FAIL;
|
|
||||||
case Result::MESSAGE_TEST_CASE_END:
|
|
||||||
return Result::MESSAGE_TEST_CASE_END;
|
|
||||||
case Result::MESSAGE_CURRENT_TEST:
|
|
||||||
return Result::MESSAGE_CURRENT_TEST;
|
|
||||||
default:
|
|
||||||
return Result::UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TestResult::resultToString(const Result::Type type)
|
QString TestResult::resultToString(const Result::Type type)
|
||||||
{
|
{
|
||||||
switch(type) {
|
if (type >= Result::INTERNAL_MESSAGES_BEGIN && type <= Result::INTERNAL_MESSAGES_END)
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
case Result::PASS:
|
case Result::PASS:
|
||||||
return QLatin1String("PASS");
|
return QLatin1String("PASS");
|
||||||
case Result::FAIL:
|
case Result::FAIL:
|
||||||
@@ -129,14 +96,6 @@ QString TestResult::resultToString(const Result::Type type)
|
|||||||
return QLatin1String("WARN");
|
return QLatin1String("WARN");
|
||||||
case Result::MESSAGE_FATAL:
|
case Result::MESSAGE_FATAL:
|
||||||
return QLatin1String("FATAL");
|
return QLatin1String("FATAL");
|
||||||
case Result::MESSAGE_INTERNAL:
|
|
||||||
case Result::MESSAGE_TEST_CASE_START:
|
|
||||||
case Result::MESSAGE_TEST_CASE_SUCCESS:
|
|
||||||
case Result::MESSAGE_TEST_CASE_WARN:
|
|
||||||
case Result::MESSAGE_TEST_CASE_FAIL:
|
|
||||||
case Result::MESSAGE_TEST_CASE_END:
|
|
||||||
case Result::MESSAGE_CURRENT_TEST:
|
|
||||||
return QString();
|
|
||||||
case Result::BLACKLISTED_PASS:
|
case Result::BLACKLISTED_PASS:
|
||||||
return QLatin1String("BPASS");
|
return QLatin1String("BPASS");
|
||||||
case Result::BLACKLISTED_FAIL:
|
case Result::BLACKLISTED_FAIL:
|
||||||
@@ -148,7 +107,10 @@ QString TestResult::resultToString(const Result::Type type)
|
|||||||
|
|
||||||
QColor TestResult::colorForType(const Result::Type type)
|
QColor TestResult::colorForType(const Result::Type type)
|
||||||
{
|
{
|
||||||
switch(type) {
|
if (type >= Result::INTERNAL_MESSAGES_BEGIN && type <= Result::INTERNAL_MESSAGES_END)
|
||||||
|
return QColor("transparent");
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
case Result::PASS:
|
case Result::PASS:
|
||||||
return QColor("#009900");
|
return QColor("#009900");
|
||||||
case Result::FAIL:
|
case Result::FAIL:
|
||||||
@@ -169,14 +131,6 @@ QColor TestResult::colorForType(const Result::Type type)
|
|||||||
return QColor("#d0bb00");
|
return QColor("#d0bb00");
|
||||||
case Result::MESSAGE_FATAL:
|
case Result::MESSAGE_FATAL:
|
||||||
return QColor("#640000");
|
return QColor("#640000");
|
||||||
case Result::MESSAGE_INTERNAL:
|
|
||||||
case Result::MESSAGE_TEST_CASE_START:
|
|
||||||
case Result::MESSAGE_TEST_CASE_SUCCESS:
|
|
||||||
case Result::MESSAGE_TEST_CASE_WARN:
|
|
||||||
case Result::MESSAGE_TEST_CASE_FAIL:
|
|
||||||
case Result::MESSAGE_TEST_CASE_END:
|
|
||||||
case Result::MESSAGE_CURRENT_TEST:
|
|
||||||
return QColor("transparent");
|
|
||||||
default:
|
default:
|
||||||
return QColor("#000000");
|
return QColor("#000000");
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,7 @@ namespace Internal {
|
|||||||
|
|
||||||
namespace Result{
|
namespace Result{
|
||||||
enum Type {
|
enum Type {
|
||||||
PASS,
|
PASS, FIRST_TYPE = PASS,
|
||||||
FAIL,
|
FAIL,
|
||||||
EXPECTED_FAIL,
|
EXPECTED_FAIL,
|
||||||
UNEXPECTED_PASS,
|
UNEXPECTED_PASS,
|
||||||
@@ -40,14 +40,17 @@ enum Type {
|
|||||||
MESSAGE_DEBUG,
|
MESSAGE_DEBUG,
|
||||||
MESSAGE_WARN,
|
MESSAGE_WARN,
|
||||||
MESSAGE_FATAL,
|
MESSAGE_FATAL,
|
||||||
MESSAGE_INTERNAL,
|
|
||||||
|
MESSAGE_INTERNAL, INTERNAL_MESSAGES_BEGIN = MESSAGE_INTERNAL,
|
||||||
MESSAGE_TEST_CASE_START,
|
MESSAGE_TEST_CASE_START,
|
||||||
MESSAGE_TEST_CASE_SUCCESS,
|
MESSAGE_TEST_CASE_SUCCESS,
|
||||||
MESSAGE_TEST_CASE_WARN,
|
MESSAGE_TEST_CASE_WARN,
|
||||||
MESSAGE_TEST_CASE_FAIL,
|
MESSAGE_TEST_CASE_FAIL,
|
||||||
MESSAGE_TEST_CASE_END,
|
MESSAGE_TEST_CASE_END,
|
||||||
MESSAGE_CURRENT_TEST,
|
MESSAGE_CURRENT_TEST, INTERNAL_MESSAGES_END = MESSAGE_CURRENT_TEST,
|
||||||
UNKNOWN // ???
|
|
||||||
|
INVALID,
|
||||||
|
LAST_TYPE = INVALID
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +60,7 @@ public:
|
|||||||
|
|
||||||
TestResult(const QString &className = QString(), const QString &testCase = QString(),
|
TestResult(const QString &className = QString(), const QString &testCase = QString(),
|
||||||
const QString &dataTag = QString(),
|
const QString &dataTag = QString(),
|
||||||
Result::Type result = Result::UNKNOWN, const QString &description = QString());
|
Result::Type result = Result::INVALID, const QString &description = QString());
|
||||||
|
|
||||||
QString className() const { return m_class; }
|
QString className() const { return m_class; }
|
||||||
QString testCase() const { return m_case; }
|
QString testCase() const { return m_case; }
|
||||||
|
@@ -275,7 +275,7 @@ void TestResultFilterModel::enableAllResultTypes()
|
|||||||
m_enabled << Result::PASS << Result::FAIL << Result::EXPECTED_FAIL
|
m_enabled << Result::PASS << Result::FAIL << Result::EXPECTED_FAIL
|
||||||
<< Result::UNEXPECTED_PASS << Result::SKIP << Result::MESSAGE_DEBUG
|
<< Result::UNEXPECTED_PASS << Result::SKIP << Result::MESSAGE_DEBUG
|
||||||
<< Result::MESSAGE_WARN << Result::MESSAGE_INTERNAL
|
<< Result::MESSAGE_WARN << Result::MESSAGE_INTERNAL
|
||||||
<< Result::MESSAGE_FATAL << Result::UNKNOWN << Result::BLACKLISTED_PASS
|
<< Result::MESSAGE_FATAL << Result::INVALID << Result::BLACKLISTED_PASS
|
||||||
<< Result::BLACKLISTED_FAIL << Result::BENCHMARK
|
<< Result::BLACKLISTED_FAIL << Result::BENCHMARK
|
||||||
<< Result::MESSAGE_CURRENT_TEST << Result::MESSAGE_TEST_CASE_START
|
<< Result::MESSAGE_CURRENT_TEST << Result::MESSAGE_TEST_CASE_START
|
||||||
<< Result::MESSAGE_TEST_CASE_SUCCESS << Result::MESSAGE_TEST_CASE_WARN
|
<< Result::MESSAGE_TEST_CASE_SUCCESS << Result::MESSAGE_TEST_CASE_WARN
|
||||||
|
@@ -195,7 +195,7 @@ void TestXmlOutputReader::processOutput()
|
|||||||
static QString className;
|
static QString className;
|
||||||
static QString testCase;
|
static QString testCase;
|
||||||
static QString dataTag;
|
static QString dataTag;
|
||||||
static Result::Type result = Result::UNKNOWN;
|
static Result::Type result = Result::INVALID;
|
||||||
static QString description;
|
static QString description;
|
||||||
static QString file;
|
static QString file;
|
||||||
static int lineNumber = 0;
|
static int lineNumber = 0;
|
||||||
@@ -223,7 +223,7 @@ void TestXmlOutputReader::processOutput()
|
|||||||
description = QString();
|
description = QString();
|
||||||
duration = QString();
|
duration = QString();
|
||||||
file = QString();
|
file = QString();
|
||||||
result = Result::UNKNOWN;
|
result = Result::INVALID;
|
||||||
lineNumber = 0;
|
lineNumber = 0;
|
||||||
readingDescription = false;
|
readingDescription = false;
|
||||||
testResultCreated(new TestResult(QString(), QString(), QString(), Result::MESSAGE_CURRENT_TEST,
|
testResultCreated(new TestResult(QString(), QString(), QString(), Result::MESSAGE_CURRENT_TEST,
|
||||||
|
Reference in New Issue
Block a user