summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2018-08-02 09:00:25 (GMT)
committerTobias Markmann <tm@ayena.de>2018-08-02 09:00:25 (GMT)
commit091f6e520694360a0407ab0cf3bb036fb461e6e3 (patch)
tree717ff863e8cd799842e5c82fc2d833ae026c9b20 /Swiften/StreamStack/UnitTest/StreamStackTest.cpp
parent80f74201f0a35718642e434c58b631b238fd85df (diff)
downloadswift-091f6e520694360a0407ab0cf3bb036fb461e6e3.zip
swift-091f6e520694360a0407ab0cf3bb036fb461e6e3.tar.bz2
Have StreamStack own the top and bottom layer
Test-Information: Builds, unit tests and integration tests pass on macOS with clang 7.0 master. Change-Id: I0db411e49339ccb2301edd1a16612cb1ad2c927c
Diffstat (limited to 'Swiften/StreamStack/UnitTest/StreamStackTest.cpp')
-rw-r--r--Swiften/StreamStack/UnitTest/StreamStackTest.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
index 0b520f1..b074736 100644
--- a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
+++ b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
@@ -39,19 +39,17 @@ class StreamStackTest : public CppUnit::TestFixture {
public:
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;
dataWriteReceived_ = 0;
}
void tearDown() {
- delete physicalStream_;
- delete xmppStream_;
}
void testWriteData_NoIntermediateStreamStack() {
- StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->writeData("foo");
@@ -60,9 +58,8 @@ class StreamStackTest : public CppUnit::TestFixture {
}
void testWriteData_OneIntermediateStream() {
- StreamStack testling(xmppStream_, physicalStream_);
std::unique_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
- testling.addLayer(std::move(xStream));
+ testling_->addLayer(std::move(xStream));
xmppStream_->writeData("foo");
@@ -71,11 +68,10 @@ class StreamStackTest : public CppUnit::TestFixture {
}
void testWriteData_TwoIntermediateStreamStack() {
- StreamStack testling(xmppStream_, physicalStream_);
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));
+ testling_->addLayer(std::move(xStream));
+ testling_->addLayer(std::move(yStream));
xmppStream_->writeData("foo");
@@ -84,7 +80,6 @@ class StreamStackTest : public CppUnit::TestFixture {
}
void testReadData_NoIntermediateStreamStack() {
- StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1));
physicalStream_->onDataRead(createSafeByteArray("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
@@ -93,10 +88,9 @@ class StreamStackTest : public CppUnit::TestFixture {
}
void testReadData_OneIntermediateStream() {
- StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1));
std::unique_ptr<MyStreamLayer> xStream(new MyStreamLayer("<"));
- testling.addLayer(std::move(xStream));
+ testling_->addLayer(std::move(xStream));
physicalStream_->onDataRead(createSafeByteArray("stream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
@@ -104,12 +98,11 @@ class StreamStackTest : public CppUnit::TestFixture {
}
void testReadData_TwoIntermediateStreamStack() {
- StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1));
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));
+ testling_->addLayer(std::move(xStream));
+ testling_->addLayer(std::move(yStream));
physicalStream_->onDataRead(createSafeByteArray("tream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
@@ -117,10 +110,9 @@ class StreamStackTest : public CppUnit::TestFixture {
}
void testAddLayer_ExistingOnWriteDataSlot() {
- StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onWriteData.connect(boost::bind(&StreamStackTest::handleWriteData, this, _1));
std::unique_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
- testling.addLayer(std::move(xStream));
+ testling_->addLayer(std::move(xStream));
xmppStream_->writeData("foo");
@@ -176,6 +168,7 @@ class StreamStackTest : public CppUnit::TestFixture {
TestLowLayer* physicalStream_;
PlatformXMLParserFactory xmlParserFactory_;
XMPPLayer* xmppStream_;
+ std::unique_ptr<StreamStack> testling_;
int elementsReceived_;
int dataWriteReceived_;
};