MockAudioEncoder: Use a dedicated marker method for test expectations
This makes the sequence of expected calls easier to read. Also, we can
save one line and get rid of a gmock warning by expecting the
MockAudioEncoder object to be destroyed at the end of the test instead
of making a final marker call.
Review URL: https://codereview.webrtc.org/1331793003
Cr-Commit-Position: refs/heads/master@{#9916}
diff --git a/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h b/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h
index a34edb3..95426d8 100644
--- a/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h
+++ b/webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h
@@ -21,6 +21,7 @@
public:
~MockAudioEncoder() override { Die(); }
MOCK_METHOD0(Die, void());
+ MOCK_METHOD1(Mark, void(std::string desc));
MOCK_CONST_METHOD0(MaxEncodedBytes, size_t());
MOCK_CONST_METHOD0(SampleRateHz, int());
MOCK_CONST_METHOD0(NumChannels, int());
diff --git a/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc b/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
index 0c510c0..ec1bb0d 100644
--- a/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
+++ b/webrtc/modules/audio_coding/main/acm2/codec_owner_unittest.cc
@@ -115,19 +115,19 @@
EXPECT_CALL(external_encoder,
EncodeInternal(0, audio, arraysize(encoded), encoded))
.WillOnce(Return(info));
- EXPECT_CALL(external_encoder, Reset());
- EXPECT_CALL(external_encoder, Reset());
+ EXPECT_CALL(external_encoder, Mark("A"));
+ EXPECT_CALL(external_encoder, Mark("B"));
info.encoded_timestamp = 2;
EXPECT_CALL(external_encoder,
EncodeInternal(2, audio, arraysize(encoded), encoded))
.WillOnce(Return(info));
- EXPECT_CALL(external_encoder, Reset());
+ EXPECT_CALL(external_encoder, Die());
}
info = codec_owner_.Encoder()->Encode(0, audio, arraysize(audio),
arraysize(encoded), encoded);
EXPECT_EQ(0u, info.encoded_timestamp);
- external_encoder.Reset(); // Dummy call to mark the sequence of expectations.
+ external_encoder.Mark("A");
// Change to internal encoder.
CodecInst codec_inst = kDefaultCodecInst;
@@ -136,14 +136,13 @@
// Don't expect any more calls to the external encoder.
info = codec_owner_.Encoder()->Encode(1, audio, arraysize(audio),
arraysize(encoded), encoded);
- external_encoder.Reset(); // Dummy call to mark the sequence of expectations.
+ external_encoder.Mark("B");
// Change back to external encoder again.
codec_owner_.SetEncoders(&external_encoder, -1, VADNormal, -1);
info = codec_owner_.Encoder()->Encode(2, audio, arraysize(audio),
arraysize(encoded), encoded);
EXPECT_EQ(2u, info.encoded_timestamp);
- external_encoder.Reset(); // Dummy call to mark the sequence of expectations.
}
} // namespace acm2