summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp')
m---------Swiften0
-rw-r--r--Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp62
2 files changed, 0 insertions, 62 deletions
diff --git a/Swiften b/Swiften
new file mode 160000
+Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c
diff --git a/Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp b/Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp
deleted file mode 100644
index 14f24c7..0000000
--- a/Swiften/EventLoop/UnitTest/SimpleEventLoopTest.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <boost/thread.hpp>
-#include <boost/bind.hpp>
-
-#include "Swiften/EventLoop/SimpleEventLoop.h"
-#include "Swiften/Base/sleep.h"
-
-using namespace Swift;
-
-class SimpleEventLoopTest : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(SimpleEventLoopTest);
- CPPUNIT_TEST(testRun);
- CPPUNIT_TEST(testPostFromMainThread);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- SimpleEventLoopTest() {}
-
- void setUp() {
- counter_ = 0;
- }
-
- void testRun() {
- SimpleEventLoop testling;
- boost::thread thread(boost::bind(&SimpleEventLoopTest::runIncrementingThread, this, &testling));
- testling.run();
-
- CPPUNIT_ASSERT_EQUAL(10, counter_);
- }
-
- void testPostFromMainThread() {
- SimpleEventLoop testling;
- testling.postEvent(boost::bind(&SimpleEventLoopTest::incrementCounterAndStop, this, &testling));
- testling.run();
-
- CPPUNIT_ASSERT_EQUAL(1, counter_);
- }
-
- private:
- void runIncrementingThread(SimpleEventLoop* loop) {
- for (unsigned int i = 0; i < 10; ++i) {
- Swift::sleep(1);
- loop->postEvent(boost::bind(&SimpleEventLoopTest::incrementCounter, this));
- }
- loop->stop();
- }
-
- void incrementCounter() {
- counter_++;
- }
-
- void incrementCounterAndStop(SimpleEventLoop* loop) {
- counter_++;
- loop->stop();
- }
-
- int counter_;
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(SimpleEventLoopTest);