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