| 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 test suite 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 |  | 
| 30 | #include <QtCore/QDirIterator> | 
| 31 | #include <QtTest/QtTest> | 
| 32 |  | 
| 33 | #include <QtXmlPatterns/QXmlQuery> | 
| 34 | #include <QtXmlPatterns/QXmlSerializer> | 
| 35 | #include "../qxmlquery/TestFundament.h" | 
| 36 |  | 
| 37 | /*! | 
| 38 |  \class tst_CheckXMLFiles | 
| 39 |  \internal | 
| 40 |  \since 4.4 | 
| 41 |  \brief Checks whether the XML files found in $QTDIR are well-formed. | 
| 42 |  */ | 
| 43 | class tst_CheckXMLFiles : public QObject | 
| 44 |                         , private TestFundament | 
| 45 | { | 
| 46 |     Q_OBJECT | 
| 47 |  | 
| 48 | private Q_SLOTS: | 
| 49 |     void checkXMLFiles() const; | 
| 50 |     void checkXMLFiles_data() const; | 
| 51 | }; | 
| 52 |  | 
| 53 | void tst_CheckXMLFiles::checkXMLFiles() const | 
| 54 | { | 
| 55 |     QFETCH(QString, file); | 
| 56 |  | 
| 57 |     QXmlQuery query; | 
| 58 |     query.setQuery(sourceCode: QLatin1String("doc-available('" ) + inputFileAsURI(file).toString() + QLatin1String("')" )); | 
| 59 |     QVERIFY(query.isValid()); | 
| 60 |  | 
| 61 |     /* We don't care about the result, we only want to ensure the files can be parsed. */ | 
| 62 |     QByteArray dummy; | 
| 63 |     QBuffer buffer(&dummy); | 
| 64 |     QVERIFY(buffer.open(QIODevice::WriteOnly)); | 
| 65 |     QXmlSerializer serializer(query, &buffer); | 
| 66 |  | 
| 67 |     /* This is the important one. */ | 
| 68 |     QVERIFY(query.evaluateTo(&serializer)); | 
| 69 | } | 
| 70 |  | 
| 71 | void tst_CheckXMLFiles::checkXMLFiles_data() const | 
| 72 | { | 
| 73 |     QTest::addColumn<QString>(name: "file" ); | 
| 74 |  | 
| 75 |     QStringList patterns; | 
| 76 |     /* List possible XML files in Qt. */ | 
| 77 |     patterns.append(t: QLatin1String("*.xml" )); | 
| 78 |     patterns.append(t: QLatin1String("*.gccxml" )); | 
| 79 |     patterns.append(t: QLatin1String("*.svg" )); | 
| 80 |     patterns.append(t: QLatin1String("*.ui" )); | 
| 81 |     patterns.append(t: QLatin1String("*.qrc" )); | 
| 82 |     patterns.append(t: QLatin1String("*.ts" )); | 
| 83 |     /* We don't do HTML files currently because so many of them in 3rd party are broken. */ | 
| 84 |     patterns.append(t: QLatin1String("*.xhtml" )); | 
| 85 |  | 
| 86 |     QDirIterator it(QLatin1String(SOURCETREE), patterns, QDir::AllEntries, QDirIterator::Subdirectories); | 
| 87 |     while(it.hasNext()) | 
| 88 |     { | 
| 89 |         it.next(); | 
| 90 |         QTest::newRow(dataTag: it.filePath().toUtf8().constData()) << it.filePath(); | 
| 91 |     } | 
| 92 | } | 
| 93 |  | 
| 94 | QTEST_MAIN(tst_CheckXMLFiles) | 
| 95 |  | 
| 96 | #include "tst_checkxmlfiles.moc" | 
| 97 |  | 
| 98 | // vim: et:ts=4:sw=4:sts=4 | 
| 99 |  |