Skip to content

Commit

Permalink
IMusicDriverTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Raffaello committed Oct 30, 2023
1 parent 2fc8450 commit 4317594
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ namespace HyperSonicDrivers::drivers
inline void setTempo(const uint32_t tempo) noexcept { m_midiTempoChanged = true; m_tempo = tempo; }
bool open_() noexcept;
private:
// this is used to "lock" the device to a specific driver output and passed to IMidiDriver
//std::shared_ptr<devices::IDevice> m_device;
// this is to abstract the specific midi driver implementation
std::unique_ptr<drivers::midi::IMidiDriver> m_midiDriver;
std::shared_ptr<audio::MIDI> m_midi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ macro_test(
"../fixtures/midifile_sample.mid"
)

macro_test(
EXE TestIMusicDriver
FILES "drivers/TestIMusicDriver.cpp"
LINKS_PRIVATE hyper-sonic-drivers-static
FIXTURES
)

macro_test(
EXE TestMameOPL2
FILES "hardware/opl/scummvm/mame/TestMameOPL2.cpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <HyperSonicDrivers/drivers/IMusicDriver.hpp>

namespace HyperSonicDrivers::drivers
{
class IMusicDriverMock : public IMusicDriver
{
public:
IMusicDriverMock(const std::shared_ptr<devices::IDevice>& device) : IMusicDriver(device) {}
void play(const uint8_t track) noexcept override {};
void stop() noexcept override {};
bool isPlaying() const noexcept override { return false; };
};

TEST(IMusicDriver, cstor_nullptr)
{
EXPECT_THROW(IMusicDriverMock md(nullptr), std::runtime_error);
}
}

int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit 4317594

Please sign in to comment.