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 autotests 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_XSDTSTestCase_H
30#define PatternistSDK_XSDTSTestCase_H
31
32#include <QDate>
33#include <QString>
34#include <QUrl>
35
36#include "TestBaseLine.h"
37#include "TestCase.h"
38
39QT_BEGIN_NAMESPACE
40
41namespace QPatternistSDK
42{
43 /**
44 * @short Represents a test case in a test suite in the XML Query Test Suite.
45 *
46 * TestCase is a memory representation of a test case, and maps
47 * to the @c test-case element in the XQuery Test Suite test
48 * case catalog.
49 *
50 * @ingroup PatternistSDK
51 * @author Frans Englich <frans.englich@nokia.com>
52 */
53 class XSDTSTestCase : public TestCase
54 {
55 public:
56 enum TestType
57 {
58 SchemaTest,
59 InstanceTest
60 };
61
62 XSDTSTestCase(const Scenario scen, TreeItem *parent, TestType testType);
63 virtual ~XSDTSTestCase();
64
65 /**
66 * Executes the test, and returns the result. The returned list
67 * will always contain exactly one TestResult.
68 *
69 * @p stage is ignored when running out-of-process.
70 */
71 virtual TestResult::List execute(const ExecutionStage stage,
72 TestSuite *ts);
73 /**
74 * The identifier, the name of the test. For example, "Literals034".
75 * The name of a test case must be unique.
76 */
77 virtual QString name() const;
78 virtual QString creator() const;
79 virtual QString description() const;
80 /**
81 * @returns the query inside the file, specified by testCasePath(). Loading
82 * of the file is not cached in order to avoid complications.
83 * @param ok is set to @c false if loading the query file fails
84 */
85 virtual QString sourceCode(bool &ok) const;
86 virtual QUrl schemaUri() const;
87 virtual QUrl instanceUri() const;
88 virtual QUrl testCasePath() const {return QUrl();}
89 virtual QDate lastModified() const;
90
91 bool isXPath() const;
92
93 /**
94 * What kind of test case this is, what kind of scenario it takes part
95 * of. For example, whether the test case should evaluate normally or fail.
96 */
97 Scenario scenario() const;
98
99 void setCreator(const QString &creator);
100 void setLastModified(const QDate &date);
101 void setDescription(const QString &description);
102 void setName(const QString &name);
103 void setSchemaUri(const QUrl &uri);
104 void setInstanceUri(const QUrl &uri);
105 void setTestCasePath(const QUrl & /* uri */) {}
106 void setContextItemSource(const QUrl &uri);
107 void addBaseLine(TestBaseLine *lines);
108
109 virtual TreeItem *parent() const;
110
111 virtual QVariant data(const Qt::ItemDataRole role, int column) const;
112
113 virtual QString title() const;
114 virtual TestBaseLine::List baseLines() const;
115
116 virtual int columnCount() const;
117
118 virtual QUrl contextItemSource() const;
119 void setParent(TreeItem *const parent);
120 virtual QPatternist::ExternalVariableLoader::Ptr externalVariableLoader() const;
121 virtual TestResult *testResult() const;
122 virtual ResultSummary resultSummary() const;
123
124 private:
125 void executeSchemaTest(TestResult::Status &resultStatus, QString &serialized, QAbstractMessageHandler *handler);
126 void executeInstanceTest(TestResult::Status &resultStatus, QString &serialized, QAbstractMessageHandler *handler);
127
128 QString m_name;
129 QString m_creator;
130 QString m_description;
131 QUrl m_schemaUri;
132 QUrl m_instanceUri;
133 QDate m_lastModified;
134 const Scenario m_scenario;
135 TreeItem * m_parent;
136 TestBaseLine::List m_baseLines;
137 QUrl m_contextItemSource;
138 TestType m_testType;
139 QPointer<TestResult> m_result;
140 };
141}
142
143QT_END_NAMESPACE
144
145#endif
146// vim: et:ts=4:sw=4:sts=4
147

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