From 95594c71ed94fe0f2328b3fb696d503e7e48c7f5 Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Thu, 2 Nov 2023 11:01:01 +0000 Subject: [PATCH] renderer max_channels | package test mocks (#267) * refactor * code rev --- CMakeLists.txt | 2 +- sdl2-hyper-sonic-drivers/CMakeLists.txt | 7 +++ .../src/HyperSonicDrivers/audio/IRenderer.hpp | 5 ++ .../HyperSonicDrivers/audio/sdl2/Mixer.cpp | 9 ++-- .../HyperSonicDrivers/audio/sdl2/Renderer.cpp | 4 +- .../HyperSonicDrivers/audio/sdl2/Renderer.hpp | 12 ++--- .../{stubs/StubMixer.hpp => IMixerMock.hpp} | 8 ++-- .../audio/sdl2/TestRenderer.cpp | 4 +- .../HyperSonicDrivers/devices/DeviceMock.hpp | 26 ++++++++++ .../devices/EmulatorTestCase.hpp | 6 +-- .../HyperSonicDrivers/devices/SpyDevice.hpp | 48 ------------------- .../HyperSonicDrivers/devices/TestAdlib.cpp | 6 +-- .../HyperSonicDrivers/devices/TestIDevice.cpp | 6 +-- .../HyperSonicDrivers/devices/TestOpl.cpp | 8 ++-- .../HyperSonicDrivers/devices/TestSbPro.cpp | 6 +-- .../HyperSonicDrivers/devices/TestSbPro2.cpp | 6 +-- .../drivers/TestMIDDriver.cpp | 8 ++-- .../drivers/westwood/TestADLDriver.cpp | 8 ++-- .../hardware/opl/OPLMock.hpp | 4 +- .../hardware/opl/TestOPLFactory.cpp | 6 +-- .../opl/scummvm/dosbox/TestDosBoxOPL.cpp | 10 ++-- .../opl/scummvm/mame/TestMameOPL2.cpp | 12 ++--- .../opl/scummvm/nuked/TestNukedOPL3.cpp | 10 ++-- .../hardware/opl/woody/TestWoodyOPL.cpp | 12 ++--- .../test/HyperSonicDrivers/utils/TestOpl.cpp | 6 +-- 25 files changed, 113 insertions(+), 126 deletions(-) rename sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/{stubs/StubMixer.hpp => IMixerMock.hpp} (91%) create mode 100644 sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/DeviceMock.hpp delete mode 100644 sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/SpyDevice.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c4ae495..d5002085 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) endif() -project ("sdl2-hyper-sonic-drivers" VERSION 0.13.0 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards") +project ("sdl2-hyper-sonic-drivers" VERSION 0.13.1 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards") include (TestBigEndian) TEST_BIG_ENDIAN(IS_BIG_ENDIAN) if(IS_BIG_ENDIAN) diff --git a/sdl2-hyper-sonic-drivers/CMakeLists.txt b/sdl2-hyper-sonic-drivers/CMakeLists.txt index 692571eb..8798416e 100644 --- a/sdl2-hyper-sonic-drivers/CMakeLists.txt +++ b/sdl2-hyper-sonic-drivers/CMakeLists.txt @@ -44,6 +44,13 @@ install(DIRECTORY PATTERN "*.h" ) +install(DIRECTORY + test/ + DESTINATION static/test/include + FILES_MATCHING + PATTERN "*Mock.hpp" +) + write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/${LIB_VER}.cmake VERSION ${CMAKE_PROJECT_VERSION} diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IRenderer.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IRenderer.hpp index c47b346e..bfa9651e 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IRenderer.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/IRenderer.hpp @@ -1,11 +1,14 @@ #pragma once +#include #include #include +#include #include #include #include #include +#include namespace HyperSonicDrivers::audio { @@ -25,5 +28,7 @@ namespace HyperSonicDrivers::audio protected: std::shared_ptr m_mixer; + std::unique_ptr m_out; + std::vector m_buf; }; } diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.cpp index cf7a86f5..6b730ed1 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Mixer.cpp @@ -25,9 +25,12 @@ namespace HyperSonicDrivers::audio::sdl2 Mixer::~Mixer() { - SDL_CloseAudioDevice(m_device_id); - - SDL_QuitSubSystem(SDL_INIT_AUDIO); + if (m_ready) + { + SDL_CloseAudioDevice(m_device_id); + SDL_QuitSubSystem(SDL_INIT_AUDIO); + m_ready = false; + } } bool Mixer::init() diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Renderer.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Renderer.cpp index 7f27958d..f79ee2f2 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Renderer.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Renderer.cpp @@ -5,9 +5,9 @@ namespace HyperSonicDrivers::audio::sdl2 { - Renderer::Renderer(const uint32_t freq, const uint16_t buffer_size) + Renderer::Renderer(const uint32_t freq, const uint16_t buffer_size, const uint8_t max_channels) { - m_mixer = make_mixer(1, freq, buffer_size); + m_mixer = make_mixer(max_channels, freq, buffer_size); } void Renderer::openOutputFile(const std::filesystem::path& path) diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Renderer.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Renderer.hpp index 9774f659..3dbf038b 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Renderer.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/audio/sdl2/Renderer.hpp @@ -1,19 +1,16 @@ #pragma once +#include +#include #include -#include #include -#include -#include -#include -#include namespace HyperSonicDrivers::audio::sdl2 { class Renderer : public IRenderer { public: - Renderer(const uint32_t freq, const uint16_t buffer_size); + Renderer(const uint32_t freq, const uint16_t buffer_size, const uint8_t max_channels = 1); ~Renderer() override = default; void openOutputFile(const std::filesystem::path& path) override; @@ -21,8 +18,5 @@ namespace HyperSonicDrivers::audio::sdl2 void renderBuffer(IAudioStream* stream) override; using IRenderer::renderBuffer; - private: - std::unique_ptr m_out; - std::vector m_buf; }; } diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/stubs/StubMixer.hpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/IMixerMock.hpp similarity index 91% rename from sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/stubs/StubMixer.hpp rename to sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/IMixerMock.hpp index 7fbecd58..3e8f1f62 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/stubs/StubMixer.hpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/IMixerMock.hpp @@ -6,15 +6,15 @@ #include #include -namespace HyperSonicDrivers::audio::stubs +namespace HyperSonicDrivers::audio { - class StubMixer : public IMixer + class IMixerMock : public IMixer { public: int rate = 44100; - StubMixer() : IMixer(32, 44100, 1024) {}; - explicit StubMixer(const int freq) : IMixer(32, freq, 1024) {}; + IMixerMock() : IMixer(32, 44100, 1024) {}; + explicit IMixerMock(const int freq) : IMixer(32, freq, 1024) {}; bool init() override { return true; }; diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/sdl2/TestRenderer.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/sdl2/TestRenderer.cpp index 47dd27d6..0b8f4e95 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/sdl2/TestRenderer.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/audio/sdl2/TestRenderer.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -28,7 +28,7 @@ namespace HyperSonicDrivers::audio::sdl2 RendererTest() { - mixer = std::make_shared(); + mixer = std::make_shared(); switch (device_name) { using enum devices::eDeviceName; diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/DeviceMock.hpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/DeviceMock.hpp new file mode 100644 index 00000000..3ce5fd52 --- /dev/null +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/DeviceMock.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include +#include +#include + + +namespace HyperSonicDrivers::devices +{ + template + class DeviceMock : public T + { + public: + explicit DeviceMock(const std::shared_ptr& mixer) : T(mixer) { + static_assert(std::is_base_of_v); + }; + DeviceMock() : T(audio::make_mixer()) { + static_assert(std::is_base_of_v); + }; + + bool init() noexcept override { return true; }; + bool shutdown() noexcept override { return true; }; + std::optional getChannelId() const noexcept { return std::nullopt; }; + }; +} + diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/EmulatorTestCase.hpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/EmulatorTestCase.hpp index 130ce8a8..cc2f145f 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/EmulatorTestCase.hpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/EmulatorTestCase.hpp @@ -3,12 +3,12 @@ #include #include #include -#include +#include #include namespace HyperSonicDrivers::devices { - using audio::stubs::StubMixer; + using audio::IMixerMock; using hardware::opl::OplEmulator; template @@ -17,7 +17,7 @@ namespace HyperSonicDrivers::devices public: const OplEmulator oplEmu = std::get<0>(GetParam()); const bool shouldFail = std::get<1>(GetParam()); - const std::shared_ptr mixer = std::make_shared(); + const std::shared_ptr mixer = std::make_shared(); void test_case() { diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/SpyDevice.hpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/SpyDevice.hpp deleted file mode 100644 index 69af14c8..00000000 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/SpyDevice.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include -#include -#include - - -namespace HyperSonicDrivers::devices -{ - template - class SpyDevice : public T - { - public: - explicit SpyDevice(const std::shared_ptr& mixer) : T(mixer) { - static_assert(std::is_base_of_v); - }; - SpyDevice() : T(audio::make_mixer()) { - static_assert(std::is_base_of_v); - }; - - bool init() noexcept override { return true; }; - bool shutdown() noexcept override { return true; }; - std::optional getChannelId() const noexcept { return std::nullopt; }; - - - /* virtual void sendEvent(const audio::midi::MIDIEvent& e) const noexcept override - { - - }; - virtual void sendMessage(const uint8_t msg[], const uint8_t size) const noexcept override - { - - } - virtual void sendSysEx(const audio::midi::MIDIEvent& e) const noexcept override - { - - }*/ - /*virtual void pause() const noexcept override - { - - } - virtual void resume() const noexcept override - { - - }*/ - }; -} - diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestAdlib.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestAdlib.cpp index b752f150..6f378c3e 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestAdlib.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestAdlib.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -13,13 +13,13 @@ namespace HyperSonicDrivers::devices { TEST(Adlib, cstor_AUTO) { - auto mixer = std::make_shared(); + auto mixer = std::make_shared(); EXPECT_NO_THROW(auto a = std::make_shared(mixer)); } TEST(Adlib, device_name) { - auto mixer = std::make_shared(); + auto mixer = std::make_shared(); auto a = std::make_shared(mixer); EXPECT_EQ(a->getName(), eDeviceName::Adlib); } diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestIDevice.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestIDevice.cpp index bec67d7c..927ce19e 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestIDevice.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestIDevice.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -11,7 +11,7 @@ namespace HyperSonicDrivers::devices TEST(IDevice, double_acquire) { - auto device = std::make_shared>(); + auto device = std::make_shared>(); MIDDriverMock middrv(device); EXPECT_THROW(MIDDriverMock middrv2(device), std::runtime_error); @@ -19,7 +19,7 @@ namespace HyperSonicDrivers::devices TEST(IDevice, acquire_release) { - auto device = std::make_shared>(); + auto device = std::make_shared>(); MIDDriverMock middrv(device); diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestOpl.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestOpl.cpp index 63d21c23..775afe13 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestOpl.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestOpl.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -10,7 +10,7 @@ namespace HyperSonicDrivers::devices::midi { - using audio::stubs::StubMixer; + using audio::IMixerMock; using hardware::opl::OplType; using hardware::opl::OplEmulator; using hardware::opl::OPL; @@ -18,7 +18,7 @@ namespace HyperSonicDrivers::devices::midi TEST(MidiOpl, cstor_) { - auto mixer = std::make_shared(); + auto mixer = std::make_shared(); EXPECT_NO_THROW(OplDeviceMock(OplType::OPL2, OplEmulator::AUTO, mixer)); } @@ -28,7 +28,7 @@ namespace HyperSonicDrivers::devices::midi const OplType oplType = std::get<0>(GetParam()); const OplEmulator oplEmu = std::get<1>(GetParam()); const bool shouldFail = std::get<2>(GetParam()); - const std::shared_ptr mixer = std::make_shared(); + const std::shared_ptr mixer = std::make_shared(); }; TEST_P(OplEmulator_, cstr_type_emu) { diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestSbPro.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestSbPro.cpp index 9490577e..03932d39 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestSbPro.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestSbPro.cpp @@ -11,13 +11,13 @@ namespace HyperSonicDrivers::devices TEST(SbPro, cstor_) { - auto mixer = std::make_shared(); + auto mixer = std::make_shared(); EXPECT_NO_THROW(auto s = SbPro(mixer, OplEmulator::DOS_BOX)); } TEST(Adlib, device_name) { - auto mixer = std::make_shared(); + auto mixer = std::make_shared(); auto s = std::make_shared(mixer); EXPECT_EQ(s->getName(), eDeviceName::SbPro); } @@ -41,7 +41,7 @@ namespace HyperSonicDrivers::devices TEST(SbPro, cstr_AUTO) { - auto mixer = std::make_shared(); + auto mixer = std::make_shared(); EXPECT_NO_THROW(SbPro(mixer, OplEmulator::AUTO)); } } diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestSbPro2.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestSbPro2.cpp index c2ae4e04..74e7ef26 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestSbPro2.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/devices/TestSbPro2.cpp @@ -9,13 +9,13 @@ namespace HyperSonicDrivers::devices { TEST(SbPro2, cstor_) { - auto mixer = std::make_shared(); + auto mixer = std::make_shared(); EXPECT_NO_THROW(auto s = SbPro2(mixer, OplEmulator::NUKED)); } TEST(Adlib, device_name) { - auto mixer = std::make_shared(); + auto mixer = std::make_shared(); auto s = std::make_shared(mixer); EXPECT_EQ(s->getName(), eDeviceName::SbPro2); } @@ -41,7 +41,7 @@ namespace HyperSonicDrivers::devices TEST(SbPro2, cstor_AUTO) { - auto mixer = std::make_shared(); + auto mixer = std::make_shared(); EXPECT_NO_THROW(auto s = SbPro2(mixer)); } } diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/drivers/TestMIDDriver.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/drivers/TestMIDDriver.cpp index a2adb833..8b55a7e5 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/drivers/TestMIDDriver.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/drivers/TestMIDDriver.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -27,7 +27,7 @@ namespace HyperSonicDrivers::drivers TEST(MIDDriver, SEQUENCE_NAME_META_EVENT) { - auto device = std::make_shared>(); + auto device = std::make_shared>(); ILogger::instance->setLevel(ILogger::eLevel::Trace, ILogger::eCategory::Audio); @@ -55,7 +55,7 @@ namespace HyperSonicDrivers::drivers TEST(MIDDriver, force_stop_on_long_delta_time_delay) { - auto device = std::make_shared>(); + auto device = std::make_shared>(); { MIDIEvent e; @@ -105,7 +105,7 @@ namespace HyperSonicDrivers::drivers TEST(MIDDriver, getTempo) { auto mf = files::MIDFile("../fixtures/midifile_sample.mid"); - auto device = std::make_shared>(); + auto device = std::make_shared>(); MIDDriverMock md(device); EXPECT_EQ(md.getTempo(), 0); EXPECT_FALSE(md.isTempoChanged()); diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/drivers/westwood/TestADLDriver.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/drivers/westwood/TestADLDriver.cpp index ff6c5763..1a811195 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/drivers/westwood/TestADLDriver.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/drivers/westwood/TestADLDriver.cpp @@ -2,19 +2,19 @@ #include #include #include -#include +#include #include #include namespace HyperSonicDrivers::drivers::westwood { // TODO: Review the tests - using audio::stubs::StubMixer; + using audio::IMixerMock; using hardware::opl::OplType; TEST(ADLDriver, cstor) { - auto mixer = std::make_shared(); + auto mixer = std::make_shared(); auto adlFile = std::make_shared("../fixtures/DUNE19.ADL"); auto adlib = devices::make_device(mixer); ADLDriver adlDrv(adlib, audio::mixer::eChannelGroup::Plain); @@ -24,7 +24,7 @@ namespace HyperSonicDrivers::drivers::westwood TEST(ADLDriver, shared_ptr) { - auto mixer = std::make_shared(); + auto mixer = std::make_shared(); EXPECT_EQ(mixer.use_count(), 1); auto adlFile = std::make_shared("../fixtures/DUNE19.ADL"); diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/OPLMock.hpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/OPLMock.hpp index 3508ebe2..ecb3e8e5 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/OPLMock.hpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/OPLMock.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include @@ -10,7 +10,7 @@ namespace HyperSonicDrivers::hardware::opl class OPLMock : public OPL { public: - OPLMock() : OPL(std::make_shared(), OplType::OPL2) {}; + OPLMock() : OPL(std::make_shared(), OplType::OPL2) {}; bool init() override { m_init = true; return true; }; void reset() override {}; void write(const uint32_t port, const uint16_t val) noexcept override {}; diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/TestOPLFactory.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/TestOPLFactory.cpp index 6990722b..88915538 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/TestOPLFactory.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/TestOPLFactory.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include @@ -10,10 +10,10 @@ namespace HyperSonicDrivers::hardware::opl { - using audio::stubs::StubMixer; + using audio::IMixerMock; using namespace hardware::opl::scummvm; - const static std::shared_ptr mixer = std::make_shared(); + const static std::shared_ptr mixer = std::make_shared(); class ConfigTest : public ::testing::TestWithParam> {}; TEST_P(ConfigTest, create) diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/dosbox/TestDosBoxOPL.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/dosbox/TestDosBoxOPL.cpp index 1380581d..18d329e3 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/dosbox/TestDosBoxOPL.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/dosbox/TestDosBoxOPL.cpp @@ -3,14 +3,14 @@ #include #include #include -#include +#include #include namespace HyperSonicDrivers::hardware::opl::scummvm::dosbox { // TODO: refactor these tests as they are the same of the one in mame. - using audio::stubs::StubMixer; + using audio::IMixerMock; class OPLType : public ::testing::TestWithParam> { @@ -20,7 +20,7 @@ namespace HyperSonicDrivers::hardware::opl::scummvm::dosbox }; TEST_P(OPLType, cstorDefault) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); EXPECT_EQ(mixer.use_count(), 1); DosBoxOPL dosbox(this->opl_type, mixer); EXPECT_EQ(mixer.use_count(), 2); @@ -33,7 +33,7 @@ namespace HyperSonicDrivers::hardware::opl::scummvm::dosbox TEST_P(OPLType, share_ptrDefault) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); EXPECT_EQ(mixer.use_count(), 1); std::shared_ptr dosbox = std::make_shared(this->opl_type, mixer); @@ -57,7 +57,7 @@ namespace HyperSonicDrivers::hardware::opl::scummvm::dosbox TEST(DISABLED_OPL, Table440Hz) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); mixer->rate = 22050; std::shared_ptr opl = std::make_shared(OplType::OPL2, mixer); opl->init(); diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/mame/TestMameOPL2.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/mame/TestMameOPL2.cpp index 7c5106f4..a9e26a91 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/mame/TestMameOPL2.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/mame/TestMameOPL2.cpp @@ -3,16 +3,16 @@ #include #include #include -#include +#include #include namespace HyperSonicDrivers::hardware::opl::scummvm::mame { - using audio::stubs::StubMixer; + using audio::IMixerMock; TEST(MameOPL2, cstorDefault) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); EXPECT_EQ(mixer.use_count(), 1); MameOPL2 mame(OplType::OPL2, mixer); EXPECT_EQ(mixer.use_count(), 2); @@ -21,14 +21,14 @@ namespace HyperSonicDrivers::hardware::opl::scummvm::mame TEST(MameOPL2, throwIfnotOPL2) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); EXPECT_EQ(mixer.use_count(), 1); EXPECT_THROW(MameOPL2 mame(OplType::OPL3, mixer), std::invalid_argument); } TEST(MameOPL2, share_ptrDefault) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); EXPECT_EQ(mixer.use_count(), 1); std::shared_ptr mame = std::make_shared(OplType::OPL2, mixer); @@ -39,7 +39,7 @@ namespace HyperSonicDrivers::hardware::opl::scummvm::mame TEST(DISABLED_OPL, Table440Hz) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); mixer->rate = 22050; std::shared_ptr opl = std::make_shared(OplType::OPL2, mixer); opl->init(); diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/nuked/TestNukedOPL3.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/nuked/TestNukedOPL3.cpp index d6a8d1c6..bbe3598d 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/nuked/TestNukedOPL3.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/scummvm/nuked/TestNukedOPL3.cpp @@ -3,14 +3,14 @@ #include #include #include -#include +#include #include namespace HyperSonicDrivers::hardware::opl::scummvm::nuked { // TODO: refactor these tests as they are the same of the one in dosbox. - using audio::stubs::StubMixer; + using audio::IMixerMock; class OPLType : public ::testing::TestWithParam> { @@ -20,7 +20,7 @@ namespace HyperSonicDrivers::hardware::opl::scummvm::nuked }; TEST_P(OPLType, cstorDefault) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); EXPECT_EQ(mixer.use_count(), 1); NukedOPL nuked(this->opl_type, mixer); EXPECT_EQ(mixer.use_count(), 2); @@ -31,7 +31,7 @@ namespace HyperSonicDrivers::hardware::opl::scummvm::nuked TEST_P(OPLType, share_ptrDefault) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); EXPECT_EQ(mixer.use_count(), 1); std::shared_ptr nuked = std::make_shared(this->opl_type, mixer); @@ -54,7 +54,7 @@ namespace HyperSonicDrivers::hardware::opl::scummvm::nuked TEST(DISABLED_OPL, Table440Hz) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); mixer->rate = 22050; std::shared_ptr opl = std::make_shared(OplType::OPL3, mixer); opl->init(); diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/woody/TestWoodyOPL.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/woody/TestWoodyOPL.cpp index 56a53729..772ddd69 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/woody/TestWoodyOPL.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/hardware/opl/woody/TestWoodyOPL.cpp @@ -3,16 +3,16 @@ #include #include #include -#include +#include #include namespace HyperSonicDrivers::hardware::opl::woody { - using audio::stubs::StubMixer; + using audio::IMixerMock; TEST(OPL, cstorDefaultFalse) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); EXPECT_EQ(mixer.use_count(), 1); WoodyOPL opl(mixer, false); EXPECT_EQ(mixer.use_count(), 2); @@ -23,7 +23,7 @@ namespace HyperSonicDrivers::hardware::opl::woody TEST(OPL, cstorDefaultTrue) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); EXPECT_EQ(mixer.use_count(), 1); WoodyOPL opl(mixer, true); EXPECT_EQ(mixer.use_count(), 2); @@ -34,7 +34,7 @@ namespace HyperSonicDrivers::hardware::opl::woody TEST(OPL, share_ptrDefault) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); EXPECT_EQ(mixer.use_count(), 1); std::shared_ptr opl = std::make_shared(mixer, false); @@ -47,7 +47,7 @@ namespace HyperSonicDrivers::hardware::opl::woody TEST(DISABLED_OPL, Table440Hz) { - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); mixer->rate = 22050; std::shared_ptr opl = std::make_shared(mixer, false); opl->init(); diff --git a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/utils/TestOpl.cpp b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/utils/TestOpl.cpp index 20b9b318..bea5cec1 100644 --- a/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/utils/TestOpl.cpp +++ b/sdl2-hyper-sonic-drivers/test/HyperSonicDrivers/utils/TestOpl.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace HyperSonicDrivers::utils @@ -16,12 +16,12 @@ namespace HyperSonicDrivers::utils using hardware::opl::OPLFactory; using hardware::opl::OplEmulator; using hardware::opl::OplType; - using audio::stubs::StubMixer; + using audio::IMixerMock; class OplType_ : public ::testing::TestWithParam> { public: - std::shared_ptr mixer = std::make_shared(); + std::shared_ptr mixer = std::make_shared(); OplEmulator opl_emu = std::get<0>(GetParam()); OplType opl_type = std::get<1>(GetParam()); bool isOpl2 = std::get<2>(GetParam());