1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the test suite of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #ifndef PatternistSDK_TestResult_H |
30 | #define PatternistSDK_TestResult_H |
31 | |
32 | #include <QList> |
33 | #include <QObject> |
34 | #include <QPointer> |
35 | #include <QString> |
36 | |
37 | #include <QtXmlPatterns/private/qitem_p.h> |
38 | #include "ErrorHandler.h" |
39 | |
40 | #include "ASTItem.h" |
41 | |
42 | |
43 | QT_BEGIN_NAMESPACE |
44 | |
45 | namespace QPatternistSDK |
46 | { |
47 | class ASTItem; |
48 | class XMLWriter; |
49 | |
50 | /** |
51 | * @short represents the result produced by running a test case. |
52 | * |
53 | * This information TestResult houses is: |
54 | * |
55 | * - The result status() of the run. Whether the test case succeeded or not, for example. |
56 | * - The astTree() which reflects the compiled test case |
57 | * - The messages issued when compiling and running the test case, retrievable via messages() |
58 | * - The data -- XPath Data Model items() -- the test case evaluated to, if any. |
59 | * |
60 | * @ingroup PatternistSDK |
61 | * @author Frans Englich <frans.englich@nokia.com> |
62 | */ |
63 | class TestResult : public QObject |
64 | { |
65 | Q_OBJECT |
66 | |
67 | public: |
68 | enum Status |
69 | { |
70 | /** |
71 | * Used when the status is unknown. |
72 | */ |
73 | Unknown = 0, |
74 | |
75 | /** |
76 | * The test case passed. |
77 | */ |
78 | Pass, |
79 | |
80 | /** |
81 | * The test case failed. |
82 | */ |
83 | Fail, |
84 | |
85 | /** |
86 | * The test was not run. Similar to "SKIP". |
87 | */ |
88 | NotTested |
89 | }; |
90 | |
91 | /** |
92 | * A list of TestResult instances. |
93 | */ |
94 | typedef QList<QPointer<TestResult> > List; |
95 | |
96 | /** |
97 | * Constructs a TestResult. |
98 | * |
99 | * @param testName the name of the test. For example, @c Literal-001. |
100 | * @param astTree may be @c null, signalling no AST being available, or point to one. |
101 | * @param status the result status of running the test-case. Whether the test-case |
102 | * passed or failed, and so forth. |
103 | * @param errors the errors and warnings that were reported while running the test-case |
104 | * @param items the XDM items that were outputted, if any |
105 | * @param serialized the output when serialized |
106 | */ |
107 | TestResult(const QString &testName, |
108 | const Status status, |
109 | ASTItem *astTree, |
110 | const ErrorHandler::Message::List &errors, |
111 | const QPatternist::Item::List &items, |
112 | const QString &serialized); |
113 | |
114 | virtual ~TestResult(); |
115 | |
116 | Status status() const; |
117 | |
118 | QString () const; |
119 | void (const QString &); |
120 | |
121 | QPatternist::Item::List items() const; |
122 | |
123 | ErrorHandler::Message::List messages() const; |
124 | |
125 | /** |
126 | * Serializes itself to @p receiver, into a test-case element, |
127 | * as per @c XQTSResult.xsd. |
128 | */ |
129 | void toXML(XMLWriter &receiver) const; |
130 | |
131 | ASTItem *astTree() const; |
132 | |
133 | /** |
134 | * @returns a string representation for @p status, as per the anonymous |
135 | * type inside the type test-case, in @c XQTSResult.xsd. For example, if @p status |
136 | * is NotTested, is "not tested" returned. |
137 | */ |
138 | static QString displayName(const TestResult::Status status); |
139 | |
140 | static Status statusFromString(const QString &string); |
141 | |
142 | /** |
143 | * @returns the output of this test result(if any) as when |
144 | * being serialized. |
145 | */ |
146 | QString asSerialized() const; |
147 | |
148 | private: |
149 | const Status m_status; |
150 | QString ; |
151 | const ErrorHandler::Message::List m_messages; |
152 | QPointer<ASTItem> m_astTree; |
153 | QString m_testName; |
154 | const QPatternist::Item::List m_items; |
155 | const QString m_asSerialized; |
156 | }; |
157 | } |
158 | |
159 | QT_END_NAMESPACE |
160 | |
161 | #endif |
162 | // vim: et:ts=4:sw=4:sts=4 |
163 | |