aboutsummaryrefslogtreecommitdiff
path: root/src/test/InputTest.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-28 09:01:37 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-28 09:01:37 +0100
commit570acb7e9258edcd6a06fff4dd2ce0ff12a3e873 (patch)
tree0b9d8406f6d6a8e2dcd187bee7277bc81a270acc /src/test/InputTest.cpp
parent8635d1ace31232c295c6cb85ea215887c6fb1319 (diff)
added on_enter and on_hover
Diffstat (limited to 'src/test/InputTest.cpp')
-rw-r--r--src/test/InputTest.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp
index d6ebb6f..2467839 100644
--- a/src/test/InputTest.cpp
+++ b/src/test/InputTest.cpp
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>
#define protected public
+#define private public
#include "api/EventManager.h"
#include "api/KeyCodes.h"
#include "system/InputSystem.h"
@@ -188,13 +189,13 @@ TEST_F(InputTest, MouseClick) {
TEST_F(InputTest, testButtonClick) {
GameObject obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
-
- auto & button = obj.add_component<Button>(100, 100);
bool button_clicked = false;
+ std::function<void()> on_click = [&]() { button_clicked = true; };
+ auto & button = obj.add_component<Button>(100, 100,on_click,false);
+
bool hover = false;
button.active = true;
- std::function<void()> on_click = [&]() { button_clicked = true; };
- button.on_click = on_click;
+
button.is_pressed = false;
button.is_toggle = false;
this->simulate_mouse_click(101, 101, SDL_BUTTON_LEFT);
@@ -210,8 +211,9 @@ TEST_F(InputTest, testButtonClick) {
TEST_F(InputTest, testButtonHover) {
GameObject obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
- auto & button = obj.add_component<Button>(100, 100);
bool button_clicked = false;
+ std::function<void()> on_click = [&]() { button_clicked = true; };
+ auto & button = obj.add_component<Button>(100, 100,on_click,false);
button.active = true;
button.width = 100;
button.height = 100;