diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-25 11:48:01 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-25 11:48:01 +0100 |
commit | ea7d7ec301968f3a542de93f487f9501b70c0cd4 (patch) | |
tree | c2a81d117f62c06d369a8e6336a4ecac675df508 /src/test | |
parent | 596358ffea72aec48b389609349f717e76396ae2 (diff) |
code standard fixing
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/inputTest.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/test/inputTest.cpp b/src/test/inputTest.cpp index 0ca415a..8f3eb48 100644 --- a/src/test/inputTest.cpp +++ b/src/test/inputTest.cpp @@ -214,29 +214,35 @@ TEST_F(InputTest, testButtonHover) { GameObject obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); auto& button = obj.add_component<Button>(); bool button_clicked = false; - bool hover = false; button.active = true; button.interactable = true; button.width = 100; button.height = 100; button.is_pressed = false; button.is_toggle = false; - + //mouse not on button SDL_Event event; SDL_zero(event); event.type = SDL_MOUSEMOTION; - event.motion.x = 10; - event.motion.y = 10; + event.motion.x = 200; + event.motion.y = 200; event.motion.xrel = 10; event.motion.yrel = 10; SDL_PushEvent(&event); - this->simulate_mouse_click(101,101, SDL_BUTTON_LEFT); input_system.update(); event_manager.dispatch_events(); - EXPECT_FALSE(button_clicked); - this->simulate_mouse_click(10,10, SDL_BUTTON_LEFT); + EXPECT_FALSE(button.hover); + //mouse on button + SDL_Event hover_event; + SDL_zero(hover_event); + hover_event.type = SDL_MOUSEMOTION; + hover_event.motion.x = 10; + hover_event.motion.y = 10; + hover_event.motion.xrel = 10; + hover_event.motion.yrel = 10; + SDL_PushEvent(&hover_event); input_system.update(); event_manager.dispatch_events(); - EXPECT_TRUE(button_clicked); + EXPECT_TRUE(button.hover); } |