aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/squish/testresult.h
blob: f09273119f8d304b270ddd5bc578b10b1ce0e36a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (C) 2022 The Qt Company Ltd
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include <QColor>
#include <QMetaType>
#include <QString>

namespace Squish {
namespace Internal {

namespace Result {
enum Type { Log, Pass, Fail, ExpectedFail, UnexpectedPass, Warn, Error, Fatal, Detail, Start, End };
}

class TestResult
{
public:
    TestResult(Result::Type type = Result::Log,
               const QString &text = QString(),
               const QString &timeStamp = QString());

    Result::Type type() const { return m_type; }
    QString text() const { return m_text; }
    QString timeStamp() const { return m_timeStamp; }

    void setText(const QString &text) { m_text = text; }
    void setFile(const QString &file) { m_file = file; }
    void setLine(int line) { m_line = line; }
    QString file() const { return m_file; }
    int line() const { return m_line; }

    static QString typeToString(Result::Type type);
    static QColor colorForType(Result::Type type);

private:
    Result::Type m_type;
    QString m_text;
    QString m_timeStamp;
    QString m_file;
    int m_line;
};

} // namespace Internal
} // namespace Squish

Q_DECLARE_METATYPE(Squish::Internal::TestResult)
Q_DECLARE_METATYPE(Squish::Internal::Result::Type)