summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@theqtcompany.com>2015-09-23 07:14:25 +0200
committerChristian Stenger <christian.stenger@theqtcompany.com>2015-10-08 17:32:48 +0300
commit17fbe92100d194250dd7567232b58830d9d447e4 (patch)
tree44f5544f13b0aaf9401e60010ae9c2946682f103
parent55f3dcb6b56ac77f64073f64a99467c5c16285df (diff)
downloadqt-creator-17fbe92100d194250dd7567232b58830d9d447e4.tar.gz
Simplify conversion from/to Result::Type
Additionally rename enum value UNKNOWN to INVALID. Change-Id: I08dc4e371afb576db10716eda00ff6368f9d2311 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
-rw-r--r--plugins/autotest/testresult.cpp72
-rw-r--r--plugins/autotest/testresult.h13
-rw-r--r--plugins/autotest/testresultmodel.cpp2
-rw-r--r--plugins/autotest/testxmloutputreader.cpp4
4 files changed, 24 insertions, 67 deletions
diff --git a/plugins/autotest/testresult.cpp b/plugins/autotest/testresult.cpp
index 0ce300eade..8859d8fb1a 100644
--- a/plugins/autotest/testresult.cpp
+++ b/plugins/autotest/testresult.cpp
@@ -61,56 +61,23 @@ Result::Type TestResult::resultFromString(const QString &resultString)
if (resultString == QLatin1String("bfail"))
return Result::BLACKLISTED_FAIL;
qDebug("Unexpected test result: %s", qPrintable(resultString));
- return Result::UNKNOWN;
+ return Result::INVALID;
}
Result::Type TestResult::toResultType(int rt)
{
- switch(rt) {
- case Result::PASS:
- return Result::PASS;
- case Result::FAIL:
- 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;
- }
+ if (rt < Result::FIRST_TYPE || rt > Result::LAST_TYPE)
+ return Result::INVALID;
+
+ return (Result::Type)rt;
}
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:
return QLatin1String("PASS");
case Result::FAIL:
@@ -129,14 +96,6 @@ QString TestResult::resultToString(const Result::Type type)
return QLatin1String("WARN");
case Result::MESSAGE_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:
return QLatin1String("BPASS");
case Result::BLACKLISTED_FAIL:
@@ -148,7 +107,10 @@ QString TestResult::resultToString(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:
return QColor("#009900");
case Result::FAIL:
@@ -169,14 +131,6 @@ QColor TestResult::colorForType(const Result::Type type)
return QColor("#d0bb00");
case Result::MESSAGE_FATAL:
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:
return QColor("#000000");
}
diff --git a/plugins/autotest/testresult.h b/plugins/autotest/testresult.h
index e1e6e770d0..cc10cf5fe3 100644
--- a/plugins/autotest/testresult.h
+++ b/plugins/autotest/testresult.h
@@ -29,7 +29,7 @@ namespace Internal {
namespace Result{
enum Type {
- PASS,
+ PASS, FIRST_TYPE = PASS,
FAIL,
EXPECTED_FAIL,
UNEXPECTED_PASS,
@@ -40,14 +40,17 @@ enum Type {
MESSAGE_DEBUG,
MESSAGE_WARN,
MESSAGE_FATAL,
- MESSAGE_INTERNAL,
+
+ MESSAGE_INTERNAL, INTERNAL_MESSAGES_BEGIN = MESSAGE_INTERNAL,
MESSAGE_TEST_CASE_START,
MESSAGE_TEST_CASE_SUCCESS,
MESSAGE_TEST_CASE_WARN,
MESSAGE_TEST_CASE_FAIL,
MESSAGE_TEST_CASE_END,
- MESSAGE_CURRENT_TEST,
- UNKNOWN // ???
+ MESSAGE_CURRENT_TEST, INTERNAL_MESSAGES_END = MESSAGE_CURRENT_TEST,
+
+ INVALID,
+ LAST_TYPE = INVALID
};
}
@@ -57,7 +60,7 @@ public:
TestResult(const QString &className = QString(), const QString &testCase = 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 testCase() const { return m_case; }
diff --git a/plugins/autotest/testresultmodel.cpp b/plugins/autotest/testresultmodel.cpp
index dd46554043..5a09b5670b 100644
--- a/plugins/autotest/testresultmodel.cpp
+++ b/plugins/autotest/testresultmodel.cpp
@@ -275,7 +275,7 @@ void TestResultFilterModel::enableAllResultTypes()
m_enabled << Result::PASS << Result::FAIL << Result::EXPECTED_FAIL
<< Result::UNEXPECTED_PASS << Result::SKIP << Result::MESSAGE_DEBUG
<< 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::MESSAGE_CURRENT_TEST << Result::MESSAGE_TEST_CASE_START
<< Result::MESSAGE_TEST_CASE_SUCCESS << Result::MESSAGE_TEST_CASE_WARN
diff --git a/plugins/autotest/testxmloutputreader.cpp b/plugins/autotest/testxmloutputreader.cpp
index f137b8d1d6..b3221f123d 100644
--- a/plugins/autotest/testxmloutputreader.cpp
+++ b/plugins/autotest/testxmloutputreader.cpp
@@ -195,7 +195,7 @@ void TestXmlOutputReader::processOutput()
static QString className;
static QString testCase;
static QString dataTag;
- static Result::Type result = Result::UNKNOWN;
+ static Result::Type result = Result::INVALID;
static QString description;
static QString file;
static int lineNumber = 0;
@@ -223,7 +223,7 @@ void TestXmlOutputReader::processOutput()
description = QString();
duration = QString();
file = QString();
- result = Result::UNKNOWN;
+ result = Result::INVALID;
lineNumber = 0;
readingDescription = false;
testResultCreated(new TestResult(QString(), QString(), QString(), Result::MESSAGE_CURRENT_TEST,