1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2015 The Qt Company Ltd. 4 ** Contact: http://www.qt.io/licensing/ 5 ** 6 ** This file is part of the test suite of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 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 http://www.qt.io/terms-conditions. For further 15 ** information use the contact form at http://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 2.1 or version 3 as published by the Free 20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and 21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the 22 ** following information to ensure the GNU Lesser General Public License 23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and 24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 25 ** 26 ** As a special exception, The Qt Company gives you certain additional 27 ** rights. These rights are described in The Qt Company LGPL Exception 28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 29 ** 30 ** GNU General Public License Usage 31 ** Alternatively, this file may be used under the terms of the GNU 32 ** General Public License version 3.0 as published by the Free Software 33 ** Foundation and appearing in the file LICENSE.GPL included in the 34 ** packaging of this file. Please review the following information to 35 ** ensure the GNU General Public License version 3.0 requirements will be 36 ** met: http://www.gnu.org/copyleft/gpl.html. 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 180