summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-15 18:07:44 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-15 18:07:44 (GMT)
commitf061668e3c1d5eac01b85303e2c81df2bc560e9a (patch)
treede56afe6d93cb36425f7c2e458575d27bd9105a4 /Swiften/StreamStack/UnitTest
parent0930cd940963be0edfe7c80b4925babca0e01443 (diff)
downloadswift-contrib-f061668e3c1d5eac01b85303e2c81df2bc560e9a.zip
swift-contrib-f061668e3c1d5eac01b85303e2c81df2bc560e9a.tar.bz2
Make stream stack layers reference counted.
Diffstat (limited to 'Swiften/StreamStack/UnitTest')
-rw-r--r--Swiften/StreamStack/UnitTest/StreamStackTest.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
index 1f6aad7..6b97c0d 100644
--- a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
+++ b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
@@ -29,15 +29,13 @@ class StreamStackTest : public CppUnit::TestFixture
StreamStackTest() {}
void setUp() {
- physicalStream_ = new TestLowLayer();
- xmppStream_ = new XMPPLayer(&parserFactories_, &serializers_);
+ physicalStream_ = boost::shared_ptr<TestLowLayer>(new TestLowLayer());
+ xmppStream_ = boost::shared_ptr<XMPPLayer>(new XMPPLayer(&parserFactories_, &serializers_));
elementsReceived_ = 0;
dataWriteReceived_ = 0;
}
void tearDown() {
- delete physicalStream_;
- delete xmppStream_;
}
void testWriteData_NoIntermediateStreamStack() {
@@ -51,8 +49,8 @@ class StreamStackTest : public CppUnit::TestFixture
void testWriteData_OneIntermediateStream() {
StreamStack testling(xmppStream_, physicalStream_);
- std::auto_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
- testling.addLayer(xStream.get());
+ boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
+ testling.addLayer(xStream);
xmppStream_->writeData("foo");
@@ -62,10 +60,10 @@ class StreamStackTest : public CppUnit::TestFixture
void testWriteData_TwoIntermediateStreamStack() {
StreamStack testling(xmppStream_, physicalStream_);
- std::auto_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
- std::auto_ptr<MyStreamLayer> yStream(new MyStreamLayer("Y"));
- testling.addLayer(xStream.get());
- testling.addLayer(yStream.get());
+ boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
+ boost::shared_ptr<MyStreamLayer> yStream(new MyStreamLayer("Y"));
+ testling.addLayer(xStream);
+ testling.addLayer(yStream);
xmppStream_->writeData("foo");
@@ -85,8 +83,8 @@ class StreamStackTest : public CppUnit::TestFixture
void testReadData_OneIntermediateStream() {
StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1));
- std::auto_ptr<MyStreamLayer> xStream(new MyStreamLayer("<"));
- testling.addLayer(xStream.get());
+ boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("<"));
+ testling.addLayer(xStream);
physicalStream_->onDataRead(ByteArray("stream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
@@ -96,10 +94,10 @@ class StreamStackTest : public CppUnit::TestFixture
void testReadData_TwoIntermediateStreamStack() {
StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1));
- std::auto_ptr<MyStreamLayer> xStream(new MyStreamLayer("s"));
- std::auto_ptr<MyStreamLayer> yStream(new MyStreamLayer("<"));
- testling.addLayer(xStream.get());
- testling.addLayer(yStream.get());
+ boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("s"));
+ boost::shared_ptr<MyStreamLayer> yStream(new MyStreamLayer("<"));
+ testling.addLayer(xStream);
+ testling.addLayer(yStream);
physicalStream_->onDataRead(ByteArray("tream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
@@ -109,8 +107,8 @@ class StreamStackTest : public CppUnit::TestFixture
void testAddLayer_ExistingOnWriteDataSlot() {
StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onWriteData.connect(boost::bind(&StreamStackTest::handleWriteData, this, _1));
- std::auto_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
- testling.addLayer(xStream.get());
+ boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
+ testling.addLayer(xStream);
xmppStream_->writeData("foo");
@@ -158,8 +156,8 @@ class StreamStackTest : public CppUnit::TestFixture
private:
FullPayloadParserFactoryCollection parserFactories_;
FullPayloadSerializerCollection serializers_;
- TestLowLayer* physicalStream_;
- XMPPLayer* xmppStream_;
+ boost::shared_ptr<TestLowLayer> physicalStream_;
+ boost::shared_ptr<XMPPLayer> xmppStream_;
int elementsReceived_;
int dataWriteReceived_;
};