summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Client')
-rw-r--r--Swiften/Client/ClientSession.cpp5
-rw-r--r--Swiften/Client/UnitTest/ClientSessionTest.cpp22
2 files changed, 27 insertions, 0 deletions
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp
index 1409195..ae98ee6 100644
--- a/Swiften/Client/ClientSession.cpp
+++ b/Swiften/Client/ClientSession.cpp
@@ -96,6 +96,7 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) {
// Add a whitespace ping layer
whitespacePingLayer_ = boost::shared_ptr<WhitespacePingLayer>(new WhitespacePingLayer());
getStreamStack()->addLayer(whitespacePingLayer_);
+ whitespacePingLayer_->setActive();
if (streamFeatures->hasSession()) {
needSessionStart_ = true;
@@ -196,6 +197,10 @@ void ClientSession::sendSessionStart() {
}
void ClientSession::handleSessionFinished(const boost::optional<SessionError>& error) {
+ if (whitespacePingLayer_) {
+ whitespacePingLayer_->setInactive();
+ }
+
if (error) {
//assert(!error_);
state_ = Error;
diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp
index bb10cfd..cbf20d2 100644
--- a/Swiften/Client/UnitTest/ClientSessionTest.cpp
+++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp
@@ -39,6 +39,7 @@ using namespace Swift;
class ClientSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(ClientSessionTest);
CPPUNIT_TEST(testConstructor);
+ CPPUNIT_TEST(testDisconnect);
/*
CPPUNIT_TEST(testStart_Error);
CPPUNIT_TEST(testStart_XMLError);
@@ -84,6 +85,21 @@ class ClientSessionTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(ClientSession::Initial, session->getState());
}
+ void testDisconnect() {
+ boost::shared_ptr<MockSession> session(createSession("me@foo.com/Bar"));
+
+ /*
+ session->startSession();
+ processEvents();
+ session->finishSession();
+ processEvents();
+
+ boost::shared_ptr<WhitespacePingLayer> whitespacePingLayer = session->getWhitespacePingLayer();
+ CPPUNIT_ASSERT(whitespacePingLayer);
+ */
+ //CPPUNIT_ASSERT(!whitespacePingLayer->isActive());
+ }
+
/*
void testStart_Error() {
boost::shared_ptr<MockSession> session(createSession("me@foo.com/Bar"));
@@ -650,6 +666,12 @@ class ClientSessionTest : public CppUnit::TestFixture {
*/
private:
+ void processEvents() {
+ eventLoop_->processEvents();
+ }
+
+
+ private:
struct MockConnection : public Connection, public XMPPParserClient {
MockConnection() :
resetParser_(false),