From b8c12ed8b1287462b897de76b7a9ad3ff5cc2194 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Mon, 16 Dec 2019 15:22:03 +0100 Subject: Bump version Change-Id: I16747fabe937d18a437880acffa35bcd3e7e2a97 --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index a8a7769..e7499a8 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,4 +2,4 @@ load(qt_build_config) CONFIG += warning_clean DEFINES += QT_NO_FOREACH -MODULE_VERSION = 5.14.0 +MODULE_VERSION = 5.14.1 -- cgit v1.2.1 From 159d7230d301f999633eecef25f8569f5e8831b6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 17 Dec 2019 16:30:29 +0100 Subject: Fix deprecation warnings about QHash::unite() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use QHash::insert() instead, fixing: schema/qxsdparticlechecker.cpp:467:83: warning: ‘QHash& QHash::unite(const QHash&) is deprecated schema/qxsdschemachecker.cpp:108:39: warning: ‘QHash& QHash::unite(const QHash&) is deprecated schema/qxsdschemaresolver.cpp:267:39: warning: ‘QHash& QHash::unite(const QHash&) is deprecated Change-Id: I5ac3ee4f9a8103a9ce1210d6c369597c6b0abddc Reviewed-by: Lars Knoll --- src/xmlpatterns/schema/qxsdparticlechecker.cpp | 2 +- src/xmlpatterns/schema/qxsdschemachecker.cpp | 2 +- src/xmlpatterns/schema/qxsdschemaresolver.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xmlpatterns/schema/qxsdparticlechecker.cpp b/src/xmlpatterns/schema/qxsdparticlechecker.cpp index 139390d..ad7cc8e 100644 --- a/src/xmlpatterns/schema/qxsdparticlechecker.cpp +++ b/src/xmlpatterns/schema/qxsdparticlechecker.cpp @@ -464,7 +464,7 @@ bool XsdParticleChecker::subsumes(const XsdParticle::Ptr &particle, const XsdPar } QHash particlesHash = XsdStateMachineBuilder::particleLookupMap(particle); - particlesHash.unite(XsdStateMachineBuilder::particleLookupMap(derivedParticle)); + particlesHash.insert(XsdStateMachineBuilder::particleLookupMap(derivedParticle)); /* static int counter = 0; diff --git a/src/xmlpatterns/schema/qxsdschemachecker.cpp b/src/xmlpatterns/schema/qxsdschemachecker.cpp index 91a796a..9f7c6a2 100644 --- a/src/xmlpatterns/schema/qxsdschemachecker.cpp +++ b/src/xmlpatterns/schema/qxsdschemachecker.cpp @@ -105,7 +105,7 @@ void XsdSchemaChecker::check() void XsdSchemaChecker::addComponentLocationHash(const ComponentLocationHash &hash) { - m_componentLocationHash.unite(hash); + m_componentLocationHash.insert(hash); } /** diff --git a/src/xmlpatterns/schema/qxsdschemaresolver.cpp b/src/xmlpatterns/schema/qxsdschemaresolver.cpp index 1d21e31..7ca3808 100644 --- a/src/xmlpatterns/schema/qxsdschemaresolver.cpp +++ b/src/xmlpatterns/schema/qxsdschemaresolver.cpp @@ -264,7 +264,7 @@ void XsdSchemaResolver::addSubstitutionGroupType(const XsdElement::Ptr &element) void XsdSchemaResolver::addComponentLocationHash(const ComponentLocationHash &hash) { - m_componentLocationHash.unite(hash); + m_componentLocationHash.insert(hash); } void XsdSchemaResolver::addEnumerationFacetValue(const AtomicValue::Ptr &facetValue, const NamespaceSupport &namespaceSupport) -- cgit v1.2.1 From 0e44a69b3546f259cd01bac1a5d10e86b287eb45 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Wed, 13 Nov 2019 15:38:28 +0100 Subject: Stop using SAX classes for reading XML files The qtxmlpatterns' tests are using SAX classes for parsing XML files. These classes will be deprecated. Replaced QXmlSimpleReader by QDomDocument where applicable. For the test suite handlers inheriting from QXmlDefaultHandler, introduced the XmlParseHelper base class, which drives the parsing loop and allows overriding the methods for handling different XML tokens. Task-number: QTBUG-76177 Change-Id: Ia1a60c898a272906ede459e95ced7ec95d154fde Reviewed-by: Friedemann Kleint --- tests/auto/xmlpatternsdiagnosticsts/Baseline.xml | 2 +- .../TestSuite/DiagnosticsCatalog.xml | 15 ++- .../ExpectedTestResults/ShouldFail/fail-3.txt | 1 - .../ShouldSucceed/succeed-15.txt | 1 + .../TestSuite/Queries/XQuery/ShouldFail/fail-17.xq | 1 - .../Queries/XQuery/ShouldSucceed/succeed-15.xq | 1 + tests/auto/xmlpatternssdk/ResultThreader.cpp | 6 +- tests/auto/xmlpatternssdk/TestBaseLine.cpp | 35 ++----- tests/auto/xmlpatternssdk/TestResultHandler.cpp | 15 ++- tests/auto/xmlpatternssdk/TestResultHandler.h | 12 +-- tests/auto/xmlpatternssdk/TestSuite.cpp | 13 +-- tests/auto/xmlpatternssdk/TestSuiteHandler.cpp | 75 ++++++++------- tests/auto/xmlpatternssdk/TestSuiteHandler.h | 19 ++-- tests/auto/xmlpatternssdk/Worker.h | 1 + tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp | 26 +++-- tests/auto/xmlpatternssdk/XSDTestSuiteHandler.h | 19 ++-- tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.cpp | 60 +++++++----- tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.h | 19 ++-- tests/auto/xmlpatternssdk/XmlParseHelper.cpp | 106 +++++++++++++++++++++ tests/auto/xmlpatternssdk/XmlParseHelper.h | 57 +++++++++++ tests/auto/xmlpatternssdk/xmlpatternssdk.pro | 6 +- 21 files changed, 317 insertions(+), 173 deletions(-) delete mode 100644 tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldFail/fail-3.txt create mode 100644 tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldSucceed/succeed-15.txt delete mode 100644 tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldFail/fail-17.xq create mode 100644 tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldSucceed/succeed-15.xq create mode 100644 tests/auto/xmlpatternssdk/XmlParseHelper.cpp create mode 100644 tests/auto/xmlpatternssdk/XmlParseHelper.h diff --git a/tests/auto/xmlpatternsdiagnosticsts/Baseline.xml b/tests/auto/xmlpatternsdiagnosticsts/Baseline.xml index 166fbf3..acf7df3 100644 --- a/tests/auto/xmlpatternsdiagnosticsts/Baseline.xml +++ b/tests/auto/xmlpatternsdiagnosticsts/Baseline.xml @@ -1,2 +1,2 @@ -

Patternist is an implementation written in C++ and with the Qt/KDE libraries. It is licensed under GNU LGPL and part of KDE, the K Desktop Environment.

XQuery
\ No newline at end of file +

Patternist is an implementation written in C++ and with the Qt/KDE libraries. It is licensed under GNU LGPL and part of KDE, the K Desktop Environment.

XQuery
diff --git a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/DiagnosticsCatalog.xml b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/DiagnosticsCatalog.xml index 5a96441..6a07a77 100644 --- a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/DiagnosticsCatalog.xml +++ b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/DiagnosticsCatalog.xml @@ -782,14 +782,6 @@ - - Space is significant. - - emptydoc - fail-3.txt - - Test that XML documents that differs on the top level, are flagged(type being runtime-error). @@ -1039,6 +1031,13 @@ succeed-14.txt + + Space is ignored. + + emptydoc + succeed-15.txt + + diff --git a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldFail/fail-3.txt b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldFail/fail-3.txt deleted file mode 100644 index a06c409..0000000 --- a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldFail/fail-3.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldSucceed/succeed-15.txt b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldSucceed/succeed-15.txt new file mode 100644 index 0000000..a06c409 --- /dev/null +++ b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldSucceed/succeed-15.txt @@ -0,0 +1 @@ + diff --git a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldFail/fail-17.xq b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldFail/fail-17.xq deleted file mode 100644 index 10a7e70..0000000 --- a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldFail/fail-17.xq +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldSucceed/succeed-15.xq b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldSucceed/succeed-15.xq new file mode 100644 index 0000000..10a7e70 --- /dev/null +++ b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldSucceed/succeed-15.xq @@ -0,0 +1 @@ + diff --git a/tests/auto/xmlpatternssdk/ResultThreader.cpp b/tests/auto/xmlpatternssdk/ResultThreader.cpp index 749a2dd..abdac88 100644 --- a/tests/auto/xmlpatternssdk/ResultThreader.cpp +++ b/tests/auto/xmlpatternssdk/ResultThreader.cpp @@ -45,11 +45,7 @@ ResultThreader::ResultThreader(QFile *file, void ResultThreader::run() { - QXmlSimpleReader reader; - reader.setContentHandler(this); - - QXmlInputSource source(m_file); - reader.parse(source); + parse(m_file); m_file->close(); } diff --git a/tests/auto/xmlpatternssdk/TestBaseLine.cpp b/tests/auto/xmlpatternssdk/TestBaseLine.cpp index e257c42..78232cd 100644 --- a/tests/auto/xmlpatternssdk/TestBaseLine.cpp +++ b/tests/auto/xmlpatternssdk/TestBaseLine.cpp @@ -310,19 +310,11 @@ TestResult::Status TestBaseLine::verify(const QString &serializedInput) const * QDomDocument does whitespace stripping when calling setContent(QString). In other words, * this workarounds a bug. */ - QXmlInputSource source; - source.setData((m_type == XML ? serializedInput : QLatin1String("") + - serializedInput + - QLatin1String("")).toUtf8()); - - QString outputReadingError; - - QXmlSimpleReader reader; - reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), true); - - const bool success = output.setContent(&source, - &reader, - &outputReadingError); + const bool success = + output.setContent((m_type == XML ? serializedInput + : QLatin1String("") + serializedInput + + QLatin1String("")) + .toUtf8()); if(!success) return TestResult::Fail; @@ -332,19 +324,12 @@ TestResult::Status TestBaseLine::verify(const QString &serializedInput) const QDomDocument baseline; { - QXmlInputSource source; - source.setData((m_type == XML ? details() : QLatin1String("") + - details() + - QLatin1String("")).toUtf8()); QString baselineReadingError; - - QXmlSimpleReader reader; - reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), true); - - const bool success = baseline.setContent(&source, - &reader, - &baselineReadingError); - + const bool success = baseline.setContent( + (m_type == XML ? details() + : QLatin1String("") + details() + QLatin1String("")) + .toUtf8(), + &baselineReadingError); if(!success) return TestResult::Fail; diff --git a/tests/auto/xmlpatternssdk/TestResultHandler.cpp b/tests/auto/xmlpatternssdk/TestResultHandler.cpp index 92f0c01..d578f3a 100644 --- a/tests/auto/xmlpatternssdk/TestResultHandler.cpp +++ b/tests/auto/xmlpatternssdk/TestResultHandler.cpp @@ -41,10 +41,8 @@ TestResultHandler::TestResultHandler() m_comments.reserve(1000); /* Comments are only used for stuff that crash, more or less. */ } -bool TestResultHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &, - const QXmlAttributes &atts) +bool TestResultHandler::startElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &, const QXmlStreamAttributes &atts) { /* We only care about 'test-case', ignore everything else. */ if(localName != QLatin1String("test-case") || @@ -55,12 +53,13 @@ bool TestResultHandler::startElement(const QString &namespaceURI, Q_ASSERT_X(atts.count() == 2 || atts.count() == 3, Q_FUNC_INFO, "The input appears to not conform to XQTSResult.xsd"); - Q_ASSERT_X(!m_result.contains(atts.value(QLatin1String("name"))), - Q_FUNC_INFO, + Q_ASSERT_X(!m_result.contains(atts.value(QLatin1String("name")).toString()), Q_FUNC_INFO, qPrintable(QString::fromLatin1("A test result for test case %1 has " - "already been read(duplicate entry it seems).").arg(atts.value(QLatin1String("name"))))); + "already been read(duplicate entry it seems).") + .arg(atts.value(QLatin1String("name"))))); - m_result.insert(atts.value(0), TestResult::statusFromString(atts.value(QLatin1String("result")))); + m_result.insert(atts.at(0).value().toString(), + TestResult::statusFromString(atts.value(QLatin1String("result")).toString())); return true; } diff --git a/tests/auto/xmlpatternssdk/TestResultHandler.h b/tests/auto/xmlpatternssdk/TestResultHandler.h index 728b7e8..014c739 100644 --- a/tests/auto/xmlpatternssdk/TestResultHandler.h +++ b/tests/auto/xmlpatternssdk/TestResultHandler.h @@ -31,9 +31,9 @@ #include #include -#include #include "TestResult.h" +#include "XmlParseHelper.h" QT_BEGIN_NAMESPACE @@ -46,7 +46,7 @@ namespace QPatternistSDK * @author Frans Englich * @ingroup PatternistSDK */ - class TestResultHandler : public QXmlDefaultHandler + class TestResultHandler : public XmlParseHelper { public: /** @@ -68,15 +68,13 @@ namespace QPatternistSDK /** * Performs finalization. */ - virtual bool endDocument(); + bool endDocument() override; /** * Reads the test-case element and its attributes, everything else is ignored. */ - virtual bool startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts); + bool startElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &qName, const QXmlStreamAttributes &atts) override; /** * @note Do not reimplement this function. * @returns the result obtained from reading the XML file. diff --git a/tests/auto/xmlpatternssdk/TestSuite.cpp b/tests/auto/xmlpatternssdk/TestSuite.cpp index 004fba5..973fe40 100644 --- a/tests/auto/xmlpatternssdk/TestSuite.cpp +++ b/tests/auto/xmlpatternssdk/TestSuite.cpp @@ -28,13 +28,12 @@ #include #include -#include -#include #include #include "Global.h" #include "TestSuiteHandler.h" #include "TestSuiteResult.h" +#include "XmlParseHelper.h" #include "XMLWriter.h" #include "XSLTTestSuiteHandler.h" #include "XSDTestSuiteHandler.h" @@ -125,8 +124,7 @@ TestSuite *TestSuite::openCatalog(QIODevice *input, { Q_ASSERT(input); - QXmlSimpleReader reader; - typedef QPatternist::AutoPtr HandlerPtr; + typedef QPatternist::AutoPtr HandlerPtr; HandlerPtr loader; @@ -137,12 +135,7 @@ TestSuite *TestSuite::openCatalog(QIODevice *input, default: Q_ASSERT(false); break; } - reader.setContentHandler(loader.data()); - - QXmlInputSource source(input); - - if(!reader.parse(source)) - { + if (!loader.data()->parse(input)) { errorMsg = QString::fromLatin1("Couldn't parse %1").arg(fileName.toString()); return 0; } diff --git a/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp b/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp index 68bedca..ba4dc8a 100644 --- a/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp +++ b/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp @@ -89,10 +89,8 @@ QStringList TestSuiteHandler::readExclusionList(const bool useExclusionList) con return avoid; } -bool TestSuiteHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &/*qName*/, - const QXmlAttributes &atts) +bool TestSuiteHandler::startElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef & /*qName*/, const QXmlStreamAttributes &atts) { if(namespaceURI != Global::xqtsCatalogNS) return true; @@ -100,7 +98,7 @@ bool TestSuiteHandler::startElement(const QString &namespaceURI, { if(localName == QLatin1String("test-group")) { - m_testGroupName.push(atts.value(QLatin1String("name"))); + m_testGroupName.push(atts.value(QLatin1String("name")).toString()); return true; } else @@ -111,16 +109,20 @@ bool TestSuiteHandler::startElement(const QString &namespaceURI, if(localName == QLatin1String("test-case")) { XQTSTestCase *const c = new XQTSTestCase( - TestCase::scenarioFromString(atts.value(QLatin1String("scenario"))), m_container); - - c->setName(atts.value(QLatin1String("name"))); - c->setCreator(atts.value(QLatin1String("Creator"))); - c->setIsXPath(Global::readBoolean(atts.value(QLatin1String("is-XPath2")))); - c->setLastModified(QDate::fromString(atts.value(QLatin1String("version-drop")), Qt::ISODate)); + TestCase::scenarioFromString(atts.value(QLatin1String("scenario")).toString()), + m_container); + + c->setName(atts.value(QLatin1String("name")).toString()); + c->setCreator(atts.value(QLatin1String("Creator")).toString()); + c->setIsXPath(Global::readBoolean(atts.value(QLatin1String("is-XPath2")).toString())); + c->setLastModified(QDate::fromString(atts.value(QLatin1String("version-drop")).toString(), + Qt::ISODate)); Q_ASSERT(c->lastModified().isNull() || c->lastModified().isValid()); - m_currentQueryPath = m_queryOffset.resolved(QUrl(atts.value(QLatin1String("FilePath")))); - m_currentBaselinePath = m_baselineOffset.resolved(QUrl(atts.value(QLatin1String("FilePath")))); + m_currentQueryPath = + m_queryOffset.resolved(QUrl(atts.value(QLatin1String("FilePath")).toString())); + m_currentBaselinePath = + m_baselineOffset.resolved(QUrl(atts.value(QLatin1String("FilePath")).toString())); m_container->appendChild(c); m_tc = c; @@ -133,11 +135,12 @@ bool TestSuiteHandler::startElement(const QString &namespaceURI, else if(localName == QLatin1String("input-file") || localName == QLatin1String("input-URI")) { - m_currentInputVariable = atts.value(QLatin1String("variable")); + m_currentInputVariable = atts.value(QLatin1String("variable")).toString(); } else if(localName == QLatin1String("output-file")) { - m_baseLine = new TestBaseLine(TestBaseLine::identifierFromString(atts.value(QLatin1String("compare")))); + m_baseLine = new TestBaseLine(TestBaseLine::identifierFromString( + atts.value(QLatin1String("compare")).toString())); } else if(localName == QLatin1String("expected-error")) { @@ -145,7 +148,7 @@ bool TestSuiteHandler::startElement(const QString &namespaceURI, } else if(localName == QLatin1String("test-group")) { - m_testGroupName.push(atts.value(QLatin1String("name"))); + m_testGroupName.push(atts.value(QLatin1String("name")).toString()); if(m_exclusionList.contains(m_testGroupName.top())) { @@ -164,35 +167,43 @@ bool TestSuiteHandler::startElement(const QString &namespaceURI, } else if(localName == QLatin1String("source")) { - m_sourceMap.insert(atts.value(QLatin1String("ID")), - m_sourceOffset.resolved(QUrl(atts.value(QLatin1String("FileName"))))); + m_sourceMap.insert( + atts.value(QLatin1String("ID")).toString(), + m_sourceOffset.resolved(QUrl(atts.value(QLatin1String("FileName")).toString()))); } else if(localName == QLatin1String("test-suite")) { m_ts = new TestSuite(); - m_ts->setVersion(atts.value(QLatin1String("version"))); - m_ts->setDesignDate(QDate::fromString(atts.value(QLatin1String("CatalogDesignDate")), Qt::ISODate)); + m_ts->setVersion(atts.value(QLatin1String("version")).toString()); + m_ts->setDesignDate(QDate::fromString( + atts.value(QLatin1String("CatalogDesignDate")).toString(), Qt::ISODate)); Q_ASSERT(m_ts->designDate().isValid()); m_container = m_ts; - m_xqueryFileExtension = atts.value(QLatin1String("XQueryFileExtension")); - m_queryOffset = m_catalogFile.resolved(atts.value(QLatin1String("XQueryQueryOffsetPath"))); - m_baselineOffset = m_catalogFile.resolved(atts.value(QLatin1String("ResultOffsetPath"))); - m_sourceOffset = m_catalogFile.resolved(atts.value(QLatin1String("SourceOffsetPath"))); + m_xqueryFileExtension = atts.value(QLatin1String("XQueryFileExtension")).toString(); + m_queryOffset = m_catalogFile.resolved( + atts.value(QLatin1String("XQueryQueryOffsetPath")).toString()); + m_baselineOffset = + m_catalogFile.resolved(atts.value(QLatin1String("ResultOffsetPath")).toString()); + m_sourceOffset = + m_catalogFile.resolved(atts.value(QLatin1String("SourceOffsetPath")).toString()); } else if(localName == QLatin1String("input-query")) { - m_tcSourceInputs.insert(atts.value(QLatin1String("variable")), - ExternalSourceLoader::VariableValue(m_currentQueryPath.resolved(atts.value(QLatin1String("name")) + m_xqueryFileExtension), - ExternalSourceLoader::Query)); + m_tcSourceInputs.insert( + atts.value(QLatin1String("variable")).toString(), + ExternalSourceLoader::VariableValue( + m_currentQueryPath.resolved(atts.value(QLatin1String("name")) + + m_xqueryFileExtension), + ExternalSourceLoader::Query)); } return true; } -bool TestSuiteHandler::endElement(const QString &namespaceURI, - const QString &localName, - const QString &/*qName*/) +bool TestSuiteHandler::endElement(const QStringRef &namespaceURI, + const QStringRef &localName, + const QStringRef &/*qName*/) { if(namespaceURI != Global::xqtsCatalogNS) return true; @@ -299,9 +310,9 @@ bool TestSuiteHandler::endElement(const QString &namespaceURI, return true; } -bool TestSuiteHandler::characters(const QString &ch) +bool TestSuiteHandler::characters(const QStringRef &ch) { - m_ch = ch; + m_ch = ch.toString(); return true; } diff --git a/tests/auto/xmlpatternssdk/TestSuiteHandler.h b/tests/auto/xmlpatternssdk/TestSuiteHandler.h index 25c2f0c..504bd3f 100644 --- a/tests/auto/xmlpatternssdk/TestSuiteHandler.h +++ b/tests/auto/xmlpatternssdk/TestSuiteHandler.h @@ -31,10 +31,10 @@ #include #include -#include #include "ExternalSourceLoader.h" #include "TestSuite.h" +#include "XmlParseHelper.h" #include "XQTSTestCase.h" QT_BEGIN_NAMESPACE @@ -57,7 +57,7 @@ namespace QPatternistSDK * @ingroup PatternistSDK * @author Frans Englich */ - class TestSuiteHandler : public QXmlDefaultHandler + class TestSuiteHandler : public XmlParseHelper { public: /** @@ -69,17 +69,14 @@ namespace QPatternistSDK */ TestSuiteHandler(const QUrl &catalogFile, const bool useExclusionList); - virtual bool characters(const QString &ch); + bool characters(const QStringRef &ch) override; - virtual bool endElement(const QString &namespaceURI, - const QString &localName, - const QString &qName); - virtual bool startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts); + bool endElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &qName) override; + bool startElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &qName, const QXmlStreamAttributes &atts) override; - virtual TestSuite *testSuite() const; + TestSuite *testSuite() const; private: QStringList readExclusionList(const bool useExclusionList) const; diff --git a/tests/auto/xmlpatternssdk/Worker.h b/tests/auto/xmlpatternssdk/Worker.h index 1d84408..b56a57a 100644 --- a/tests/auto/xmlpatternssdk/Worker.h +++ b/tests/auto/xmlpatternssdk/Worker.h @@ -33,6 +33,7 @@ #include #include #include +#include #include "ResultThreader.h" diff --git a/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp b/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp index 854fef6..4e56af6 100644 --- a/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp +++ b/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp @@ -782,10 +782,8 @@ XSDTestSuiteHandler::XSDTestSuiteHandler(const QUrl &catalogFile) : m_ts(0) << QLatin1String("wildZ010"); } -bool XSDTestSuiteHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &/*qName*/, - const QXmlAttributes &atts) +bool XSDTestSuiteHandler::startElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef & /*qName*/, const QXmlStreamAttributes &atts) { if(namespaceURI != QString::fromLatin1("http://www.w3.org/XML/2004/xml-schema-test-suite/")) return true; @@ -793,16 +791,16 @@ bool XSDTestSuiteHandler::startElement(const QString &namespaceURI, if (localName == QLatin1String("testSet")) { m_currentTestSet = new TestGroup(m_topLevelGroup); Q_ASSERT(m_currentTestSet); - m_currentTestSet->setTitle(atts.value("name")); + m_currentTestSet->setTitle(atts.value("name").toString()); m_topLevelGroup->appendChild(m_currentTestSet); } else if (localName == QLatin1String("testGroup")) { m_currentTestGroup = new TestGroup(m_currentTestSet); Q_ASSERT(m_currentTestGroup); - m_currentTestGroup->setTitle(atts.value("name")); + m_currentTestGroup->setTitle(atts.value("name").toString()); m_currentTestSet->appendChild(m_currentTestGroup); m_inTestGroup = true; } else if (localName == QLatin1String("schemaTest")) { - if (m_blackList.contains(atts.value("name"))) { + if (m_blackList.contains(atts.value("name").toString())) { m_currentTestCase = 0; m_schemaBlacklisted = true; return true; @@ -832,12 +830,12 @@ bool XSDTestSuiteHandler::startElement(const QString &namespaceURI, m_inInstanceTest = true; } else if (localName == QLatin1String("schemaDocument") || localName == QLatin1String("instanceDocument")) { if (m_inSchemaTest) { - m_currentTestCase->setSchemaUri(QUrl(atts.value("xlink:href"))); + m_currentTestCase->setSchemaUri(QUrl(atts.value("xlink:href").toString())); if (m_currentSchemaLink.isEmpty()) // we only use the first schema document for validation - m_currentSchemaLink = atts.value("xlink:href"); + m_currentSchemaLink = atts.value("xlink:href").toString(); } if (m_inInstanceTest) { - m_currentTestCase->setInstanceUri(QUrl(atts.value("xlink:href"))); + m_currentTestCase->setInstanceUri(QUrl(atts.value("xlink:href").toString())); m_currentTestCase->setSchemaUri(QUrl(m_currentSchemaLink)); } } else if (localName == QLatin1String("expected") && (m_inSchemaTest || m_inInstanceTest)) { @@ -858,9 +856,9 @@ bool XSDTestSuiteHandler::startElement(const QString &namespaceURI, return true; } -bool XSDTestSuiteHandler::endElement(const QString &/*namespaceURI*/, - const QString &localName, - const QString &/*qName*/) +bool XSDTestSuiteHandler::endElement(const QStringRef &/*namespaceURI*/, + const QStringRef &localName, + const QStringRef &/*qName*/) { if (localName == QLatin1String("testGroup")) { m_inTestGroup = false; @@ -880,7 +878,7 @@ bool XSDTestSuiteHandler::endElement(const QString &/*namespaceURI*/, return true; } -bool XSDTestSuiteHandler::characters(const QString &ch) +bool XSDTestSuiteHandler::characters(const QStringRef &ch) { if (m_inDescription) m_documentation += ch; diff --git a/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.h b/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.h index 3015d8c..2affbab 100644 --- a/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.h +++ b/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.h @@ -30,10 +30,10 @@ #define PatternistSDK_XSDTestSuiteHandler_H #include -#include #include "ExternalSourceLoader.h" #include "TestSuite.h" +#include "XmlParseHelper.h" #include "XQTSTestCase.h" QT_BEGIN_NAMESPACE @@ -57,7 +57,7 @@ namespace QPatternistSDK * @ingroup PatternistSDK * @author Tobias Koenig */ - class XSDTestSuiteHandler : public QXmlDefaultHandler + class XSDTestSuiteHandler : public XmlParseHelper { public: /** @@ -68,17 +68,14 @@ namespace QPatternistSDK * test groups when loading */ XSDTestSuiteHandler(const QUrl &catalogFile); - virtual bool characters(const QString &ch); + bool characters(const QStringRef &ch) override; - virtual bool endElement(const QString &namespaceURI, - const QString &localName, - const QString &qName); - virtual bool startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts); + bool endElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &qName) override; + bool startElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &qName, const QXmlStreamAttributes &atts) override; - virtual TestSuite *testSuite() const; + TestSuite *testSuite() const; private: TestSuite* m_ts; diff --git a/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.cpp b/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.cpp index 5d2a3db..e690dd2 100644 --- a/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.cpp +++ b/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.cpp @@ -69,11 +69,9 @@ XSLTTestSuiteHandler::XSLTTestSuiteHandler(const QUrl &catalogFile) : m_ts(0) Q_ASSERT(!m_catalogFile.isRelative()); } -bool XSLTTestSuiteHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &/*qName*/, - const QXmlAttributes &atts) - { +bool XSLTTestSuiteHandler::startElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef & /*qName*/, const QXmlStreamAttributes &atts) +{ if(namespaceURI != Global::xsltsCatalogNS) return true; @@ -83,40 +81,50 @@ bool XSLTTestSuiteHandler::startElement(const QString &namespaceURI, /* We pass m_ts temporarily, and change it later. */ m_tc = new XQTSTestCase(TestCase::Standard, 0, QXmlQuery::XSLT20); - m_currentQueryPath = m_queryOffset.resolved(QUrl(atts.value(QLatin1String("FilePath")))); - m_currentBaselinePath = m_baselineOffset.resolved(QUrl(atts.value(QLatin1String("FilePath")))); + m_currentQueryPath = + m_queryOffset.resolved(QUrl(atts.value(QLatin1String("FilePath")).toString())); + m_currentBaselinePath = + m_baselineOffset.resolved(QUrl(atts.value(QLatin1String("FilePath")).toString())); } else if(localName == QLatin1String("stylesheet")) - m_tc->setQueryPath(m_currentQueryPath.resolved(atts.value(QLatin1String("file")))); + m_tc->setQueryPath( + m_currentQueryPath.resolved(atts.value(QLatin1String("file")).toString())); else if(localName == QLatin1String("error")) { m_baseLine = new TestBaseLine(TestBaseLine::ExpectedError); - m_baseLine->setDetails(atts.value(QLatin1String("error-id"))); + m_baseLine->setDetails(atts.value(QLatin1String("error-id")).toString()); m_tc->addBaseLine(m_baseLine); } else if(localName == QLatin1String("testcases")) { m_ts = new TestSuite(); - m_ts->setVersion(atts.value(QLatin1String("testSuiteVersion"))); - - m_queryOffset = m_catalogFile.resolved(atts.value(QLatin1String("InputOffsetPath"))); - m_baselineOffset = m_catalogFile.resolved(atts.value(QLatin1String("ResultOffsetPath"))); - m_sourceOffset = m_catalogFile.resolved(atts.value(QLatin1String("InputOffsetPath"))); + m_ts->setVersion(atts.value(QLatin1String("testSuiteVersion")).toString()); + + m_queryOffset = + m_catalogFile.resolved(atts.value(QLatin1String("InputOffsetPath")).toString()); + m_baselineOffset = + m_catalogFile.resolved(atts.value(QLatin1String("ResultOffsetPath")).toString()); + m_sourceOffset = + m_catalogFile.resolved(atts.value(QLatin1String("InputOffsetPath")).toString()); } else if(localName == QLatin1String("source-document")) { if(atts.value(QLatin1String("role")) == QLatin1String("principal")) - m_tc->setContextItemSource(m_sourceOffset.resolved(QUrl(atts.value(QLatin1String("file"))))); + m_tc->setContextItemSource( + m_sourceOffset.resolved(QUrl(atts.value(QLatin1String("file")).toString()))); } else if(localName == QLatin1String("result-document")) { - m_baseLine = new TestBaseLine(TestBaseLine::identifierFromString(atts.value(QLatin1String("type")))); - m_baseLine->setDetails(m_currentBaselinePath.resolved(atts.value(QLatin1String("file"))).toString()); + m_baseLine = new TestBaseLine( + TestBaseLine::identifierFromString(atts.value(QLatin1String("type")).toString())); + m_baseLine->setDetails( + m_currentBaselinePath.resolved(atts.value(QLatin1String("file")).toString()) + .toString()); m_tc->addBaseLine(m_baseLine); } else if(localName == QLatin1String("discretionary-feature")) { - const QString feature(atts.value(QLatin1String("name"))); + const QString feature(atts.value(QLatin1String("name")).toString()); m_removeTestcase = feature == QLatin1String("schema_aware") || feature == QLatin1String("namespace_axis") || @@ -126,9 +134,9 @@ bool XSLTTestSuiteHandler::startElement(const QString &namespaceURI, else if(localName == QLatin1String("discretionary-choice")) { m_baseLine = new TestBaseLine(TestBaseLine::ExpectedError); - m_baseLine->setDetails(atts.value(QLatin1String("name"))); + m_baseLine->setDetails(atts.value(QLatin1String("name")).toString()); m_tc->addBaseLine(m_baseLine); - const QString feature(atts.value(QLatin1String("name"))); + const QString feature(atts.value(QLatin1String("name")).toString()); m_removeTestcase = feature == QLatin1String("schema_aware") || feature == QLatin1String("namespace_axis") || @@ -137,7 +145,7 @@ bool XSLTTestSuiteHandler::startElement(const QString &namespaceURI, } else if(localName == QLatin1String("entry-named-template")) { - const QString name(atts.value(QLatin1String("qname"))); + const QString name(atts.value(QLatin1String("qname")).toString()); if(!name.contains(QLatin1Char(':'))) { @@ -166,9 +174,9 @@ TestGroup *XSLTTestSuiteHandler::containerFor(const QString &name) return c; } -bool XSLTTestSuiteHandler::endElement(const QString &namespaceURI, - const QString &localName, - const QString &/*qName*/) +bool XSLTTestSuiteHandler::endElement(const QStringRef &namespaceURI, + const QStringRef &localName, + const QStringRef &/*qName*/) { if(namespaceURI != Global::xsltsCatalogNS) return true; @@ -221,9 +229,9 @@ bool XSLTTestSuiteHandler::endElement(const QString &namespaceURI, return true; } -bool XSLTTestSuiteHandler::characters(const QString &ch) +bool XSLTTestSuiteHandler::characters(const QStringRef &ch) { - m_ch = ch; + m_ch = ch.toString(); return true; } diff --git a/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.h b/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.h index 231b55d..b5879c1 100644 --- a/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.h +++ b/tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.h @@ -31,10 +31,10 @@ #include #include -#include #include "ExternalSourceLoader.h" #include "TestSuite.h" +#include "XmlParseHelper.h" #include "XQTSTestCase.h" QT_BEGIN_NAMESPACE @@ -59,7 +59,7 @@ namespace QPatternistSDK * @ingroup PatternistSDK * @author Frans Englich */ - class XSLTTestSuiteHandler : public QXmlDefaultHandler + class XSLTTestSuiteHandler : public XmlParseHelper { public: /** @@ -70,17 +70,14 @@ namespace QPatternistSDK * test groups when loading */ XSLTTestSuiteHandler(const QUrl &catalogFile); - virtual bool characters(const QString &ch); + bool characters(const QStringRef &ch) override; - virtual bool endElement(const QString &namespaceURI, - const QString &localName, - const QString &qName); - virtual bool startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts); + bool endElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &qName) override; + bool startElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &qName, const QXmlStreamAttributes &atts) override; - virtual TestSuite *testSuite() const; + TestSuite *testSuite() const; private: TestGroup *containerFor(const QString &name); diff --git a/tests/auto/xmlpatternssdk/XmlParseHelper.cpp b/tests/auto/xmlpatternssdk/XmlParseHelper.cpp new file mode 100644 index 0000000..7629753 --- /dev/null +++ b/tests/auto/xmlpatternssdk/XmlParseHelper.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "XmlParseHelper.h" + +QT_BEGIN_NAMESPACE + +namespace QPatternistSDK { + +bool XmlParseHelper::parse(QIODevice *input) +{ + QXmlStreamReader reader(input); + + while (!reader.atEnd()) { + reader.readNext(); + if (reader.hasError()) + return false; + + switch (reader.tokenType()) { + case QXmlStreamReader::StartElement: + if (!startElement(reader.namespaceUri(), reader.name(), + reader.qualifiedName(), reader.attributes())) { + return false; + } + break; + case QXmlStreamReader::EndElement: + if (!endElement(reader.namespaceUri(), reader.name(), + reader.qualifiedName())) { + return false; + } + break; + case QXmlStreamReader::Characters: + if (!reader.isWhitespace() && !reader.text().toString().trimmed().isEmpty()) { + if (!characters(reader.text())) + return false; + } + break; + default: + break; + } + } + + if (reader.isEndDocument() && !endDocument()) + return false; + + return true; +} + +bool XmlParseHelper::startElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &qName, const QXmlStreamAttributes &atts) +{ + Q_UNUSED(namespaceURI) + Q_UNUSED(localName) + Q_UNUSED(qName) + Q_UNUSED(atts) + return true; +} + +bool XmlParseHelper::endElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &qName) +{ + Q_UNUSED(namespaceURI) + Q_UNUSED(localName) + Q_UNUSED(qName) + return true; +} + +bool XmlParseHelper::characters(const QStringRef &text) +{ + Q_UNUSED(text) + return true; +} + +bool XmlParseHelper::endDocument() +{ + return true; +} + +} // namespace QPatternistSDK + +QT_END_NAMESPACE diff --git a/tests/auto/xmlpatternssdk/XmlParseHelper.h b/tests/auto/xmlpatternssdk/XmlParseHelper.h new file mode 100644 index 0000000..2bf6314 --- /dev/null +++ b/tests/auto/xmlpatternssdk/XmlParseHelper.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef XMLPARSEHELPER_H +#define XMLPARSEHELPER_H + +#include + +QT_BEGIN_NAMESPACE + +namespace QPatternistSDK { +class XmlParseHelper +{ +public: + virtual ~XmlParseHelper() = default; + + bool parse(QIODevice *input); + +protected: + virtual bool startElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &qName, const QXmlStreamAttributes &atts); + virtual bool endElement(const QStringRef &namespaceURI, const QStringRef &localName, + const QStringRef &qName); + virtual bool characters(const QStringRef &text); + virtual bool endDocument(); +}; + +} // namespace QPatternistSDK + +QT_END_NAMESPACE + +#endif // XMLPARSEHELPER_H diff --git a/tests/auto/xmlpatternssdk/xmlpatternssdk.pro b/tests/auto/xmlpatternssdk/xmlpatternssdk.pro index e52962c..5512aec 100644 --- a/tests/auto/xmlpatternssdk/xmlpatternssdk.pro +++ b/tests/auto/xmlpatternssdk/xmlpatternssdk.pro @@ -53,7 +53,8 @@ HEADERS = ASTItem.h \ XQTSTestCase.h \ XSDTestSuiteHandler.h \ XSDTSTestCase.h \ - XSLTTestSuiteHandler.h + XSLTTestSuiteHandler.h \ + XmlParseHelper.h SOURCES = ASTItem.cpp \ DebugExpressionFactory.cpp \ @@ -80,4 +81,5 @@ SOURCES = ASTItem.cpp \ XQTSTestCase.cpp \ XSDTestSuiteHandler.cpp \ XSDTSTestCase.cpp \ - XSLTTestSuiteHandler.cpp + XSLTTestSuiteHandler.cpp \ + XmlParseHelper.cpp -- cgit v1.2.1 From 3839255e1c11c78046896a37948cda849b0c5bc8 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Fri, 22 Nov 2019 17:41:08 +0100 Subject: Stop using SAX classes for writing XML in tests Removed the dependency of XMLWriter from QXmlContentHandler and QXmlLexicalHandler which are about to be deprecated. There's no need in inheriting from these interfaces, the tests call the methods of XMLWriter directly via XMLWriter instance. Task-number: QTBUG-76177 Change-Id: I2fe237b962774a004a9014f3dab1b5de5072f180 Reviewed-by: Friedemann Kleint --- tests/auto/xmlpatternssdk/TestBaseLine.cpp | 16 ++--- tests/auto/xmlpatternssdk/TestCase.cpp | 20 +++---- tests/auto/xmlpatternssdk/TestResult.cpp | 8 +-- tests/auto/xmlpatternssdk/TestSuite.cpp | 32 ++++------ tests/auto/xmlpatternssdk/TestSuiteResult.cpp | 31 +++++----- tests/auto/xmlpatternssdk/XMLWriter.cpp | 47 +++------------ tests/auto/xmlpatternssdk/XMLWriter.h | 84 ++------------------------- 7 files changed, 54 insertions(+), 184 deletions(-) diff --git a/tests/auto/xmlpatternssdk/TestBaseLine.cpp b/tests/auto/xmlpatternssdk/TestBaseLine.cpp index 78232cd..f8ad128 100644 --- a/tests/auto/xmlpatternssdk/TestBaseLine.cpp +++ b/tests/auto/xmlpatternssdk/TestBaseLine.cpp @@ -127,11 +127,9 @@ void TestBaseLine::toXML(XMLWriter &receiver) const case SchemaIsValid: /* Fallthrough. */ case Text: { - QXmlAttributes inspectAtts; - inspectAtts.append(QLatin1String("role"), QString(), - QLatin1String("role"), QLatin1String("principal")); - inspectAtts.append(QLatin1String("compare"), QString(), - QLatin1String("compare"), displayName(m_type)); + QXmlStreamAttributes inspectAtts; + inspectAtts.append(QLatin1String("role"), QLatin1String("principal")); + inspectAtts.append(QLatin1String("compare"), displayName(m_type)); receiver.startElement(QLatin1String("output-file"), inspectAtts); receiver.characters(m_details); receiver.endElement(QLatin1String("output-file")); @@ -144,11 +142,9 @@ void TestBaseLine::toXML(XMLWriter &receiver) const } case Inspect: { - QXmlAttributes inspectAtts; - inspectAtts.append(QLatin1String("role"), QString(), - QLatin1String("role"), QLatin1String("principal")); - inspectAtts.append(QLatin1String("compare"), QString(), - QLatin1String("compare"), QLatin1String("Inspect")); + QXmlStreamAttributes inspectAtts; + inspectAtts.append(QLatin1String("role"), QLatin1String("principal")); + inspectAtts.append(QLatin1String("compare"), QLatin1String("Inspect")); receiver.startElement(QLatin1String("output-file"), inspectAtts); receiver.characters(m_details); receiver.endElement(QLatin1String("output-file")); diff --git a/tests/auto/xmlpatternssdk/TestCase.cpp b/tests/auto/xmlpatternssdk/TestCase.cpp index bf9241c..6827f36 100644 --- a/tests/auto/xmlpatternssdk/TestCase.cpp +++ b/tests/auto/xmlpatternssdk/TestCase.cpp @@ -336,12 +336,11 @@ TestCase::Scenario TestCase::scenarioFromString(const QString &string) void TestCase::toXML(XMLWriter &receiver) const { /* */ - QXmlAttributes test_caseAtts; - test_caseAtts.append(QLatin1String("is-XPath2"), QString(), - QLatin1String("is-XPath2"), isXPath() ? QLatin1String("true") + QXmlStreamAttributes test_caseAtts; + test_caseAtts.append(QLatin1String("is-XPath2"), isXPath() ? QLatin1String("true") : QLatin1String("false")); - test_caseAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), name()); - test_caseAtts.append(QLatin1String("creator"), QString(), QLatin1String("creator"), creator()); + test_caseAtts.append(QLatin1String("name"), name()); + test_caseAtts.append(QLatin1String("creator"), creator()); QString scen; switch(scenario()) { @@ -368,9 +367,8 @@ void TestCase::toXML(XMLWriter &receiver) const default: /* includes 'AnyError' */ Q_ASSERT(false); } - test_caseAtts.append(QLatin1String("scenario"), QString(), QLatin1String("scenario"), scen); - test_caseAtts.append(QLatin1String(QLatin1String("FilePath")), QString(), - QLatin1String("FilePath"), QString()); + test_caseAtts.append(QLatin1String("scenario"), scen); + test_caseAtts.append(QLatin1String("FilePath"), QString()); receiver.startElement(QLatin1String("test-case"), test_caseAtts); /* */ @@ -381,10 +379,10 @@ void TestCase::toXML(XMLWriter &receiver) const receiver.endElement(QLatin1String("description")); /* */ - QXmlAttributes queryAtts; - queryAtts.append(QLatin1String("date"), QString(), QLatin1String("date"), /* This date is a dummy. */ + QXmlStreamAttributes queryAtts; + queryAtts.append(QLatin1String("date"), /* This date is a dummy. */ QDate::currentDate().toString(Qt::ISODate)); - queryAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), testCasePath().toString()); + queryAtts.append(QLatin1String("name"), testCasePath().toString()); receiver.startElement(QLatin1String("query"), queryAtts); /* */ diff --git a/tests/auto/xmlpatternssdk/TestResult.cpp b/tests/auto/xmlpatternssdk/TestResult.cpp index 5629971..5599ab4 100644 --- a/tests/auto/xmlpatternssdk/TestResult.cpp +++ b/tests/auto/xmlpatternssdk/TestResult.cpp @@ -94,12 +94,12 @@ TestResult::~TestResult() void TestResult::toXML(XMLWriter &receiver) const { - QXmlAttributes atts; - atts.append(QLatin1String("name"), QString(), QLatin1String("name"), m_testName); - atts.append(QLatin1String("result"), QString(), QLatin1String("result"), displayName(m_status)); + QXmlStreamAttributes atts; + atts.append(QLatin1String("name"), m_testName); + atts.append(QLatin1String("result"), displayName(m_status)); if(!m_comment.isEmpty()) - atts.append(QLatin1String("comment"), QString(), QLatin1String("comment"), m_comment); + atts.append(QLatin1String("comment"), m_comment); receiver.startElement(QLatin1String("test-case"), atts); receiver.endElement(QLatin1String("test-case")); diff --git a/tests/auto/xmlpatternssdk/TestSuite.cpp b/tests/auto/xmlpatternssdk/TestSuite.cpp index 973fe40..c729837 100644 --- a/tests/auto/xmlpatternssdk/TestSuite.cpp +++ b/tests/auto/xmlpatternssdk/TestSuite.cpp @@ -164,32 +164,22 @@ void TestSuite::toXML(XMLWriter &receiver, TestCase *const tc) const receiver.startDocument(); /* */ - QXmlAttributes test_suiteAtts; - test_suiteAtts.append(QLatin1String("CatalogDesignDate"), QString(), - QLatin1String("CatalogDesignDate"), m_designDate.toString(Qt::ISODate)); - test_suiteAtts.append(QLatin1String("version"), QString(), - QLatin1String("version"), m_version); - test_suiteAtts.append(QLatin1String("SourceOffsetPath"), QString(), - QLatin1String("SourceOffsetPath"), QString()); - test_suiteAtts.append(QLatin1String("ResultOffsetPath"), QString(), - QLatin1String("ResultOffsetPath"), QString()); - test_suiteAtts.append(QLatin1String("XQueryQueryOffsetPath"), QString(), - QLatin1String("XQueryQueryOffsetPath"), QString()); - test_suiteAtts.append(QLatin1String("QueryXQueryOffsetPath"), QString(), - QLatin1String("QueryXQueryOffsetPath"), QString()); - test_suiteAtts.append(QLatin1String("XQueryFileExtension"), QString(), - QLatin1String("XQueryFileExtension"), QString()); - test_suiteAtts.append(QLatin1String("XQueryXFileExtension"), QString(), - QLatin1String("XQueryXFileExtension"), QString()); + QXmlStreamAttributes test_suiteAtts; + test_suiteAtts.append(QLatin1String("CatalogDesignDate"), m_designDate.toString(Qt::ISODate)); + test_suiteAtts.append(QLatin1String("version"), m_version); + test_suiteAtts.append(QLatin1String("SourceOffsetPath"), QString()); + test_suiteAtts.append(QLatin1String("ResultOffsetPath"), QString()); + test_suiteAtts.append(QLatin1String("XQueryQueryOffsetPath"), QString()); + test_suiteAtts.append(QLatin1String("QueryXQueryOffsetPath"), QString()); + test_suiteAtts.append(QLatin1String("XQueryFileExtension"), QString()); + test_suiteAtts.append(QLatin1String("XQueryXFileExtension"), QString()); receiver.startPrefixMapping(QString(), Global::xqtsCatalogNS); receiver.startElement(QLatin1String("test-suite"), test_suiteAtts); - receiver.endPrefixMapping(QString()); /* */ - QXmlAttributes test_groupAtts; - test_groupAtts.append(QLatin1String("GeneratedGroupByPatternistSDKRunSuite"), QString(), - QLatin1String("GeneratedGroupByPatternistSDKRunSuite"), QString()); + QXmlStreamAttributes test_groupAtts; + test_groupAtts.append(QLatin1String("GeneratedGroupByPatternistSDKRunSuite"), QString()); receiver.startElement(QLatin1String("test-group"), test_groupAtts); /* */ diff --git a/tests/auto/xmlpatternssdk/TestSuiteResult.cpp b/tests/auto/xmlpatternssdk/TestSuiteResult.cpp index 39508a4..b5a0ee7 100644 --- a/tests/auto/xmlpatternssdk/TestSuiteResult.cpp +++ b/tests/auto/xmlpatternssdk/TestSuiteResult.cpp @@ -76,31 +76,26 @@ void TestSuiteResult::toXML(XMLWriter &receiver) const /* */ receiver.startPrefixMapping(QString(), Global::xqtsResultNS); receiver.startElement(QLatin1String("test-suite-result")); - receiver.endPrefixMapping(QString()); /* */ - QXmlAttributes implementationAtts; - implementationAtts.append(QLatin1String("name"), QString(), - QLatin1String("name"), implementationName); - implementationAtts.append(QLatin1String("version"), QString(), - QLatin1String("version"), implementationVersion); + QXmlStreamAttributes implementationAtts; + implementationAtts.append(QLatin1String("name"), implementationName); + implementationAtts.append(QLatin1String("version"), implementationVersion); receiver.startElement(QLatin1String("implementation"), implementationAtts); /* */ - QXmlAttributes organizationAtts; - organizationAtts.append(QLatin1String("name"), QString(), - QLatin1String("name"), organizationName); - organizationAtts.append(QLatin1String("website"), QString(), - QLatin1String("website"), organizationWebsite); + QXmlStreamAttributes organizationAtts; + organizationAtts.append(QLatin1String("name"), organizationName); + organizationAtts.append(QLatin1String("website"), organizationWebsite); receiver.startElement(QLatin1String("organization"), organizationAtts); /* */ receiver.endElement(QLatin1String("organization")); /* */ - QXmlAttributes submittorAtts; - submittorAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), submittorName); - submittorAtts.append(QLatin1String("email"), QString(), QLatin1String("email"), submittorEmail); + QXmlStreamAttributes submittorAtts; + submittorAtts.append(QLatin1String("name"), submittorName); + submittorAtts.append(QLatin1String("email"), submittorEmail); receiver.startElement(QLatin1String("submittor"), submittorAtts); /* */ @@ -129,13 +124,13 @@ void TestSuiteResult::toXML(XMLWriter &receiver) const receiver.endElement(QLatin1String("syntax")); /* */ - QXmlAttributes test_runAtts; - test_runAtts.append(QLatin1String("dateRun"), QString(), QLatin1String("dateRun"), m_runDate.toString(QLatin1String("yyyy-MM-dd"))); + QXmlStreamAttributes test_runAtts; + test_runAtts.append(QLatin1String("dateRun"), m_runDate.toString(Qt::ISODate)); receiver.startElement(QLatin1String("test-run"), test_runAtts); /* */ - QXmlAttributes test_suiteAtts; - test_suiteAtts.append(QLatin1String("version"), QString(), QLatin1String("version"), m_testSuiteVersion); + QXmlStreamAttributes test_suiteAtts; + test_suiteAtts.append(QLatin1String("version"), m_testSuiteVersion); receiver.startElement(QLatin1String("test-suite"), test_suiteAtts); /* */ diff --git a/tests/auto/xmlpatternssdk/XMLWriter.cpp b/tests/auto/xmlpatternssdk/XMLWriter.cpp index 8ba5884..38a2d0d 100644 --- a/tests/auto/xmlpatternssdk/XMLWriter.cpp +++ b/tests/auto/xmlpatternssdk/XMLWriter.cpp @@ -328,16 +328,7 @@ bool XMLWriter::startDocument() return true; } -bool XMLWriter::startElement(const QString &/*namespaceURI*/, - const QString &/*localName*/, - const QString &qName, - const QXmlAttributes &atts) -{ - return startElement(qName, atts); -} - -bool XMLWriter::startElement(const QString &qName, - const QXmlAttributes &atts) +bool XMLWriter::startElement(const QString &qName, const QXmlStreamAttributes &atts) { Q_ASSERT_X(!d->insideCDATA, Q_FUNC_INFO, "Only characters() can be received when inside CDATA."); @@ -377,18 +368,16 @@ bool XMLWriter::startElement(const QString &qName, } d->namespaces.clear(); - const int c = atts.count(); + for (const auto &attr : atts) { + const auto qName = attr.qualifiedName().toString(); - /* Serialize attributes. */ - for(int i = 0; i != c; ++i) - { - d->validateQName(atts.qName(i)); - d->verifyNS(atts.qName(i)); + d->validateQName(qName); + d->verifyNS(qName); serialize(' '); - serialize(atts.qName(i)); + serialize(qName); serialize("=\""); - serialize(d->escapeAttributeContent(atts.value(i))); + serialize(d->escapeAttributeContent(attr.value().toString())); serialize('"'); } @@ -396,13 +385,6 @@ bool XMLWriter::startElement(const QString &qName, return true; } -bool XMLWriter::endElement(const QString &/*namespaceURI*/, - const QString &/*localName*/, - const QString &qName) -{ - return endElement(qName); -} - bool XMLWriter::endElement(const QString &qName) { Q_ASSERT_X(!d->insideCDATA, Q_FUNC_INFO, @@ -611,21 +593,6 @@ bool XMLWriter::ignorableWhitespace(const QString &ch) return characters(ch); } -bool XMLWriter::endPrefixMapping(const QString &) -{ - /* Again, should we do something with this? */ - return true; -} - -bool XMLWriter::skippedEntity(const QString &) -{ - return true; -} - -void XMLWriter::setDocumentLocator(QXmlLocator *) -{ -} - QIODevice *XMLWriter::device() const { return d->dev; diff --git a/tests/auto/xmlpatternssdk/XMLWriter.h b/tests/auto/xmlpatternssdk/XMLWriter.h index 0051d66..3d17d50 100644 --- a/tests/auto/xmlpatternssdk/XMLWriter.h +++ b/tests/auto/xmlpatternssdk/XMLWriter.h @@ -31,8 +31,7 @@ #include "Global.h" -#include -#include +#include QT_BEGIN_NAMESPACE @@ -52,10 +51,6 @@ namespace QPatternistSDK * specified in XMLWriter's constructor or via setDevice(). If writing to * the device fails, the content functions such as startElement() returns @c false. * - * XMLWriter sub-classes QXmlContentHandler meaning it can serialize content - * from any code that produces SAX events. The class can also be used manually, - * by calling startElement(), endCDATA(), and so forth. - * * XMLWriter cannot be used to serialize multiple documents. One instance per * document must be used. * @@ -95,8 +90,7 @@ namespace QPatternistSDK * @author Frans Englich * @ingroup PatternistSDK */ - class XMLWriter : public QXmlContentHandler - , public QXmlLexicalHandler + class XMLWriter { public: /** @@ -132,35 +126,8 @@ namespace QPatternistSDK * To declare namespaces, don't put attributes with name xmlns:* in @p atts, * but use startPrefixMapping(). */ - virtual bool startElement(const QString &qName, const QXmlAttributes &atts = QXmlAttributes()); - - /** - * - * Behaves essentially as startElement(const QString &qName, const QXmlAttributes &atts). This - * function is used in conjunction with other SAX classes. - * - * The call: - * - * @code - * startElement(QString(), QString(), qName, atts); - * @endcode - * - * is equivalent to: - * - * @code - * startElement(qName, atts); - * @endcode - * - * @p namespaceURI and @p localName are not used. This function is - * used in conjunction with other SAX classes. - * - * @returns @c false if failure occurs in writing to the QIODevice, otherwise - * @c true - */ - virtual bool startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts); + virtual bool startElement(const QString &qName, + const QXmlStreamAttributes &atts = QXmlStreamAttributes()); /** * Signals the end of an element with name @p qName. @p qName must @@ -173,31 +140,6 @@ namespace QPatternistSDK */ virtual bool endElement(const QString &qName); - /** - * Behaves essentially as endElement(const QString &qName). This function - * is used when XMLWriter is used in SAX code. - * - * @p namespaceURI and @p localName are not used. - * - * The call: - * - * @code - * endElement(QString(), QString(), qName); - * @endcode - * - * is equivalent to: - * - * @code - * endElement(qName); - * @endcode - * - * @returns @c false if failure occurs in writing to the QIODevice, otherwise - * @c true - */ - virtual bool endElement(const QString &namespaceURI, - const QString &localName, - const QString &qName); - /** * A description of an error if it occurred. This is typically * QIODevice::errorString(). If no error has occurred, an empty @@ -325,24 +267,6 @@ namespace QPatternistSDK */ virtual bool ignorableWhitespace(const QString &ch); - /** - * This function is not used by XMLWriter, but is implemented - * in order to satisfy QXmlContentHandler's interface. - */ - virtual bool endPrefixMapping(const QString &prefix); - - /** - * This function is not used by XMLWriter, but is implemented - * in order to satisfy QXmlContentHandler's interface. - */ - virtual bool skippedEntity(const QString &name); - - /** - * This function is not used by XMLWriter, but is implemented - * in order to satisfy QXmlContentHandler's interface. - */ - virtual void setDocumentLocator(QXmlLocator *); - /** * @returns the device XMLWriter writes its output to. * XMLWriter does not own the device. -- cgit v1.2.1 From a3ab5864425532fcfe44979381db7ce772ea22e2 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 11 Jul 2019 11:31:44 +0200 Subject: Bump Qt version to Qt 6 Also fix usage of text stream operators. Change-Id: I6c3ca0fe501f0565ecae5782a52cc70e1a4b6c04 Reviewed-by: Simon Hausmann (cherry picked from commit 2fc7a39180270c7551e99b918e827a93507e32a0) Reviewed-by: Sona Kurazyan --- tools/xmlpatterns/qapplicationargumentparser.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/xmlpatterns/qapplicationargumentparser.cpp b/tools/xmlpatterns/qapplicationargumentparser.cpp index 8aaae31..ce73485 100644 --- a/tools/xmlpatterns/qapplicationargumentparser.cpp +++ b/tools/xmlpatterns/qapplicationargumentparser.cpp @@ -245,7 +245,7 @@ bool QApplicationArgumentParserPrivate::error(const QString &message) bool QApplicationArgumentParserPrivate::errorMessage(const QString &message) { QTextStream out(stderr, QIODevice::WriteOnly); - out << message << endl; + out << message << Qt::endl; return false; } @@ -290,7 +290,7 @@ void QApplicationArgumentParserPrivate::displayVersion() const QTextStream out(stderr); out << tr("%1 version %2 using Qt %3").arg(QCoreApplication::applicationName(), applicationVersion, QString::fromLatin1(qVersion())) - << endl; + << Qt::endl; } void QApplicationArgumentParserPrivate::displayHelp() const @@ -356,16 +356,16 @@ void QApplicationArgumentParserPrivate::displayHelp() const } QTextStream out(stderr); - out << endl + out << Qt::endl << QString(IndentPadding, QLatin1Char(' ')) << QCoreApplication::applicationName() << QLatin1String(" -- ") << applicationDescription - << endl; + << Qt::endl; // TODO synopsis /* One extra so we get some space between the overview and the options. */ - out << endl; + out << Qt::endl; const int indentWidth = maxWidth + 3; @@ -408,7 +408,7 @@ void QApplicationArgumentParserPrivate::displayHelp() const out << prolog << lineWrap(at.description(), indentWidth, LineWrapAt) - << endl; + << Qt::endl; } } -- cgit v1.2.1 From e263fec484d23fc2e652f538f39934b5364339e1 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 14 Jan 2020 16:28:32 +0100 Subject: Use QNetworkReply::networkError() instead of deprecated error() Task-number: QTBUG-80369 Change-Id: I6e71a6b888f292c283c85b6aeb3aa5804f032c91 Reviewed-by: Friedemann Kleint --- src/imports/xmllistmodel/qqmlxmllistmodel.cpp | 2 +- src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp index 053e16a..494a007 100644 --- a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp +++ b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp @@ -1107,7 +1107,7 @@ void QQuickXmlListModel::requestFinished() } d->redirectCount = 0; - if (d->reply->error() != QNetworkReply::NoError) { + if (d->reply->networkError() != QNetworkReply::NoError) { d->errorString = d->reply->errorString(); d->deleteReply(); diff --git a/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp b/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp index e25a9b6..b41f80f 100644 --- a/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp +++ b/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp @@ -129,7 +129,7 @@ QNetworkReply *AccelTreeResourceLoader::load(const QUrl &uri, ftpNetworkLoop.exec(QEventLoop::ExcludeUserInputEvents); } - if (reply->error() != QNetworkReply::NoError) { + if (reply->networkError() != QNetworkReply::NoError) { const QString errorMessage(escape(reply->errorString())); /* Note, we delete reply before we exit this function with error(). */ -- cgit v1.2.1