MushMachine/framework/simple_sdl_renderer/test/start_test.cpp

51 lines
1.1 KiB
C++
Raw Normal View History

#include <gtest/gtest.h>
#include <mm/engine.hpp>
#include <mm/services/sdl_service.hpp>
#include <mm/services/simple_sdl_renderer.hpp>
2022-11-07 00:52:37 +01:00
#include <mm/services/count_down.hpp>
TEST(simple_sdl_renderer, basic) {
srand(1);
MM::Engine engine;
// sdl dep
{
engine.addService<MM::Services::SDLService>();
ASSERT_TRUE(engine.enableService<MM::Services::SDLService>());
}
auto& ren = engine.addService<MM::Services::SimpleSDLRendererService>();
ASSERT_TRUE(engine.enableService<MM::Services::SimpleSDLRendererService>());
ren.processors.emplace_back([](auto& r, auto&) {
r.targets["display"].set(r.renderer);
SDL_Rect rect {
rand() % 700,
rand() % 500,
100,
100
};
SDL_SetRenderDrawColor(r.renderer, 255, 0, 0, 255);
SDL_RenderFillRect(r.renderer, &rect);
}
);
2022-11-07 00:52:37 +01:00
#ifdef MM_AUTOTEST
engine.addService<MM::Services::CountDown>(50); // 50 frames
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
#endif
engine.run();
}
2022-11-01 18:44:34 +01:00
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}