summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-12-09 21:45:53 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-12-09 21:45:53 (GMT)
commit53e476d1c202119ddc87102208103675e47f9e43 (patch)
tree8d882982020fe515d8abc941c9c9ee2112e8cb1b /Swiften/Client/UnitTest/ClientSessionTest.cpp
parent9bcba37ce570e0ca839cf3489fd9e34b3b5d44c8 (diff)
downloadswift-53e476d1c202119ddc87102208103675e47f9e43.zip
swift-53e476d1c202119ddc87102208103675e47f9e43.tar.bz2
Handle stream errors in client session.
Diffstat (limited to 'Swiften/Client/UnitTest/ClientSessionTest.cpp')
-rw-r--r--Swiften/Client/UnitTest/ClientSessionTest.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp
index 74f3376..dbed9aa 100644
--- a/Swiften/Client/UnitTest/ClientSessionTest.cpp
+++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp
@@ -9,11 +9,13 @@
#include <deque>
#include <boost/bind.hpp>
#include <boost/optional.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include "Swiften/Session/SessionStream.h"
#include "Swiften/Client/ClientSession.h"
#include "Swiften/Elements/StartTLSRequest.h"
#include "Swiften/Elements/StreamFeatures.h"
+#include "Swiften/Elements/StreamError.h"
#include "Swiften/Elements/TLSProceed.h"
#include "Swiften/Elements/StartTLSFailure.h"
#include "Swiften/Elements/AuthRequest.h"
@@ -32,6 +34,7 @@ using namespace Swift;
class ClientSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(ClientSessionTest);
CPPUNIT_TEST(testStart_Error);
+ CPPUNIT_TEST(testStart_StreamError);
CPPUNIT_TEST(testStartTLS);
CPPUNIT_TEST(testStartTLS_ServerError);
CPPUNIT_TEST(testStartTLS_ConnectError);
@@ -77,6 +80,17 @@ class ClientSessionTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(sessionFinishedError);
}
+ void testStart_StreamError() {
+ boost::shared_ptr<ClientSession> session(createSession());
+ session->start();
+ server->sendStreamStart();
+ server->sendStreamError();
+
+ CPPUNIT_ASSERT_EQUAL(ClientSession::Finished, session->getState());
+ CPPUNIT_ASSERT(sessionFinishedReceived);
+ CPPUNIT_ASSERT(sessionFinishedError);
+ }
+
void testStartTLS() {
boost::shared_ptr<ClientSession> session(createSession());
session->setCertificateTrustChecker(blindCertificateTrustChecker);
@@ -351,6 +365,10 @@ class ClientSessionTest : public CppUnit::TestFixture {
onElementReceived(streamFeatures);
}
+ void sendStreamError() {
+ onElementReceived(boost::make_shared<StreamError>());
+ }
+
void sendTLSProceed() {
onElementReceived(boost::shared_ptr<TLSProceed>(new TLSProceed()));
}