summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/StreamStack/UnitTest/StreamStackTest.cpp')
-rw-r--r--Swiften/StreamStack/UnitTest/StreamStackTest.cpp45
1 files changed, 19 insertions, 26 deletions
diff --git a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
index f0f82c9..b074736 100644
--- a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
+++ b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
@@ -41,4 +41,5 @@ class StreamStackTest : public CppUnit::TestFixture {
void setUp() {
- physicalStream_ = new TestLowLayer();
- xmppStream_ = new XMPPLayer(&parserFactories_, &serializers_, &xmlParserFactory_, ClientStreamType);
+ testling_ = std::make_unique<StreamStack>(std::make_unique<XMPPLayer>(&parserFactories_, &serializers_, &xmlParserFactory_, ClientStreamType), std::make_unique<TestLowLayer>());
+ physicalStream_ = testling_->getLayer<TestLowLayer>();
+ xmppStream_ = testling_->getLayer<XMPPLayer>();
elementsReceived_ = 0;
@@ -48,4 +49,2 @@ class StreamStackTest : public CppUnit::TestFixture {
void tearDown() {
- delete physicalStream_;
- delete xmppStream_;
}
@@ -53,3 +52,2 @@ class StreamStackTest : public CppUnit::TestFixture {
void testWriteData_NoIntermediateStreamStack() {
- StreamStack testling(xmppStream_, physicalStream_);
@@ -62,5 +60,4 @@ class StreamStackTest : public CppUnit::TestFixture {
void testWriteData_OneIntermediateStream() {
- StreamStack testling(xmppStream_, physicalStream_);
- std::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
- testling.addLayer(xStream.get());
+ std::unique_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
+ testling_->addLayer(std::move(xStream));
@@ -73,7 +70,6 @@ class StreamStackTest : public CppUnit::TestFixture {
void testWriteData_TwoIntermediateStreamStack() {
- StreamStack testling(xmppStream_, physicalStream_);
- std::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
- std::shared_ptr<MyStreamLayer> yStream(new MyStreamLayer("Y"));
- testling.addLayer(xStream.get());
- testling.addLayer(yStream.get());
+ std::unique_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
+ std::unique_ptr<MyStreamLayer> yStream(new MyStreamLayer("Y"));
+ testling_->addLayer(std::move(xStream));
+ testling_->addLayer(std::move(yStream));
@@ -86,3 +82,2 @@ class StreamStackTest : public CppUnit::TestFixture {
void testReadData_NoIntermediateStreamStack() {
- StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1));
@@ -95,6 +90,5 @@ class StreamStackTest : public CppUnit::TestFixture {
void testReadData_OneIntermediateStream() {
- StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1));
- std::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("<"));
- testling.addLayer(xStream.get());
+ std::unique_ptr<MyStreamLayer> xStream(new MyStreamLayer("<"));
+ testling_->addLayer(std::move(xStream));
@@ -106,8 +100,7 @@ class StreamStackTest : public CppUnit::TestFixture {
void testReadData_TwoIntermediateStreamStack() {
- StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1));
- std::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("s"));
- std::shared_ptr<MyStreamLayer> yStream(new MyStreamLayer("<"));
- testling.addLayer(xStream.get());
- testling.addLayer(yStream.get());
+ std::unique_ptr<MyStreamLayer> xStream(new MyStreamLayer("s"));
+ std::unique_ptr<MyStreamLayer> yStream(new MyStreamLayer("<"));
+ testling_->addLayer(std::move(xStream));
+ testling_->addLayer(std::move(yStream));
@@ -119,6 +112,5 @@ class StreamStackTest : public CppUnit::TestFixture {
void testAddLayer_ExistingOnWriteDataSlot() {
- StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onWriteData.connect(boost::bind(&StreamStackTest::handleWriteData, this, _1));
- std::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
- testling.addLayer(xStream.get());
+ std::unique_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
+ testling_->addLayer(std::move(xStream));
@@ -178,2 +170,3 @@ class StreamStackTest : public CppUnit::TestFixture {
XMPPLayer* xmppStream_;
+ std::unique_ptr<StreamStack> testling_;
int elementsReceived_;