From 20e364e00ce9b89d984038f20e6b4ab87141c7ef Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Fri, 15 Jan 2021 12:42:47 +0100 Subject: tst_qdom: clean-up the code enabled only before Qt 6 Change-Id: Ifcf863ccb2094661b43bd5ccf8387960447ddd8e Reviewed-by: Friedemann Kleint --- tests/auto/xml/dom/qdom/tst_qdom.cpp | 157 +---------------------------------- 1 file changed, 4 insertions(+), 153 deletions(-) (limited to 'tests') diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index 04e4172e54..c44626e161 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -174,65 +174,7 @@ void tst_QDom::setContent_data() " \n" "\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() - << QString("\n" - "\n" - " \n" - " foo\n" - " bar\n" - " foo & bar\n" - " foo and bar\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n"); - - QTest::newRow( "03" ) << doc01 - << QString("http://trolltech.com/xml/features/report-start-end-entity").split(' ') - << QString("http://trolltech.com/xml/features/report-whitespace-only-CharData").split(' ') - << QString("\n" - "]>\n" - "\n" - " \n" - " foo\n" - " bar\n" - " foo & bar\n" - " foo &blubber; bar\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n"); - - QTest::newRow( "04" ) << doc01 - << QString("http://trolltech.com/xml/features/report-whitespace-only-CharData http://trolltech.com/xml/features/report-start-end-entity").split(' ') - << QStringList() - << QString("\n" - "]>\n" - "\n" - " \n" - " foo\n" - " bar\n" - " foo & bar\n" - " foo &blubber; bar\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n"); -#endif - - QTest::newRow("05") << QString("\n" + QTest::newRow("02") << QString("\n" " <b>foo</b>>]]>\n" "\n") << QStringList() << QStringList() @@ -247,31 +189,8 @@ 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 ); - - QFETCH( QStringList, featuresTrue ); - QFETCH( QStringList, featuresFalse ); - QXmlSimpleReader reader; - QStringList::Iterator it; - for ( it = featuresTrue.begin(); it != featuresTrue.end(); ++it ) { - QVERIFY( reader.hasFeature( *it ) ); - reader.setFeature( *it, true ); - } - for ( it = featuresFalse.begin(); it != featuresFalse.end(); ++it ) { - QVERIFY( reader.hasFeature( *it ) ); - reader.setFeature( *it, false ); - } - - 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 ); @@ -1547,10 +1466,6 @@ void tst_QDom::normalizeAttributes() const QDomDocument doc; QVERIFY(doc.setContent(&buffer, true)); - -#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")); } @@ -1593,25 +1508,8 @@ void tst_QDom::serializeNamespaces() const 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)); - - QXmlInputSource source(&buffer); - QXmlSimpleReader reader; - reader.setFeature("http://xml.org/sax/features/namespaces", true); - 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)); -#endif - const QByteArray serialized(doc.toByteArray()); QDomDocument doc2; @@ -1634,9 +1532,6 @@ 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))); } @@ -1649,25 +1544,8 @@ void tst_QDom::flagUndeclaredNamespace() const 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)); - - QXmlInputSource source(&buffer); - QXmlSimpleReader reader; - reader.setFeature("http://xml.org/sax/features/namespaces", true); - reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false); - - 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 @@ -1733,10 +1611,6 @@ void tst_QDom::reportDuplicateAttributes() const { QDomDocument dd; bool isSuccess = dd.setContent(QLatin1String("")); - -#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."); } @@ -1934,18 +1808,8 @@ 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); @@ -1961,19 +1825,8 @@ QT_WARNING_POP 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("")); - doc.setContent(&data, true); -QT_WARNING_POP -#else QXmlStreamReader streamReader(QByteArray("")); doc.setContent(&streamReader, true); -#endif QCOMPARE(doc.documentElement().nodeName(), QString::fromLatin1("e")); } @@ -2068,20 +1921,18 @@ 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("" "" " How will this sentence be handled?" ""); QDomDocument d; + QTest::ignoreMessage( + QtWarningMsg, + "QDomDocument::save(): Unsupported encoding \"unknown-encoding\" specified."); QVERIFY(d.setContent(xmlWithUnknownEncoding)); QString dontAssert = d.toString(); // this should not assert QVERIFY(true); -#endif } void tst_QDom::cloneDTD_QTBUG8398() const -- cgit v1.2.3