summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2017-06-10 17:23:25 (GMT)
committerTobias Markmann <tm@ayena.de>2017-06-18 15:40:29 (GMT)
commitb8c1d6fb59bd4ae528d807fc30b02dab45aafabf (patch)
treee03a723b0f7b9b64c68d38fa0e38817adab3be8a /Swiften/Serializer/PayloadSerializers/UnitTest
parentccefa0d4d90fd89a6d7e9cd6167066f3797020d7 (diff)
downloadswift-b8c1d6fb59bd4ae528d807fc30b02dab45aafabf.zip
swift-b8c1d6fb59bd4ae528d807fc30b02dab45aafabf.tar.bz2
Adds MIX Participant Element, its Parsers and Serializers.
License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: Adds tests for MIX Participant Parser and Serializer from XEP-0369, which passes. Tested on Ubuntu 16.04 LTS. Change-Id: Iee2d96c8ebdf9461c28518f8f8c28c11d2a94524
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/UnitTest')
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXParticipantSerializerTest.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXParticipantSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXParticipantSerializerTest.cpp
new file mode 100644
index 0000000..a298d78
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXParticipantSerializerTest.cpp
@@ -0,0 +1,59 @@
+/*
+ * 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/Serializer/PayloadSerializers/MIXParticipantSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
+
+using namespace Swift;
+
+TEST(MIXParticipantSerializerTest, testSerializeEmpty) {
+ MIXParticipantSerializer testling;
+
+ std::shared_ptr<MIXParticipant> participant(new MIXParticipant());
+
+ std::string expectedResult = "<participant xmlns=\"urn:xmpp:mix:0\"/>";
+ ASSERT_EQ(expectedResult, testling.serialize(participant));
+}
+
+TEST(MIXParticipantSerializerTest, testSerializeNick) {
+ MIXParticipantSerializer testling;
+
+ std::shared_ptr<MIXParticipant> participant(new MIXParticipant());
+ participant->setNick("thirdwitch");
+
+ std::string expectedResult = "<participant xmlns=\"urn:xmpp:mix:0\">"
+ "<nick>thirdwitch</nick>"
+ "</participant>";
+ ASSERT_EQ(expectedResult, testling.serialize(participant));
+}
+
+TEST(MIXParticipantSerializerTest, testSerializeJID) {
+ MIXParticipantSerializer testling;
+
+ std::shared_ptr<MIXParticipant> participant(new MIXParticipant());
+ participant->setJID(JID("hecate@mix.shakespeare.example"));
+
+ std::string expectedResult = "<participant xmlns=\"urn:xmpp:mix:0\">"
+ "<jid>hecate@mix.shakespeare.example</jid>"
+ "</participant>";
+ ASSERT_EQ(expectedResult, testling.serialize(participant));
+}
+
+TEST(MIXParticipantSerializerTest, testSerializeJIDAndNick) {
+ MIXParticipantSerializer testling;
+
+ std::shared_ptr<MIXParticipant> participant(new MIXParticipant());
+ participant->setNick("thirdwitch");
+ participant->setJID(JID("hecate@mix.shakespeare.example"));
+
+ std::string expectedResult = "<participant xmlns=\"urn:xmpp:mix:0\">"
+ "<nick>thirdwitch</nick>"
+ "<jid>hecate@mix.shakespeare.example</jid>"
+ "</participant>";
+ ASSERT_EQ(expectedResult, testling.serialize(participant));
+}