diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-09 13:46:45 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-09 13:46:45 +0100 |
commit | 87c41870e7e66308ee0c74270e1f91f4943bd733 (patch) | |
tree | 244184f92420a77da2d6d7176d65fcca2efe60e7 /src/test | |
parent | e3318b7e0e075567a6a9e29239e074f4e02fc595 (diff) |
testing window events
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/InputTest.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp index 4d35eef..7d4a017 100644 --- a/src/test/InputTest.cpp +++ b/src/test/InputTest.cpp @@ -1,4 +1,7 @@ #include <gtest/gtest.h> + +#include <iostream> + #define protected public #define private public #include "api/KeyCodes.h" @@ -32,8 +35,6 @@ public: protected: void SetUp() override { - mediator.event_manager = event_manager; - mediator.component_manager = mgr; event_manager.clear(); } @@ -291,3 +292,25 @@ TEST_F(InputTest, testButtonHover) { event_manager.dispatch_events(); EXPECT_TRUE(button.hover); } + +TEST_F(InputTest, WindowResizeTest) { + bool callback_triggered = false; + EventHandler<WindowResizeEvent> on_window_resize = [&](const WindowResizeEvent & event) { + std::cout << "test callback" << std::endl; + callback_triggered = true; + EXPECT_EQ(event.dimensions.x, 0); + EXPECT_EQ(event.dimensions.y, 0); + return false; + }; + event_manager.subscribe<WindowResizeEvent>(on_window_resize); + SDL_Event resize_event; + SDL_zero(resize_event); + resize_event.type = SDL_WINDOWEVENT; + resize_event.window.event = SDL_WINDOWEVENT_RESIZED; + resize_event.window.data1 = 800; // new width + resize_event.window.data2 = 600; // new height + SDL_PushEvent(&resize_event); + input_system.update(); + event_manager.dispatch_events(); + EXPECT_TRUE(callback_triggered); +} |