summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-05-03 20:39:27 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-05-05 19:43:14 (GMT)
commit772b2ec0243d7b55d91e4027d828881d18093ed0 (patch)
tree83a58b2b97f3992165ee20c05e0630452eb50457 /Swiften/StreamStack
parent0b3db8fd68abee7269d5a38aabd8a816e099eae5 (diff)
downloadswift-contrib-772b2ec0243d7b55d91e4027d828881d18093ed0.zip
swift-contrib-772b2ec0243d7b55d91e4027d828881d18093ed0.tar.bz2
Replace ByteArray by typedef.
Diffstat (limited to 'Swiften/StreamStack')
-rw-r--r--Swiften/StreamStack/UnitTest/StreamStackTest.cpp18
-rw-r--r--Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp14
-rw-r--r--Swiften/StreamStack/WhitespacePingLayer.cpp2
-rw-r--r--Swiften/StreamStack/XMPPLayer.cpp10
4 files changed, 23 insertions, 21 deletions
diff --git a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
index 97d29c9..19dd37c 100644
--- a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
+++ b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
@@ -12,7 +12,9 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <QA/Checker/IO.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>
@@ -52,7 +54,7 @@ class StreamStackTest : public CppUnit::TestFixture {
xmppStream_->writeData("foo");
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), physicalStream_->data_.size());
- CPPUNIT_ASSERT_EQUAL(ByteArray("foo"), physicalStream_->data_[0]);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("foo"), physicalStream_->data_[0]);
}
void testWriteData_OneIntermediateStream() {
@@ -63,7 +65,7 @@ class StreamStackTest : public CppUnit::TestFixture {
xmppStream_->writeData("foo");
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), physicalStream_->data_.size());
- CPPUNIT_ASSERT_EQUAL(ByteArray("Xfoo"), physicalStream_->data_[0]);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("Xfoo"), physicalStream_->data_[0]);
}
void testWriteData_TwoIntermediateStreamStack() {
@@ -76,14 +78,14 @@ class StreamStackTest : public CppUnit::TestFixture {
xmppStream_->writeData("foo");
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), physicalStream_->data_.size());
- CPPUNIT_ASSERT_EQUAL(ByteArray("XYfoo"), physicalStream_->data_[0]);
+ CPPUNIT_ASSERT_EQUAL(createByteArray("XYfoo"), physicalStream_->data_[0]);
}
void testReadData_NoIntermediateStreamStack() {
StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1));
- physicalStream_->onDataRead(ByteArray("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
+ physicalStream_->onDataRead(createByteArray("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
CPPUNIT_ASSERT_EQUAL(1, elementsReceived_);
}
@@ -94,7 +96,7 @@ class StreamStackTest : public CppUnit::TestFixture {
boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("<"));
testling.addLayer(xStream.get());
- physicalStream_->onDataRead(ByteArray("stream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
+ physicalStream_->onDataRead(createByteArray("stream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
CPPUNIT_ASSERT_EQUAL(1, elementsReceived_);
}
@@ -107,7 +109,7 @@ class StreamStackTest : public CppUnit::TestFixture {
testling.addLayer(xStream.get());
testling.addLayer(yStream.get());
- physicalStream_->onDataRead(ByteArray("tream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
+ physicalStream_->onDataRead(createByteArray("tream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
CPPUNIT_ASSERT_EQUAL(1, elementsReceived_);
}
@@ -138,11 +140,11 @@ class StreamStackTest : public CppUnit::TestFixture {
}
virtual void writeData(const ByteArray& data) {
- writeDataToChildLayer(ByteArray(prepend_) + data);
+ writeDataToChildLayer(concat(createByteArray(prepend_), data));
}
virtual void handleDataRead(const ByteArray& data) {
- writeDataToParentLayer(ByteArray(prepend_) + data);
+ writeDataToParentLayer(concat(createByteArray(prepend_), data));
}
private:
diff --git a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
index f6a75c1..602699d 100644
--- a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
+++ b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
@@ -46,7 +46,7 @@ class XMPPLayerTest : public CppUnit::TestFixture {
void testParseData_Error() {
testling_->onError.connect(boost::bind(&XMPPLayerTest::handleError, this));
- testling_->handleDataRead("<iq>");
+ testling_->handleDataRead(createByteArray("<iq>"));
CPPUNIT_ASSERT_EQUAL(1, errorReceived_);
}
@@ -55,10 +55,10 @@ class XMPPLayerTest : public CppUnit::TestFixture {
testling_->onElement.connect(boost::bind(&XMPPLayerTest::handleElement, this, _1));
testling_->onError.connect(boost::bind(&XMPPLayerTest::handleError, this));
- testling_->handleDataRead("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" >");
+ testling_->handleDataRead(createByteArray("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" >"));
testling_->resetParser();
- testling_->handleDataRead("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" >");
- testling_->handleDataRead("<presence/>");
+ testling_->handleDataRead(createByteArray("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" >"));
+ testling_->handleDataRead(createByteArray("<presence/>"));
CPPUNIT_ASSERT_EQUAL(1, elementsReceived_);
CPPUNIT_ASSERT_EQUAL(0, errorReceived_);
@@ -66,8 +66,8 @@ class XMPPLayerTest : public CppUnit::TestFixture {
void testResetParser_FromSlot() {
testling_->onElement.connect(boost::bind(&XMPPLayerTest::handleElementAndReset, this, _1));
- testling_->handleDataRead("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" ><presence/>");
- testling_->handleDataRead("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" ><presence/>");
+ testling_->handleDataRead(createByteArray("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" ><presence/>"));
+ testling_->handleDataRead(createByteArray("<stream:stream to=\"example.com\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" ><presence/>"));
CPPUNIT_ASSERT_EQUAL(2, elementsReceived_);
CPPUNIT_ASSERT_EQUAL(0, errorReceived_);
@@ -121,7 +121,7 @@ class XMPPLayerTest : public CppUnit::TestFixture {
class DummyLowLayer : public LowLayer {
public:
virtual void writeData(const ByteArray& data) {
- writtenData += data.toString();
+ writtenData += byteArrayToString(data);
}
std::string writtenData;
diff --git a/Swiften/StreamStack/WhitespacePingLayer.cpp b/Swiften/StreamStack/WhitespacePingLayer.cpp
index 9fb4b06..6a95899 100644
--- a/Swiften/StreamStack/WhitespacePingLayer.cpp
+++ b/Swiften/StreamStack/WhitespacePingLayer.cpp
@@ -30,7 +30,7 @@ void WhitespacePingLayer::handleDataRead(const ByteArray& data) {
void WhitespacePingLayer::handleTimerTick() {
timer->stop();
- writeDataToChildLayer(" ");
+ writeDataToChildLayer(createByteArray(" "));
timer->start();
}
diff --git a/Swiften/StreamStack/XMPPLayer.cpp b/Swiften/StreamStack/XMPPLayer.cpp
index 3c7dcb4..37cda65 100644
--- a/Swiften/StreamStack/XMPPLayer.cpp
+++ b/Swiften/StreamStack/XMPPLayer.cpp
@@ -29,19 +29,19 @@ XMPPLayer::~XMPPLayer() {
}
void XMPPLayer::writeHeader(const ProtocolHeader& header) {
- writeDataInternal(ByteArray(xmppSerializer_->serializeHeader(header)));
+ writeDataInternal(createByteArray(xmppSerializer_->serializeHeader(header)));
}
void XMPPLayer::writeFooter() {
- writeDataInternal(ByteArray(xmppSerializer_->serializeFooter()));
+ writeDataInternal(createByteArray(xmppSerializer_->serializeFooter()));
}
void XMPPLayer::writeElement(boost::shared_ptr<Element> element) {
- writeDataInternal(ByteArray(xmppSerializer_->serializeElement(element)));
+ writeDataInternal(createByteArray(xmppSerializer_->serializeElement(element)));
}
void XMPPLayer::writeData(const std::string& data) {
- writeDataInternal(ByteArray(data));
+ writeDataInternal(createByteArray(data));
}
void XMPPLayer::writeDataInternal(const ByteArray& data) {
@@ -52,7 +52,7 @@ void XMPPLayer::writeDataInternal(const ByteArray& data) {
void XMPPLayer::handleDataRead(const ByteArray& data) {
onDataRead(data);
inParser_ = true;
- if (!xmppParser_->parse(data.toString())) {
+ if (!xmppParser_->parse(byteArrayToString(data))) {
inParser_ = false;
onError();
return;