| 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_XSLTTestSuiteHandler_H |
| 30 | #define PatternistSDK_XSLTTestSuiteHandler_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 | |
| 40 | QT_BEGIN_NAMESPACE |
| 41 | |
| 42 | namespace QPatternistSDK |
| 43 | { |
| 44 | class TestBaseLine; |
| 45 | class TestGroup; |
| 46 | |
| 47 | /** |
| 48 | * @short Creates a TestSuite from the XQuery Test Suite catalog. |
| 49 | * |
| 50 | * The created TestSuite can be retrieved via testSuite(). |
| 51 | * |
| 52 | * @note XSLTTestSuiteHandler assumes the XML is valid by having been validated |
| 53 | * against the W3C XML Schema. It has 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 | * @see http://www.w3.org/XML/Group/xslt20-test/TestSuiteStagingArea/catalog.html |
| 58 | * @see http://www.w3.org/XML/Group/xslt20-test/Documentation/XSLT2Test.htm |
| 59 | * @ingroup PatternistSDK |
| 60 | * @author Frans Englich <frans.englich@nokia.com> |
| 61 | */ |
| 62 | class XSLTTestSuiteHandler : public XmlParseHelper |
| 63 | { |
| 64 | public: |
| 65 | /** |
| 66 | * @param catalogFile the URI for the catalog file being parsed. This |
| 67 | * URI is used for creating absolute URIs for files mentioned in |
| 68 | * the catalog with relative URIs. |
| 69 | * @param useExclusionList whether excludeTestGroups.txt should be used to ignore |
| 70 | * test groups when loading |
| 71 | */ |
| 72 | XSLTTestSuiteHandler(const QUrl &catalogFile); |
| 73 | bool characters(const QStringRef &ch) override; |
| 74 | |
| 75 | bool endElement(const QStringRef &namespaceURI, const QStringRef &localName, |
| 76 | const QStringRef &qName) override; |
| 77 | bool startElement(const QStringRef &namespaceURI, const QStringRef &localName, |
| 78 | const QStringRef &qName, const QXmlStreamAttributes &atts) override; |
| 79 | |
| 80 | TestSuite *testSuite() const; |
| 81 | |
| 82 | private: |
| 83 | TestGroup *containerFor(const QString &name); |
| 84 | |
| 85 | QHash<QString, TestGroup *> m_containers; |
| 86 | |
| 87 | TestSuite * m_ts; |
| 88 | XQTSTestCase * m_tc; |
| 89 | TestBaseLine * m_baseLine; |
| 90 | QString m_ch; |
| 91 | const QUrl m_catalogFile; |
| 92 | |
| 93 | /** |
| 94 | * The base URI for where the XQuery query files are found. |
| 95 | * It is absolute, resolved against catalogFile. |
| 96 | */ |
| 97 | QUrl m_queryOffset; |
| 98 | |
| 99 | QUrl m_baselineOffset; |
| 100 | QUrl m_sourceOffset; |
| 101 | QUrl m_currentQueryPath; |
| 102 | QUrl m_currentBaselinePath; |
| 103 | |
| 104 | /** |
| 105 | * In the XQTSCatalog.xml, each source file in each test is referred to |
| 106 | * by a key, which can be fully looked up in the @c sources element. This QHash |
| 107 | * maps the keys to absolute URIs pointing to the source files. |
| 108 | */ |
| 109 | ExternalSourceLoader::SourceMap m_sourceMap; |
| 110 | |
| 111 | ExternalSourceLoader::VariableMap m_tcSourceInputs; |
| 112 | |
| 113 | QPatternist::ResourceLoader::Ptr m_resourceLoader; |
| 114 | |
| 115 | /** |
| 116 | * The current value of <tt>input-file/\@variable</tt>. |
| 117 | */ |
| 118 | QString m_currentInputVariable; |
| 119 | |
| 120 | /** |
| 121 | * The names of the test groups. |
| 122 | */ |
| 123 | QStack<QString> m_testGroupName; |
| 124 | |
| 125 | /** |
| 126 | * Holds the content of the current <tt>input-URI</tt> element. |
| 127 | */ |
| 128 | QString m_inputURI; |
| 129 | QString m_contextItemSource; |
| 130 | QString m_currentCategory; |
| 131 | bool m_removeTestcase; |
| 132 | }; |
| 133 | } |
| 134 | |
| 135 | QT_END_NAMESPACE |
| 136 | |
| 137 | #endif |
| 138 | // vim: et:ts=4:sw=4:sts=4 |
| 139 | |