diff options
-rw-r--r-- | src/test/InputTest.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp index 975dbd6..1d29cee 100644 --- a/src/test/InputTest.cpp +++ b/src/test/InputTest.cpp @@ -37,11 +37,11 @@ public: RenderSystem render{mediator}; EventManager event_manager{mediator}; //GameObject camera; - int offset = 100; - + int offset_x = 100; + int offset_y = 200; protected: void SetUp() override { - GameObject obj = mgr.new_object("camera", "camera", vec2{offset, offset}, 0, 1); + GameObject obj = mgr.new_object("camera", "camera", vec2{offset_x, offset_y}, 0, 1); auto & camera = obj.add_component<Camera>(ivec2{500, 500}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); @@ -77,8 +77,8 @@ TEST_F(InputTest, MouseDown) { EventHandler<MousePressEvent> on_mouse_down = [&](const MousePressEvent & event) { mouse_triggered = true; //middle of the screen = 0,0 - EXPECT_EQ(event.mouse_pos.x, offset); - EXPECT_EQ(event.mouse_pos.y, offset); + EXPECT_EQ(event.mouse_pos.x, offset_x); + EXPECT_EQ(event.mouse_pos.y, offset_y); EXPECT_EQ(event.button, MouseButton::LEFT_MOUSE); return false; }; @@ -102,8 +102,8 @@ TEST_F(InputTest, MouseUp) { bool function_triggered = false; EventHandler<MouseReleaseEvent> on_mouse_release = [&](const MouseReleaseEvent & e) { function_triggered = true; - EXPECT_EQ(e.mouse_pos.x, offset); - EXPECT_EQ(e.mouse_pos.y, offset); + EXPECT_EQ(e.mouse_pos.x, offset_x); + EXPECT_EQ(e.mouse_pos.y, offset_y); EXPECT_EQ(e.button, MouseButton::LEFT_MOUSE); return false; }; @@ -126,8 +126,8 @@ TEST_F(InputTest, MouseMove) { bool function_triggered = false; EventHandler<MouseMoveEvent> on_mouse_move = [&](const MouseMoveEvent & e) { function_triggered = true; - EXPECT_EQ(e.mouse_pos.x, offset); - EXPECT_EQ(e.mouse_pos.y, offset); + EXPECT_EQ(e.mouse_pos.x, offset_x); + EXPECT_EQ(e.mouse_pos.y, offset_y); EXPECT_EQ(e.mouse_delta.x, 10); EXPECT_EQ(e.mouse_delta.y, 10); return false; @@ -200,8 +200,8 @@ TEST_F(InputTest, MouseClick) { EventHandler<MouseClickEvent> on_mouse_click = [&](const MouseClickEvent & event) { on_click_triggered = true; EXPECT_EQ(event.button, MouseButton::LEFT_MOUSE); - EXPECT_EQ(event.mouse_pos.x, offset); - EXPECT_EQ(event.mouse_pos.y, offset); + EXPECT_EQ(event.mouse_pos.x, offset_x); + EXPECT_EQ(event.mouse_pos.y, offset_y); return false; }; event_manager.subscribe<MouseClickEvent>(on_mouse_click); @@ -217,7 +217,6 @@ TEST_F(InputTest, testButtonClick) { bool button_clicked = false; std::function<void()> on_click = [&]() { button_clicked = true; }; auto & button = button_obj.add_component<Button>(vec2{10, 10}, vec2{0, 0}, on_click); - // button.world_space = bool hover = false; button.active = true; this->simulate_mouse_click(999, 999, SDL_BUTTON_LEFT); |