summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/xmlpatternsdiagnosticsts/Baseline.xml2
-rw-r--r--tests/auto/xmlpatternsdiagnosticsts/TestSuite/DiagnosticsCatalog.xml15
-rw-r--r--tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldSucceed/succeed-15.txt (renamed from tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldFail/fail-3.txt)0
-rw-r--r--tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldSucceed/succeed-15.xq (renamed from tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldFail/fail-17.xq)0
-rw-r--r--tests/auto/xmlpatternssdk/ResultThreader.cpp6
-rw-r--r--tests/auto/xmlpatternssdk/TestBaseLine.cpp51
-rw-r--r--tests/auto/xmlpatternssdk/TestCase.cpp20
-rw-r--r--tests/auto/xmlpatternssdk/TestResult.cpp8
-rw-r--r--tests/auto/xmlpatternssdk/TestResultHandler.cpp15
-rw-r--r--tests/auto/xmlpatternssdk/TestResultHandler.h12
-rw-r--r--tests/auto/xmlpatternssdk/TestSuite.cpp45
-rw-r--r--tests/auto/xmlpatternssdk/TestSuiteHandler.cpp75
-rw-r--r--tests/auto/xmlpatternssdk/TestSuiteHandler.h19
-rw-r--r--tests/auto/xmlpatternssdk/TestSuiteResult.cpp31
-rw-r--r--tests/auto/xmlpatternssdk/Worker.h1
-rw-r--r--tests/auto/xmlpatternssdk/XMLWriter.cpp47
-rw-r--r--tests/auto/xmlpatternssdk/XMLWriter.h84
-rw-r--r--tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp26
-rw-r--r--tests/auto/xmlpatternssdk/XSDTestSuiteHandler.h19
-rw-r--r--tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.cpp60
-rw-r--r--tests/auto/xmlpatternssdk/XSLTTestSuiteHandler.h19
-rw-r--r--tests/auto/xmlpatternssdk/XmlParseHelper.cpp106
-rw-r--r--tests/auto/xmlpatternssdk/XmlParseHelper.h57
-rw-r--r--tests/auto/xmlpatternssdk/xmlpatternssdk.pro6
24 files changed, 369 insertions, 355 deletions
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 @@
<?xml version="1.0" encoding="UTF-8"?>
-<test-suite-result xmlns="http://www.w3.org/2005/02/query-test-XQTSResult"><implementation name="Patternist" version="0.1"><organization name="K Desktop Environment(KDE)" website="http://www.kde.org/"/><submittor name="Frans Englich" email="frans.englich@nokia.com"/><description><p>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.</p></description></implementation><syntax>XQuery</syntax><test-run dateRun="2008-06-23"><test-suite version="0.1"/></test-run><test-case name="fail-1" result="fail"/><test-case name="fail-2" result="fail"/><test-case name="fail-3" result="fail"/><test-case name="fail-4" result="fail"/><test-case name="fail-5" result="fail"/><test-case name="fail-6" result="fail"/><test-case name="fail-7" result="fail"/><test-case name="fail-8" result="fail"/><test-case name="fail-9" result="fail"/><test-case name="fail-10" result="fail"/><test-case name="fail-11" result="fail"/><test-case name="fail-12" result="fail"/><test-case name="fail-13" result="fail"/><test-case name="fail-14" result="fail"/><test-case name="fail-15" result="fail"/><test-case name="fail-16" result="fail"/><test-case name="fail-17" result="fail"/><test-case name="fail-18" result="fail"/><test-case name="fail-19" result="fail"/><test-case name="fail-20" result="fail"/><test-case name="fail-21" result="fail"/><test-case name="fail-22" result="fail"/><test-case name="fail-23" result="fail"/><test-case name="fail-24" result="fail"/><test-case name="succeed-1" result="pass"/><test-case name="succeed-2" result="pass"/><test-case name="succeed-3" result="pass"/><test-case name="succeed-4" result="pass"/><test-case name="succeed-5" result="pass"/><test-case name="succeed-6" result="pass"/><test-case name="succeed-7" result="pass"/><test-case name="succeed-8" result="pass"/><test-case name="succeed-9" result="pass"/><test-case name="succeed-10" result="pass"/><test-case name="succeed-11" result="pass"/><test-case name="succeed-12" result="pass"/><test-case name="succeed-13" result="pass"/><test-case name="succeed-14" result="pass"/></test-suite-result> \ No newline at end of file
+<test-suite-result xmlns="http://www.w3.org/2005/02/query-test-XQTSResult"><implementation name="Patternist" version="0.1"><organization name="K Desktop Environment(KDE)" website="http://www.kde.org/"/><submittor name="Frans Englich" email="frans.englich@nokia.com"/><description><p>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.</p></description></implementation><syntax>XQuery</syntax><test-run dateRun="2008-06-23"><test-suite version="0.1"/></test-run><test-case name="fail-1" result="fail"/><test-case name="fail-2" result="fail"/><test-case name="fail-3" result="fail"/><test-case name="fail-4" result="fail"/><test-case name="fail-5" result="fail"/><test-case name="fail-6" result="fail"/><test-case name="fail-7" result="fail"/><test-case name="fail-8" result="fail"/><test-case name="fail-9" result="fail"/><test-case name="fail-10" result="fail"/><test-case name="fail-11" result="fail"/><test-case name="fail-12" result="fail"/><test-case name="fail-13" result="fail"/><test-case name="fail-14" result="fail"/><test-case name="fail-15" result="fail"/><test-case name="fail-16" result="fail"/><test-case name="fail-18" result="fail"/><test-case name="fail-19" result="fail"/><test-case name="fail-20" result="fail"/><test-case name="fail-21" result="fail"/><test-case name="fail-22" result="fail"/><test-case name="fail-23" result="fail"/><test-case name="fail-24" result="fail"/><test-case name="succeed-1" result="pass"/><test-case name="succeed-2" result="pass"/><test-case name="succeed-3" result="pass"/><test-case name="succeed-4" result="pass"/><test-case name="succeed-5" result="pass"/><test-case name="succeed-6" result="pass"/><test-case name="succeed-7" result="pass"/><test-case name="succeed-8" result="pass"/><test-case name="succeed-9" result="pass"/><test-case name="succeed-10" result="pass"/><test-case name="succeed-11" result="pass"/><test-case name="succeed-12" result="pass"/><test-case name="succeed-13" result="pass"/><test-case name="succeed-14" result="pass"/><test-case name="succeed-15" result="pass"/></test-suite-result>
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 @@
<output-file role="principal" compare="Ignore"/>
</test-case>
- <test-case is-XPath2="false" name="fail-17" FilePath="ShouldFail/"
- scenario="standard" Creator="Frans Englich" >
- <description>Space is significant.</description>
- <query name="fail-17" date="2007-06-07"/>
- <input-file role="principal-data" variable="input-context">emptydoc</input-file>
- <output-file role="principal" compare="XML">fail-3.txt</output-file>
- </test-case>
-
<test-case is-XPath2="false" name="fail-18" FilePath="ShouldFail/"
scenario="runtime-error" Creator="Frans Englich" >
<description>Test that XML documents that differs on the top level, are flagged(type being runtime-error).</description>
@@ -1039,6 +1031,13 @@
<output-file compare="XML" role="principal">succeed-14.txt</output-file>
</test-case>
+ <test-case is-XPath2="false" name="succeed-15" FilePath="ShouldSucceed/" scenario="standard" Creator="Frans Englich" >
+ <description>Space is ignored.</description>
+ <query name="succeed-15" date="2007-06-07"/>
+ <input-file role="principal-data" variable="input-context">emptydoc</input-file>
+ <output-file role="principal" compare="XML">succeed-15.txt</output-file>
+ </test-case>
+
</test-group>
</test-suite>
diff --git a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldFail/fail-3.txt b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldSucceed/succeed-15.txt
index a06c409..a06c409 100644
--- a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldFail/fail-3.txt
+++ b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/ExpectedTestResults/ShouldSucceed/succeed-15.txt
diff --git a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldFail/fail-17.xq b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldSucceed/succeed-15.xq
index 10a7e70..10a7e70 100644
--- a/tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldFail/fail-17.xq
+++ b/tests/auto/xmlpatternsdiagnosticsts/TestSuite/Queries/XQuery/ShouldSucceed/succeed-15.xq
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..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"));
@@ -310,19 +306,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("<r>") +
- serializedInput +
- QLatin1String("</r>")).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("<r>") + serializedInput
+ + QLatin1String("</r>"))
+ .toUtf8());
if(!success)
return TestResult::Fail;
@@ -332,19 +320,12 @@ TestResult::Status TestBaseLine::verify(const QString &serializedInput) const
QDomDocument baseline;
{
- QXmlInputSource source;
- source.setData((m_type == XML ? details() : QLatin1String("<r>") +
- details() +
- QLatin1String("</r>")).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("<r>") + details() + QLatin1String("</r>"))
+ .toUtf8(),
+ &baselineReadingError);
if(!success)
return TestResult::Fail;
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
{
/* <test-case> */
- 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);
/* <description> */
@@ -381,10 +379,10 @@ void TestCase::toXML(XMLWriter &receiver) const
receiver.endElement(QLatin1String("description"));
/* <query> */
- 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);
/* </query> */
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/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 <QHash>
#include <QString>
-#include <QtXml/QXmlDefaultHandler>
#include "TestResult.h"
+#include "XmlParseHelper.h"
QT_BEGIN_NAMESPACE
@@ -46,7 +46,7 @@ namespace QPatternistSDK
* @author Frans Englich <frans.englich@nokia.com>
* @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 <tt>test-case</tt> 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..c729837 100644
--- a/tests/auto/xmlpatternssdk/TestSuite.cpp
+++ b/tests/auto/xmlpatternssdk/TestSuite.cpp
@@ -28,13 +28,12 @@
#include <QFileInfo>
#include <QVariant>
-#include <QXmlInputSource>
-#include <QXmlSimpleReader>
#include <QtDebug>
#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<QXmlDefaultHandler> HandlerPtr;
+ typedef QPatternist::AutoPtr<XmlParseHelper> 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;
}
@@ -171,32 +164,22 @@ void TestSuite::toXML(XMLWriter &receiver, TestCase *const tc) const
receiver.startDocument();
/* <test-suite> */
- 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());
/* <test-group> */
- 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);
/* <GroupInfo> */
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 <QStack>
#include <QUrl>
-#include <QXmlDefaultHandler>
#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 <frans.englich@nokia.com>
*/
- 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/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
/* <test-suite-result> */
receiver.startPrefixMapping(QString(), Global::xqtsResultNS);
receiver.startElement(QLatin1String("test-suite-result"));
- receiver.endPrefixMapping(QString());
/* <implementation> */
- 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);
/* <organization> */
- 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);
/* </organization> */
receiver.endElement(QLatin1String("organization"));
/* <submittor> */
- 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);
/* </submittor> */
@@ -129,13 +124,13 @@ void TestSuiteResult::toXML(XMLWriter &receiver) const
receiver.endElement(QLatin1String("syntax"));
/* <test-run> */
- 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);
/* <test-suite> */
- 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);
/* </test-suite> */
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 <QList>
#include <QObject>
#include <QStringList>
+#include <QTextStream>
#include "ResultThreader.h"
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 <QtXml/QXmlContentHandler>
-#include <QtXml/QXmlLexicalHandler>
+#include <QXmlStreamAttributes>
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 <frans.englich@nokia.com>
* @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 <tt>xmlns:*</tt> 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
@@ -174,31 +141,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
* string is returned.
@@ -326,24 +268,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.
*/
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 <QUrl>
-#include <QXmlDefaultHandler>
#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 <tobias.koenig@nokia.com>
*/
- 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 <QStack>
#include <QUrl>
-#include <QXmlDefaultHandler>
#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 <frans.englich@nokia.com>
*/
- 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 <qxmlstream.h>
+
+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