1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the test suite of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef PatternistSDK_TestBaseLine_H
43 #define PatternistSDK_TestBaseLine_H
48 #include "TestResult.h"
54 class QDomNamedNodeMap;
57 template<typename T> class QList;
59 namespace QPatternistSDK
62 * @short Represents an expected test result for a test case.
64 * TestBaseLine represents a valid outcome for a test case,
65 * the "base line". A XQTS test case can have many different valid
66 * base lines, and one TestBaseLine instance represents on of them.
68 * Of highest interest, TestBaseLine have the function scan() and
69 * scanErrors(), which allows serialized output to be
70 * compared to the base line.
72 * @ingroup PatternistSDK
73 * @author Frans Englich <frans.englich@nokia.com>
75 class Q_PATTERNISTSDK_EXPORT TestBaseLine
78 typedef QList<TestBaseLine *> List;
81 * Identifies what kind of comparator to use. The documentation
82 * for each enumerator is copied from
83 * <a href="http://www.w3.org/XML/Query/test-suite/Guidelines
84 * for Running the XML Query Test Suite.html">Guidelines
85 * for Running the XML Query Test Suite</a>
90 * The test harness must canonicalize both, the actual result
91 * and the expected result according to the "Canonical XML" recommendation [2],
92 * which refers to a number of open-source implementations. Byte-comparison can
93 * then be applied to the resulting XML documents. If the test harness does
94 * this process in a different manner, it must be documented.
99 * For XML fragments, the same root node must be created for both,
100 * implementation result and test suite result. The resulting XML
101 * can be compared using XML comparison.
106 * Text (that has been produced by XML serialization) is compared
107 * using byte-comparison.
112 * No comparison needs to be applied; the result is always @c true if
113 * the implementation successfully executes the test case.
118 * A human is required to make the call about correctness of the result
119 * according to the description in the test case.
124 * The expected result of the test case is an error, identified as an
125 * eight-character error code (e.g., XPST0003). The result of a test is
126 * @c true, if the implementation raises an error. However, raising an error
127 * because an implementation does not support the feature is not
128 * considered a correct result.
133 * A special comparison for the schema validation tests. The details
134 * can only be 'true' or 'false' depending on whether it is a valid
141 * Takes a string identifying a comparator either in the XSL-T or the
142 * XQuery test suite, and returns an enum value for it.
144 * If the value is unknown, the code asserts.
146 static Type identifierFromString(const QString &string);
149 * @returns a display name for @p id. For example, if Inspect was passed, "Inspect"
152 static QString displayName(const Type id);
155 * Compares @p items(typically the result of an evaluation) against
156 * the base lines @p lines.
158 * @returns the status of the first base line which passes,
159 * otherwise TestResult::Fail.
161 static TestResult::Status scan(const QString &serialized,
162 const TestBaseLine::List &lines);
164 static TestResult::Status scanErrors(const ErrorHandler::Message::List &errors,
165 const TestBaseLine::List &lines);
168 * Constructs a TestBaseLine of type @p type.
170 TestBaseLine(const Type type);
173 * What @p details contains depends on the type(). If the type() is ExpectedError,
174 * @p details contains the relevant error code. If the type() is one which compares
175 * result against a base line, it is a filename locating the baseline.
177 void setDetails(const QString &details);
181 QString details() const;
183 void toXML(XMLWriter &receiver) const;
186 TestResult::Status verify(const QString &serializedInput) const;
189 static bool isDeepEqual(const QDomNode &n1, const QDomNode &n2);
192 * @returns @c true if the nodes in @p cl1 are equal to @p cl2, by calling isDeepEqual()
195 static bool isChildrenDeepEqual(const QDomNodeList &cl1, const QDomNodeList &cl2);
198 * Considers @p cl1 and @p cl2 to be lists containing attributes. The list are equal
199 * if they contain attributes by same value and name, but regardless of order.
201 static bool isAttributesEqual(const QDomNamedNodeMap &cl1, const QDomNamedNodeMap &cl2);
212 // vim: et:ts=4:sw=4:sts=4