diff options
| author | Richard Maudsley <richard.maudsley@isode.com> | 2014-04-28 08:36:39 (GMT) |
|---|---|---|
| committer | Richard Maudsley <richard.maudsley@isode.com> | 2014-04-28 15:23:59 (GMT) |
| commit | be642f17bfa2df7cb88ddb5fb4aa37438d9e2110 (patch) | |
| tree | c11e239dfcfcab2b38b64e6a19ffb48e8c30c44d /Swiften/Parser/UnitTest/XMPPParserTest.cpp | |
| parent | 64511948b075e650cacfcc78e40371abee1d2716 (diff) | |
| download | swift-contrib-be642f17bfa2df7cb88ddb5fb4aa37438d9e2110.zip swift-contrib-be642f17bfa2df7cb88ddb5fb4aa37438d9e2110.tar.bz2 | |
Create ToplevelElement to replace Element.
Change-Id: I3460f6f4a2ffa9b795080664f49d9138440de72d
Diffstat (limited to 'Swiften/Parser/UnitTest/XMPPParserTest.cpp')
| -rw-r--r-- | Swiften/Parser/UnitTest/XMPPParserTest.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Swiften/Parser/UnitTest/XMPPParserTest.cpp b/Swiften/Parser/UnitTest/XMPPParserTest.cpp index f8d60f2..7d2d3fa 100644 --- a/Swiften/Parser/UnitTest/XMPPParserTest.cpp +++ b/Swiften/Parser/UnitTest/XMPPParserTest.cpp @@ -1,37 +1,37 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2014 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 <vector> #include <Swiften/Elements/ProtocolHeader.h> #include <string> #include <Swiften/Parser/XMPPParser.h> #include <Swiften/Parser/ElementParser.h> #include <Swiften/Parser/XMPPParserClient.h> #include <Swiften/Parser/PayloadParserFactoryCollection.h> #include <Swiften/Parser/PlatformXMLParserFactory.h> #include <Swiften/Elements/Presence.h> #include <Swiften/Elements/IQ.h> #include <Swiften/Elements/Message.h> #include <Swiften/Elements/StreamFeatures.h> #include <Swiften/Elements/UnknownElement.h> using namespace Swift; class XMPPParserTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(XMPPParserTest); CPPUNIT_TEST(testParse_SimpleSession); CPPUNIT_TEST(testParse_SimpleClientFromServerSession); CPPUNIT_TEST(testParse_Presence); CPPUNIT_TEST(testParse_IQ); CPPUNIT_TEST(testParse_Message); CPPUNIT_TEST(testParse_StreamFeatures); CPPUNIT_TEST(testParse_UnknownElement); CPPUNIT_TEST(testParse_StrayCharacterData); CPPUNIT_TEST(testParse_InvalidStreamStart); CPPUNIT_TEST(testParse_ElementEndAfterInvalidStreamStart); @@ -130,67 +130,67 @@ class XMPPParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(dynamic_cast<UnknownElement*>(client_.events[3].element.get())); CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[4].type); CPPUNIT_ASSERT(dynamic_cast<Presence*>(client_.events[4].element.get())); } void testParse_StrayCharacterData() { XMPPParser testling(&client_, &factories_, &xmlParserFactory_); CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>")); CPPUNIT_ASSERT(testling.parse("<presence/>")); CPPUNIT_ASSERT(testling.parse("bla")); CPPUNIT_ASSERT(testling.parse("<iq/>")); CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(client_.events.size())); CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[2].type); CPPUNIT_ASSERT(dynamic_cast<IQ*>(client_.events[2].element.get())); } void testParse_InvalidStreamStart() { XMPPParser testling(&client_, &factories_, &xmlParserFactory_); CPPUNIT_ASSERT(!testling.parse("<tream>")); } void testParse_ElementEndAfterInvalidStreamStart() { XMPPParser testling(&client_, &factories_, &xmlParserFactory_); CPPUNIT_ASSERT(!testling.parse("<tream/>")); } private: class Client : public XMPPParserClient { public: enum Type { StreamStart, ElementEvent, StreamEnd }; struct Event { - Event(Type type, boost::shared_ptr<Element> element) + Event(Type type, boost::shared_ptr<ToplevelElement> element) : type(type), element(element) {} Event(Type type, const ProtocolHeader& header) : type(type), header(header) {} Event(Type type) : type(type) {} Type type; boost::optional<ProtocolHeader> header; - boost::shared_ptr<Element> element; + boost::shared_ptr<ToplevelElement> element; }; Client() {} void handleStreamStart(const ProtocolHeader& header) { events.push_back(Event(StreamStart, header)); } - void handleElement(boost::shared_ptr<Element> element) { + void handleElement(boost::shared_ptr<ToplevelElement> element) { events.push_back(Event(ElementEvent, element)); } void handleStreamEnd() { events.push_back(Event(StreamEnd)); } std::vector<Event> events; } client_; PayloadParserFactoryCollection factories_; PlatformXMLParserFactory xmlParserFactory_; }; CPPUNIT_TEST_SUITE_REGISTRATION(XMPPParserTest); |
Swift