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_TestSuite_H |
30 | #define PatternistSDK_TestSuite_H |
31 | |
32 | #include <QDate> |
33 | #include <QString> |
34 | |
35 | #include "TestContainer.h" |
36 | |
37 | QT_BEGIN_NAMESPACE |
38 | |
39 | class QIODevice; |
40 | class QUrl; |
41 | class QVariant; |
42 | |
43 | namespace QPatternistSDK |
44 | { |
45 | class TestCase; |
46 | class TestSuiteResult; |
47 | |
48 | /** |
49 | * @short Represents a test suite in the W3C XML Query Test Suite format. |
50 | * |
51 | * TestSuite contains the test suite's test cases and meta data. |
52 | * |
53 | * @ingroup PatternistSDK |
54 | * @author Frans Englich <frans.englich@nokia.com> |
55 | */ |
56 | class TestSuite : public TestContainer |
57 | { |
58 | public: |
59 | /** |
60 | * Describes the type of test suite. |
61 | */ |
62 | enum SuiteType |
63 | { |
64 | XQuerySuite, ///< The test suite for XQuery |
65 | XsltSuite, ///< The test suite for XSLT |
66 | XsdSuite ///< The test suite for XML Schema |
67 | }; |
68 | |
69 | TestSuite(); |
70 | |
71 | virtual QVariant data(const Qt::ItemDataRole role, int column) const; |
72 | |
73 | /** |
74 | * The version of the catalog test suite. For example, "0.8.0". |
75 | */ |
76 | QString version() const; |
77 | |
78 | /** |
79 | * When the catalog was designed, last modified. |
80 | */ |
81 | QDate designDate() const; |
82 | |
83 | void setVersion(const QString &version); |
84 | void setDesignDate(const QDate &version); |
85 | |
86 | /** |
87 | * @return always @c null |
88 | */ |
89 | virtual TestContainer *parent() const; |
90 | |
91 | /** |
92 | * Creates and returns a pointer to a TestSuite instance, which |
93 | * was instantiated from the XQuery Test Suite catalog file @p catalogFile. |
94 | * |
95 | * If loading went wrong, @c null is returned and @p errorMsg is set with a |
96 | * human readable message string. However, @p catalogFile is not validated; |
97 | * if the XML file is not valid against the XQTS task force's W3C XML Schema, the |
98 | * behavior and result for this function is undefined. |
99 | * |
100 | * This function blocks. Currently is only local files supported. |
101 | */ |
102 | static TestSuite *openCatalog(const QUrl &catalogFile, |
103 | QString &errorMsg, |
104 | const bool useExclusionList, |
105 | SuiteType type); |
106 | |
107 | void toXML(XMLWriter &receiver, TestCase *const tc) const; |
108 | |
109 | /** |
110 | * Evaluates all the test cases in this TestSuite, and returns |
111 | * it all in a TestSuiteResult. |
112 | */ |
113 | TestSuiteResult *runSuite(); |
114 | |
115 | private: |
116 | /** |
117 | * Essentially similar to open(const QUrl &, QString &errorMsg), |
118 | * with the difference that it takes directly a QIODevice as input, |
119 | * as opposed to a file name locating the catalog file to read. |
120 | * |
121 | * @param input the test suite catalog |
122 | * @param fileName this URI is used for resolving relative paths inside |
123 | * the catalog file into absolute. |
124 | * @param errorMsg if an error occurs, this QString is set to contain the message. |
125 | * Whether an error occurred can therefore be determined by checking if this variable |
126 | * still is @c null after the call |
127 | * @param useExclusionList whether the excludeTestGroups.txt file should be used |
128 | * to exclude test groups for this catalog |
129 | */ |
130 | static TestSuite *openCatalog(QIODevice *input, |
131 | QString &errorMsg, |
132 | const QUrl &fileName, |
133 | const bool useExclusionList, |
134 | SuiteType type); |
135 | QString m_version; |
136 | QDate m_designDate; |
137 | }; |
138 | } |
139 | |
140 | QT_END_NAMESPACE |
141 | |
142 | #endif |
143 | // vim: et:ts=4:sw=4:sts=4 |
144 | |