From 947ad50e7c62a8d65544d64bb7a85303522dfd80 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Sat, 10 Oct 2020 21:41:13 +0200 Subject: tests: Adapt to Qt6's stricter XML parsing --- .../tst_qxmppstreamfeatures.cpp | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp') diff --git a/tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp b/tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp index fe011789..3a0dd5e3 100644 --- a/tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp +++ b/tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp @@ -25,6 +25,23 @@ #include "util.h" +template +static void parsePacketWithStream(T &packet, const QByteArray &xml) +{ + QDomDocument doc; + const auto wrappedXml = + QByteArrayLiteral("") + + xml + QByteArrayLiteral(""); + + QString err; + bool parsingSuccess = doc.setContent(wrappedXml, true, &err); + if (!err.isNull()) + qDebug() << err; + QVERIFY(parsingSuccess); + + packet.parse(doc.documentElement().firstChildElement()); +} + class tst_QXmppStreamFeatures : public QObject { Q_OBJECT @@ -41,7 +58,7 @@ void tst_QXmppStreamFeatures::testEmpty() const QByteArray xml(""); QXmppStreamFeatures features; - parsePacket(features, xml); + parsePacketWithStream(features, xml); QCOMPARE(features.bindMode(), QXmppStreamFeatures::Disabled); QCOMPARE(features.sessionMode(), QXmppStreamFeatures::Disabled); QCOMPARE(features.nonSaslAuthMode(), QXmppStreamFeatures::Disabled); @@ -65,7 +82,7 @@ void tst_QXmppStreamFeatures::testRequired() ""); QXmppStreamFeatures features; - parsePacket(features, xml); + parsePacketWithStream(features, xml); QCOMPARE(features.tlsMode(), QXmppStreamFeatures::Required); serializePacket(features, xml); } @@ -86,7 +103,7 @@ void tst_QXmppStreamFeatures::testFull() ""); QXmppStreamFeatures features; - parsePacket(features, xml); + parsePacketWithStream(features, xml); QCOMPARE(features.bindMode(), QXmppStreamFeatures::Enabled); QCOMPARE(features.sessionMode(), QXmppStreamFeatures::Enabled); QCOMPARE(features.nonSaslAuthMode(), QXmppStreamFeatures::Enabled); -- cgit v1.2.3