aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMelvin Keskin <melvo@olomono.de>2021-05-08 19:35:40 +0200
committerGitHub <noreply@github.com>2021-05-08 19:35:40 +0200
commit826ece0480385c47c72f216e35e004b276d82498 (patch)
tree0ebddddd5db2c32c567e256be1117c62a4978c49 /tests
parentab2ead62e9f5241cc28801d742698ba65d4c8bd5 (diff)
downloadqxmpp-826ece0480385c47c72f216e35e004b276d82498.tar.gz
RosterManager: Add subscription request signal with full presence (#346)
This makes it possible to get the statusText of subscription requests.
Diffstat (limited to 'tests')
-rw-r--r--tests/qxmpprostermanager/tst_qxmpprostermanager.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/qxmpprostermanager/tst_qxmpprostermanager.cpp b/tests/qxmpprostermanager/tst_qxmpprostermanager.cpp
index 044567de..1cee09b1 100644
--- a/tests/qxmpprostermanager/tst_qxmpprostermanager.cpp
+++ b/tests/qxmpprostermanager/tst_qxmpprostermanager.cpp
@@ -3,6 +3,7 @@
*
* Authors:
* Linus Jahn
+ * Melvin Keskin
*
* Source:
* https://github.com/qxmpp-project/qxmpp
@@ -36,6 +37,7 @@ private slots:
void testDiscoFeatures();
void testRenameItem();
+ void subscriptionRequestReceived();
private:
QXmppClient client;
@@ -105,5 +107,25 @@ void tst_QXmppRosterManager::testRenameItem()
QVERIFY(requestSent);
}
+void tst_QXmppRosterManager::subscriptionRequestReceived()
+{
+ QXmppPresence presence;
+ presence.setType(QXmppPresence::Subscribe);
+ presence.setFrom(QStringLiteral("alice@example.org/notebook"));
+ presence.setStatusText(QStringLiteral("Hi, I'm Alice."));
+
+ bool subscriptionRequestReceived = false;
+
+ connect(manager, &QXmppRosterManager::subscriptionRequestReceived, this, [&](const QString &subscriberBareJid, const QXmppPresence &presence) {
+ subscriptionRequestReceived = true;
+
+ QCOMPARE(subscriberBareJid, QStringLiteral("alice@example.org"));
+ QCOMPARE(presence.statusText(), QStringLiteral("Hi, I'm Alice."));
+ });
+
+ emit client.presenceReceived(presence);
+ QVERIFY(subscriptionRequestReceived);
+}
+
QTEST_MAIN(tst_QXmppRosterManager)
#include "tst_qxmpprostermanager.moc"