MushMachine/systems/player_velocity/test/player_velocity_test.cpp

59 lines
1.7 KiB
C++
Raw Normal View History

#include <gtest/gtest.h>
#include <mm/engine.hpp>
#include <mm/services/sdl_service.hpp>
#include <mm/services/input_service.hpp>
2021-12-12 22:56:16 +01:00
#include <mm/services/organizer_scene.hpp>
#include <entt/entity/registry.hpp>
2021-12-12 22:56:16 +01:00
#include <entt/entity/organizer.hpp>
#include <mm/systems/player_velocity2d_system.hpp>
TEST(player_velocity, basic_run) {
float delta = 1/60.f;
MM::Engine engine;
engine.addService<MM::Services::SDLService>();
ASSERT_TRUE(engine.enableService<MM::Services::SDLService>());
engine.addService<MM::Services::InputService>();
ASSERT_TRUE(engine.enableService<MM::Services::InputService>());
2021-12-12 22:56:16 +01:00
engine.addService<MM::Services::OrganizerSceneService>(delta);
ASSERT_TRUE(engine.enableService<MM::Services::OrganizerSceneService>());
2021-12-12 22:56:16 +01:00
bool provide_ret = engine.provide<MM::Services::SceneServiceInterface, MM::Services::OrganizerSceneService>();
ASSERT_TRUE(provide_ret);
auto& scene = engine.getService<MM::Services::SceneServiceInterface>().getScene();
// setup v system
2022-03-25 19:17:01 +01:00
auto& org = scene.ctx().emplace<entt::organizer>();
2021-12-12 22:56:16 +01:00
org.emplace<&MM::Systems::player_velocity2d>("player_velocity2d");
// HACK: instead you would switch to this scene
engine.getService<MM::Services::OrganizerSceneService>().updateOrganizerVertices(scene);
//auto [e, t, v] = scene.create<MM::Components::Transform, MM::Components::Velocity>();
//t.position = { 0.f, 0.f };
//t.rotation = 0.f;
//v.velocity = { 1.f, 1.f };
//v.rotation = 0.f;
2021-04-24 02:03:11 +02:00
//engine.getUpdateStrategy().addDeferred([](auto& e) { e.stop(); });
//engine.run();
engine.update();
//ASSERT_EQ(t.position.x, 1.f * delta);
// TODO: TEST
}
2022-11-01 18:44:34 +01:00
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}