diff options
| author | Tarun Gupta <tarun1995gupta@gmail.com> | 2015-06-23 20:36:59 (GMT) |
|---|---|---|
| committer | Kevin Smith <kevin.smith@isode.com> | 2015-07-14 16:06:27 (GMT) |
| commit | 7aa2011c591e2ca9f31ce550b884ed1c6ad75080 (patch) | |
| tree | 79dc096225544ee958d69e3b7fabaf1bd7409336 /Swiften/Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp | |
| parent | 0cfa934c4c0323cc9e8e1431f25a05977e3670a6 (diff) | |
| download | swift-7aa2011c591e2ca9f31ce550b884ed1c6ad75080.zip swift-7aa2011c591e2ca9f31ce550b884ed1c6ad75080.tar.bz2 | |
Add tests for Parsers and Serializers.
Adds InBandRegistrationPayloadParserTest, IBBSerializerTest, IsodeIQDelegationSerializerTest.
Adds UserTune Parser and Serializer.
Adds UserLocation Parser and Serializer.
License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Test-Information:
All tests passes.
Change-Id: Ida220574c33ca9ee6f2aa8a2f4fba4c68e3fec60
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp')
| -rw-r--r-- | Swiften/Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp new file mode 100644 index 0000000..f9a9efd --- /dev/null +++ b/Swiften/Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2015 Tarun Gupta. | ||
| 3 | * Licensed under the simplified BSD license. | ||
| 4 | * See Documentation/Licenses/BSD-simplified.txt for more information. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <cppunit/extensions/HelperMacros.h> | ||
| 8 | #include <cppunit/extensions/TestFactoryRegistry.h> | ||
| 9 | |||
| 10 | #include <Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.h> | ||
| 11 | #include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h> | ||
| 12 | #include <Swiften/Elements/Form.h> | ||
| 13 | #include <Swiften/Elements/InBandRegistrationPayload.h> | ||
| 14 | |||
| 15 | using namespace Swift; | ||
| 16 | |||
| 17 | class InBandRegistrationPayloadParserTest : public CppUnit::TestFixture | ||
| 18 | { | ||
| 19 | CPPUNIT_TEST_SUITE(InBandRegistrationPayloadParserTest); | ||
| 20 | CPPUNIT_TEST(testParse); | ||
| 21 | CPPUNIT_TEST(testParse_Form); | ||
| 22 | CPPUNIT_TEST_SUITE_END(); | ||
| 23 | |||
| 24 | public: | ||
| 25 | InBandRegistrationPayloadParserTest() {} | ||
| 26 | |||
| 27 | void testParse() { | ||
| 28 | PayloadsParserTester parser; | ||
| 29 | |||
| 30 | CPPUNIT_ASSERT(parser.parse( | ||
| 31 | "<query xmlns=\"jabber:iq:register\">" | ||
| 32 | "<registered/>" | ||
| 33 | "</query>")); | ||
| 34 | |||
| 35 | InBandRegistrationPayload* payload = dynamic_cast<InBandRegistrationPayload*>(parser.getPayload().get()); | ||
| 36 | CPPUNIT_ASSERT(payload); | ||
| 37 | CPPUNIT_ASSERT(payload->isRegistered()); | ||
| 38 | } | ||
| 39 | |||
| 40 | void testParse_Form() { | ||
| 41 | PayloadsParserTester parser; | ||
| 42 | |||
| 43 | CPPUNIT_ASSERT(parser.parse( | ||
| 44 | "<query xmlns=\"jabber:iq:register\">" | ||
| 45 | "<instructions>Use the enclosed form to register.</instructions>" | ||
| 46 | "<x type=\"form\" xmlns=\"jabber:x:data\">" | ||
| 47 | "<title>Contest Registration</title>" | ||
| 48 | "<field type=\"hidden\" var=\"FORM_TYPE\">" | ||
| 49 | "<value>jabber:iq:register</value>" | ||
| 50 | "</field>" | ||
| 51 | "</x>" | ||
| 52 | "</query>")); | ||
| 53 | |||
| 54 | InBandRegistrationPayload* payload = dynamic_cast<InBandRegistrationPayload*>(parser.getPayload().get()); | ||
| 55 | CPPUNIT_ASSERT(payload); | ||
| 56 | boost::optional<std::string> instruction = payload->getInstructions(); | ||
| 57 | CPPUNIT_ASSERT(instruction); | ||
| 58 | CPPUNIT_ASSERT_EQUAL(std::string("Use the enclosed form to register."), instruction.get()); | ||
| 59 | |||
| 60 | Form::ref form = payload->getForm(); | ||
| 61 | CPPUNIT_ASSERT(form); | ||
| 62 | CPPUNIT_ASSERT_EQUAL(std::string("Contest Registration"), form->getTitle()); | ||
| 63 | CPPUNIT_ASSERT_EQUAL(Form::FormType, form->getType()); | ||
| 64 | CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:register"), form->getFormType()); | ||
| 65 | } | ||
| 66 | }; | ||
| 67 | |||
| 68 | CPPUNIT_TEST_SUITE_REGISTRATION(InBandRegistrationPayloadParserTest); | ||
Swift