From 2de3ed22a78b1978e5e3c9350f67d82554130c39 Mon Sep 17 00:00:00 2001
From: heavydemon21 <nielsstunnebrink1@gmail.com>
Date: Wed, 11 Dec 2024 22:00:41 +0100
Subject: hotfix inputtest.cpp

---
 src/test/InputTest.cpp | 46 +++++++++++-----------------------------------
 1 file changed, 11 insertions(+), 35 deletions(-)

(limited to 'src/test')

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; };
-- 
cgit v1.2.3