tst_qdom: clean-up the code enabled only before Qt 6

Change-Id: Ifcf863ccb2094661b43bd5ccf8387960447ddd8e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
Sona Kurazyan 2021-01-15 12:42:47 +01:00
parent b5ce973b29
commit 20e364e00c
1 changed files with 4 additions and 153 deletions

View File

@ -174,65 +174,7 @@ 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()
<< QString("<!DOCTYPE a1>\n"
"<a1>\n"
" <b1>\n"
" <c1>foo</c1>\n"
" <c2>bar</c2>\n"
" <c3>foo &amp; bar</c3>\n"
" <c4>foo and bar</c4>\n"
" </b1>\n"
" <b2> </b2>\n"
" <b3>\n"
" <c1/>\n"
" </b3>\n"
"</a1>\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("<!DOCTYPE a1 [\n"
"<!ENTITY blubber \"and\">\n"
"]>\n"
"<a1>\n"
" <b1>\n"
" <c1>foo</c1>\n"
" <c2>bar</c2>\n"
" <c3>foo &amp; bar</c3>\n"
" <c4>foo &blubber; bar</c4>\n"
" </b1>\n"
" <b2/>\n"
" <b3>\n"
" <c1/>\n"
" </b3>\n"
"</a1>\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("<!DOCTYPE a1 [\n"
"<!ENTITY blubber \"and\">\n"
"]>\n"
"<a1>\n"
" <b1>\n"
" <c1>foo</c1>\n"
" <c2>bar</c2>\n"
" <c3>foo &amp; bar</c3>\n"
" <c4>foo &blubber; bar</c4>\n"
" </b1>\n"
" <b2> </b2>\n"
" <b3>\n"
" <c1/>\n"
" </b3>\n"
"</a1>\n");
#endif
QTest::newRow("05") << QString("<message>\n"
QTest::newRow("02") << QString("<message>\n"
" <body>&lt;b&gt;foo&lt;/b&gt;>]]&gt;</body>\n"
"</message>\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("<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.");
}
@ -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("<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"));
}
@ -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("<?xml version='1.0' encoding='unknown-encoding'?>"
"<foo>"
" <bar>How will this sentence be handled?</bar>"
"</foo>");
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