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/Component/UnitTest
parenta7da393cfc807048d320ddba8a1c7d24ef23a46e (diff)
downloadswift-6810a2896f27e7ee07aee847f5e8dbccd1f6ec89.zip
swift-6810a2896f27e7ee07aee847f5e8dbccd1f6ec89.tar.bz2
Remove MainEventLoop singleton.
The event loop now needs to be explicitly passed to clients using it.
Diffstat (limited to 'Swiften/Component/UnitTest')
-rw-r--r--Swiften/Component/UnitTest/ComponentConnectorTest.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp b/Swiften/Component/UnitTest/ComponentConnectorTest.cpp
index 4648365..7d00b09 100644
--- a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp
+++ b/Swiften/Component/UnitTest/ComponentConnectorTest.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;
@@ -38,8 +37,8 @@ class ComponentConnectorTest : 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();
}
@@ -164,14 +163,14 @@ class ComponentConnectorTest : 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));
}
}
@@ -179,19 +178,21 @@ class ComponentConnectorTest : public CppUnit::TestFixture {
void write(const ByteArray&) { assert(false); }
HostAddressPort getLocalAddress() const { return HostAddressPort(); }
+ 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;
};