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 | |||
| @@ -23,6 +23,7 @@ class EventLoopTest : public CppUnit::TestFixture { | |||
| 23 | CPPUNIT_TEST(testPost); | 23 | CPPUNIT_TEST(testPost); |
| 24 | CPPUNIT_TEST(testRemove); | 24 | CPPUNIT_TEST(testRemove); |
| 25 | CPPUNIT_TEST(testHandleEvent_Recursive); | 25 | CPPUNIT_TEST(testHandleEvent_Recursive); |
| 26 | CPPUNIT_TEST(testHandleEvent_FirstEventRemovesSecondEvent); | ||
| 26 | CPPUNIT_TEST_SUITE_END(); | 27 | CPPUNIT_TEST_SUITE_END(); |
| 27 | 28 | ||
| 28 | public: | 29 | public: |
| @@ -74,6 +75,18 @@ class EventLoopTest : public CppUnit::TestFixture { | |||
| 74 | CPPUNIT_ASSERT_EQUAL(1, events_[1]); | 75 | CPPUNIT_ASSERT_EQUAL(1, events_[1]); |
| 75 | } | 76 | } |
| 76 | 77 | ||
| 78 | void testHandleEvent_FirstEventRemovesSecondEvent() { | ||
| 79 | DummyEventLoop testling; | ||
| 80 | auto eventOwner = std::make_shared<MyEventOwner>(); | ||
| 81 | auto secondEventFired = false; | ||
| 82 | |||
| 83 | testling.postEvent([&](){ testling.removeEventsFromOwner(eventOwner); }, eventOwner); | ||
| 84 | testling.postEvent([&](){ secondEventFired = true; }, eventOwner); | ||
| 85 | testling.processEvents(); | ||
| 86 | |||
| 87 | CPPUNIT_ASSERT_EQUAL(false, secondEventFired); | ||
| 88 | } | ||
| 89 | |||
| 77 | private: | 90 | private: |
| 78 | struct MyEventOwner : public EventOwner {}; | 91 | struct MyEventOwner : public EventOwner {}; |
| 79 | void logEvent(int i) { | 92 | void logEvent(int i) { |
Swift