Skip to content

Commit 4165b12

Browse files
committed
Issue #19 : The Mock of the rpp_driver::Adau1361 is missing.
Added Mock for the Adau1361. And test it.
1 parent 1c41fdd commit 4165b12

2 files changed

Lines changed: 39 additions & 4 deletions

File tree

src/codec/adau1361.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,12 @@ class MockAdau1361 : public Adau1361 {
167167
MockAdau1361(Adau1361Lower& adau1361_lower)
168168
: Adau1361(48'000, 12'000'000, adau1361_lower) {
169169
} // with dummy fs and dummy mclock
170-
MOCK_METHOD0(GetStateMachine, uint32_t(void));
170+
171171
MOCK_METHOD0(Start, void(void));
172-
MOCK_METHOD0(Stop, void(void));
173-
MOCK_METHOD1(PutFifoBlocking, void(int32_t value));
174-
MOCK_METHOD0(GetFifoBlocking, int32_t());
172+
MOCK_METHOD3(SetGain,
173+
void(CodecChannel channel, float left_gain, float right_gain));
174+
MOCK_METHOD2(Mute, void(CodecChannel channel, bool mute));
175+
MOCK_METHOD1(Mute, void(CodecChannel channel));
175176
};
176177
// GCOVR_EXCL_STOP
177178
#endif // __has_include(<gmock/gmock.h>)

test/test_mockadau1361.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Test the MockAdau1361 class.
3+
* Only constructor is tested.
4+
*/
5+
6+
#include <gmock/gmock.h>
7+
#include <gtest/gtest.h>
8+
9+
#include "adau1361.hpp"
10+
#include "sdkwrapper.hpp"
11+
12+
using ::testing::_;
13+
class MockAdau1361Test : public ::testing::Test {
14+
protected:
15+
virtual void SetUp() {
16+
codec_lower_ = new ::rpp_driver::MockAdau1361Lower(i2c_);
17+
codec_ = new ::rpp_driver::MockAdau1361(*codec_lower_);
18+
}
19+
20+
virtual void TearDown() {
21+
delete codec_;
22+
delete codec_lower_;
23+
}
24+
25+
::rpp_driver::MockI2cMasterInterface i2c_;
26+
::rpp_driver::MockAdau1361Lower *codec_lower_;
27+
::rpp_driver::Adau1361 *codec_;
28+
}; // MockAdau1361Test
29+
30+
/*
31+
* In this test case, we test teh MockAdau1361 is surely able to
32+
* compile. So, none of the other methods are tested.
33+
*/
34+
TEST_F(MockAdau1361Test, Constructor) {}

0 commit comments

Comments
 (0)