From 6b9e2c85f144a44a2b5b664ee6772ec09e1ccc60 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Fri, 23 Jul 2021 21:00:05 +0200 Subject: tests: TestClient: Add both QString & QByteArray packet injection --- tests/TestClient.h | 3 ++- tests/qxmppdiscoverymanager/tst_qxmppdiscoverymanager.cpp | 4 ++-- tests/qxmpprostermanager/tst_qxmpprostermanager.cpp | 8 ++++---- tests/util.h | 3 ++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/TestClient.h b/tests/TestClient.h index d11e1398..2dda4055 100644 --- a/tests/TestClient.h +++ b/tests/TestClient.h @@ -54,7 +54,8 @@ public: { } - void inject(const QByteArray &xml) + template + void inject(const String &xml) { d->stream->handleIqResponse(xmlToDom(xml)); QCoreApplication::processEvents(); diff --git a/tests/qxmppdiscoverymanager/tst_qxmppdiscoverymanager.cpp b/tests/qxmppdiscoverymanager/tst_qxmppdiscoverymanager.cpp index 43dfd836..676b000c 100644 --- a/tests/qxmppdiscoverymanager/tst_qxmppdiscoverymanager.cpp +++ b/tests/qxmppdiscoverymanager/tst_qxmppdiscoverymanager.cpp @@ -40,7 +40,7 @@ void tst_QXmppDiscoveryManager::testInfo() auto future = discoManager->requestDiscoInfo("user@example.org"); test.expect(""); - test.inject(R"( + test.inject(R"( @@ -64,7 +64,7 @@ void tst_QXmppDiscoveryManager::testItems() auto future = discoManager->requestDiscoItems("user@example.org"); test.expect(""); qDebug() << "Moin"; - test.inject(R"( + test.inject(R"( diff --git a/tests/qxmpprostermanager/tst_qxmpprostermanager.cpp b/tests/qxmpprostermanager/tst_qxmpprostermanager.cpp index a3cd82ab..8b1ed5be 100644 --- a/tests/qxmpprostermanager/tst_qxmpprostermanager.cpp +++ b/tests/qxmpprostermanager/tst_qxmpprostermanager.cpp @@ -136,12 +136,12 @@ void tst_QXmppRosterManager::testAddItem() auto future = rosterManager->addRosterItem("contact@example.org"); test.expect(""); - test.inject(""); + test.inject(""); expectFutureVariant(future); future = rosterManager->addRosterItem("contact@example.org"); test.expect(""); - test.inject(R"( + test.inject(R"( @@ -160,12 +160,12 @@ void tst_QXmppRosterManager::testRemoveItem() auto future = rosterManager->removeRosterItem("contact@example.org"); test.expect(""); - test.inject(""); + test.inject(""); expectFutureVariant(future); future = rosterManager->removeRosterItem("contact@example.org"); test.expect(""); - test.inject(R"( + test.inject(R"( diff --git a/tests/util.h b/tests/util.h index dc36e7af..035c8293 100644 --- a/tests/util.h +++ b/tests/util.h @@ -38,7 +38,8 @@ if (!QTest::qVerify(statement, #statement, description, __FILE__, __LINE__)) \ return {}; -inline QDomElement xmlToDom(const QByteArray &xml) +template +inline QDomElement xmlToDom(const String &xml) { QDomDocument doc; QVERIFY_RV(doc.setContent(xml, true), "XML is not valid"); -- cgit v1.2.3