diff --git a/CHANGELOG.md b/CHANGELOG.md index b1062d5..c54d203 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,8 @@ The issue #16 changes its public member function. But it is referred internally - [Issue #11](https://github.com/suikan4github/rpp_driver/issues/11) Fails to compile in MSVC. - [Issue #17](https://github.com/suikan4github/rpp_driver/issues/17) The mock of the GpioBasic has the wrong definition. - [Issue #18](https://github.com/suikan4github/rpp_driver/issues/18) The constructor of the MockI2sSlaveDuplex.hpp is missing. -### Security +- [Issue #19](https://github.com/suikan4github/rpp_driver/issues/19) The Mock of the rpp_driver::Adau1361 is missing. + ### Security ### Known Issue ## [v1.0.0] 2024-10-03 diff --git a/src/codec/adau1361.hpp b/src/codec/adau1361.hpp index 74ec5f9..d21657d 100644 --- a/src/codec/adau1361.hpp +++ b/src/codec/adau1361.hpp @@ -159,6 +159,24 @@ class Adau1361 { bool line_output_mute_; bool hp_output_mute_; // headphone }; + +#if __has_include() +// GCOVR_EXCL_START +class MockAdau1361 : public Adau1361 { + public: + MockAdau1361(Adau1361Lower& adau1361_lower) + : Adau1361(48'000, 12'000'000, adau1361_lower) { + } // with dummy fs and dummy mclock + + MOCK_METHOD0(Start, void(void)); + MOCK_METHOD3(SetGain, + void(CodecChannel channel, float left_gain, float right_gain)); + MOCK_METHOD2(Mute, void(CodecChannel channel, bool mute)); + MOCK_METHOD1(Mute, void(CodecChannel channel)); +}; +// GCOVR_EXCL_STOP +#endif // __has_include() + } // namespace rpp_driver #endif /* PICO_DRIVER_SRC_CODEC_ADAU1361_HPP_ */ \ No newline at end of file diff --git a/src/i2s/i2sslaveduplex.hpp b/src/i2s/i2sslaveduplex.hpp index a8d419c..eb84a21 100644 --- a/src/i2s/i2sslaveduplex.hpp +++ b/src/i2s/i2sslaveduplex.hpp @@ -154,15 +154,15 @@ class I2sSlaveDuplex { class MockI2sSlaveDuplex : public I2sSlaveDuplex { public: MockI2sSlaveDuplex(SdkWrapper &sdk) - : I2sSlaveDuplex(sdk, 0, 0) {} // // 0 is dummy. We don't care. + : I2sSlaveDuplex(sdk, 0, 0) {} // 0 is dummy. We don't care. MOCK_METHOD0(GetStateMachine, uint32_t(void)); MOCK_METHOD0(Start, void(void)); MOCK_METHOD0(Stop, void(void)); MOCK_METHOD1(PutFifoBlocking, void(int32_t value)); MOCK_METHOD0(GetFifoBlocking, int32_t()); }; -#endif // __has_include() // GCOVR_EXCL_STOP +#endif // __has_include() } // namespace rpp_driver #endif // PICO_DRIVER_SRC_I2S_DUPLEXSLAVEI2S_HPP_ \ No newline at end of file diff --git a/test/test_mockadau1361.cpp b/test/test_mockadau1361.cpp new file mode 100644 index 0000000..bb9e480 --- /dev/null +++ b/test/test_mockadau1361.cpp @@ -0,0 +1,34 @@ +/* + * Test the MockAdau1361 class. + * Only constructor is tested. + */ + +#include +#include + +#include "adau1361.hpp" +#include "sdkwrapper.hpp" + +using ::testing::_; +class MockAdau1361Test : public ::testing::Test { + protected: + virtual void SetUp() { + codec_lower_ = new ::rpp_driver::MockAdau1361Lower(i2c_); + codec_ = new ::rpp_driver::MockAdau1361(*codec_lower_); + } + + virtual void TearDown() { + delete codec_; + delete codec_lower_; + } + + ::rpp_driver::MockI2cMasterInterface i2c_; + ::rpp_driver::MockAdau1361Lower *codec_lower_; + ::rpp_driver::Adau1361 *codec_; +}; // MockAdau1361Test + +/* + * In this test case, we test teh MockAdau1361 is surely able to + * compile. So, none of the other methods are tested. + */ +TEST_F(MockAdau1361Test, Constructor) {} \ No newline at end of file