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