mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-04 03:15:59 -04:00
Added PollAllEvents()
This commit is contained in:
parent
78cc589fc9
commit
c10ffbb867
@ -28,4 +28,12 @@ namespace SDL2pp {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PollAllEvents() {
|
||||||
|
int result;
|
||||||
|
|
||||||
|
for (result = 0; PollEvent(); result++);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ namespace SDL2pp {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PollAllEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -111,4 +111,21 @@ BEGIN_TEST(int, char*[])
|
|||||||
EXPECT_TRUE(PollEvent(eventHandler) == false);
|
EXPECT_TRUE(PollEvent(eventHandler) == false);
|
||||||
EXPECT_TRUE(eventHandler.events.size() == 1);
|
EXPECT_TRUE(eventHandler.events.size() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// With no callback and no polled events
|
||||||
|
{
|
||||||
|
EXPECT_TRUE(PollAllEvents() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// With no callback and several polled events
|
||||||
|
{
|
||||||
|
constexpr int totalEvents = 5;
|
||||||
|
for (int n = 0; n < totalEvents; ++n) {
|
||||||
|
PushUserEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_TRUE(PollAllEvents() == totalEvents);
|
||||||
|
// Verify no further events
|
||||||
|
EXPECT_TRUE(PollEvent() == false);
|
||||||
|
}
|
||||||
END_TEST()
|
END_TEST()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user