summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-07 21:37:48 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-07 21:39:40 (GMT)
commit091f554f42dcdef534718fb759eb45b622adfd4f (patch)
treeb8753f62884ef5ef46d04782bb38d8ef2ed38d01 /Swiften/Network/UnitTest
parent88eab3d1d9b722590da3837e3c79839189ea58d2 (diff)
downloadswift-091f554f42dcdef534718fb759eb45b622adfd4f.zip
swift-091f554f42dcdef534718fb759eb45b622adfd4f.tar.bz2
Fix crashes on disconnect during connect.
Resolves: #588
Diffstat (limited to 'Swiften/Network/UnitTest')
-rw-r--r--Swiften/Network/UnitTest/ConnectorTest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/Swiften/Network/UnitTest/ConnectorTest.cpp b/Swiften/Network/UnitTest/ConnectorTest.cpp
index 32a7157..2e396b3 100644
--- a/Swiften/Network/UnitTest/ConnectorTest.cpp
+++ b/Swiften/Network/UnitTest/ConnectorTest.cpp
@@ -34,6 +34,8 @@ class ConnectorTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testConnect_TimeoutDuringResolve);
CPPUNIT_TEST(testConnect_TimeoutDuringConnect);
CPPUNIT_TEST(testConnect_NoTimeout);
+ CPPUNIT_TEST(testStop_DuringSRVQuery);
+ CPPUNIT_TEST(testStop_Timeout);
CPPUNIT_TEST_SUITE_END();
public:
@@ -208,6 +210,35 @@ class ConnectorTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(connections[0]);
}
+ void testStop_DuringSRVQuery() {
+ Connector::ref testling(createConnector());
+ resolver->addXMPPClientService("foo.com", host1);
+
+ testling->start();
+ testling->stop();
+
+ eventLoop->processEvents();
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(connections.size()));
+ CPPUNIT_ASSERT(!connections[0]);
+ }
+
+ void testStop_Timeout() {
+ Connector::ref testling(createConnector());
+ testling->setTimeoutMilliseconds(10);
+ resolver->addXMPPClientService("foo.com", host1);
+
+ testling->start();
+ testling->stop();
+
+ eventLoop->processEvents();
+ timerFactory->setTime(10);
+ eventLoop->processEvents();
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(connections.size()));
+ CPPUNIT_ASSERT(!connections[0]);
+ }
+
private:
Connector::ref createConnector() {