summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/EventLoop/UnitTest/EventLoopTest.cpp')
-rw-r--r--Swiften/EventLoop/UnitTest/EventLoopTest.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/Swiften/EventLoop/UnitTest/EventLoopTest.cpp b/Swiften/EventLoop/UnitTest/EventLoopTest.cpp
index 00a4376..26c56d3 100644
--- a/Swiften/EventLoop/UnitTest/EventLoopTest.cpp
+++ b/Swiften/EventLoop/UnitTest/EventLoopTest.cpp
@@ -23,6 +23,7 @@ class EventLoopTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testPost);
CPPUNIT_TEST(testRemove);
CPPUNIT_TEST(testHandleEvent_Recursive);
+ CPPUNIT_TEST(testHandleEvent_FirstEventRemovesSecondEvent);
CPPUNIT_TEST_SUITE_END();
public:
@@ -74,6 +75,18 @@ class EventLoopTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(1, events_[1]);
}
+ void testHandleEvent_FirstEventRemovesSecondEvent() {
+ DummyEventLoop testling;
+ auto eventOwner = std::make_shared<MyEventOwner>();
+ auto secondEventFired = false;
+
+ testling.postEvent([&](){ testling.removeEventsFromOwner(eventOwner); }, eventOwner);
+ testling.postEvent([&](){ secondEventFired = true; }, eventOwner);
+ testling.processEvents();
+
+ CPPUNIT_ASSERT_EQUAL(false, secondEventFired);
+ }
+
private:
struct MyEventOwner : public EventOwner {};
void logEvent(int i) {