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/StreamStack/UnitTest/StreamStackTest.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/StreamStack/UnitTest/StreamStackTest.cpp')
| -rw-r--r-- | Swiften/StreamStack/UnitTest/StreamStackTest.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp index 213948a..35146d6 100644 --- a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp +++ b/Swiften/StreamStack/UnitTest/StreamStackTest.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 <Swiften/Base/ByteArray.h> #include <QA/Checker/IO.h> #include <vector> #include <boost/bind.hpp> #include <boost/smart_ptr.hpp> #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> #include <Swiften/Base/ByteArray.h> #include <Swiften/Base/Concat.h> #include <Swiften/StreamStack/StreamStack.h> #include <Swiften/StreamStack/LowLayer.h> #include <Swiften/StreamStack/XMPPLayer.h> #include <Swiften/StreamStack/StreamLayer.h> #include <Swiften/Parser/PlatformXMLParserFactory.h> #include <Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h> #include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> using namespace Swift; class StreamStackTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(StreamStackTest); CPPUNIT_TEST(testWriteData_NoIntermediateStreamStack); CPPUNIT_TEST(testWriteData_OneIntermediateStream); CPPUNIT_TEST(testWriteData_TwoIntermediateStreamStack); CPPUNIT_TEST(testReadData_NoIntermediateStreamStack); CPPUNIT_TEST(testReadData_OneIntermediateStream); CPPUNIT_TEST(testReadData_TwoIntermediateStreamStack); CPPUNIT_TEST(testAddLayer_ExistingOnWriteDataSlot); CPPUNIT_TEST_SUITE_END(); @@ -94,71 +94,71 @@ class StreamStackTest : public CppUnit::TestFixture { void testReadData_OneIntermediateStream() { StreamStack testling(xmppStream_, physicalStream_); xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1)); boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("<")); testling.addLayer(xStream.get()); physicalStream_->onDataRead(createSafeByteArray("stream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>")); CPPUNIT_ASSERT_EQUAL(1, elementsReceived_); } void testReadData_TwoIntermediateStreamStack() { StreamStack testling(xmppStream_, physicalStream_); xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1)); boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("s")); boost::shared_ptr<MyStreamLayer> yStream(new MyStreamLayer("<")); testling.addLayer(xStream.get()); testling.addLayer(yStream.get()); physicalStream_->onDataRead(createSafeByteArray("tream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>")); CPPUNIT_ASSERT_EQUAL(1, elementsReceived_); } void testAddLayer_ExistingOnWriteDataSlot() { StreamStack testling(xmppStream_, physicalStream_); xmppStream_->onWriteData.connect(boost::bind(&StreamStackTest::handleWriteData, this, _1)); boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X")); testling.addLayer(xStream.get()); xmppStream_->writeData("foo"); CPPUNIT_ASSERT_EQUAL(1, dataWriteReceived_); } - void handleElement(boost::shared_ptr<Element>) { + void handleElement(boost::shared_ptr<ToplevelElement>) { ++elementsReceived_; } void handleWriteData(const SafeByteArray&) { ++dataWriteReceived_; } private: class MyStreamLayer : public StreamLayer { public: MyStreamLayer(const std::string& prepend) : prepend_(prepend) { } virtual void writeData(const SafeByteArray& data) { writeDataToChildLayer(concat(createSafeByteArray(prepend_), data)); } virtual void handleDataRead(const SafeByteArray& data) { writeDataToParentLayer(concat(createSafeByteArray(prepend_), data)); } private: std::string prepend_; }; class TestLowLayer : public LowLayer { public: TestLowLayer() { } virtual void writeData(const SafeByteArray& data) { data_.push_back(data); } void onDataRead(const SafeByteArray& data) { |
Swift