summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Network/UnitTest')
-rw-r--r--Swiften/Network/UnitTest/ConnectorTest.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/Swiften/Network/UnitTest/ConnectorTest.cpp b/Swiften/Network/UnitTest/ConnectorTest.cpp
index 07e520c..a71d4b7 100644
--- a/Swiften/Network/UnitTest/ConnectorTest.cpp
+++ b/Swiften/Network/UnitTest/ConnectorTest.cpp
@@ -16,7 +16,6 @@
#include "Swiften/Network/HostAddressPort.h"
#include "Swiften/Network/StaticDomainNameResolver.h"
#include "Swiften/Network/DummyTimerFactory.h"
-#include "Swiften/EventLoop/MainEventLoop.h"
#include "Swiften/EventLoop/DummyEventLoop.h"
using namespace Swift;
@@ -44,8 +43,8 @@ class ConnectorTest : public CppUnit::TestFixture {
void setUp() {
eventLoop = new DummyEventLoop();
- resolver = new StaticDomainNameResolver();
- connectionFactory = new MockConnectionFactory();
+ resolver = new StaticDomainNameResolver(eventLoop);
+ connectionFactory = new MockConnectionFactory(eventLoop);
timerFactory = new DummyTimerFactory();
}
@@ -257,14 +256,14 @@ class ConnectorTest : public CppUnit::TestFixture {
struct MockConnection : public Connection {
public:
- MockConnection(const std::vector<HostAddressPort>& failingPorts, bool isResponsive) : failingPorts(failingPorts), isResponsive(isResponsive) {}
+ MockConnection(const std::vector<HostAddressPort>& failingPorts, bool isResponsive, EventLoop* eventLoop) : eventLoop(eventLoop), failingPorts(failingPorts), isResponsive(isResponsive) {}
void listen() { assert(false); }
void connect(const HostAddressPort& address) {
hostAddressPort = address;
if (isResponsive) {
bool fail = std::find(failingPorts.begin(), failingPorts.end(), address) != failingPorts.end();
- MainEventLoop::postEvent(boost::bind(boost::ref(onConnectFinished), fail));
+ eventLoop->postEvent(boost::bind(boost::ref(onConnectFinished), fail));
}
}
@@ -272,19 +271,21 @@ class ConnectorTest : public CppUnit::TestFixture {
void disconnect() { assert(false); }
void write(const ByteArray&) { assert(false); }
+ EventLoop* eventLoop;
boost::optional<HostAddressPort> hostAddressPort;
std::vector<HostAddressPort> failingPorts;
bool isResponsive;
};
struct MockConnectionFactory : public ConnectionFactory {
- MockConnectionFactory() : isResponsive(true) {
+ MockConnectionFactory(EventLoop* eventLoop) : eventLoop(eventLoop), isResponsive(true) {
}
boost::shared_ptr<Connection> createConnection() {
- return boost::shared_ptr<Connection>(new MockConnection(failingPorts, isResponsive));
+ return boost::shared_ptr<Connection>(new MockConnection(failingPorts, isResponsive, eventLoop));
}
+ EventLoop* eventLoop;
bool isResponsive;
std::vector<HostAddressPort> failingPorts;
};