aboutsummaryrefslogtreecommitdiff
path: root/src/test/EventTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/EventTest.cpp')
-rw-r--r--src/test/EventTest.cpp36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/test/EventTest.cpp b/src/test/EventTest.cpp
index b0e6c9c..c75bcc1 100644
--- a/src/test/EventTest.cpp
+++ b/src/test/EventTest.cpp
@@ -158,29 +158,37 @@ TEST_F(EventManagerTest, EventManagerTest_queue_dispatch) {
bool triggered1 = false;
bool triggered2 = false;
int test_channel = 1;
- EventHandler<MouseClickEvent> mouse_handler1 = [&](const MouseClickEvent & e) {
+
+ // Adjusted to use KeyPressEvent with repeat as the first variable
+ EventHandler<KeyPressEvent> key_handler1 = [&](const KeyPressEvent & e) {
triggered1 = true;
- EXPECT_EQ(e.mouse_x, 100);
- EXPECT_EQ(e.mouse_y, 200);
- EXPECT_EQ(e.button, MouseButton::LEFT_MOUSE);
+ EXPECT_EQ(e.repeat, false); // Expecting repeat to be false
+ EXPECT_EQ(e.key, Keycode::A); // Adjust expected key code
return false; // Allows propagation
};
- EventHandler<MouseClickEvent> mouse_handler2 = [&](const MouseClickEvent & e) {
+
+ EventHandler<KeyPressEvent> key_handler2 = [&](const KeyPressEvent & e) {
triggered2 = true;
- EXPECT_EQ(e.mouse_x, 100);
- EXPECT_EQ(e.mouse_y, 200);
- EXPECT_EQ(e.button, MouseButton::LEFT_MOUSE);
+ EXPECT_EQ(e.repeat, false); // Expecting repeat to be false
+ EXPECT_EQ(e.key, Keycode::A); // Adjust expected key code
return false; // Allows propagation
};
- event_manager.subscribe<MouseClickEvent>(mouse_handler1);
- event_manager.subscribe<MouseClickEvent>(mouse_handler2, test_channel);
- event_manager.queue_event<MouseClickEvent>(
- MouseClickEvent{.mouse_x = 100, .mouse_y = 200, .button = MouseButton::LEFT_MOUSE});
- event_manager.queue_event<MouseClickEvent>(
- MouseClickEvent{.mouse_x = 100, .mouse_y = 200, .button = MouseButton::LEFT_MOUSE},
+ // Subscribe handlers to KeyPressEvent
+ event_manager.subscribe<KeyPressEvent>(key_handler1);
+ event_manager.subscribe<KeyPressEvent>(key_handler2, test_channel);
+
+ // Queue a KeyPressEvent instead of KeyDownEvent
+ event_manager.queue_event<KeyPressEvent>(KeyPressEvent{
+ .repeat = false, .key = Keycode::A}); // Adjust event with repeat flag first
+
+ event_manager.queue_event<KeyPressEvent>(
+ KeyPressEvent{.repeat = false,
+ .key = Keycode::A}, // Adjust event for second subscription
test_channel);
+
event_manager.dispatch_events();
+
EXPECT_TRUE(triggered1);
EXPECT_TRUE(triggered2);
}