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 module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
43 #include <QtTest/QtTest>
44 #include <QLibraryInfo>
46 #include "../qxmlquery/TestFundament.h"
49 \class tst_XmlPatterns
52 \brief Tests the command line interface, \c xmlpatternsvalidator, for the XML validation code.
54 class tst_XmlPatternsValidator : public QObject
55 , private TestFundament
60 tst_XmlPatternsValidator();
65 void xsdSupport_data() const;
68 const QString m_command;
72 tst_XmlPatternsValidator::tst_XmlPatternsValidator()
73 : m_command(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/xmlpatternsvalidator"))
78 void tst_XmlPatternsValidator::initTestCase()
81 process.start(m_command);
83 if(!process.waitForFinished())
88 "The command line tool (%1) could not be run, possibly because Qt was "
89 "incompletely built or installed. No tests will be run."
95 void tst_XmlPatternsValidator::xsdSupport()
98 QSKIP("The command line utility is not in the path.");
101 QSKIP("WinCE: This test uses unsupported WinCE functionality");
104 QFETCH(int, expectedExitCode);
105 QFETCH(QStringList, arguments);
106 QFETCH(QString, cwd);
111 process.setWorkingDirectory(inputFile(cwd));
113 process.start(m_command, arguments);
115 QVERIFY(process.waitForFinished());
116 QCOMPARE(process.exitStatus(), QProcess::NormalExit);
118 if(process.exitCode() != expectedExitCode)
119 QTextStream(stderr) << "foo:" << process.readAllStandardError();
121 QCOMPARE(process.exitCode(), expectedExitCode);
124 void tst_XmlPatternsValidator::xsdSupport_data() const
130 QTest::addColumn<int>("expectedExitCode");
131 QTest::addColumn<QStringList>("arguments");
132 QTest::addColumn<QString>("cwd");
134 QTest::newRow("No arguments")
139 QTest::newRow("A valid schema")
141 << QStringList(QLatin1String("files/valid_schema.xsd"))
144 QTest::newRow("An invalid schema")
146 << QStringList(QLatin1String("files/invalid_schema.xsd"))
149 QTest::newRow("An instance and valid schema")
151 << (QStringList() << QLatin1String("files/instance.xml")
152 << QLatin1String("files/valid_schema.xsd"))
155 QTest::newRow("An instance and invalid schema")
157 << (QStringList() << QLatin1String("files/instance.xml")
158 << QLatin1String("files/invalid_schema.xsd"))
161 QTest::newRow("An instance and not matching schema")
163 << (QStringList() << QLatin1String("files/instance.xml")
164 << QLatin1String("files/other_valid_schema.xsd"))
167 QTest::newRow("Two instance documents")
169 << (QStringList() << QLatin1String("files/instance.xml")
170 << QLatin1String("files/instance.xml"))
173 QTest::newRow("Three instance documents")
175 << (QStringList() << QLatin1String("files/instance.xml")
176 << QLatin1String("files/instance.xml")
177 << QLatin1String("files/instance.xml"))
180 QTest::newRow("Two schema documents")
182 << (QStringList() << QLatin1String("files/valid_schema.xsd")
183 << QLatin1String("files/valid_schema.xsd"))
186 QTest::newRow("A schema aware valid instance document")
188 << (QStringList() << QLatin1String("files/sa_valid_instance.xml"))
191 QTest::newRow("A schema aware invalid instance document")
193 << (QStringList() << QLatin1String("files/sa_invalid_instance.xml"))
196 QTest::newRow("A non-schema aware instance document")
198 << (QStringList() << QLatin1String("files/instance.xml"))
201 QTest::newRow("QTBUG-8394 A schema with an indirectly included type")
203 << (QStringList() << QLatin1String("files/indirect-include-a.xsd"))
206 QTest::newRow("QTBUG-8394 A schema with an indirectly imported type")
208 << (QStringList() << QLatin1String("files/indirect-import-a.xsd"))
211 QTest::newRow("QTBUG-8394 A schema with an indirectly redefined type")
213 << (QStringList() << QLatin1String("files/indirect-redefine-a.xsd"))
216 QTest::newRow("QTBUG-8920 A schema with a complex type that indirectly includes an anonymous type")
218 << (QStringList() << QLatin1String("files/complex-type-including-anonymous-type.xsd"))
221 QTest::newRow("QTBUG-11559 A schema and instance with a dateTime containing microseconds")
223 << (QStringList() << QLatin1String("files/dateTime-with-microseconds.xml")
224 << QLatin1String("files/dateTime-with-microseconds.xsd"))
228 QTEST_MAIN(tst_XmlPatternsValidator)
230 #include "tst_xmlpatternsvalidator.moc"
232 // vim: et:ts=4:sw=4:sts=4