summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-14 17:27:32 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-14 17:27:32 (GMT)
commitee3a46975986865fe5064f9d87a27277fc6c235a (patch)
tree51bae2ed1669ca881f761ca7547fbaf22432ae12 /Swiften/QA/NetworkTest
parentc34f50d3371f47c88d2ee927a5d59af8e135304c (diff)
downloadswift-ee3a46975986865fe5064f9d87a27277fc6c235a.zip
swift-ee3a46975986865fe5064f9d87a27277fc6c235a.tar.bz2
Consolidating IncomingConnection & Connection.
BoostConnections no longer have their own thread, but are managed from a central Boost IO thread instead.
Diffstat (limited to 'Swiften/QA/NetworkTest')
-rw-r--r--Swiften/QA/NetworkTest/BoostConnectionTest.cpp50
-rw-r--r--Swiften/QA/NetworkTest/Makefile.inc1
2 files changed, 28 insertions, 23 deletions
diff --git a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp b/Swiften/QA/NetworkTest/BoostConnectionTest.cpp
index 639097a..6090a97 100644
--- a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp
+++ b/Swiften/QA/NetworkTest/BoostConnectionTest.cpp
@@ -4,6 +4,7 @@
#include "Swiften/Base/String.h"
#include "Swiften/Base/sleep.h"
#include "Swiften/Network/BoostConnection.h"
+#include "Swiften/Network/BoostIOServiceThread.h"
#include "Swiften/EventLoop/DummyEventLoop.h"
using namespace Swift;
@@ -11,41 +12,44 @@ using namespace Swift;
class BoostConnectionTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(BoostConnectionTest);
CPPUNIT_TEST(testDestructor);
- CPPUNIT_TEST(testDestructor_PendingEvents);
+ CPPUNIT_TEST(testDestructor_PendingEvents);
CPPUNIT_TEST_SUITE_END();
public:
BoostConnectionTest() {}
- void setUp() {
- eventLoop_ = new DummyEventLoop();
- }
+ void setUp() {
+ eventLoop_ = new DummyEventLoop();
+ boostIOServiceThread_ = new BoostIOServiceThread();
+ }
- void tearDown() {
- delete eventLoop_;
- }
+ void tearDown() {
+ delete boostIOServiceThread_;
+ delete eventLoop_;
+ }
void testDestructor() {
- {
- std::string domain("el-tramo.be");
- std::auto_ptr<BoostConnection> testling(new BoostConnection(domain));
- testling->connect();
- }
- }
+ {
+ std::string domain("el-tramo.be");
+ std::auto_ptr<BoostConnection> testling(new BoostConnection(&boostIOServiceThread_->getIOService()));
+ testling->connect(domain);
+ }
+ }
void testDestructor_PendingEvents() {
- {
- std::auto_ptr<BoostConnection> testling(new BoostConnection("el-tramo.be"));
- testling->connect();
- while (!eventLoop_->hasEvents()) {
- Swift::sleep(10);
- }
- }
- eventLoop_->processEvents();
+ {
+ std::auto_ptr<BoostConnection> testling(new BoostConnection(&boostIOServiceThread_->getIOService()));
+ testling->connect("el-tramo.be");
+ while (!eventLoop_->hasEvents()) {
+ Swift::sleep(10);
+ }
+ }
+ eventLoop_->processEvents();
}
- private:
- DummyEventLoop* eventLoop_;
+ private:
+ BoostIOServiceThread* boostIOServiceThread_;
+ DummyEventLoop* eventLoop_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(BoostConnectionTest);
diff --git a/Swiften/QA/NetworkTest/Makefile.inc b/Swiften/QA/NetworkTest/Makefile.inc
index 055937b..5ac14c0 100644
--- a/Swiften/QA/NetworkTest/Makefile.inc
+++ b/Swiften/QA/NetworkTest/Makefile.inc
@@ -9,6 +9,7 @@ NETWORKTEST_OBJECTS = \
TEST_TARGETS += NetworkTest
CLEANFILES += $(NETWORKTEST_OBJECTS) $(NETWORKTEST_TARGET)
+DEPS += $(NETWORKTEST_SOURCES:.cpp=.dep)
$(NETWORKTEST_TARGET): $(SWIFTEN_TARGET) $(CPPUNIT_TARGET) $(NETWORKTEST_OBJECTS) $(BUNDLED_LIBS)
$(QUIET_LINK)$(CXX) -o $(NETWORKTEST_TARGET) $(NETWORKTEST_OBJECTS) $(LDFLAGS) $(CPPNETWORK_LDFLAGS) $(SWIFTEN_TARGET) $(CPPUNIT_TARGET) $(BUNDLED_LIBS) $(LIBS)