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

Unified Diff: webrtc/test/mock_voice_engine.h

Issue 1991233004: Moved creation of AudioDecoderFactory to inside PeerConnectionFactory. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@audio-decoder-factory-injections-3
Patch Set: Parental Advisory: Explicit Content Created 4 years, 6 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
« no previous file with comments | « webrtc/test/mock_voe_channel_proxy.h ('k') | webrtc/voice_engine/channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/test/mock_voice_engine.h
diff --git a/webrtc/test/mock_voice_engine.h b/webrtc/test/mock_voice_engine.h
index aa71e434b7e46bcc8d9601d759e2408be2ab958b..be72e0d631524a3413431e448b4f1e1ee255ab48 100644
--- a/webrtc/test/mock_voice_engine.h
+++ b/webrtc/test/mock_voice_engine.h
@@ -28,17 +28,26 @@ class MockVoiceEngine : public VoiceEngineImpl {
// methods don't use any override declarations, and we want to avoid
// warnings from -Winconsistent-missing-override. See
// http://crbug.com/428099.
- MockVoiceEngine() : VoiceEngineImpl(new Config(), true) {
+ MockVoiceEngine(
+ rtc::scoped_refptr<AudioDecoderFactory> decoder_factory = nullptr)
+ : VoiceEngineImpl(new Config(), true),
+ decoder_factory_(decoder_factory) {
// Increase ref count so this object isn't automatically deleted whenever
// interfaces are Release():d.
++_ref_count;
// We add this default behavior to make the mock easier to use in tests. It
// will create a NiceMock of a voe::ChannelProxy.
+ // TODO(ossu): As long as AudioReceiveStream is implmented as a wrapper
+ // around Channel, we need to make sure ChannelProxy returns the same
+ // decoder factory as the one passed in when creating an AudioReceiveStream.
ON_CALL(*this, ChannelProxyFactory(testing::_))
- .WillByDefault(
- testing::Invoke([](int channel_id) {
- return new testing::NiceMock<MockVoEChannelProxy>();
- }));
+ .WillByDefault(testing::Invoke([this](int channel_id) {
+ auto* proxy =
+ new testing::NiceMock<webrtc::test::MockVoEChannelProxy>();
+ EXPECT_CALL(*proxy, GetAudioDecoderFactory())
+ .WillRepeatedly(testing::ReturnRef(decoder_factory_));
+ return proxy;
+ }));
}
~MockVoiceEngine() /* override */ {
// Decrease ref count before base class d-tor is called; otherwise it will
@@ -323,6 +332,15 @@ class MockVoiceEngine : public VoiceEngineImpl {
MOCK_METHOD2(GetChannelOutputVolumeScaling, int(int channel, float& scaling));
MOCK_METHOD3(SetOutputVolumePan, int(int channel, float left, float right));
MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right));
+
+ private:
+ // TODO(ossu): I'm not particularly happy about keeping the decoder factory
+ // here, but due to how gmock is implemented, I cannot just keep it in the
+ // functor implementing the default version of ChannelProxyFactory, above.
+ // GMock creates an unfortunate copy of the functor, which would cause us to
+ // return a dangling reference. Fortunately, this should go away once
+ // voe::Channel does.
+ rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
};
} // namespace test
} // namespace webrtc
« no previous file with comments | « webrtc/test/mock_voe_channel_proxy.h ('k') | webrtc/voice_engine/channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698