summaryrefslogtreecommitdiffstats
path: root/tests/auto/xml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/xml')
-rw-r--r--tests/auto/xml/dom/qdom/tst_qdom.cpp133
-rw-r--r--tests/auto/xml/sax/qxml/tst_qxml.cpp7
-rw-r--r--tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp10
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp10
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/parser/parser.h6
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp9
6 files changed, 165 insertions, 10 deletions
diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp
index 901cadc34a..9cb06f5185 100644
--- a/tests/auto/xml/dom/qdom/tst_qdom.cpp
+++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp
@@ -57,6 +57,7 @@ private slots:
void toString_02();
void hasAttributes_data();
void hasAttributes();
+ void setGetAttributes();
void save_data();
void save();
void saveWithSerialization() const;
@@ -172,6 +173,8 @@ void tst_QDom::setContent_data()
" </b3>\n"
"</a1>\n");
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+ // These configurations cannot be supported by the QXmlStreamReader-based implementation
QTest::newRow( "02" ) << doc01
<< QString("http://trolltech.com/xml/features/report-whitespace-only-CharData").split(' ')
<< QStringList()
@@ -226,6 +229,7 @@ void tst_QDom::setContent_data()
" <c1/>\n"
" </b3>\n"
"</a1>\n");
+#endif
QTest::newRow("05") << QString("<message>\n"
" <body>&lt;b&gt;foo&lt;/b&gt;>]]&gt;</body>\n"
@@ -241,6 +245,10 @@ void tst_QDom::setContent()
{
QFETCH( QString, doc );
+ QDomDocument domDoc;
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlInputSource source;
source.setData( doc );
@@ -257,8 +265,12 @@ void tst_QDom::setContent()
reader.setFeature( *it, false );
}
- QDomDocument domDoc;
QVERIFY( domDoc.setContent( &source, &reader ) );
+QT_WARNING_POP
+#else
+ QXmlStreamReader reader(doc);
+ QVERIFY(domDoc.setContent(&reader, true));
+#endif
QString eRes;
QTextStream ts( &eRes, QIODevice::WriteOnly );
@@ -392,6 +404,74 @@ void tst_QDom::hasAttributes()
QTEST( visitedNodes, "visitedNodes" );
}
+void tst_QDom::setGetAttributes()
+{
+ QDomDocument doc;
+ QDomElement rootNode = doc.createElement("Root");
+ doc.appendChild(rootNode);
+
+ const QLocale oldLocale = QLocale();
+ QLocale::setDefault(QLocale::German); // decimal separator != '.'
+
+ const QString qstringVal("QString");
+ const qlonglong qlonglongVal = std::numeric_limits<qlonglong>::min();
+ const qulonglong qulonglongVal = std::numeric_limits<qulonglong>::max();
+ const int intVal = std::numeric_limits<int>::min();
+ const uint uintVal = std::numeric_limits<uint>::max();
+ const float floatVal = 0.1234f;
+ const double doubleVal = 0.1234;
+
+ rootNode.setAttribute("qstringVal", qstringVal);
+ rootNode.setAttribute("qlonglongVal", qlonglongVal);
+ rootNode.setAttribute("qulonglongVal", qulonglongVal);
+ rootNode.setAttribute("intVal", intVal);
+ rootNode.setAttribute("uintVal", uintVal);
+ rootNode.setAttribute("floatVal", floatVal);
+ rootNode.setAttribute("doubleVal", doubleVal);
+
+ QDomElement nsNode = doc.createElement("NS");
+ rootNode.appendChild(nsNode);
+ nsNode.setAttributeNS("namespace", "qstringVal", qstringVal);
+ nsNode.setAttributeNS("namespace", "qlonglongVal", qlonglongVal);
+ nsNode.setAttributeNS("namespace", "qulonglongVal", qulonglongVal);
+ nsNode.setAttributeNS("namespace", "intVal", intVal);
+ nsNode.setAttributeNS("namespace", "uintVal", uintVal);
+ nsNode.setAttributeNS("namespace", "floatVal", floatVal); // not available atm
+ nsNode.setAttributeNS("namespace", "doubleVal", doubleVal);
+
+ bool bOk;
+ QCOMPARE(rootNode.attribute("qstringVal"), qstringVal);
+ QCOMPARE(rootNode.attribute("qlonglongVal").toLongLong(&bOk), qlonglongVal);
+ QVERIFY(bOk);
+ QCOMPARE(rootNode.attribute("qulonglongVal").toULongLong(&bOk), qulonglongVal);
+ QVERIFY(bOk);
+ QCOMPARE(rootNode.attribute("intVal").toInt(&bOk), intVal);
+ QVERIFY(bOk);
+ QCOMPARE(rootNode.attribute("uintVal").toUInt(&bOk), uintVal);
+ QVERIFY(bOk);
+ QCOMPARE(rootNode.attribute("floatVal").toFloat(&bOk), floatVal);
+ QVERIFY(bOk);
+ QCOMPARE(rootNode.attribute("doubleVal").toDouble(&bOk), doubleVal);
+ QVERIFY(bOk);
+
+ QCOMPARE(nsNode.attributeNS("namespace", "qstringVal"), qstringVal);
+ QCOMPARE(nsNode.attributeNS("namespace", "qlonglongVal").toLongLong(&bOk), qlonglongVal);
+ QVERIFY(bOk);
+ QCOMPARE(nsNode.attributeNS("namespace", "qulonglongVal").toULongLong(&bOk), qulonglongVal);
+ QVERIFY(bOk);
+ QCOMPARE(nsNode.attributeNS("namespace", "intVal").toInt(&bOk), intVal);
+ QVERIFY(bOk);
+ QCOMPARE(nsNode.attributeNS("namespace", "uintVal").toUInt(&bOk), uintVal);
+ QVERIFY(bOk);
+ QCOMPARE(nsNode.attributeNS("namespace", "floatVal").toFloat(&bOk), floatVal);
+ QVERIFY(bOk);
+ QCOMPARE(nsNode.attributeNS("namespace", "doubleVal").toDouble(&bOk), doubleVal);
+ QVERIFY(bOk);
+
+ QLocale::setDefault(oldLocale);
+}
+
+
int tst_QDom::hasAttributesHelper( const QDomNode& node )
{
int visitedNodes = 1;
@@ -1406,8 +1486,9 @@ void tst_QDom::normalizeAttributes() const
QDomDocument doc;
QVERIFY(doc.setContent(&buffer, true));
- // ### Qt 5: fix this, if we keep QDom at all
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
QEXPECT_FAIL("", "The parser doesn't perform Attribute Value Normalization. Fixing that would change behavior.", Continue);
+#endif
QCOMPARE(doc.documentElement().attribute(QLatin1String("attribute")), QString::fromLatin1("a a"));
}
@@ -1448,9 +1529,13 @@ void tst_QDom::serializeNamespaces() const
"<b:element b:name=''/>"
"</doc>";
+ QDomDocument doc;
QByteArray ba(input);
- QBuffer buffer(&ba);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+ QBuffer buffer(&ba);
QVERIFY(buffer.open(QIODevice::ReadOnly));
QXmlInputSource source(&buffer);
@@ -1458,8 +1543,12 @@ void tst_QDom::serializeNamespaces() const
reader.setFeature("http://xml.org/sax/features/namespaces", true);
reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
- QDomDocument doc;
QVERIFY(doc.setContent(&source, &reader));
+QT_WARNING_POP
+#else
+ QXmlStreamReader streamReader(input);
+ QVERIFY(doc.setContent(&streamReader, true));
+#endif
const QByteArray serialized(doc.toByteArray());
@@ -1483,7 +1572,9 @@ void tst_QDom::flagInvalidNamespaces() const
QDomDocument doc;
QVERIFY(!doc.setContent(QString::fromLatin1(input, true)));
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
QEXPECT_FAIL("", "The parser doesn't flag identical qualified attribute names. Fixing this would change behavior.", Continue);
+#endif
QVERIFY(!doc.setContent(QString::fromLatin1(input)));
}
@@ -1494,7 +1585,11 @@ void tst_QDom::flagUndeclaredNamespace() const
"<b:element b:name=''/>"
"</a:doc>";
+ QDomDocument doc;
QByteArray ba(input);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QBuffer buffer(&ba);
QVERIFY(buffer.open(QIODevice::ReadOnly));
@@ -1504,9 +1599,13 @@ void tst_QDom::flagUndeclaredNamespace() const
reader.setFeature("http://xml.org/sax/features/namespaces", true);
reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
- QDomDocument doc;
QEXPECT_FAIL("", "The parser doesn't flag not declared prefixes. Fixing this would change behavior.", Continue);
QVERIFY(!doc.setContent(&source, &reader));
+QT_WARNING_POP
+#else
+ QXmlStreamReader streamReader(ba);
+ QVERIFY(!doc.setContent(&streamReader, true));
+#endif
}
void tst_QDom::indentComments() const
@@ -1573,7 +1672,9 @@ void tst_QDom::reportDuplicateAttributes() const
QDomDocument dd;
bool isSuccess = dd.setContent(QLatin1String("<test x=\"1\" x=\"2\"/>"));
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
QEXPECT_FAIL("", "The parser doesn't flag duplicate attributes. Fixing this would change behavior.", Continue);
+#endif
QVERIFY2(!isSuccess, "Duplicate attributes are well-formedness errors, and should be reported as such.");
}
@@ -1773,10 +1874,18 @@ void tst_QDom::doubleNamespaceDeclarations() const
QFile file(testFile);
QVERIFY(file.open(QIODevice::ReadOnly));
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlSimpleReader reader;
QXmlInputSource source(&file);
QVERIFY(doc.setContent(&source, &reader));
+QT_WARNING_POP
+#else
+ QXmlStreamReader streamReader(&file);
+ QVERIFY(doc.setContent(&streamReader, true));
+#endif
// tst_QDom relies on a specific QHash ordering, see QTBUG-25071
QString docAsString = doc.toString(0);
@@ -1793,11 +1902,18 @@ void tst_QDom::setContentQXmlReaderOverload() const
{
QDomDocument doc;
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlSimpleReader reader;
QXmlInputSource data;
data.setData(QByteArray("<e/>"));
-
doc.setContent(&data, true);
+QT_WARNING_POP
+#else
+ QXmlStreamReader streamReader(QByteArray("<e/>"));
+ doc.setContent(&streamReader, true);
+#endif
QCOMPARE(doc.documentElement().nodeName(), QString::fromLatin1("e"));
}
@@ -1892,6 +2008,10 @@ void tst_QDom::setContentWhitespace_data() const
void tst_QDom::taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() const
{
+ // QXmlStreamReader fails to read XML documents with unknown encoding. It
+ // needs to be modified if we want to support this case with the QXmlStreamReader-based
+ // implementation.
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
QString xmlWithUnknownEncoding("<?xml version='1.0' encoding='unknown-encoding'?>"
"<foo>"
" <bar>How will this sentence be handled?</bar>"
@@ -1901,6 +2021,7 @@ void tst_QDom::taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() co
QString dontAssert = d.toString(); // this should not assert
QVERIFY(true);
+#endif
}
void tst_QDom::cloneDTD_QTBUG8398() const
diff --git a/tests/auto/xml/sax/qxml/tst_qxml.cpp b/tests/auto/xml/sax/qxml/tst_qxml.cpp
index 1cdb9701fa..db6584edda 100644
--- a/tests/auto/xml/sax/qxml/tst_qxml.cpp
+++ b/tests/auto/xml/sax/qxml/tst_qxml.cpp
@@ -26,7 +26,6 @@
**
****************************************************************************/
-
#include <QtTest/QtTest>
#include <qcoreapplication.h>
@@ -38,13 +37,17 @@ class tst_QXml : public QObject
Q_OBJECT
private slots:
+#if QT_DEPRECATED_SINCE(5, 15)
void getSetCheck();
void interpretedAs0D() const;
#ifndef QT_NO_EXCEPTIONS
void exception();
#endif
+#endif // QT_DEPRECATED_SINCE(5, 15)
};
+#if QT_DEPRECATED_SINCE(5, 15)
+
class MyXmlEntityResolver : public QXmlEntityResolver
{
public:
@@ -225,5 +228,7 @@ void tst_QXml::exception()
}
#endif
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
QTEST_MAIN(tst_QXml)
#include "tst_qxml.moc"
diff --git a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
index d40c8c2fd6..5dce69bd8c 100644
--- a/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
+++ b/tests/auto/xml/sax/qxmlinputsource/tst_qxmlinputsource.cpp
@@ -45,13 +45,18 @@ class tst_QXmlInputSource : public QObject
{
Q_OBJECT
+#if QT_DEPRECATED_SINCE(5, 15)
private slots:
void reset() const;
void resetSimplified() const;
void waitForReadyIODevice() const;
void inputFromSlowDevice() const;
+#endif // QT_DEPRECATED_SINCE(5, 15)
};
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
/*!
\internal
\since 4.4
@@ -144,7 +149,7 @@ public slots:
void requestFinished(QNetworkReply *reply)
{
- QCOMPARE(reply->error(), QNetworkReply::NoError);
+ QCOMPARE(reply->networkError(), QNetworkReply::NoError);
reply->deleteLater();
}
@@ -292,5 +297,8 @@ void tst_QXmlInputSource::inputFromSlowDevice() const
QCOMPARE(data, expectedData);
}
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
QTEST_MAIN(tst_QXmlInputSource)
#include "tst_qxmlinputsource.moc"
diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp
index 556603a681..44f8101955 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp
+++ b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp
@@ -26,12 +26,15 @@
**
****************************************************************************/
+#include "parser.h"
+
+#if QT_DEPRECATED_SINCE(5, 15)
#include <qxml.h>
#include <qregularexpression.h>
-#include "parser.h"
-
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
class ContentHandler : public QXmlDefaultHandler
{
public:
@@ -440,3 +443,6 @@ QString Parser::errorMsg() const
{
return handler->errorMsg();
}
+
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(5, 15)
diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.h b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.h
index 604678f06b..9c51cdf095 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.h
+++ b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.h
@@ -28,6 +28,10 @@
#ifndef PARSER_H
#define PARSER_H
+#include <qglobal.h>
+
+#if QT_DEPRECATED_SINCE(5, 15)
+
#include <qfile.h>
#include <qstring.h>
#include <qxml.h>
@@ -48,4 +52,6 @@ private:
ContentHandler *handler;
};
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
#endif
diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
index 8c4c6c7179..cea4e3c8b8 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
+++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
@@ -127,6 +127,7 @@ class tst_QXmlSimpleReader : public QObject
{
Q_OBJECT
+#if QT_DEPRECATED_SINCE(5, 15)
public:
tst_QXmlSimpleReader();
~tst_QXmlSimpleReader();
@@ -157,8 +158,13 @@ class tst_QXmlSimpleReader : public QObject
static QDomDocument fromByteArray(const QString &title, const QByteArray &ba, bool *ok);
XmlServer *server;
QString prefix;
+#endif // QT_DEPRECATED_SINCE(5, 15)
};
+#if QT_DEPRECATED_SINCE(5, 15)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
tst_QXmlSimpleReader::tst_QXmlSimpleReader() : server(new XmlServer(this))
{
server->start();
@@ -820,5 +826,8 @@ void tst_QXmlSimpleReader::dtdRecursionLimit()
}
}
+QT_WARNING_POP
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
QTEST_MAIN(tst_QXmlSimpleReader)
#include "tst_qxmlsimplereader.moc"