diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-11 22:00:41 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-11 22:00:41 +0100 |
commit | 2de3ed22a78b1978e5e3c9350f67d82554130c39 (patch) | |
tree | 45b2960b5d193563198a9c9f34c5219b61f5dce1 /src | |
parent | 194ee3f192c3343c3ccc28dfa97fed180503ffd4 (diff) |
hotfix inputtest.cpp
Diffstat (limited to 'src')
-rw-r--r-- | src/test/InputTest.cpp | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp index 29ef941..7d9f47d 100644 --- a/src/test/InputTest.cpp +++ b/src/test/InputTest.cpp @@ -1,4 +1,7 @@ +#include "system/RenderSystem.h" +#include <algorithm> #include <gtest/gtest.h> +#include <iostream> #define protected public #define private public #include "api/KeyCodes.h" @@ -27,14 +30,19 @@ public: SDLContext sdl_context{mediator}; InputSystem input_system{mediator}; + RenderSystem render{mediator}; EventManager event_manager{mediator}; //GameObject camera; protected: void SetUp() override { - mediator.event_manager = event_manager; - mediator.component_manager = mgr; - event_manager.clear(); + GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); + auto & camera = obj.add_component<Camera>( + ivec2{500, 500}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + render.update(); + //mediator.event_manager = event_manager; + //mediator.component_manager = mgr; + //event_manager.clear(); } void simulate_mouse_click(int mouse_x, int mouse_y, Uint8 mouse_button) { @@ -59,10 +67,6 @@ protected: }; TEST_F(InputTest, MouseDown) { - GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); - auto & camera = obj.add_component<Camera>( - ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); - camera.active = true; bool mouse_triggered = false; EventHandler<MousePressEvent> on_mouse_down = [&](const MousePressEvent & event) { mouse_triggered = true; @@ -89,10 +93,6 @@ TEST_F(InputTest, MouseDown) { } TEST_F(InputTest, MouseUp) { - GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); - auto & camera = obj.add_component<Camera>( - ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); - camera.active = true; bool function_triggered = false; EventHandler<MouseReleaseEvent> on_mouse_release = [&](const MouseReleaseEvent & e) { function_triggered = true; @@ -117,10 +117,6 @@ TEST_F(InputTest, MouseUp) { } TEST_F(InputTest, MouseMove) { - GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); - auto & camera = obj.add_component<Camera>( - ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); - camera.active = true; bool function_triggered = false; EventHandler<MouseMoveEvent> on_mouse_move = [&](const MouseMoveEvent & e) { function_triggered = true; @@ -147,10 +143,6 @@ TEST_F(InputTest, MouseMove) { } TEST_F(InputTest, KeyDown) { - GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); - auto & camera = obj.add_component<Camera>( - ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); - camera.active = true; bool function_triggered = false; // Define event handler for KeyPressEvent @@ -178,10 +170,6 @@ TEST_F(InputTest, KeyDown) { } TEST_F(InputTest, KeyUp) { - GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); - auto & camera = obj.add_component<Camera>( - ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); - camera.active = true; bool function_triggered = false; EventHandler<KeyReleaseEvent> on_key_release = [&](const KeyReleaseEvent & event) { function_triggered = true; @@ -202,10 +190,6 @@ TEST_F(InputTest, KeyUp) { } TEST_F(InputTest, MouseClick) { - GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); - auto & camera = obj.add_component<Camera>( - ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); - camera.active = true; bool on_click_triggered = false; EventHandler<MouseClickEvent> on_mouse_click = [&](const MouseClickEvent & event) { on_click_triggered = true; @@ -223,10 +207,6 @@ TEST_F(InputTest, MouseClick) { } TEST_F(InputTest, testButtonClick) { - GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); - auto & camera = obj.add_component<Camera>( - ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); - camera.active = true; GameObject button_obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); bool button_clicked = false; std::function<void()> on_click = [&]() { button_clicked = true; }; @@ -250,10 +230,6 @@ TEST_F(InputTest, testButtonClick) { } TEST_F(InputTest, testButtonHover) { - GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); - auto & camera = obj.add_component<Camera>( - ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); - camera.active = true; GameObject button_obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); bool button_clicked = false; std::function<void()> on_click = [&]() { button_clicked = true; }; |