10 #include <gtest/gtest.h>
11 #include <audio_manager.hpp>
18 void set_chunks(ska::bytell_hash_map<uint16_t, Mix_Chunk *> *assets) {
19 test_mngr->chunks_ptr = assets;
22 void set_music(ska::bytell_hash_map<uint16_t, Mix_Music *> *assets) {
23 test_mngr->music_ptr = assets;
26 void play_sound(uint16_t arg, uint8_t volume, uint8_t loops) {
27 test_mngr->play_sound(arg, volume, loops);
30 void play_music(uint16_t arg, uint8_t volume, uint8_t loops) {
31 test_mngr->play_music(arg, volume, loops);
38 static void SetUpTestCase() {
39 SDL_Init(SDL_INIT_VIDEO);
40 Mix_OpenAudio(22050, AUDIO_F32SYS, 2, 1024);
41 Mix_Init(MIX_INIT_OGG);
44 static void TearDownTestCase() {
53 void SetUp()
override {
59 void TearDown()
override {
67 auto test_wav = Mix_LoadWAV(
"test_sound.wav");
68 ASSERT_TRUE(test_wav);
69 ska::bytell_hash_map<uint16_t, Mix_Chunk *> assets;
72 play_sound(1, MIX_MAX_VOLUME, 0);
74 Mix_FreeChunk(test_wav);
78 auto test_wav = Mix_LoadWAV(
"test_sound.wav");
79 ASSERT_TRUE(test_wav);
80 ska::bytell_hash_map<uint16_t, Mix_Chunk *> assets;
83 play_sound(1, MIX_MAX_VOLUME / 2, 0);
85 Mix_FreeChunk(test_wav);
89 auto test_wav = Mix_LoadWAV(
"test_sound.wav");
90 ASSERT_TRUE(test_wav);
91 ska::bytell_hash_map<uint16_t, Mix_Chunk *> assets;
94 play_sound(1, MIX_MAX_VOLUME, 3);
96 Mix_FreeChunk(test_wav);
100 auto test_ogg = Mix_LoadMUS(
"test_music.ogg");
101 ASSERT_TRUE(test_ogg);
102 ska::bytell_hash_map<uint16_t, Mix_Music *> assets;
103 assets[1] = test_ogg;
105 play_music(1, MIX_MAX_VOLUME, 3);
107 Mix_FreeMusic(test_ogg);
111 auto test_ogg = Mix_LoadMUS(
"test_music.ogg");
112 ASSERT_TRUE(test_ogg);
113 ska::bytell_hash_map<uint16_t, Mix_Music *> assets;
114 assets[1] = test_ogg;
116 play_music(1, MIX_MAX_VOLUME / 2, 3);
118 Mix_FreeMusic(test_ogg);
121 int main(
int argc,
char **argv) {
122 ::testing::InitGoogleTest(&argc, argv);
123 return RUN_ALL_TESTS();
Tests fixture for the audio_manager.
This object is responsible for playing sounds and music.
The central messaging system of the engine. All subsystem make extensive use of it.
The Task Manager handles all things multi-threaded in the engine.