From 82d02b7b95908dec16e41c5af1c63579729c589b Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Thu, 7 Nov 2019 17:26:55 +0100 Subject: Deprecate SAX classes in Qt XML Deprecated the SAX classes and disabled or replaced their uses in tests if applicable. Removed the saxbookmarks example, no point in keeping examples for the deprecated code. [ChangeLog][QtXml] SAX classes are now deprecated. Use QXmlStreamReader, QXmlStreamWriter in QtCore instead. Task-number: QTBUG-76177 Change-Id: Ic171d62fa0527b0f36f94cf09a69586092269957 Reviewed-by: Friedemann Kleint Reviewed-by: Paul Wicking Reviewed-by: Kai Koehne --- tests/auto/xml/dom/qdom/tst_qdom.cpp | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'tests/auto/xml/dom/qdom/tst_qdom.cpp') diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index ab62307704..a2a5b22cad 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -173,7 +173,7 @@ void tst_QDom::setContent_data() " \n" "\n"); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#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(' ') @@ -246,7 +246,9 @@ void tst_QDom::setContent() QFETCH( QString, doc ); QDomDocument domDoc; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#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 ); @@ -264,6 +266,7 @@ void tst_QDom::setContent() } QVERIFY( domDoc.setContent( &source, &reader ) ); +QT_WARNING_POP #else QXmlStreamReader reader(doc); QVERIFY(domDoc.setContent(&reader, true)); @@ -1483,7 +1486,7 @@ void tst_QDom::normalizeAttributes() const QDomDocument doc; QVERIFY(doc.setContent(&buffer, true)); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#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")); @@ -1528,7 +1531,10 @@ void tst_QDom::serializeNamespaces() const QDomDocument doc; QByteArray ba(input); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#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)); @@ -1538,6 +1544,7 @@ void tst_QDom::serializeNamespaces() const reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false); QVERIFY(doc.setContent(&source, &reader)); +QT_WARNING_POP #else QXmlStreamReader streamReader(input); QVERIFY(doc.setContent(&streamReader, true)); @@ -1565,7 +1572,7 @@ void tst_QDom::flagInvalidNamespaces() const QDomDocument doc; QVERIFY(!doc.setContent(QString::fromLatin1(input, true))); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#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))); @@ -1580,7 +1587,9 @@ void tst_QDom::flagUndeclaredNamespace() const QDomDocument doc; QByteArray ba(input); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#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)); @@ -1592,6 +1601,7 @@ void tst_QDom::flagUndeclaredNamespace() const 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)); @@ -1662,7 +1672,7 @@ void tst_QDom::reportDuplicateAttributes() const QDomDocument dd; bool isSuccess = dd.setContent(QLatin1String("")); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#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."); @@ -1864,11 +1874,14 @@ void tst_QDom::doubleNamespaceDeclarations() const QFile file(testFile); QVERIFY(file.open(QIODevice::ReadOnly)); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#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)); @@ -1889,11 +1902,14 @@ void tst_QDom::setContentQXmlReaderOverload() const { QDomDocument doc; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#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("")); doc.setContent(&data, true); +QT_WARNING_POP #else QXmlStreamReader streamReader(QByteArray("")); doc.setContent(&streamReader, true); @@ -1995,7 +2011,7 @@ void tst_QDom::taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() co // 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) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15) QString xmlWithUnknownEncoding("" "" " How will this sentence be handled?" -- cgit v1.2.3