From ee6bf92b661a3762fa3886409641958f32544f88 Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Wed, 18 Dec 2024 21:36:34 +0100 Subject: made test better by seperating x and y values --- src/test/InputTest.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src') 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(ivec2{500, 500}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); @@ -77,8 +77,8 @@ TEST_F(InputTest, MouseDown) { EventHandler 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 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 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 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(on_mouse_click); @@ -217,7 +217,6 @@ TEST_F(InputTest, testButtonClick) { bool button_clicked = false; std::function on_click = [&]() { button_clicked = true; }; auto & button = button_obj.add_component