OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ | 11 #ifndef WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ |
12 #define WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ | 12 #define WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
| 16 #include "webrtc/modules/audio_device/include/mock_audio_device.h" |
| 17 #include "webrtc/modules/audio_device/include/mock_audio_transport.h" |
| 18 #include "webrtc/modules/audio_processing/include/mock_audio_processing.h" |
16 #include "webrtc/test/gmock.h" | 19 #include "webrtc/test/gmock.h" |
17 #include "webrtc/test/mock_voe_channel_proxy.h" | 20 #include "webrtc/test/mock_voe_channel_proxy.h" |
18 #include "webrtc/voice_engine/voice_engine_impl.h" | 21 #include "webrtc/voice_engine/voice_engine_impl.h" |
19 | 22 |
20 namespace webrtc { | 23 namespace webrtc { |
21 namespace test { | 24 namespace test { |
22 | 25 |
23 // NOTE: This class inherits from VoiceEngineImpl so that its clients will be | 26 // NOTE: This class inherits from VoiceEngineImpl so that its clients will be |
24 // able to get the various interfaces as usual, via T::GetInterface(). | 27 // able to get the various interfaces as usual, via T::GetInterface(). |
25 class MockVoiceEngine : public VoiceEngineImpl { | 28 class MockVoiceEngine : public VoiceEngineImpl { |
(...skipping 14 matching lines...) Expand all Loading... |
40 // around Channel, we need to make sure ChannelProxy returns the same | 43 // around Channel, we need to make sure ChannelProxy returns the same |
41 // decoder factory as the one passed in when creating an AudioReceiveStream. | 44 // decoder factory as the one passed in when creating an AudioReceiveStream. |
42 ON_CALL(*this, ChannelProxyFactory(testing::_)) | 45 ON_CALL(*this, ChannelProxyFactory(testing::_)) |
43 .WillByDefault(testing::Invoke([this](int channel_id) { | 46 .WillByDefault(testing::Invoke([this](int channel_id) { |
44 auto* proxy = | 47 auto* proxy = |
45 new testing::NiceMock<webrtc::test::MockVoEChannelProxy>(); | 48 new testing::NiceMock<webrtc::test::MockVoEChannelProxy>(); |
46 EXPECT_CALL(*proxy, GetAudioDecoderFactory()) | 49 EXPECT_CALL(*proxy, GetAudioDecoderFactory()) |
47 .WillRepeatedly(testing::ReturnRef(decoder_factory_)); | 50 .WillRepeatedly(testing::ReturnRef(decoder_factory_)); |
48 return proxy; | 51 return proxy; |
49 })); | 52 })); |
| 53 |
| 54 ON_CALL(*this, audio_device_module()) |
| 55 .WillByDefault(testing::Return(&mock_audio_device_)); |
| 56 ON_CALL(*this, audio_processing()) |
| 57 .WillByDefault(testing::Return(&mock_audio_processing_)); |
| 58 ON_CALL(*this, audio_transport()) |
| 59 .WillByDefault(testing::Return(&mock_audio_transport_)); |
50 } | 60 } |
51 ~MockVoiceEngine() /* override */ { | 61 ~MockVoiceEngine() /* override */ { |
52 // Decrease ref count before base class d-tor is called; otherwise it will | 62 // Decrease ref count before base class d-tor is called; otherwise it will |
53 // trigger an assertion. | 63 // trigger an assertion. |
54 --_ref_count; | 64 --_ref_count; |
55 } | 65 } |
56 // Allows injecting a ChannelProxy factory. | 66 // Allows injecting a ChannelProxy factory. |
57 MOCK_METHOD1(ChannelProxyFactory, voe::ChannelProxy*(int channel_id)); | 67 MOCK_METHOD1(ChannelProxyFactory, voe::ChannelProxy*(int channel_id)); |
58 | 68 |
59 // VoiceEngineImpl | 69 // VoiceEngineImpl |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 114 |
105 // VoEBase | 115 // VoEBase |
106 MOCK_METHOD1(RegisterVoiceEngineObserver, int(VoiceEngineObserver& observer)); | 116 MOCK_METHOD1(RegisterVoiceEngineObserver, int(VoiceEngineObserver& observer)); |
107 MOCK_METHOD0(DeRegisterVoiceEngineObserver, int()); | 117 MOCK_METHOD0(DeRegisterVoiceEngineObserver, int()); |
108 MOCK_METHOD3( | 118 MOCK_METHOD3( |
109 Init, | 119 Init, |
110 int(AudioDeviceModule* external_adm, | 120 int(AudioDeviceModule* external_adm, |
111 AudioProcessing* audioproc, | 121 AudioProcessing* audioproc, |
112 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory)); | 122 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory)); |
113 MOCK_METHOD0(audio_processing, AudioProcessing*()); | 123 MOCK_METHOD0(audio_processing, AudioProcessing*()); |
| 124 MOCK_METHOD0(audio_device_module, AudioDeviceModule*()); |
114 MOCK_METHOD0(Terminate, int()); | 125 MOCK_METHOD0(Terminate, int()); |
115 MOCK_METHOD0(CreateChannel, int()); | 126 MOCK_METHOD0(CreateChannel, int()); |
116 MOCK_METHOD1(CreateChannel, int(const ChannelConfig& config)); | 127 MOCK_METHOD1(CreateChannel, int(const ChannelConfig& config)); |
117 MOCK_METHOD1(DeleteChannel, int(int channel)); | 128 MOCK_METHOD1(DeleteChannel, int(int channel)); |
118 MOCK_METHOD1(StartReceive, int(int channel)); | 129 MOCK_METHOD1(StartReceive, int(int channel)); |
119 MOCK_METHOD1(StopReceive, int(int channel)); | 130 MOCK_METHOD1(StopReceive, int(int channel)); |
120 MOCK_METHOD1(StartPlayout, int(int channel)); | 131 MOCK_METHOD1(StartPlayout, int(int channel)); |
121 MOCK_METHOD1(StopPlayout, int(int channel)); | 132 MOCK_METHOD1(StopPlayout, int(int channel)); |
122 MOCK_METHOD1(StartSend, int(int channel)); | 133 MOCK_METHOD1(StartSend, int(int channel)); |
123 MOCK_METHOD1(StopSend, int(int channel)); | 134 MOCK_METHOD1(StopSend, int(int channel)); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right)); | 334 MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right)); |
324 | 335 |
325 private: | 336 private: |
326 // TODO(ossu): I'm not particularly happy about keeping the decoder factory | 337 // TODO(ossu): I'm not particularly happy about keeping the decoder factory |
327 // here, but due to how gmock is implemented, I cannot just keep it in the | 338 // here, but due to how gmock is implemented, I cannot just keep it in the |
328 // functor implementing the default version of ChannelProxyFactory, above. | 339 // functor implementing the default version of ChannelProxyFactory, above. |
329 // GMock creates an unfortunate copy of the functor, which would cause us to | 340 // GMock creates an unfortunate copy of the functor, which would cause us to |
330 // return a dangling reference. Fortunately, this should go away once | 341 // return a dangling reference. Fortunately, this should go away once |
331 // voe::Channel does. | 342 // voe::Channel does. |
332 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; | 343 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; |
| 344 |
| 345 MockAudioDeviceModule mock_audio_device_; |
| 346 MockAudioProcessing mock_audio_processing_; |
| 347 MockAudioTransport mock_audio_transport_; |
333 }; | 348 }; |
334 } // namespace test | 349 } // namespace test |
335 } // namespace webrtc | 350 } // namespace webrtc |
336 | 351 |
337 #endif // WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ | 352 #endif // WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ |
OLD | NEW |