diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-11-03 08:56:33 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-11-09 18:33:39 +0100 |
commit | a4ce85f356b78401fe727a07b908a1e7b5a25198 (patch) | |
tree | e85e799c210d641367c222812e1a832f58e80abe /tests/auto/xml | |
parent | c677b3b8afcdc1d7b57353826cc01f378cd25e99 (diff) |
QDomDocument::setContent: Open device if necessary
This restores the Qt 5 behavior in Qt 6, but prepares for disabling it
in Qt 7. We want to deprecate the current behavior, as it makes it
unclear who is responsible for calling close.
Fixes: QTBUG-97747
Pick-to: 6.2
Change-Id: I2c99eb96667e784576d8850085068ca334d75b16
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/xml')
-rw-r--r-- | tests/auto/xml/dom/qdom/tst_qdom.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index c44626e161..b1c9b2e9c9 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -111,6 +111,7 @@ private slots: void checkIntOverflow() const; void setContentWhitespace() const; void setContentWhitespace_data() const; + void setContentUnopenedQIODevice() const; void taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() const; void cloneDTD_QTBUG8398() const; @@ -1919,6 +1920,23 @@ void tst_QDom::setContentWhitespace_data() const QTest::newRow("data25") << QString::fromLatin1("\t\t\t\t<?xml version='1.0' ?><e/>") << false; } +void tst_QDom::setContentUnopenedQIODevice() const +{ + QByteArray data("<foo>bar</foo>"); + QBuffer buffer(&data); + + QDomDocument doc; + + QTest::ignoreMessage(QtWarningMsg, + "QDomDocument called with unopened QIODevice. " + "This will not be supported in future Qt versions"); + + // Note: the check below is expected to fail in Qt 7. + // Fix the test and remove the obsolete code from setContent(). + QVERIFY(doc.setContent(&buffer, true)); + QCOMPARE(doc.toString().trimmed(), data); +} + void tst_QDom::taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() const { QString xmlWithUnknownEncoding("<?xml version='1.0' encoding='unknown-encoding'?>" |