From fd7dfd2202c9435b86ac10ed96c6515f2505daa8 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Mon, 25 Nov 2024 11:54:06 +0100 Subject: changed enum name --- src/test/EventTest.cpp | 74 +++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'src/test/EventTest.cpp') diff --git a/src/test/EventTest.cpp b/src/test/EventTest.cpp index c75bcc1..4af0830 100644 --- a/src/test/EventTest.cpp +++ b/src/test/EventTest.cpp @@ -154,45 +154,45 @@ TEST_F(EventManagerTest, EventManagerTest_callback_propagation) { } TEST_F(EventManagerTest, EventManagerTest_queue_dispatch) { - EventManager & event_manager = EventManager::get_instance(); - bool triggered1 = false; - bool triggered2 = false; - int test_channel = 1; - - // Adjusted to use KeyPressEvent with repeat as the first variable - EventHandler key_handler1 = [&](const KeyPressEvent & e) { - triggered1 = true; - 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 key_handler2 = [&](const KeyPressEvent & e) { - triggered2 = true; - EXPECT_EQ(e.repeat, false); // Expecting repeat to be false - EXPECT_EQ(e.key, Keycode::A); // Adjust expected key code - return false; // Allows propagation - }; - - // Subscribe handlers to KeyPressEvent - event_manager.subscribe(key_handler1); - event_manager.subscribe(key_handler2, test_channel); - - // Queue a KeyPressEvent instead of KeyDownEvent - event_manager.queue_event(KeyPressEvent{ - .repeat = false, .key = Keycode::A}); // Adjust event with repeat flag first - - event_manager.queue_event( - KeyPressEvent{.repeat = false, - .key = Keycode::A}, // Adjust event for second subscription - test_channel); - - event_manager.dispatch_events(); - - EXPECT_TRUE(triggered1); - EXPECT_TRUE(triggered2); + EventManager & event_manager = EventManager::get_instance(); + bool triggered1 = false; + bool triggered2 = false; + int test_channel = 1; + + // Adjusted to use KeyPressEvent with repeat as the first variable + EventHandler key_handler1 = [&](const KeyPressEvent & e) { + triggered1 = true; + 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 key_handler2 = [&](const KeyPressEvent & e) { + triggered2 = true; + EXPECT_EQ(e.repeat, false); // Expecting repeat to be false + EXPECT_EQ(e.key, Keycode::A); // Adjust expected key code + return false; // Allows propagation + }; + + // Subscribe handlers to KeyPressEvent + event_manager.subscribe(key_handler1); + event_manager.subscribe(key_handler2, test_channel); + + // Queue a KeyPressEvent instead of KeyDownEvent + event_manager.queue_event( + KeyPressEvent{.repeat = false, .key = Keycode::A}); // Adjust event with repeat flag first + + event_manager.queue_event( + KeyPressEvent{.repeat = false, .key = Keycode::A}, // Adjust event for second subscription + test_channel); + + event_manager.dispatch_events(); + + EXPECT_TRUE(triggered1); + EXPECT_TRUE(triggered2); } + TEST_F(EventManagerTest, EventManagerTest_unsubscribe) { EventManager & event_manager = EventManager::get_instance(); -- cgit v1.2.3