Skip to content

Commit ff2b8c8

Browse files
committed
Some more testing
1 parent 49e7020 commit ff2b8c8

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

modules/yup_events/native/yup_Messaging_linux.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,14 @@ void MessageManager::broadcastMessage (const String&)
389389
void 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

400402
void LinuxEventLoop::unregisterFdCallback (int fd)

tests/yup_events/yup_Timer.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,48 @@
2323

2424
#include <yup_events/yup_events.h>
2525

26-
#include <tuple>
27-
2826
using namespace yup;
2927

3028
class TimerTests : public ::testing::Test
3129
{
3230
protected:
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
}

0 commit comments

Comments
 (0)