Skip to content

Commit

Permalink
Merge branch 'feature/19' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
suikan4github committed Oct 17, 2024
2 parents 186ae14 + 3ca44f1 commit 6553683
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/codec/adau1361.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,24 @@ class Adau1361 {
bool line_output_mute_;
bool hp_output_mute_; // headphone
};

#if __has_include(<gmock/gmock.h>)
// 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(<gmock/gmock.h>)

} // namespace rpp_driver

#endif /* PICO_DRIVER_SRC_CODEC_ADAU1361_HPP_ */
4 changes: 2 additions & 2 deletions src/i2s/i2sslaveduplex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(<gmock/gmock.h>)
// GCOVR_EXCL_STOP
#endif // __has_include(<gmock/gmock.h>)
} // namespace rpp_driver

#endif // PICO_DRIVER_SRC_I2S_DUPLEXSLAVEI2S_HPP_
34 changes: 34 additions & 0 deletions test/test_mockadau1361.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Test the MockAdau1361 class.
* Only constructor is tested.
*/

#include <gmock/gmock.h>
#include <gtest/gtest.h>

#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) {}

0 comments on commit 6553683

Please # to comment.