From 052e7c52424e0db0f622bd99ab02318b7cdf4d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 13 Sep 2009 10:21:00 +0200 Subject: Added PayloadsSerializer. By using PayloadsSerializer in unit tests, we also test whether the serializer has been added to the full collection. diff --git a/Swiften/SConscript b/Swiften/SConscript index ece2c0e..77cb61d 100644 --- a/Swiften/SConscript +++ b/Swiften/SConscript @@ -247,6 +247,7 @@ env.Append(UNITTEST_SOURCES = [ File("Roster/UnitTest/OfflineRosterFilterTest.cpp"), File("Roster/UnitTest/RosterTest.cpp"), File("SASL/UnitTest/PLAINMessageTest.cpp"), + File("Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp"), File("Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp"), diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp new file mode 100644 index 0000000..23ff4a0 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp @@ -0,0 +1,21 @@ +#include "Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h" + +#include + +#include "Swiften/Serializer/PayloadSerializer.h" + +namespace Swift { + +String PayloadsSerializer::serialize(boost::shared_ptr payload) { + PayloadSerializer* serializer = serializers.getPayloadSerializer(payload); + if (serializer) { + return serializer->serialize(payload); + } + else { + CPPUNIT_ASSERT(false); + return ""; + } +} + + +} diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h new file mode 100644 index 0000000..9fca334 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +#include "Swiften/Elements/Payload.h" +#include "Swiften/Base/String.h" +#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h" + +namespace Swift { + class PayloadsSerializer { + public: + String serialize(boost::shared_ptr payload); + + private: + FullPayloadSerializerCollection serializers; + }; +} diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp index 158e7f1..daf43c5 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp @@ -1,7 +1,8 @@ #include #include -#include "Swiften/Serializer/PayloadSerializers/StorageSerializer.h" +#include "Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h" +#include "Swiften/Elements/Storage.h" using namespace Swift; @@ -15,7 +16,7 @@ class StorageSerializerTest : public CppUnit::TestFixture { StorageSerializerTest() {} void testSerialize() { - StorageSerializer testling; + PayloadsSerializer serializer; boost::shared_ptr storage(new Storage()); Storage::Conference conference; conference.name = "Council of Oberon"; @@ -34,11 +35,11 @@ class StorageSerializerTest : public CppUnit::TestFixture { "Puck" "MyPass" "" - ""), testling.serialize(storage)); + ""), serializer.serialize(storage)); } void testSerialize_NoNickOrPassword() { - StorageSerializer testling; + PayloadsSerializer serializer; boost::shared_ptr storage(new Storage()); Storage::Conference conference; conference.name = "Council of Oberon"; @@ -52,7 +53,7 @@ class StorageSerializerTest : public CppUnit::TestFixture { "autojoin=\"1\" " "jid=\"council@conference.underhill.org\" " "name=\"Council of Oberon\"/>" - ""), testling.serialize(storage)); + ""), serializer.serialize(storage)); } }; -- cgit v0.10.2-6-g49f6