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-10-31 13:11:52 +01:00
|
|
|
#include <utils/qtcassert.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())
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-13 10:20:17 +02:00
|
|
|
TestResult::TestResult(const QString &name)
|
|
|
|
|
: m_name(name)
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-13 10:20:17 +02:00
|
|
|
const QString TestResult::outputString(bool selected) const
|
|
|
|
|
{
|
2016-09-29 12:15:43 +02:00
|
|
|
return selected ? m_description : m_description.split('\n').first();
|
2016-04-13 10:20:17 +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
|
|
|
{
|
2016-09-29 12:15:43 +02:00
|
|
|
if (resultString == "pass")
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::Pass;
|
2017-06-19 15:58:21 +02:00
|
|
|
if (resultString == "fail" || resultString == "fail!")
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::Fail;
|
2016-09-29 12:15:43 +02:00
|
|
|
if (resultString == "xfail")
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::ExpectedFail;
|
2016-09-29 12:15:43 +02:00
|
|
|
if (resultString == "xpass")
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::UnexpectedPass;
|
2016-09-29 12:15:43 +02:00
|
|
|
if (resultString == "skip")
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::Skip;
|
2017-06-19 15:58:21 +02:00
|
|
|
if (resultString == "result")
|
|
|
|
|
return Result::Benchmark;
|
2016-09-29 12:15:43 +02:00
|
|
|
if (resultString == "qdebug")
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::MessageDebug;
|
2017-06-19 15:58:21 +02:00
|
|
|
if (resultString == "qinfo" || resultString == "info")
|
2016-07-11 10:55:43 +02:00
|
|
|
return Result::MessageInfo;
|
2017-06-19 15:58:21 +02:00
|
|
|
if (resultString == "warn" || resultString == "qwarn" || resultString == "warning")
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::MessageWarn;
|
2016-09-29 12:15:43 +02:00
|
|
|
if (resultString == "qfatal")
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::MessageFatal;
|
2016-09-29 12:15:43 +02:00
|
|
|
if (resultString == "system")
|
2016-07-11 15:13:52 +02:00
|
|
|
return Result::MessageSystem;
|
2016-09-29 12:15:43 +02:00
|
|
|
if (resultString == "bpass")
|
2015-12-07 08:26:54 +01:00
|
|
|
return Result::BlacklistedPass;
|
2016-09-29 12:15:43 +02:00
|
|
|
if (resultString == "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
|
|
|
switch (type) {
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Pass:
|
2016-12-14 14:42:28 +01:00
|
|
|
case Result::MessageTestCaseSuccess:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("PASS");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Fail:
|
2016-12-14 14:42:28 +01:00
|
|
|
case Result::MessageTestCaseFail:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("FAIL");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::ExpectedFail:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("XFAIL");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::UnexpectedPass:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("XPASS");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Skip:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("SKIP");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::Benchmark:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("BENCH");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageDebug:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("DEBUG");
|
2016-07-11 10:55:43 +02:00
|
|
|
case Result::MessageInfo:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("INFO");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageWarn:
|
2016-12-14 14:42:28 +01:00
|
|
|
case Result::MessageTestCaseWarn:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("WARN");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::MessageFatal:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("FATAL");
|
2016-07-11 15:13:52 +02:00
|
|
|
case Result::MessageSystem:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("SYSTEM");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::BlacklistedPass:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("BPASS");
|
2015-12-07 08:26:54 +01:00
|
|
|
case Result::BlacklistedFail:
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("BFAIL");
|
2014-10-07 15:51:02 +02:00
|
|
|
default:
|
2016-12-14 14:42:28 +01:00
|
|
|
if (type >= Result::INTERNAL_MESSAGES_BEGIN && type <= Result::INTERNAL_MESSAGES_END)
|
|
|
|
|
return QString();
|
2017-02-13 10:05:06 +01:00
|
|
|
return QString("UNKNOWN");
|
2014-10-07 15:51:02 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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-07-11 10:55:43 +02:00
|
|
|
case Result::MessageInfo:
|
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-07-11 15:13:52 +02:00
|
|
|
case Result::MessageSystem:
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-19 12:15:59 +01:00
|
|
|
bool TestResult::isMessageCaseStart(const Result::Type type)
|
|
|
|
|
{
|
|
|
|
|
return type == Result::MessageTestCaseStart || type == Result::MessageTestCaseSuccess
|
|
|
|
|
|| type == Result::MessageTestCaseFail || type == Result::MessageTestCaseWarn
|
|
|
|
|
|| type == Result::MessageIntermediate;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-31 13:11:52 +01:00
|
|
|
bool TestResult::isDirectParentOf(const TestResult *other, bool * /*needsIntermediate*/) const
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(other, return false);
|
|
|
|
|
return m_name == other->m_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TestResult::isIntermediateFor(const TestResult *other) const
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(other, return false);
|
|
|
|
|
return m_name == other->m_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TestResult *TestResult::createIntermediateResultFor(const TestResult *other)
|
|
|
|
|
{
|
2017-02-13 10:05:06 +01:00
|
|
|
QTC_ASSERT(other, return nullptr);
|
2016-10-31 13:11:52 +01:00
|
|
|
TestResult *intermediate = new TestResult(other->m_name);
|
|
|
|
|
return intermediate;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|