Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Unified Diff: webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc

Issue 1725143003: Changed AudioEncoder::Encode to take an rtc::Buffer* instead of uint8_t* and a maximum size. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added more fixes for override hiding in AudioEncoder implementations. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
index fbfd999d39855b067299566a912368ef4eb46778..459ccb58c072ab1d49eeb008358254784e4aad0b 100644
--- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
+++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
@@ -70,7 +70,6 @@ class AudioEncoderCngTest : public ::testing::Test {
EXPECT_CALL(mock_encoder_, MaxEncodedBytes())
.WillRepeatedly(Return(kMockMaxEncodedBytes));
cng_.reset(new AudioEncoderCng(config_));
- encoded_.resize(cng_->MaxEncodedBytes(), 0);
}
void Encode() {
@@ -78,7 +77,7 @@ class AudioEncoderCngTest : public ::testing::Test {
encoded_info_ = cng_->Encode(
timestamp_,
rtc::ArrayView<const int16_t>(audio_, num_audio_samples_10ms_),
- encoded_.size(), &encoded_[0]);
+ &encoded_);
timestamp_ += static_cast<uint32_t>(num_audio_samples_10ms_);
}
@@ -89,12 +88,13 @@ class AudioEncoderCngTest : public ::testing::Test {
InSequence s;
AudioEncoder::EncodedInfo info;
for (size_t j = 0; j < num_calls - 1; ++j) {
- EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _))
+ EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
.WillOnce(Return(info));
}
info.encoded_bytes = kMockReturnEncodedBytes;
- EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _))
- .WillOnce(Return(info));
+ EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _))
+ .WillOnce(Invoke(
+ MockAudioEncoder::FakeEncoding(kMockReturnEncodedBytes)));
}
// Verifies that the cng_ object waits until it has collected
@@ -108,7 +108,7 @@ class AudioEncoderCngTest : public ::testing::Test {
.WillRepeatedly(Return(active_speech ? Vad::kActive : Vad::kPassive));
// Don't expect any calls to the encoder yet.
- EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0);
+ EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _)).Times(0);
for (size_t i = 0; i < blocks_per_frame - 1; ++i) {
Encode();
EXPECT_EQ(0u, encoded_info_.encoded_bytes);
@@ -191,7 +191,7 @@ class AudioEncoderCngTest : public ::testing::Test {
uint32_t timestamp_;
int16_t audio_[kMaxNumSamples];
size_t num_audio_samples_10ms_;
- std::vector<uint8_t> encoded_;
+ rtc::Buffer encoded_;
AudioEncoder::EncodedInfo encoded_info_;
int sample_rate_hz_;
};
@@ -259,7 +259,7 @@ TEST_F(AudioEncoderCngTest, EncodePassive) {
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
.WillRepeatedly(Return(Vad::kPassive));
// Expect no calls at all to the speech encoder mock.
- EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0);
+ EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _)).Times(0);
uint32_t expected_timestamp = timestamp_;
for (size_t i = 0; i < 100; ++i) {
Encode();
@@ -341,7 +341,7 @@ TEST_F(AudioEncoderCngTest, VadInputSize60Ms) {
// Verifies that the correct payload type is set when CNG is encoded.
TEST_F(AudioEncoderCngTest, VerifyCngPayloadType) {
CreateCng();
- EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).Times(0);
+ EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _)).Times(0);
EXPECT_CALL(mock_encoder_, Num10MsFramesInNextPacket()).WillOnce(Return(1U));
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
.WillOnce(Return(Vad::kPassive));
@@ -373,9 +373,8 @@ TEST_F(AudioEncoderCngTest, VerifySidFrameAfterSpeech) {
encoded_info_.payload_type = 0;
EXPECT_CALL(*mock_vad_, VoiceActivity(_, _, _))
.WillOnce(Return(Vad::kActive));
- AudioEncoder::EncodedInfo info;
- info.encoded_bytes = kMockReturnEncodedBytes;
- EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _)).WillOnce(Return(info));
+ EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _)).WillOnce(
+ Invoke(MockAudioEncoder::FakeEncoding(kMockReturnEncodedBytes)));
Encode();
EXPECT_EQ(kMockReturnEncodedBytes, encoded_info_.encoded_bytes);

Powered by Google App Engine
This is Rietveld 408576698