summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-17 12:13:36 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-21 18:25:00 (GMT)
commit1b58ef2af54456004390a0888c3edf104e3baa99 (patch)
treedbe4ae29de1b765a88ea704dfaa1c03af4b196b3 /Swiften/Serializer/PayloadSerializers/UnitTest
parent07402c4e3451f2084a1c3ddc5bacfb38a66899a7 (diff)
downloadswift-contrib-1b58ef2af54456004390a0888c3edf104e3baa99.zip
swift-contrib-1b58ef2af54456004390a0888c3edf104e3baa99.tar.bz2
Added beginnings of outgoing file transfer to Swiften.
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/UnitTest')
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp4
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp69
2 files changed, 71 insertions, 2 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp
index ebc8664..4ed3ba9 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp
@@ -84,7 +84,7 @@ class FormSerializerTest : public CppUnit::TestFixture {
field->addOption(FormField::Option("30", "30"));
field->addOption(FormField::Option("50", "50"));
field->addOption(FormField::Option("100", "100"));
- field->addOption(FormField::Option("None", "none"));
+ field->addOption(FormField::Option("", "none"));
form->addField(field);
std::vector<JID> jids;
@@ -132,7 +132,7 @@ class FormSerializerTest : public CppUnit::TestFixture {
"<option label=\"30\"><value>30</value></option>"
"<option label=\"50\"><value>50</value></option>"
"<option label=\"100\"><value>100</value></option>"
- "<option label=\"None\"><value>none</value></option>"
+ "<option><value>none</value></option>"
"</field>"
"<field label=\"People to invite\" type=\"jid-multi\" var=\"invitelist\">"
"<desc>Tell all your friends about your new bot!</desc>"
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp
new file mode 100644
index 0000000..12c8485
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h"
+
+using namespace Swift;
+
+class StreamInitiationSerializerTest : public CppUnit::TestFixture{
+ CPPUNIT_TEST_SUITE(StreamInitiationSerializerTest);
+ CPPUNIT_TEST(testSerialize_Request);
+ CPPUNIT_TEST(testSerialize_Response);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testSerialize_Request() {
+ StreamInitiationSerializer testling;
+ boost::shared_ptr<StreamInitiation> streamInitiation(new StreamInitiation());
+ StreamInitiation::FileInfo fileInfo("test.txt", "This is info about the file.", 1022);
+ streamInitiation->setID("a0");
+ streamInitiation->setFileInfo(fileInfo);
+ streamInitiation->addProvidedMethod("http://jabber.org/protocol/bytestreams");
+ streamInitiation->addProvidedMethod("jabber:iq:oob");
+ streamInitiation->addProvidedMethod("http://jabber.org/protocol/ibb");
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<si id=\"a0\" profile=\"http://jabber.org/protocol/si/profile/file-transfer\" xmlns=\"http://jabber.org/protocol/si\">"
+ "<file name=\"test.txt\" size=\"1022\" xmlns=\"http://jabber.org/protocol/si/profile/file-transfer\">"
+ "<desc>This is info about the file.</desc>"
+ "</file>"
+ "<feature xmlns=\"http://jabber.org/protocol/feature-neg\">"
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<field type=\"list-single\" var=\"stream-method\">"
+ "<option><value>http://jabber.org/protocol/bytestreams</value></option>"
+ "<option><value>jabber:iq:oob</value></option>"
+ "<option><value>http://jabber.org/protocol/ibb</value></option>"
+ "</field>"
+ "</x>"
+ "</feature>"
+ "</si>"
+ ), testling.serialize(streamInitiation));
+ }
+
+ void testSerialize_Response() {
+ StreamInitiationSerializer testling;
+ boost::shared_ptr<StreamInitiation> streamInitiation(new StreamInitiation());
+ streamInitiation->setRequestedMethod("http://jabber.org/protocol/bytestreams");
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<si profile=\"http://jabber.org/protocol/si/profile/file-transfer\" xmlns=\"http://jabber.org/protocol/si\">"
+ "<feature xmlns=\"http://jabber.org/protocol/feature-neg\">"
+ "<x type=\"submit\" xmlns=\"jabber:x:data\">"
+ "<field type=\"list-single\" var=\"stream-method\">"
+ "<value>http://jabber.org/protocol/bytestreams</value>"
+ "</field>"
+ "</x>"
+ "</feature>"
+ "</si>"
+ ), testling.serialize(streamInitiation));
+ }
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(StreamInitiationSerializerTest);