2014-10-07 15:51:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2015-02-19 08:09:02 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd
|
2014-10-07 15:51:02 +02:00
|
|
|
** All rights reserved.
|
2015-02-19 08:09:02 +01:00
|
|
|
** For any questions to The Qt Company, please use contact form at
|
|
|
|
|
** http://www.qt.io/contact-us
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of the Qt Creator Enterprise Auto Test Add-on.
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Enterprise licenses may use this file in
|
|
|
|
|
** accordance with the Qt Enterprise License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-02-19 08:09:02 +01:00
|
|
|
** a written agreement between you and The Qt Company.
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please use
|
2015-02-19 08:09:02 +01:00
|
|
|
** contact form at http://www.qt.io/contact-us
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "testresult.h"
|
|
|
|
|
|
|
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2015-01-08 13:46:28 +01:00
|
|
|
FaultyTestResult::FaultyTestResult(Result::Type result, const QString &description)
|
2014-12-19 11:22:53 +01:00
|
|
|
{
|
2015-09-23 07:47:12 +02:00
|
|
|
setResult(result);
|
|
|
|
|
setDescription(description);
|
2014-12-19 11:22:53 +01:00
|
|
|
}
|
|
|
|
|
|
2015-09-23 07:47:12 +02:00
|
|
|
TestResult::TestResult()
|
|
|
|
|
: TestResult(QString())
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TestResult::TestResult(const QString &className)
|
|
|
|
|
: m_class(className)
|
2015-12-07 08:26:54 +01:00
|
|
|
, m_result(Result::Invalid)
|
2015-09-23 07:47:12 +02:00
|
|
|
, m_line(0)
|
2015-12-14 10:19:37 +01:00
|
|
|
, m_type(Qt)
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-08 13:46:28 +01:00
|
|
|
Result::Type TestResult::resultFromString(const QString &resultString)
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
|
|
|
|
if (resultString == QLatin1String("pass"))
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::Pass;
|
2014-10-07 15:51:02 +02:00
|
|
|
if (resultString == QLatin1String("fail"))
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::Fail;
|
2014-10-07 15:51:02 +02:00
|
|
|
if (resultString == QLatin1String("xfail"))
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::ExpectedFail;
|
2014-10-07 15:51:02 +02:00
|
|
|
if (resultString == QLatin1String("xpass"))
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::UnexpectedPass;
|
2014-10-07 15:51:02 +02:00
|
|
|
if (resultString == QLatin1String("skip"))
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::Skip;
|
2014-10-07 15:51:02 +02:00
|
|
|
if (resultString == QLatin1String("qdebug"))
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::MessageDebug;
|
2014-11-19 08:52:40 +01:00
|
|
|
if (resultString == QLatin1String("warn") || resultString == QLatin1String("qwarn"))
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::MessageWarn;
|
2014-10-07 15:51:02 +02:00
|
|
|
if (resultString == QLatin1String("qfatal"))
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::MessageFatal;
|
2014-12-01 11:42:28 +01:00
|
|
|
if (resultString == QLatin1String("bpass"))
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::BlacklistedPass;
|
2014-12-01 11:42:28 +01:00
|
|
|
if (resultString == QLatin1String("bfail"))
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::BlacklistedFail;
|
2015-02-05 07:51:51 +01:00
|
|
|
qDebug("Unexpected test result: %s", qPrintable(resultString));
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::Invalid;
|
2014-10-07 15:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-08 13:46:28 +01:00
|
|
|
Result::Type TestResult::toResultType(int rt)
|
2014-11-11 17:30:34 +01:00
|
|
|
{
|
2015-09-23 07:14:25 +02:00
|
|
|
if (rt < Result::FIRST_TYPE || rt > Result::LAST_TYPE)
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::Invalid;
|
2015-09-23 07:14:25 +02:00
|
|
|
|
|
|
|
|
return (Result::Type)rt;
|
2014-11-11 17:30:34 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-08 13:46:28 +01:00
|
|
|
QString TestResult::resultToString(const Result::Type type)
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
2015-09-23 07:14:25 +02:00
|
|
|
if (type >= Result::INTERNAL_MESSAGES_BEGIN && type <= Result::INTERNAL_MESSAGES_END)
|
|
|
|
|
return QString();
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Pass:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QLatin1String("PASS");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Fail:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QLatin1String("FAIL");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::ExpectedFail:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QLatin1String("XFAIL");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::UnexpectedPass:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QLatin1String("XPASS");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Skip:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QLatin1String("SKIP");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Benchmark:
|
2014-12-01 16:12:05 +01:00
|
|
|
return QLatin1String("BENCH");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageDebug:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QLatin1String("DEBUG");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageWarn:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QLatin1String("WARN");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageFatal:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QLatin1String("FATAL");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::BlacklistedPass:
|
2014-12-01 11:42:28 +01:00
|
|
|
return QLatin1String("BPASS");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::BlacklistedFail:
|
2014-12-01 11:42:28 +01:00
|
|
|
return QLatin1String("BFAIL");
|
2014-10-07 15:51:02 +02:00
|
|
|
default:
|
|
|
|
|
return QLatin1String("UNKNOWN");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-08 13:46:28 +01:00
|
|
|
QColor TestResult::colorForType(const Result::Type type)
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
2015-09-23 07:14:25 +02:00
|
|
|
if (type >= Result::INTERNAL_MESSAGES_BEGIN && type <= Result::INTERNAL_MESSAGES_END)
|
|
|
|
|
return QColor("transparent");
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Pass:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QColor("#009900");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Fail:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QColor("#a00000");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::ExpectedFail:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QColor("#00ff00");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::UnexpectedPass:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QColor("#ff0000");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Skip:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QColor("#787878");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::BlacklistedPass:
|
2014-12-01 11:42:28 +01:00
|
|
|
return QColor(0, 0, 0);
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::BlacklistedFail:
|
2014-12-01 11:42:28 +01:00
|
|
|
return QColor(0, 0, 0);
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageDebug:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QColor("#329696");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageWarn:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QColor("#d0bb00");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageFatal:
|
2014-11-11 17:30:34 +01:00
|
|
|
return QColor("#640000");
|
2014-10-07 15:51:02 +02:00
|
|
|
default:
|
|
|
|
|
return QColor("#000000");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool operator==(const TestResult &t1, const TestResult &t2)
|
|
|
|
|
{
|
|
|
|
|
return t1.className() == t2.className()
|
|
|
|
|
&& t1.testCase() == t2.testCase()
|
|
|
|
|
&& t1.dataTag() == t2.dataTag()
|
|
|
|
|
&& t1.result() == t2.result();
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 10:19:37 +01:00
|
|
|
QTestResult::QTestResult(const QString &className)
|
|
|
|
|
: TestResult(className)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GTestResult::GTestResult(const QString &className)
|
|
|
|
|
: TestResult(className)
|
|
|
|
|
{
|
|
|
|
|
setTestType(GTest);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|