blob: 920aca780c23ce99731b73d6e7edefc28a0f7721 (
plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*
* Copyright (c) 2017 Tarun Gupta
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#include <gtest/gtest.h>
#include <Swiften/Elements/MIXPayload.h>
#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
using namespace Swift;
TEST(MIXPayloadParserTest, WithNick) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
"<mix xmlns=\"urn:xmpp:mix:0\"> <nick>thirdwitch</nick> </mix>"
));
auto payload = parser.getPayload<MIXPayload>();
ASSERT_TRUE(payload);
ASSERT_TRUE(payload->getNick());
std::string nick = *payload->getNick();
ASSERT_EQ("thirdwitch", nick);
ASSERT_FALSE(payload->getJID());
ASSERT_FALSE(payload->getSubmissionID());
}
TEST(MIXPayloadParserTest, WithJID) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
"<mix xmlns=\"urn:xmpp:mix:0\"> <jid>hecate@mix.shakespeare.example</jid> </mix>"
));
auto payload = parser.getPayload<MIXPayload>();
ASSERT_TRUE(payload);
ASSERT_TRUE(payload->getJID());
JID jid = *payload->getJID();
ASSERT_EQ("hecate@mix.shakespeare.example", jid.toString());
ASSERT_FALSE(payload->getNick());
ASSERT_FALSE(payload->getSubmissionID());
}
TEST(MIXPayloadParserTest, WithAll) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
"<mix xmlns=\"urn:xmpp:mix:0\">"
"<nick>thirdwitch</nick>"
"<jid>hecate@mix.shakespeare.example</jid>"
"<submission-id>92vax143g</submission-id>"
"</mix>"
));
auto payload = parser.getPayload<MIXPayload>();
ASSERT_TRUE(payload);
ASSERT_TRUE(payload->getNick());
std::string nick = *payload->getNick();
ASSERT_EQ("thirdwitch", nick);
ASSERT_TRUE(payload->getJID());
JID jid = *payload->getJID();
ASSERT_EQ("hecate@mix.shakespeare.example", jid.toString());
ASSERT_TRUE(payload->getSubmissionID());
std::string subID = *payload->getSubmissionID();
ASSERT_EQ("92vax143g", subID);
}
TEST(MIXPayloadParserTest, Empty) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
"<mix xmlns=\"urn:xmpp:mix:0\"/>"
));
auto payload = parser.getPayload<MIXPayload>();
ASSERT_TRUE(payload);
ASSERT_FALSE(payload->getNick());
ASSERT_FALSE(payload->getJID());
ASSERT_FALSE(payload->getSubmissionID());
}
|