37282189e69cc3e5f20d501f2cde037e64292367
[profile/ivi/qtxmlpatterns.git] / tests / auto / xmlpatternssdk / TestSuite.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef PatternistSDK_TestSuite_H
43 #define PatternistSDK_TestSuite_H
44
45 #include <QDate>
46 #include <QString>
47
48 #include "TestContainer.h"
49
50 QT_BEGIN_HEADER
51
52 QT_BEGIN_NAMESPACE
53
54 class QIODevice;
55 class QUrl;
56 class QVariant;
57
58 namespace QPatternistSDK
59 {
60     class TestCase;
61     class TestSuiteResult;
62
63     /**
64      * @short Represents a test suite in the W3C XML Query Test Suite format.
65      *
66      * TestSuite contains the test suite's test cases and meta data.
67      *
68      * @ingroup PatternistSDK
69      * @author Frans Englich <frans.englich@nokia.com>
70      */
71     class Q_PATTERNISTSDK_EXPORT TestSuite : public TestContainer
72     {
73     public:
74         /**
75          * Describes the type of test suite.
76          */
77         enum SuiteType
78         {
79             XQuerySuite,    ///< The test suite for XQuery
80             XsltSuite,      ///< The test suite for XSLT
81             XsdSuite        ///< The test suite for XML Schema
82         };
83
84         TestSuite();
85
86         virtual QVariant data(const Qt::ItemDataRole role, int column) const;
87
88         /**
89          * The version of the catalog test suite. For example, "0.8.0".
90          */
91         QString version() const;
92
93         /**
94          * When the catalog was designed, last modified.
95          */
96         QDate designDate() const;
97
98         void setVersion(const QString &version);
99         void setDesignDate(const QDate &version);
100
101         /**
102          * @return always @c null
103          */
104         virtual TestContainer *parent() const;
105
106         /**
107          * Creates and returns a pointer to a TestSuite instance, which
108          * was instantiated from the XQuery Test Suite catalog file @p catalogFile.
109          *
110          * If loading went wrong, @c null is returned and @p errorMsg is set with a
111          * human readable message string. However, @p catalogFile is not validated;
112          * if the XML file is not valid against the XQTS task force's W3C XML Schema, the
113          * behavior and result for this function is undefined.
114          *
115          * This function blocks. Currently is only local files supported.
116          */
117         static TestSuite *openCatalog(const QUrl &catalogFile,
118                                       QString &errorMsg,
119                                       const bool useExclusionList,
120                                       SuiteType type);
121
122         void toXML(XMLWriter &receiver, TestCase *const tc) const;
123
124         /**
125          * Evaluates all the test cases in this TestSuite, and returns
126          * it all in a TestSuiteResult.
127          */
128         TestSuiteResult *runSuite();
129
130     private:
131         /**
132          * Essentially similar to open(const QUrl &, QString &errorMsg),
133          * with the difference that it takes directly a QIODevice as input,
134          * as opposed to a file name locating the catalog file to read.
135          *
136          * @param input the test suite catalog
137          * @param fileName this URI is used for resolving relative paths inside
138          * the catalog file into absolute.
139          * @param errorMsg if an error occurs, this QString is set to contain the message.
140          * Whether an error occurred can therefore be determined by checking if this variable
141          * still is @c null after the call
142          * @param useExclusionList whether the excludeTestGroups.txt file should be used
143          * to exclude test groups for this catalog
144          */
145         static TestSuite *openCatalog(QIODevice *input,
146                                       QString &errorMsg,
147                                       const QUrl &fileName,
148                                       const bool useExclusionList,
149                                       SuiteType type);
150         QString m_version;
151         QDate m_designDate;
152     };
153 }
154
155 QT_END_NAMESPACE
156
157 QT_END_HEADER
158
159 #endif
160 // vim: et:ts=4:sw=4:sts=4