1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// SPDX-FileCopyrightText: 2020 Carl Schwan <carlschwan@kde.org>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#include "events/callcandidatesevent.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();
Quotient::CallCandidatesEvent callCandidatesEvent(object);
QCOMPARE(callCandidatesEvent.version(), 0);
QCOMPARE(callCandidatesEvent.callId(), QStringLiteral("12345"));
QCOMPARE(callCandidatesEvent.candidates().count(), 1);
const QJsonObject &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"
|