diff options
author | Christian Stenger <[email protected]> | 2019-02-06 14:11:19 +0100 |
---|---|---|
committer | Christian Stenger <[email protected]> | 2019-04-26 12:19:05 +0000 |
commit | cbab457cf4f7c906598279f31ba9c64b0a0aa725 (patch) | |
tree | eec9838138d311f1edcef48083d8d878c83048ab /src/plugins/autotest/testresult.h | |
parent | 443d8e4713d4c0a2d4d8a8dc0341910500c943b5 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/plugins/autotest/testresult.h')
-rw-r--r-- | src/plugins/autotest/testresult.h | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/src/plugins/autotest/testresult.h b/src/plugins/autotest/testresult.h index 39f6cb7de70..390b2633199 100644 --- a/src/plugins/autotest/testresult.h +++ b/src/plugins/autotest/testresult.h @@ -37,8 +37,8 @@ namespace Internal { class TestTreeItem; -namespace Result{ -enum Type { +enum class ResultType { + // result types (have icon, color, short text) Pass, FIRST_TYPE = Pass, Fail, ExpectedFail, @@ -48,36 +48,44 @@ enum Type { BlacklistedFail, BlacklistedXPass, BlacklistedXFail, + + // special (message) types (have icon, color, short text) Benchmark, MessageDebug, MessageInfo, MessageWarn, MessageFatal, MessageSystem, - MessageLocation, + // special message - get's icon (but no color/short text) from parent + MessageLocation, + // anything below is an internal message (or a pure message without icon) MessageInternal, INTERNAL_MESSAGES_BEGIN = MessageInternal, - MessageTestCaseStart, + // TODO make the following 5 a single start item (get icon/short text depending on children) + TestStart, MessageTestCaseSuccess, MessageTestCaseSuccessWarn, MessageTestCaseFail, MessageTestCaseFailWarn, - MessageTestCaseEnd, - MessageIntermediate, + // usually no icon/short text - more or less an indicator (and can contain test duration) + TestEnd, + // special global (temporary) message MessageCurrentTest, INTERNAL_MESSAGES_END = MessageCurrentTest, - Application, - - Invalid, + Application, // special.. not to be used outside of testresultmodel + Invalid, // indicator for unknown result items LAST_TYPE = Invalid }; + +inline uint qHash(const ResultType &result) +{ + return QT_PREPEND_NAMESPACE(qHash(int(result))); } class TestResult { public: - TestResult(); - explicit TestResult(const QString &name); + TestResult() = default; TestResult(const QString &id, const QString &name); virtual ~TestResult() {} @@ -86,7 +94,7 @@ public: QString id() const { return m_id; } QString name() const { return m_name; } - Result::Type result() const { return m_result; } + ResultType result() const { return m_result; } QString description() const { return m_description; } QString fileName() const { return m_file; } int line() const { return m_line; } @@ -94,22 +102,21 @@ public: void setDescription(const QString &description) { m_description = description; } void setFileName(const QString &fileName) { m_file = fileName; } void setLine(int line) { m_line = line; } - void setResult(Result::Type type) { m_result = type; } + void setResult(ResultType type) { m_result = type; } - static Result::Type resultFromString(const QString &resultString); - static Result::Type toResultType(int rt); - static QString resultToString(const Result::Type type); - static QColor colorForType(const Result::Type type); - static bool isMessageCaseStart(const Result::Type type); + static ResultType resultFromString(const QString &resultString); + static ResultType toResultType(int rt); + static QString resultToString(const ResultType type); + static QColor colorForType(const ResultType type); + static bool isMessageCaseStart(const ResultType type); virtual bool isDirectParentOf(const TestResult *other, bool *needsIntermediate) const; virtual bool isIntermediateFor(const TestResult *other) const; virtual TestResult *createIntermediateResultFor(const TestResult *other); - private: QString m_id; QString m_name; - Result::Type m_result = Result::Invalid; + ResultType m_result = ResultType::Invalid; // the real result.. QString m_description; QString m_file; int m_line = 0; @@ -117,14 +124,8 @@ private: using TestResultPtr = QSharedPointer<TestResult>; -class FaultyTestResult : public TestResult -{ -public: - FaultyTestResult(Result::Type result, const QString &description); -}; - } // namespace Internal } // namespace Autotest Q_DECLARE_METATYPE(Autotest::Internal::TestResult) -Q_DECLARE_METATYPE(Autotest::Internal::Result::Type) +Q_DECLARE_METATYPE(Autotest::Internal::ResultType) |