2014-10-07 15:51:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** This file is part of Qt Creator.
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
2014-10-07 15:51:02 +02:00
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-22 10:37:55 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "testresult.h"
|
|
|
|
|
|
2016-03-02 16:23:45 +01:00
|
|
|
#include <utils/theme/theme.h>
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
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)
|
2016-01-12 13:52:21 +01:00
|
|
|
, m_type(TestTypeQt)
|
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");
|
|
|
|
|
|
2016-03-02 16:23:45 +01:00
|
|
|
Utils::Theme *creatorTheme = Utils::creatorTheme();
|
2015-09-23 07:14:25 +02:00
|
|
|
switch (type) {
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Pass:
|
2016-03-02 16:23:45 +01:00
|
|
|
return creatorTheme->color(Utils::Theme::OutputPanes_TestPassTextColor);
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Fail:
|
2016-03-02 16:23:45 +01:00
|
|
|
return creatorTheme->color(Utils::Theme::OutputPanes_TestFailTextColor);
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::ExpectedFail:
|
2016-03-02 16:23:45 +01:00
|
|
|
return creatorTheme->color(Utils::Theme::OutputPanes_TestXFailTextColor);
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::UnexpectedPass:
|
2016-03-02 16:23:45 +01:00
|
|
|
return creatorTheme->color(Utils::Theme::OutputPanes_TestXPassTextColor);
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Skip:
|
2016-03-02 16:23:45 +01:00
|
|
|
return creatorTheme->color(Utils::Theme::OutputPanes_TestSkipTextColor);
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageDebug:
|
2016-03-02 16:23:45 +01:00
|
|
|
return creatorTheme->color(Utils::Theme::OutputPanes_TestDebugTextColor);
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageWarn:
|
2016-03-02 16:23:45 +01:00
|
|
|
return creatorTheme->color(Utils::Theme::OutputPanes_TestWarnTextColor);
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageFatal:
|
2016-03-02 16:23:45 +01:00
|
|
|
return creatorTheme->color(Utils::Theme::OutputPanes_TestFatalTextColor);
|
|
|
|
|
case Result::BlacklistedPass:
|
|
|
|
|
case Result::BlacklistedFail:
|
2014-10-07 15:51:02 +02:00
|
|
|
default:
|
2016-03-02 16:23:45 +01:00
|
|
|
return creatorTheme->color(Utils::Theme::OutputPanes_StdOutTextColor);
|
2014-10-07 15:51:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2016-01-12 13:52:21 +01:00
|
|
|
setTestType(TestTypeGTest);
|
2015-12-14 10:19:37 +01:00
|
|
|
}
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|