aboutsummaryrefslogtreecommitdiff
path: root/autotests/callcandidateseventtest.cpp
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2022-10-06 19:27:24 +0200
committern-peugnet <n.peugnet@free.fr>2022-10-06 19:27:24 +0200
commitd911b207f49e936b3e992200796110f0749ed150 (patch)
tree96d20ebb4d074a4c1755e21cb316a52d584daee3 /autotests/callcandidateseventtest.cpp
parent8ad8a74152c5701b6ca1f9a00487ba9257a439b4 (diff)
parent56c2f2e2b809b9077393eb617828f33d144f5634 (diff)
downloadlibquotient-d911b207f49e936b3e992200796110f0749ed150.tar.gz
libquotient-d911b207f49e936b3e992200796110f0749ed150.zip
New upstream version 0.7.0
Diffstat (limited to 'autotests/callcandidateseventtest.cpp')
-rw-r--r--autotests/callcandidateseventtest.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/autotests/callcandidateseventtest.cpp b/autotests/callcandidateseventtest.cpp
new file mode 100644
index 00000000..257e0ef2
--- /dev/null
+++ b/autotests/callcandidateseventtest.cpp
@@ -0,0 +1,60 @@
+// SPDX-FileCopyrightText: 2020 Carl Schwan <carlschwan@kde.org>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#include "events/callevents.h"
+
+#include <QtTest/QtTest>
+
+class TestCallCandidatesEvent : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void fromJson();
+};
+
+void TestCallCandidatesEvent::fromJson()
+{
+ auto document = QJsonDocument::fromJson(R"({
+ "age": 242352,
+ "content": {
+ "call_id": "12345",
+ "candidates": [
+ {
+ "candidate": "candidate:863018703 1 udp 2122260223 10.9.64.156 43670 typ host generation 0",
+ "sdpMLineIndex": 0,
+ "sdpMid": "audio"
+ }
+ ],
+ "version": 0
+ },
+ "event_id": "$WLGTSEFSEF:localhost",
+ "origin_server_ts": 1431961217939,
+ "room_id": "!Cuyf34gef24t:localhost",
+ "sender": "@example:localhost",
+ "type": "m.call.candidates"
+ })");
+
+ QVERIFY(document.isObject());
+
+ auto object = document.object();
+
+ using namespace Quotient;
+ const auto& callCandidatesEvent = loadEvent<CallCandidatesEvent>(object);
+ QVERIFY(callCandidatesEvent);
+ QVERIFY(callCandidatesEvent->is<CallCandidatesEvent>());
+
+ QCOMPARE(callCandidatesEvent->version(), 0);
+ QCOMPARE(callCandidatesEvent->callId(), QStringLiteral("12345"));
+ QCOMPARE(callCandidatesEvent->candidates().count(), 1);
+
+ const auto& candidate = callCandidatesEvent->candidates().at(0).toObject();
+ QCOMPARE(candidate.value("sdpMid").toString(), QStringLiteral("audio"));
+ QCOMPARE(candidate.value("sdpMLineIndex").toInt(), 0);
+ QCOMPARE(candidate.value("candidate").toString(),
+ QStringLiteral("candidate:863018703 1 udp 2122260223 10.9.64.156 43670 typ host generation 0"));
+}
+
+QTEST_APPLESS_MAIN(TestCallCandidatesEvent)
+#include "callcandidateseventtest.moc"