aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-28 10:13:11 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-28 10:13:11 +0100
commit6fd7cec7d4bbf5aeb361b3f1337671bb0f9af61b (patch)
tree01f6977c66a1e07e07aae42358a7e1a4e55ef53c /src/test
parentd1eed940b8119e95a14f1d08bf26184c7f0a0d8f (diff)
manager mediator refactor
Diffstat (limited to 'src/test')
-rw-r--r--src/test/DBTest.cpp3
-rw-r--r--src/test/ECSTest.cpp5
-rw-r--r--src/test/EventTest.cpp11
-rw-r--r--src/test/ParticleTest.cpp8
-rw-r--r--src/test/PhysicsTest.cpp7
-rw-r--r--src/test/RenderSystemTest.cpp9
-rw-r--r--src/test/SceneManagerTest.cpp23
-rw-r--r--src/test/ScriptTest.cpp11
8 files changed, 44 insertions, 33 deletions
diff --git a/src/test/DBTest.cpp b/src/test/DBTest.cpp
index e80814c..99dedff 100644
--- a/src/test/DBTest.cpp
+++ b/src/test/DBTest.cpp
@@ -1,6 +1,7 @@
-#include <crepe/facade/DB.h>
#include <gtest/gtest.h>
+#include <crepe/facade/DB.h>
+
using namespace std;
using namespace crepe;
using namespace testing;
diff --git a/src/test/ECSTest.cpp b/src/test/ECSTest.cpp
index af9d6f2..22c4fe7 100644
--- a/src/test/ECSTest.cpp
+++ b/src/test/ECSTest.cpp
@@ -2,7 +2,7 @@
#define protected public
-#include <crepe/ComponentManager.h>
+#include <crepe/manager/ComponentManager.h>
#include <crepe/api/GameObject.h>
#include <crepe/api/Metadata.h>
#include <crepe/api/Transform.h>
@@ -12,8 +12,9 @@ using namespace std;
using namespace crepe;
class ECSTest : public ::testing::Test {
+ Mediator m;
public:
- ComponentManager mgr{};
+ ComponentManager mgr{m};
};
TEST_F(ECSTest, createGameObject) {
diff --git a/src/test/EventTest.cpp b/src/test/EventTest.cpp
index b0e6c9c..f232027 100644
--- a/src/test/EventTest.cpp
+++ b/src/test/EventTest.cpp
@@ -1,10 +1,11 @@
-
-#include "api/Event.h"
-#include "api/EventManager.h"
-#include "api/IKeyListener.h"
-#include "api/IMouseListener.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+
+#include <crepe/api/Event.h>
+#include <crepe/manager/EventManager.h>
+#include <crepe/api/IKeyListener.h>
+#include <crepe/api/IMouseListener.h>
+
using namespace std;
using namespace std::chrono_literals;
using namespace crepe;
diff --git a/src/test/ParticleTest.cpp b/src/test/ParticleTest.cpp
index 8b81e74..cf43e35 100644
--- a/src/test/ParticleTest.cpp
+++ b/src/test/ParticleTest.cpp
@@ -1,5 +1,4 @@
-#include "api/Vector2.h"
-#include <crepe/ComponentManager.h>
+#include <crepe/manager/ComponentManager.h>
#include <crepe/Particle.h>
#include <crepe/api/Config.h>
#include <crepe/api/GameObject.h>
@@ -16,9 +15,10 @@ using namespace std::chrono_literals;
using namespace crepe;
class ParticlesTest : public ::testing::Test {
+ Mediator m;
public:
- ComponentManager component_manager;
- ParticleSystem particle_system{component_manager};
+ ComponentManager component_manager{m};
+ ParticleSystem particle_system{m};
void SetUp() override {
ComponentManager & mgr = this->component_manager;
diff --git a/src/test/PhysicsTest.cpp b/src/test/PhysicsTest.cpp
index 33b6020..01b7c51 100644
--- a/src/test/PhysicsTest.cpp
+++ b/src/test/PhysicsTest.cpp
@@ -1,4 +1,4 @@
-#include <crepe/ComponentManager.h>
+#include <crepe/manager/ComponentManager.h>
#include <crepe/api/Config.h>
#include <crepe/api/GameObject.h>
#include <crepe/api/Rigidbody.h>
@@ -11,9 +11,10 @@ using namespace std::chrono_literals;
using namespace crepe;
class PhysicsTest : public ::testing::Test {
+ Mediator m;
public:
- ComponentManager component_manager;
- PhysicsSystem system{component_manager};
+ ComponentManager component_manager{m};
+ PhysicsSystem system{m};
void SetUp() override {
ComponentManager & mgr = this->component_manager;
diff --git a/src/test/RenderSystemTest.cpp b/src/test/RenderSystemTest.cpp
index f37fb56..f479443 100644
--- a/src/test/RenderSystemTest.cpp
+++ b/src/test/RenderSystemTest.cpp
@@ -1,4 +1,3 @@
-#include "api/Camera.h"
#include <functional>
#include <gtest/gtest.h>
#include <memory>
@@ -7,7 +6,8 @@
#define private public
#define protected public
-#include <crepe/ComponentManager.h>
+#include <crepe/api/Camera.h>
+#include <crepe/manager/ComponentManager.h>
#include <crepe/api/Color.h>
#include <crepe/api/GameObject.h>
#include <crepe/api/Sprite.h>
@@ -20,9 +20,10 @@ using namespace crepe;
using namespace testing;
class RenderSystemTest : public Test {
+ Mediator m;
public:
- ComponentManager mgr{};
- RenderSystem sys{mgr};
+ ComponentManager mgr{m};
+ RenderSystem sys{m};
GameObject entity1 = this->mgr.new_object("name");
GameObject entity2 = this->mgr.new_object("name");
GameObject entity3 = this->mgr.new_object("name");
diff --git a/src/test/SceneManagerTest.cpp b/src/test/SceneManagerTest.cpp
index 62b7d33..d027d89 100644
--- a/src/test/SceneManagerTest.cpp
+++ b/src/test/SceneManagerTest.cpp
@@ -1,12 +1,13 @@
-#include "types.h"
-#include <crepe/ComponentManager.h>
+#include <gtest/gtest.h>
+
+#include <crepe/types.h>
+#include <crepe/manager/SceneManager.h>
+#include <crepe/manager/ComponentManager.h>
#include <crepe/api/GameObject.h>
#include <crepe/api/Metadata.h>
#include <crepe/api/Scene.h>
-#include <crepe/api/SceneManager.h>
#include <crepe/api/Transform.h>
#include <crepe/api/Vector2.h>
-#include <gtest/gtest.h>
using namespace std;
using namespace crepe;
@@ -14,7 +15,8 @@ using namespace crepe;
class ConcreteScene1 : public Scene {
public:
void load_scene() {
- ComponentManager & mgr = this->component_manager;
+ Mediator & mediator = this->mediator;
+ ComponentManager & mgr = mediator.component_manager;
GameObject object1 = mgr.new_object("scene_1", "tag_scene_1", vec2{0, 0}, 0, 1);
GameObject object2 = mgr.new_object("scene_1", "tag_scene_1", vec2{1, 0}, 0, 1);
GameObject object3 = mgr.new_object("scene_1", "tag_scene_1", vec2{2, 0}, 0, 1);
@@ -26,7 +28,8 @@ public:
class ConcreteScene2 : public Scene {
public:
void load_scene() {
- ComponentManager & mgr = this->component_manager;
+ Mediator & mediator = this->mediator;
+ ComponentManager & mgr = mediator.component_manager;
GameObject object1 = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 0}, 0, 1);
GameObject object2 = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 1}, 0, 1);
GameObject object3 = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 2}, 0, 1);
@@ -41,7 +44,8 @@ public:
ConcreteScene3(const string & name) : name(name) {}
void load_scene() {
- ComponentManager & mgr = this->component_manager;
+ Mediator & mediator = this->mediator;
+ ComponentManager & mgr = mediator.component_manager;
GameObject object1 = mgr.new_object("scene_3", "tag_scene_3", vec2{0, 0}, 0, 1);
}
@@ -52,9 +56,10 @@ private:
};
class SceneManagerTest : public ::testing::Test {
+ Mediator m;
public:
- ComponentManager component_mgr{};
- SceneManager scene_mgr{component_mgr};
+ ComponentManager component_mgr{m};
+ SceneManager scene_mgr{m};
};
TEST_F(SceneManagerTest, loadScene) {
diff --git a/src/test/ScriptTest.cpp b/src/test/ScriptTest.cpp
index 78d5061..3187ed2 100644
--- a/src/test/ScriptTest.cpp
+++ b/src/test/ScriptTest.cpp
@@ -4,10 +4,10 @@
#define private public
#define protected public
-#include <crepe/ComponentManager.h>
+#include <crepe/manager/ComponentManager.h>
+#include <crepe/manager/EventManager.h>
#include <crepe/api/BehaviorScript.h>
#include <crepe/api/Event.h>
-#include <crepe/api/EventManager.h>
#include <crepe/api/GameObject.h>
#include <crepe/api/Script.h>
#include <crepe/api/Vector2.h>
@@ -20,10 +20,11 @@ using namespace testing;
class MyEvent : public Event {};
class ScriptTest : public Test {
+ Mediator m;
public:
- ComponentManager component_manager{};
- ScriptSystem system{component_manager};
- EventManager & event_manager = EventManager::get_instance();
+ ComponentManager component_manager{m};
+ ScriptSystem system{m};
+ EventManager & event_manager = m.event_manager;
class MyScript : public Script {
// NOTE: default (private) visibility of init and update shouldn't cause