diff options
| author | Linus Jahn <lnj@kaidan.im> | 2020-10-10 21:41:13 +0200 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2020-10-10 22:33:41 +0200 |
| commit | 947ad50e7c62a8d65544d64bb7a85303522dfd80 (patch) | |
| tree | 98df0bd8c0737b9eb92255e6da03672cc6f9ea62 /tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp | |
| parent | 3fce512b43b00f1f0b30a79d849597682ab9098f (diff) | |
| download | qxmpp-947ad50e7c62a8d65544d64bb7a85303522dfd80.tar.gz | |
tests: Adapt to Qt6's stricter XML parsing
Diffstat (limited to 'tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp')
| -rw-r--r-- | tests/qxmppstreamfeatures/tst_qxmppstreamfeatures.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
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<class T> +static void parsePacketWithStream(T &packet, const QByteArray &xml) +{ + QDomDocument doc; + const auto wrappedXml = + QByteArrayLiteral("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>") + + xml + QByteArrayLiteral("</stream:stream>"); + + 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("<stream:features/>"); 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() "</stream:features>"); QXmppStreamFeatures features; - parsePacket(features, xml); + parsePacketWithStream(features, xml); QCOMPARE(features.tlsMode(), QXmppStreamFeatures::Required); serializePacket(features, xml); } @@ -86,7 +103,7 @@ void tst_QXmppStreamFeatures::testFull() "</stream:features>"); QXmppStreamFeatures features; - parsePacket(features, xml); + parsePacketWithStream(features, xml); QCOMPARE(features.bindMode(), QXmppStreamFeatures::Enabled); QCOMPARE(features.sessionMode(), QXmppStreamFeatures::Enabled); QCOMPARE(features.nonSaslAuthMode(), QXmppStreamFeatures::Enabled); |
