diff options
Diffstat (limited to 'Swiften/EventLoop/UnitTest/EventLoopTest.cpp')
| -rw-r--r-- | Swiften/EventLoop/UnitTest/EventLoopTest.cpp | 13 |
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 @@ -20,12 +20,13 @@ using namespace Swift; class EventLoopTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(EventLoopTest); CPPUNIT_TEST(testPost); CPPUNIT_TEST(testRemove); CPPUNIT_TEST(testHandleEvent_Recursive); + CPPUNIT_TEST(testHandleEvent_FirstEventRemovesSecondEvent); CPPUNIT_TEST_SUITE_END(); public: void setUp() { events_.clear(); } @@ -71,12 +72,24 @@ class EventLoopTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(events_.size())); CPPUNIT_ASSERT_EQUAL(0, events_[0]); 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) { events_.push_back(i); } void runEventLoop(DummyEventLoop* loop, std::shared_ptr<MyEventOwner> eventOwner) { |
Swift