From 519cc5d16e65ff501d330c03eeb35d2d095ead29 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Sun, 8 Dec 2024 19:49:41 +0100 Subject: made sdlcontext not a singleton anymore --- src/test/Profiling.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/test/Profiling.cpp') diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp index c753bca..46da378 100644 --- a/src/test/Profiling.cpp +++ b/src/test/Profiling.cpp @@ -1,4 +1,6 @@ +#include "facade/SDLContext.h" #include "manager/Mediator.h" +#include "manager/ResourceManager.h" #include "system/ParticleSystem.h" #include "system/PhysicsSystem.h" #include "system/RenderSystem.h" @@ -41,7 +43,7 @@ class TestScript : public Script { } }; -class DISABLED_ProfilingTest : public Test { +class ProfilingTest : public Test { public: // Config for test // Minimum amount to let test pass @@ -61,6 +63,8 @@ public: ParticleSystem particle_sys{m}; RenderSystem render_sys{m}; ScriptSystem script_sys{m}; + SDLContext ctx{m}; + ResourceManager resource_manager{m}; // Test data std::map timings; @@ -130,7 +134,7 @@ public: } }; -TEST_F(DISABLED_ProfilingTest, Profiling_1) { +TEST_F(ProfilingTest, Profiling_1) { while (this->total_time / this->average < this->duration) { { @@ -153,7 +157,7 @@ TEST_F(DISABLED_ProfilingTest, Profiling_1) { EXPECT_GE(this->game_object_count, this->min_gameobject_count); } -TEST_F(DISABLED_ProfilingTest, Profiling_2) { +TEST_F(ProfilingTest, Profiling_2) { while (this->total_time / this->average < this->duration) { { @@ -167,7 +171,7 @@ TEST_F(DISABLED_ProfilingTest, Profiling_2) { gameobject.add_component(vec2{0, 0}, vec2{1, 1}); gameobject.add_component().set_script(); - auto img = Texture("asset/texture/square.png"); + auto img = Asset("asset/texture/square.png"); Sprite & test_sprite = gameobject.add_component( img, Sprite::Data{ .color = {0, 0, 0, 0}, @@ -192,7 +196,7 @@ TEST_F(DISABLED_ProfilingTest, Profiling_2) { EXPECT_GE(this->game_object_count, this->min_gameobject_count); } -TEST_F(DISABLED_ProfilingTest, Profiling_3) { +TEST_F(ProfilingTest, Profiling_3) { while (this->total_time / this->average < this->duration) { { @@ -205,7 +209,7 @@ TEST_F(DISABLED_ProfilingTest, Profiling_3) { }); gameobject.add_component(vec2{0, 0}, vec2{1, 1}); gameobject.add_component().set_script(); - auto img = Texture("asset/texture/square.png"); + auto img = Asset("asset/texture/square.png"); Sprite & test_sprite = gameobject.add_component( img, Sprite::Data{ .color = {0, 0, 0, 0}, -- cgit v1.2.3 From bcb2e9d7a802680598085ad04ac06926f1e448a2 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 11 Dec 2024 16:12:46 +0100 Subject: reverted to master --- src/crepe/manager/EventManager.cpp | 2 -- src/crepe/manager/SceneManager.cpp | 3 --- src/crepe/system/ScriptSystem.cpp | 2 +- src/test/CMakeLists.txt | 2 +- src/test/Profiling.cpp | 16 ++++++---------- 5 files changed, 8 insertions(+), 17 deletions(-) (limited to 'src/test/Profiling.cpp') diff --git a/src/crepe/manager/EventManager.cpp b/src/crepe/manager/EventManager.cpp index 17fe528..20f0dd3 100644 --- a/src/crepe/manager/EventManager.cpp +++ b/src/crepe/manager/EventManager.cpp @@ -1,11 +1,9 @@ #include "EventManager.h" -#include "util/Log.h" using namespace crepe; using namespace std; EventManager & EventManager::get_instance() { - dbg_trace(); static EventManager instance; return instance; } diff --git a/src/crepe/manager/SceneManager.cpp b/src/crepe/manager/SceneManager.cpp index a788c51..50a9fbb 100644 --- a/src/crepe/manager/SceneManager.cpp +++ b/src/crepe/manager/SceneManager.cpp @@ -4,13 +4,10 @@ #include "ComponentManager.h" #include "SceneManager.h" -#include "util/Log.h" - using namespace crepe; using namespace std; SceneManager::SceneManager(Mediator & mediator) : Manager(mediator) { - dbg_trace(); mediator.scene_manager = *this; } diff --git a/src/crepe/system/ScriptSystem.cpp b/src/crepe/system/ScriptSystem.cpp index df358e6..d6b2ca1 100644 --- a/src/crepe/system/ScriptSystem.cpp +++ b/src/crepe/system/ScriptSystem.cpp @@ -8,7 +8,7 @@ using namespace std; using namespace crepe; void ScriptSystem::update() { - //dbg_trace(); + dbg_trace(); ComponentManager & mgr = this->mediator.component_manager; RefVector behavior_scripts = mgr.get_components_by_type(); diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 15937af..7196404 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -15,7 +15,7 @@ target_sources(test_main PUBLIC ValueBrokerTest.cpp DBTest.cpp Vector2Test.cpp - #InputTest.cpp + InputTest.cpp ScriptEventTest.cpp ScriptSceneTest.cpp Profiling.cpp diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp index 46da378..c753bca 100644 --- a/src/test/Profiling.cpp +++ b/src/test/Profiling.cpp @@ -1,6 +1,4 @@ -#include "facade/SDLContext.h" #include "manager/Mediator.h" -#include "manager/ResourceManager.h" #include "system/ParticleSystem.h" #include "system/PhysicsSystem.h" #include "system/RenderSystem.h" @@ -43,7 +41,7 @@ class TestScript : public Script { } }; -class ProfilingTest : public Test { +class DISABLED_ProfilingTest : public Test { public: // Config for test // Minimum amount to let test pass @@ -63,8 +61,6 @@ public: ParticleSystem particle_sys{m}; RenderSystem render_sys{m}; ScriptSystem script_sys{m}; - SDLContext ctx{m}; - ResourceManager resource_manager{m}; // Test data std::map timings; @@ -134,7 +130,7 @@ public: } }; -TEST_F(ProfilingTest, Profiling_1) { +TEST_F(DISABLED_ProfilingTest, Profiling_1) { while (this->total_time / this->average < this->duration) { { @@ -157,7 +153,7 @@ TEST_F(ProfilingTest, Profiling_1) { EXPECT_GE(this->game_object_count, this->min_gameobject_count); } -TEST_F(ProfilingTest, Profiling_2) { +TEST_F(DISABLED_ProfilingTest, Profiling_2) { while (this->total_time / this->average < this->duration) { { @@ -171,7 +167,7 @@ TEST_F(ProfilingTest, Profiling_2) { gameobject.add_component(vec2{0, 0}, vec2{1, 1}); gameobject.add_component().set_script(); - auto img = Asset("asset/texture/square.png"); + auto img = Texture("asset/texture/square.png"); Sprite & test_sprite = gameobject.add_component( img, Sprite::Data{ .color = {0, 0, 0, 0}, @@ -196,7 +192,7 @@ TEST_F(ProfilingTest, Profiling_2) { EXPECT_GE(this->game_object_count, this->min_gameobject_count); } -TEST_F(ProfilingTest, Profiling_3) { +TEST_F(DISABLED_ProfilingTest, Profiling_3) { while (this->total_time / this->average < this->duration) { { @@ -209,7 +205,7 @@ TEST_F(ProfilingTest, Profiling_3) { }); gameobject.add_component(vec2{0, 0}, vec2{1, 1}); gameobject.add_component().set_script(); - auto img = Asset("asset/texture/square.png"); + auto img = Texture("asset/texture/square.png"); Sprite & test_sprite = gameobject.add_component( img, Sprite::Data{ .color = {0, 0, 0, 0}, -- cgit v1.2.3 From d9609abd77b3d98bb8fd87c3e31e80402f5f7dcb Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 11 Dec 2024 16:37:52 +0100 Subject: removed Texture from profiling --- src/test/Profiling.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/test/Profiling.cpp') diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp index c753bca..84272f6 100644 --- a/src/test/Profiling.cpp +++ b/src/test/Profiling.cpp @@ -1,3 +1,4 @@ +#include "api/Asset.h" #include "manager/Mediator.h" #include "system/ParticleSystem.h" #include "system/PhysicsSystem.h" @@ -167,7 +168,7 @@ TEST_F(DISABLED_ProfilingTest, Profiling_2) { gameobject.add_component(vec2{0, 0}, vec2{1, 1}); gameobject.add_component().set_script(); - auto img = Texture("asset/texture/square.png"); + auto img = Asset("asset/texture/square.png"); Sprite & test_sprite = gameobject.add_component( img, Sprite::Data{ .color = {0, 0, 0, 0}, @@ -205,7 +206,7 @@ TEST_F(DISABLED_ProfilingTest, Profiling_3) { }); gameobject.add_component(vec2{0, 0}, vec2{1, 1}); gameobject.add_component().set_script(); - auto img = Texture("asset/texture/square.png"); + auto img = Asset("asset/texture/square.png"); Sprite & test_sprite = gameobject.add_component( img, Sprite::Data{ .color = {0, 0, 0, 0}, -- cgit v1.2.3 From 1954d06895a82b3b963aac5ae7cb450205119637 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 11 Dec 2024 16:48:16 +0100 Subject: fix tests --- src/test/InputTest.cpp | 1 + src/test/Profiling.cpp | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/test/Profiling.cpp') diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp index 73eaab3..4c05e56 100644 --- a/src/test/InputTest.cpp +++ b/src/test/InputTest.cpp @@ -24,6 +24,7 @@ class InputTest : public ::testing::Test { public: Mediator mediator; ComponentManager mgr{mediator}; + SDLContext sdl_context{mediator}; InputSystem input_system{mediator}; diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp index 84272f6..9767cb9 100644 --- a/src/test/Profiling.cpp +++ b/src/test/Profiling.cpp @@ -1,8 +1,9 @@ -#include "api/Asset.h" -#include "manager/Mediator.h" -#include "system/ParticleSystem.h" -#include "system/PhysicsSystem.h" -#include "system/RenderSystem.h" +#include +#include +#include +#include +#include +#include #include #include #include @@ -55,6 +56,8 @@ public: const std::chrono::microseconds duration = 16000us; Mediator m; + SDLContext sdl_context{m}; + ResourceManager resman{m}; ComponentManager mgr{m}; // Add system used for profling tests CollisionSystem collision_sys{m}; @@ -168,9 +171,8 @@ TEST_F(DISABLED_ProfilingTest, Profiling_2) { gameobject.add_component(vec2{0, 0}, vec2{1, 1}); gameobject.add_component().set_script(); - auto img = Asset("asset/texture/square.png"); Sprite & test_sprite = gameobject.add_component( - img, Sprite::Data{ + Asset{"asset/texture/square.png"}, Sprite::Data{ .color = {0, 0, 0, 0}, .flip = {.flip_x = false, .flip_y = false}, .sorting_in_layer = 1, @@ -206,9 +208,8 @@ TEST_F(DISABLED_ProfilingTest, Profiling_3) { }); gameobject.add_component(vec2{0, 0}, vec2{1, 1}); gameobject.add_component().set_script(); - auto img = Asset("asset/texture/square.png"); Sprite & test_sprite = gameobject.add_component( - img, Sprite::Data{ + Asset{"asset/texture/square.png"}, Sprite::Data{ .color = {0, 0, 0, 0}, .flip = {.flip_x = false, .flip_y = false}, .sorting_in_layer = 1, -- cgit v1.2.3 From 30c17c98e54c1534664de08ca3838c40c859d166 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 11 Dec 2024 16:48:34 +0100 Subject: `make format` --- mwe/events/include/event.h | 2 +- src/test/Profiling.cpp | 36 +++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 18 deletions(-) (limited to 'src/test/Profiling.cpp') diff --git a/mwe/events/include/event.h b/mwe/events/include/event.h index e1b220b..ee1bf52 100644 --- a/mwe/events/include/event.h +++ b/mwe/events/include/event.h @@ -148,7 +148,7 @@ private: }; class ShutDownEvent : public Event { public: - ShutDownEvent() : Event("ShutDownEvent"){}; + ShutDownEvent() : Event("ShutDownEvent") {}; REGISTER_EVENT_TYPE(ShutDownEvent) diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp index 9767cb9..cc4c637 100644 --- a/src/test/Profiling.cpp +++ b/src/test/Profiling.cpp @@ -1,11 +1,11 @@ +#include +#include #include #include +#include #include #include #include -#include -#include -#include #include #define private public @@ -172,13 +172,14 @@ TEST_F(DISABLED_ProfilingTest, Profiling_2) { gameobject.add_component().set_script(); Sprite & test_sprite = gameobject.add_component( - Asset{"asset/texture/square.png"}, Sprite::Data{ - .color = {0, 0, 0, 0}, - .flip = {.flip_x = false, .flip_y = false}, - .sorting_in_layer = 1, - .order_in_layer = 1, - .size = {.y = 500}, - }); + Asset{"asset/texture/square.png"}, + Sprite::Data{ + .color = {0, 0, 0, 0}, + .flip = {.flip_x = false, .flip_y = false}, + .sorting_in_layer = 1, + .order_in_layer = 1, + .size = {.y = 500}, + }); } this->game_object_count++; @@ -209,13 +210,14 @@ TEST_F(DISABLED_ProfilingTest, Profiling_3) { gameobject.add_component(vec2{0, 0}, vec2{1, 1}); gameobject.add_component().set_script(); Sprite & test_sprite = gameobject.add_component( - Asset{"asset/texture/square.png"}, Sprite::Data{ - .color = {0, 0, 0, 0}, - .flip = {.flip_x = false, .flip_y = false}, - .sorting_in_layer = 1, - .order_in_layer = 1, - .size = {.y = 500}, - }); + Asset{"asset/texture/square.png"}, + Sprite::Data{ + .color = {0, 0, 0, 0}, + .flip = {.flip_x = false, .flip_y = false}, + .sorting_in_layer = 1, + .order_in_layer = 1, + .size = {.y = 500}, + }); auto & test = gameobject.add_component(ParticleEmitter::Data{ .max_particles = 10, .emission_rate = 100, -- cgit v1.2.3