summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-27 19:06:56 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-27 19:07:55 (GMT)
commit6810a2896f27e7ee07aee847f5e8dbccd1f6ec89 (patch)
treef7ea87f030e57cb4494a4f897506fb18fc3d2241 /Swiften/Network/UnitTest
parenta7da393cfc807048d320ddba8a1c7d24ef23a46e (diff)
downloadswift-contrib-6810a2896f27e7ee07aee847f5e8dbccd1f6ec89.zip
swift-contrib-6810a2896f27e7ee07aee847f5e8dbccd1f6ec89.tar.bz2
Remove MainEventLoop singleton.
The event loop now needs to be explicitly passed to clients using it.
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;
};