File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed
modules/yup_events/native Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -389,12 +389,14 @@ void MessageManager::broadcastMessage (const String&)
389389void LinuxEventLoop::registerFdCallback (int fd, std::function<void (int )> readCallback, short eventMask)
390390{
391391 if (auto * runLoop = InternalRunLoop::getInstanceWithoutCreating ())
392+ {
392393 runLoop->registerFdCallback (
393394 fd, [cb = std::move (readCallback), fd]
394395 {
395396 cb (fd);
396397 },
397398 eventMask);
399+ }
398400}
399401
400402void LinuxEventLoop::unregisterFdCallback (int fd)
Original file line number Diff line number Diff line change 2323
2424#include < yup_events/yup_events.h>
2525
26- #include < tuple>
27-
2826using namespace yup ;
2927
3028class TimerTests : public ::testing::Test
3129{
3230protected:
3331 void SetUp () override
3432 {
33+ mm = MessageManager::getInstance ();
34+ jassert (mm != nullptr );
3535 }
3636
3737 void TearDown () override
3838 {
3939 }
40+
41+ void runDispatchLoopUntil (int millisecondsToRunFor = 10 )
42+ {
43+ #if YUP_MODAL_LOOPS_PERMITTED
44+ mm->runDispatchLoopUntil (millisecondsToRunFor);
45+ #endif
46+ }
47+
48+ MessageManager* mm = nullptr ;
4049};
4150
42- TEST_F (TimerTests, Existence )
51+ TEST_F (TimerTests, SimpleTimerSingleCall )
4352{
53+ struct TestTimer : Timer
54+ {
55+ int calledCount = 0 ;
56+
57+ void timerCallback () override
58+ {
59+ calledCount = 1 ;
60+
61+ stopTimer ();
62+ }
63+ } testTimer;
64+
65+ testTimer.startTimer (0 );
66+
67+ EXPECT_EQ (testTimer.calledCount , 0 );
68+ runDispatchLoopUntil ();
69+ EXPECT_EQ (testTimer.calledCount , 1 );
4470}
You can’t perform that action at this time.
0 commit comments