diff options
Diffstat (limited to 'Swiften/FileTransfer')
-rw-r--r-- | Swiften/FileTransfer/SOCKS5BytestreamServerManager.h | 2 | ||||
-rw-r--r-- | Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp | 24 |
2 files changed, 11 insertions, 15 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h index 6dbdd1b..3c06513 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamServerManager.h @@ -78,7 +78,7 @@ namespace Swift { enum { Start, Initializing, Initialized } state; SOCKS5BytestreamServer* server; std::shared_ptr<ConnectionServer> connectionServer; - int connectionServerPort; + int connectionServerPort = -1; std::shared_ptr<NATTraversalGetPublicIPRequest> getPublicIPRequest; std::shared_ptr<NATTraversalForwardPortRequest> forwardPortRequest; diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp index b241320..cb43d78 100644 --- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp @@ -59,9 +59,9 @@ public: crypto = std::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create()); destination = "092a44d859d19c9eed676b551ee80025903351c2"; randomGen.seed(static_cast<unsigned int>(time(nullptr))); - eventLoop = new DummyEventLoop(); - timerFactory = new DummyTimerFactory(); - connection = std::make_shared<MockeryConnection>(failingPorts, true, eventLoop); + eventLoop = std::unique_ptr<DummyEventLoop>(new DummyEventLoop()); + timerFactory = std::unique_ptr<DummyTimerFactory>(new DummyTimerFactory()); + connection = std::make_shared<MockeryConnection>(failingPorts, true, eventLoop.get()); //connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1)); //stream1 = std::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg"))); // connection->onDataRead.connect(boost::bind(&SOCKS5BytestreamClientSessionTest::handleDataRead, this, _1)); @@ -69,15 +69,13 @@ public: void tearDown() { //connection.reset(); - delete timerFactory; - delete eventLoop; } void testForSessionReady() { TestHelper helper; connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1)); - SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); + SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get()); clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1)); clientSession->start(); @@ -103,7 +101,7 @@ public: TestHelper helper; connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1)); - SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); + SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get()); clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1)); clientSession->start(); @@ -123,7 +121,7 @@ public: TestHelper helper; connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1)); - SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); + SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get()); clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1)); clientSession->start(); @@ -150,7 +148,7 @@ public: TestHelper helper; connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1)); - SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); + SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get()); clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1)); clientSession->start(); @@ -178,7 +176,7 @@ public: TestHelper helper; connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1)); - SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory); + SOCKS5BytestreamClientSession::ref clientSession = std::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory.get()); clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1)); clientSession->start(); @@ -203,8 +201,6 @@ public: CPPUNIT_ASSERT_EQUAL(createByteArray(vecptr(transferData), transferData.size()), helper.unprocessedInput); } - - private: static ByteArray generateRandomByteArray(size_t len) { boost::uniform_int<> dist(0, 255); @@ -308,8 +304,8 @@ private: private: HostAddressPort destinationAddressPort; std::string destination; - DummyEventLoop* eventLoop; - DummyTimerFactory* timerFactory; + std::unique_ptr<DummyEventLoop> eventLoop; + std::unique_ptr<DummyTimerFactory> timerFactory; std::shared_ptr<MockeryConnection> connection; const std::vector<HostAddressPort> failingPorts; std::shared_ptr<CryptoProvider> crypto; |