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_TestSuiteHandler_H
30#define PatternistSDK_TestSuiteHandler_H
31
32#include <QStack>
33#include <QUrl>
34
35#include "ExternalSourceLoader.h"
36#include "TestSuite.h"
37#include "XmlParseHelper.h"
38#include "XQTSTestCase.h"
39
40QT_BEGIN_NAMESPACE
41
42namespace QPatternistSDK
43{
44 class TestBaseLine;
45
46 /**
47 * @short Creates a TestSuite from the XQuery Test Suite catalog,
48 * represented as a SAX stream.
49 *
50 * The created TestSuite can be retrieved via testSuite().
51 *
52 * @note TestSuiteHandler assumes the XML is valid by having been validated
53 * against the W3C XML Schema. It have no safety checks for that the XML format
54 * is correct but is hard coded for it. Thus, the behavior is undefined if
55 * the XML is invalid.
56 *
57 * @ingroup PatternistSDK
58 * @author Frans Englich <frans.englich@nokia.com>
59 */
60 class TestSuiteHandler : public XmlParseHelper
61 {
62 public:
63 /**
64 * @param catalogFile the URI for the catalog file being parsed. This
65 * URI is used for creating absolute URIs for files mentioned in
66 * the catalog with relative URIs.
67 * @param useExclusionList whether excludeTestGroups.txt should be used to ignore
68 * test groups when loading
69 */
70 TestSuiteHandler(const QUrl &catalogFile,
71 const bool useExclusionList);
72 bool characters(const QStringRef &ch) override;
73
74 bool endElement(const QStringRef &namespaceURI, const QStringRef &localName,
75 const QStringRef &qName) override;
76 bool startElement(const QStringRef &namespaceURI, const QStringRef &localName,
77 const QStringRef &qName, const QXmlStreamAttributes &atts) override;
78
79 TestSuite *testSuite() const;
80
81 private:
82 QStringList readExclusionList(const bool useExclusionList) const;
83
84 TestSuite * m_ts;
85 TestContainer * m_container;
86 XQTSTestCase * m_tc;
87 TestBaseLine * m_baseLine;
88 QString m_ch;
89 const QUrl m_catalogFile;
90
91 /**
92 * The extension of XQuery files. For example, ".xq"
93 */
94 QString m_xqueryFileExtension;
95
96 /**
97 * The base URI for where the XQuery query files are found.
98 * It is absolute, resolved against catalogFile.
99 */
100 QUrl m_queryOffset;
101
102 QUrl m_baselineOffset;
103 QUrl m_sourceOffset;
104 QUrl m_currentQueryPath;
105 QUrl m_currentBaselinePath;
106
107 /**
108 * In the XQTSCatalog.xml, each source file in each test is referred to
109 * by a key, which can be fully looked up in the @c sources element. This QHash
110 * maps the keys to absolute URIs pointing to the source files.
111 */
112 ExternalSourceLoader::SourceMap m_sourceMap;
113
114 ExternalSourceLoader::VariableMap m_tcSourceInputs;
115
116 QPatternist::ResourceLoader::Ptr m_resourceLoader;
117
118 /**
119 * The current value of <tt>input-file/\@variable/</tt>.
120 */
121 QString m_currentInputVariable;
122
123 /**
124 * The names of the test groups we're excluding.
125 */
126 const QStringList m_exclusionList;
127
128 /**
129 * This is set when we're inside a test-group that we're excluding.
130 */
131 bool m_isExcluding;
132
133 /**
134 * The names of the test groups.
135 */
136 QStack<QString> m_testGroupName;
137
138 /**
139 * Holds the content of the current <tt>input-URI</tt> element.
140 */
141 QString m_inputURI;
142 QString m_contextItemSource;
143 };
144}
145
146QT_END_NAMESPACE
147
148#endif
149// vim: et:ts=4:sw=4:sts=4
150

source code of qtxmlpatterns/tests/auto/xmlpatternssdk/TestSuiteHandler.h