summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/UnitTest')
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXCreateSerializerTest.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXDestroySerializerTest.cpp2
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXJoinSerializerTest.cpp100
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXLeaveSerializerTest.cpp30
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp61
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXRegisterNickSerializerTest.cpp22
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXSetNickSerializerTest.cpp22
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXUpdateSubscriptionSerializerTest.cpp36
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/MIXUserPreferenceSerializerTest.cpp8
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/ReferencePayloadSerializerTest.cpp81
10 files changed, 293 insertions, 73 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXCreateSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXCreateSerializerTest.cpp
index 78424be..80210a5 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXCreateSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXCreateSerializerTest.cpp
@@ -14,7 +14,7 @@ TEST(MIXCreateSerializerTest, XEP0369_Example31) {
MIXCreateSerializer testling;
auto create = std::make_shared<MIXCreate>();
- std::string expectedResult = "<create xmlns=\"urn:xmpp:mix:1\"/>";
+ std::string expectedResult = "<create xmlns=\"urn:xmpp:mix:0\"/>";
ASSERT_EQ(expectedResult, testling.serialize(create));
}
@@ -24,6 +24,6 @@ TEST(MIXCreateSerializerTest, XEP0369_Example66) {
auto create = std::make_shared<MIXCreate>();
create->setChannel(std::string("coven"));
- std::string expectedResult = "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>";
+ std::string expectedResult = "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>";
ASSERT_EQ(expectedResult, testling.serialize(create));
}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXDestroySerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXDestroySerializerTest.cpp
index e9cfa8b..5b21873 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXDestroySerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXDestroySerializerTest.cpp
@@ -16,6 +16,6 @@ TEST(MIXDestroySerializerTest, XEP0369_Example31) {
auto destroy = std::make_shared<MIXDestroy>();
destroy->setChannel(std::string("coven"));
- std::string expectedResult = "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>";
+ std::string expectedResult = "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>";
ASSERT_EQ(expectedResult, testling.serialize(destroy));
}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXJoinSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXJoinSerializerTest.cpp
index 61d8a4a..2987a20 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXJoinSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXJoinSerializerTest.cpp
@@ -16,24 +16,16 @@ TEST(MIXJoinSerializerTest, XEP0369_Example22) {
auto join = std::make_shared<MIXJoin>();
join->setChannel(JID("coven@mix.shakespeare.example"));
- std::shared_ptr<MIXSubscribe> node1(new MIXSubscribe());
- node1->setNode(std::string("urn:xmpp:mix:nodes:messages"));
- join->addSubscription(node1);
- std::shared_ptr<MIXSubscribe> node2(new MIXSubscribe());
- node2->setNode(std::string("urn:xmpp:mix:nodes:presence"));
- join->addSubscription(node2);
- std::shared_ptr<MIXSubscribe> node3(new MIXSubscribe());
- node3->setNode(std::string("urn:xmpp:mix:nodes:participants"));
- join->addSubscription(node3);
- std::shared_ptr<MIXSubscribe> node4(new MIXSubscribe());
- node4->setNode(std::string("urn:xmpp:mix:nodes:config"));
- join->addSubscription(node4);
-
- std::string expectedResult = "<join channel=\"coven@mix.shakespeare.example\" xmlns=\"urn:xmpp:mix:1\">"
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:messages"));
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:presence"));
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:participants"));
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:config"));
+
+ std::string expectedResult = "<join channel=\"coven@mix.shakespeare.example\" xmlns=\"urn:xmpp:mix:0\">"
+ "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
- "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>"
- "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>"
+ "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"</join>";
ASSERT_EQ(expectedResult, testling.serialize(join));
}
@@ -43,24 +35,16 @@ TEST(MIXJoinSerializerTest, XEP0369_Example23) {
std::shared_ptr<MIXJoin> join(new MIXJoin());
- std::shared_ptr<MIXSubscribe> node1(new MIXSubscribe());
- node1->setNode(std::string("urn:xmpp:mix:nodes:messages"));
- join->addSubscription(node1);
- std::shared_ptr<MIXSubscribe> node2(new MIXSubscribe());
- node2->setNode(std::string("urn:xmpp:mix:nodes:presence"));
- join->addSubscription(node2);
- std::shared_ptr<MIXSubscribe> node3(new MIXSubscribe());
- node3->setNode(std::string("urn:xmpp:mix:nodes:participants"));
- join->addSubscription(node3);
- std::shared_ptr<MIXSubscribe> node4(new MIXSubscribe());
- node4->setNode(std::string("urn:xmpp:mix:nodes:config"));
- join->addSubscription(node4);
-
- std::string expectedResult = "<join xmlns=\"urn:xmpp:mix:1\">"
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:messages"));
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:presence"));
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:participants"));
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:config"));
+
+ std::string expectedResult = "<join xmlns=\"urn:xmpp:mix:0\">"
+ "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
- "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>"
- "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>"
+ "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"</join>";
ASSERT_EQ(expectedResult, testling.serialize(join));
}
@@ -71,24 +55,16 @@ TEST(MIXJoinSerializerTest, XEP0369_Example24) {
std::shared_ptr<MIXJoin> join(new MIXJoin());
join->setJID(JID("123456#coven@mix.shakespeare.example"));
- std::shared_ptr<MIXSubscribe> node1(new MIXSubscribe());
- node1->setNode(std::string("urn:xmpp:mix:nodes:messages"));
- join->addSubscription(node1);
- std::shared_ptr<MIXSubscribe> node2(new MIXSubscribe());
- node2->setNode(std::string("urn:xmpp:mix:nodes:presence"));
- join->addSubscription(node2);
- std::shared_ptr<MIXSubscribe> node3(new MIXSubscribe());
- node3->setNode(std::string("urn:xmpp:mix:nodes:participants"));
- join->addSubscription(node3);
- std::shared_ptr<MIXSubscribe> node4(new MIXSubscribe());
- node4->setNode(std::string("urn:xmpp:mix:nodes:config"));
- join->addSubscription(node4);
-
- std::string expectedResult = "<join jid=\"123456#coven@mix.shakespeare.example\" xmlns=\"urn:xmpp:mix:1\">"
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:messages"));
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:presence"));
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:participants"));
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:config"));
+
+ std::string expectedResult = "<join jid=\"123456#coven@mix.shakespeare.example\" xmlns=\"urn:xmpp:mix:0\">"
+ "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
- "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>"
- "<subscribe node=\"urn:xmpp:mix:nodes:config\"/>"
+ "<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"</join>";
ASSERT_EQ(expectedResult, testling.serialize(join));
}
@@ -98,19 +74,15 @@ TEST(MIXJoinSerializerTest, XEP0369_Example29) {
std::shared_ptr<MIXJoin> join(new MIXJoin());
- std::shared_ptr<MIXSubscribe> node1(new MIXSubscribe());
- node1->setNode(std::string("urn:xmpp:mix:nodes:messages"));
- join->addSubscription(node1);
- std::shared_ptr<MIXSubscribe> node2(new MIXSubscribe());
- node2->setNode(std::string("urn:xmpp:mix:nodes:presence"));
- join->addSubscription(node2);
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:messages"));
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:presence"));
std::shared_ptr<Form> parameters(std::make_shared<Form>());
parameters->setType(Form::Type::SubmitType);
std::shared_ptr<FormField> fieldType = std::make_shared<FormField>(FormField::HiddenType);
fieldType->setName("FORM_TYPE");
- fieldType->addValue("urn:xmpp:mix:1");
+ fieldType->addValue("urn:xmpp:mix:0");
parameters->addField(fieldType);
std::shared_ptr<FormField> fieldJIDVisibility = std::make_shared<FormField>();
@@ -120,12 +92,12 @@ TEST(MIXJoinSerializerTest, XEP0369_Example29) {
join->setForm(parameters);
- std::string expectedResult = "<join xmlns=\"urn:xmpp:mix:1\">"
+ std::string expectedResult = "<join xmlns=\"urn:xmpp:mix:0\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<x type=\"submit\" xmlns=\"jabber:x:data\">"
"<field type=\"hidden\" var=\"FORM_TYPE\">"
- "<value>urn:xmpp:mix:1</value>"
+ "<value>urn:xmpp:mix:0</value>"
"</field>"
"<field var=\"JID Visibility\">"
"<value>never</value>"
@@ -141,19 +113,15 @@ TEST(MIXJoinSerializerTest, XEP0369_Example30) {
std::shared_ptr<MIXJoin> join(new MIXJoin());
join->setJID(JID("hag66@shakespeare.example"));
- std::shared_ptr<MIXSubscribe> node1(new MIXSubscribe());
- node1->setNode(std::string("urn:xmpp:mix:nodes:messages"));
- join->addSubscription(node1);
- std::shared_ptr<MIXSubscribe> node2(new MIXSubscribe());
- node2->setNode(std::string("urn:xmpp:mix:nodes:presence"));
- join->addSubscription(node2);
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:messages"));
+ join->addSubscription(std::string("urn:xmpp:mix:nodes:presence"));
std::shared_ptr<Form> parameters(std::make_shared<Form>());
parameters->setType(Form::Type::ResultType);
std::shared_ptr<FormField> fieldType = std::make_shared<FormField>(FormField::HiddenType);
fieldType->setName("FORM_TYPE");
- fieldType->addValue("urn:xmpp:mix:1");
+ fieldType->addValue("urn:xmpp:mix:0");
parameters->addField(fieldType);
std::shared_ptr<FormField> fieldJIDVisibility = std::make_shared<FormField>();
@@ -173,12 +141,12 @@ TEST(MIXJoinSerializerTest, XEP0369_Example30) {
join->setForm(parameters);
- std::string expectedResult = "<join jid=\"hag66@shakespeare.example\" xmlns=\"urn:xmpp:mix:1\">"
+ std::string expectedResult = "<join jid=\"hag66@shakespeare.example\" xmlns=\"urn:xmpp:mix:0\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<x type=\"result\" xmlns=\"jabber:x:data\">"
"<field type=\"hidden\" var=\"FORM_TYPE\">"
- "<value>urn:xmpp:mix:1</value>"
+ "<value>urn:xmpp:mix:0</value>"
"</field>"
"<field var=\"JID Visibility\">"
"<value>never</value>"
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXLeaveSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXLeaveSerializerTest.cpp
new file mode 100644
index 0000000..d9537a8
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXLeaveSerializerTest.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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/MIXLeaveSerializer.h>
+
+using namespace Swift;
+
+TEST(MIXLeaveSerializerTest, XEP0369_Example33) {
+ MIXLeaveSerializer testling;
+
+ auto leave = std::shared_ptr<MIXLeave>(new MIXLeave());
+ leave->setChannel(JID("coven@mix.shakespeare.example"));
+
+ std::string expectedResult = "<leave channel=\"coven@mix.shakespeare.example\" xmlns=\"urn:xmpp:mix:0\"/>";
+ ASSERT_EQ(expectedResult, testling.serialize(leave));
+}
+
+TEST(MIXLeaveSerializerTest, XEP0369_Example34) {
+ MIXLeaveSerializer testling;
+
+ auto leave = std::shared_ptr<MIXLeave>(new MIXLeave());
+
+ std::string expectedResult = "<leave xmlns=\"urn:xmpp:mix:0\"/>";
+ ASSERT_EQ(expectedResult, testling.serialize(leave));
+}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp
new file mode 100644
index 0000000..266b066
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXPayloadSerializerTest.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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/MIXPayloadSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
+
+using namespace Swift;
+
+TEST(MIXPayloadSerializerTest, testSerializeEmpty) {
+ MIXPayloadSerializer testling;
+
+ auto mix = std::shared_ptr<MIXPayload>(new MIXPayload());
+
+ std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\"/>";
+ ASSERT_EQ(expectedResult, testling.serialize(mix));
+}
+
+TEST(MIXPayloadSerializerTest, testSerializeNick) {
+ MIXPayloadSerializer testling;
+
+ auto mix = std::shared_ptr<MIXPayload>(new MIXPayload());
+ mix->setNick("thirdwitch");
+
+ std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\">"
+ "<nick>thirdwitch</nick>"
+ "</mix>";
+ ASSERT_EQ(expectedResult, testling.serialize(mix));
+}
+
+TEST(MIXPayloadSerializerTest, testSerializeJID) {
+ MIXPayloadSerializer testling;
+
+ auto mix = std::shared_ptr<MIXPayload>(new MIXPayload());
+ mix->setJID(JID("hecate@mix.shakespeare.example"));
+
+ std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\">"
+ "<jid>hecate@mix.shakespeare.example</jid>"
+ "</mix>";
+ ASSERT_EQ(expectedResult, testling.serialize(mix));
+}
+
+TEST(MIXPayloadSerializerTest, testSerializeAll) {
+ MIXPayloadSerializer testling;
+
+ auto mix = std::shared_ptr<MIXPayload>(new MIXPayload());
+ mix->setNick("thirdwitch");
+ mix->setJID(JID("hecate@mix.shakespeare.example"));
+ mix->setSubmissionID("92vax143g");
+
+ std::string expectedResult = "<mix xmlns=\"urn:xmpp:mix:0\">"
+ "<nick>thirdwitch</nick>"
+ "<jid>hecate@mix.shakespeare.example</jid>"
+ "<submission-id>92vax143g</submission-id>"
+ "</mix>";
+ ASSERT_EQ(expectedResult, testling.serialize(mix));
+}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXRegisterNickSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXRegisterNickSerializerTest.cpp
new file mode 100644
index 0000000..dc6cf0c
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXRegisterNickSerializerTest.cpp
@@ -0,0 +1,22 @@
+/*
+ * 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/MIXRegisterNickSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
+
+using namespace Swift;
+
+TEST(MIXRegisterNickSerializerTest, testSerializeNick) {
+ MIXRegisterNickSerializer testling;
+
+ auto mix = std::shared_ptr<MIXRegisterNick>(new MIXRegisterNick());
+ mix->setNick(std::string("thirdwitch"));
+
+ std::string expectedResult = "<register xmlns=\"urn:xmpp:mix:0\"><nick>thirdwitch</nick></register>";
+ ASSERT_EQ(expectedResult, testling.serialize(mix));
+}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXSetNickSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXSetNickSerializerTest.cpp
new file mode 100644
index 0000000..ab29bc5
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXSetNickSerializerTest.cpp
@@ -0,0 +1,22 @@
+/*
+ * 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/MIXSetNickSerializer.h>
+#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
+
+using namespace Swift;
+
+TEST(MIXSetNickSerializerTest, testSerializeNick) {
+ MIXSetNickSerializer testling;
+
+ auto mix = std::shared_ptr<MIXSetNick>(new MIXSetNick());
+ mix->setNick(std::string("thirdwitch"));
+
+ std::string expectedResult = "<setnick xmlns=\"urn:xmpp:mix:0\"><nick>thirdwitch</nick></setnick>";
+ ASSERT_EQ(expectedResult, testling.serialize(mix));
+}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUpdateSubscriptionSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUpdateSubscriptionSerializerTest.cpp
new file mode 100644
index 0000000..3e35a82
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUpdateSubscriptionSerializerTest.cpp
@@ -0,0 +1,36 @@
+/*
+ * 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/MIXUpdateSubscriptionSerializer.h>
+
+using namespace Swift;
+
+TEST(MIXUpdateSubscriptionSerializerTest, XEP0369_Example28) {
+ MIXUpdateSubscriptionSerializer testling;
+
+ auto update = std::make_shared<MIXUpdateSubscription>();
+ update->addSubscription(std::string("urn:xmpp:mix:nodes:messages"));
+
+ std::string expectedResult = "<update-subscription xmlns=\"urn:xmpp:mix:0\">"
+ "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
+ "</update-subscription>";
+ ASSERT_EQ(expectedResult, testling.serialize(update));
+}
+
+TEST(MIXUpdateSubscriptionSerializerTest, XEP0369_Example28WithJID) {
+ MIXUpdateSubscriptionSerializer testling;
+
+ auto update = std::make_shared<MIXUpdateSubscription>();
+ update->setJID(JID("hag66@shakespeare.example"));
+ update->addSubscription(std::string("urn:xmpp:mix:nodes:messages"));
+
+ std::string expectedResult = "<update-subscription jid=\"hag66@shakespeare.example\" xmlns=\"urn:xmpp:mix:0\">"
+ "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
+ "</update-subscription>";
+ ASSERT_EQ(expectedResult, testling.serialize(update));
+}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUserPreferenceSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUserPreferenceSerializerTest.cpp
index 7cbfbfc..0226b0f 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUserPreferenceSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MIXUserPreferenceSerializerTest.cpp
@@ -15,7 +15,7 @@ TEST(MIXUserPreferenceSerializerTest, XEP0369_Example31) {
MIXUserPreferenceSerializer testling;
auto userpreference = std::shared_ptr<MIXUserPreference>(new MIXUserPreference());
- std::string expectedResult = "<user-preference xmlns=\"urn:xmpp:mix:1\"/>";
+ std::string expectedResult = "<user-preference xmlns=\"urn:xmpp:mix:0\"/>";
ASSERT_EQ(expectedResult, testling.serialize(userpreference));
}
@@ -28,7 +28,7 @@ TEST(MIXUserPreferenceSerializerTest, XEP0369_Example32) {
std::shared_ptr<FormField> fieldType = std::make_shared<FormField>(FormField::HiddenType);
fieldType->setName("FORM_TYPE");
- fieldType->addValue("urn:xmpp:mix:1");
+ fieldType->addValue("urn:xmpp:mix:0");
parameters->addField(fieldType);
std::shared_ptr<FormField> fieldJIDVisibility = std::make_shared<FormField>();
@@ -48,10 +48,10 @@ TEST(MIXUserPreferenceSerializerTest, XEP0369_Example32) {
userpreference->setData(parameters);
- std::string expectedResult = "<user-preference xmlns=\"urn:xmpp:mix:1\">"
+ std::string expectedResult = "<user-preference xmlns=\"urn:xmpp:mix:0\">"
"<x type=\"result\" xmlns=\"jabber:x:data\">"
"<field type=\"hidden\" var=\"FORM_TYPE\">"
- "<value>urn:xmpp:mix:1</value>"
+ "<value>urn:xmpp:mix:0</value>"
"</field>"
"<field var=\"JID Visibility\">"
"<value>never</value>"
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ReferencePayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ReferencePayloadSerializerTest.cpp
new file mode 100644
index 0000000..82465d7
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ReferencePayloadSerializerTest.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2018 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Serializer/PayloadSerializers/ReferencePayloadSerializer.h>
+
+#include <Swiften/Elements/Body.h>
+#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
+
+using namespace Swift;
+
+static FullPayloadSerializerCollection serializers;
+
+TEST(ReferencePayloadSerializerTest, testSerialize) {
+ ReferencePayloadSerializer testling(&serializers);
+ auto reference = std::make_shared<ReferencePayload>();
+ reference->setType(ReferencePayload::Type::Data);
+ reference->setUri(boost::optional<std::string>("https://www.example.com/mindBlowingImage.jpeg"));
+ reference->setBegin(boost::optional<std::string>("11"));
+ reference->setEnd(boost::optional<std::string>("22"));
+ reference->setAnchor(boost::optional<std::string>("xmpp:data@localhost.example.test"));
+
+ std::string expectedResult =
+ "<reference "
+ "anchor=\"xmpp:data@localhost.example.test\" "
+ "begin=\"11\" "
+ "end=\"22\" "
+ "type=\"data\" "
+ "uri=\"https://www.example.com/mindBlowingImage.jpeg\" "
+ "xmlns=\"urn:xmpp:reference:0\"/>";
+
+ ASSERT_EQ(expectedResult, testling.serialize(reference));
+}
+
+TEST(ReferencePayloadSerializerTest, testSerializeNoType) {
+ ReferencePayloadSerializer testling(&serializers);
+ auto reference = std::make_shared<ReferencePayload>();
+ reference->setUri(boost::optional<std::string>("https://www.example.com/mindBlowingImage.jpeg"));
+ reference->setBegin(boost::optional<std::string>("11"));
+ reference->setEnd(boost::optional<std::string>("22"));
+ reference->setAnchor(boost::optional<std::string>("xmpp:data@localhost.example.test"));
+
+ std::string expectedResult =
+ "<reference "
+ "anchor=\"xmpp:data@localhost.example.test\" "
+ "begin=\"11\" "
+ "end=\"22\" "
+ "type=\"data\" "
+ "uri=\"https://www.example.com/mindBlowingImage.jpeg\" "
+ "xmlns=\"urn:xmpp:reference:0\"/>";
+
+ ASSERT_EQ(expectedResult, testling.serialize(reference));
+}
+
+TEST(ReferencePayloadSerializerTest, testSerializeWithEmbeddedPayload) {
+ ReferencePayloadSerializer testling(&serializers);
+ auto reference = std::make_shared<ReferencePayload>();
+ reference->setUri(boost::optional<std::string>("https://www.example.com/mindBlowingImage.jpeg"));
+ reference->setBegin(boost::optional<std::string>("11"));
+ reference->setEnd(boost::optional<std::string>("22"));
+ reference->setAnchor(boost::optional<std::string>("xmpp:data@localhost.example.test"));
+ auto payload = std::make_shared<Body>(std::string("Look, I'm in a reference"));
+ reference->addPayload(payload);
+
+ std::string expectedResult =
+ "<reference "
+ "anchor=\"xmpp:data@localhost.example.test\" "
+ "begin=\"11\" "
+ "end=\"22\" "
+ "type=\"data\" "
+ "uri=\"https://www.example.com/mindBlowingImage.jpeg\" "
+ "xmlns=\"urn:xmpp:reference:0\">"
+ "<body>Look, I'm in a reference</body>"
+ "</reference>";
+
+ ASSERT_EQ(expectedResult, testling.serialize(reference));
+}