mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2024-10-29 22:45:34 +01:00
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include <mm/engine.hpp>
|
|
|
|
#include <mm/services/sdl_service.hpp>
|
|
#include <mm/services/simple_sdl_renderer.hpp>
|
|
|
|
#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);
|
|
}
|
|
);
|
|
|
|
#ifdef MM_AUTOTEST
|
|
engine.addService<MM::Services::CountDown>(50); // 50 frames
|
|
ASSERT_TRUE(engine.enableService<MM::Services::CountDown>());
|
|
#endif
|
|
|
|
engine.run();
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
}
|
|
|