1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
42 #ifndef PatternistSDK_TestCase_H
43 #define PatternistSDK_TestCase_H
45 #include <QtXmlPatterns/QXmlQuery>
47 #include <private/qexternalvariableloader_p.h>
49 #include "ErrorHandler.h"
50 #include "TestBaseLine.h"
63 namespace QPatternistSDK
68 * @short A generic abstract base class for test cases.
70 * @ingroup PatternistSDK
71 * @author Frans Englich <frans.englich@nokia.com>
73 class Q_PATTERNISTSDK_EXPORT TestCase : public TestItem
77 * Corresponds to the simpleType test:scenarios-enum
82 * The test case should evaluate normally and that the output
83 * should match the supplied base line.
88 * The test case should result in a static error, a parser error.
93 * The test case should result in a dynamic error, a runtime error.
100 * ParseError and RuntimeError OR'd.
102 AnyError = RuntimeError | ParseError
110 * Executes the test, and returns the result. The returned list
111 * will always contain exactly one TestResult.
113 * @p stage is ignored when running out-of-process.
115 virtual TestResult::List execute(const ExecutionStage stage,
119 * Determines the corresponding Scenario enumerator from the string
120 * representation @p string.
122 * The following mappings are in effect:
123 * @arg @c Standard "standard"
124 * @arg @c ParseError "parse-error"
125 * @arg @c RuntimeError "runtime-error"
127 static Scenario scenarioFromString(const QString &string);
130 * @return always @c true
132 virtual bool isFinalNode() const;
135 * Calling this function makes no sense, so it always
136 * performs an Q_ASSERT check.
138 virtual void appendChild(TreeItem *);
141 * Calling this function makes no sense, so it always
142 * performs an Q_ASSERT check.
144 virtual TreeItem *child(const unsigned int) const;
147 * @return always zero
149 virtual unsigned int childCount() const;
152 * @return always an empty list.
154 virtual TreeItem::List children() const;
157 * A description of the test case for human consumption.
159 virtual QString description() const = 0;
162 * The title of the test. This can be the identifier of the test, for example.
164 virtual QString title() const = 0;
167 * Whether this test case only make use of XPath features.
169 * @returns @c false if the test case exercises any XQuery feature
170 * which is not available in XPath 2.0.
172 virtual bool isXPath() const = 0;
175 * The full name of the creator of the test case. For example, "Frans Englich".
177 virtual QString creator() const = 0;
180 * The date of when the test case was created or last modified.
182 virtual QDate lastModified() const = 0;
185 * The test's source code. That is, the XPath/XQuery code for the test.
187 * @param ok the function sets this value to @c false if loading the query
188 * failed, and returns a description of the error for human consumption. If
189 * everything went ok, @p ok is set to @c true, and the query is returned.
191 virtual QString sourceCode(bool &ok) const = 0;
194 * The path to the file containing the code of the test case.
196 virtual QUrl testCasePath() const = 0;
199 * The test case's identifier. For example, "Literals001".
201 virtual QString name() const = 0;
204 * What kind of test this is. For example, whether the test case
205 * should result in a parser error or should evaluate without errors.
207 * The vast common case is that one Scenario is returned; the bit signifiance
208 * is for the TestCase sub-class UserTestCase.
210 virtual Scenario scenario() const = 0;
212 static QString displayName(const Scenario scen);
215 * @returns the valid test baselines for this test case. If only
216 * one outcome is valid, the returned list only contains
219 virtual TestBaseLine::List baseLines() const = 0;
221 virtual TestResult *testResult() const;
223 virtual ResultSummary resultSummary() const;
225 void toXML(XMLWriter &receiver) const;
227 virtual QPatternist::ExternalVariableLoader::Ptr externalVariableLoader() const = 0;
230 * @short The XML document that should be used as focus. If none should
231 * be used, and hence the focus be undefined, a default constructed
234 virtual QUrl contextItemSource() const = 0;
237 * Returns by default QXmlQuery::XQuery10.
239 virtual QXmlQuery::QueryLanguage language() const;
241 virtual QXmlName initialTemplateName() const;
243 TestResult::List execute(const ExecutionStage stage);
244 TestResult *createTestResult(const TestResult::Status status,
245 const QString &comment) const;
247 QPointer<TestResult> m_result;
256 // vim: et:ts=4:sw=4:sts=4