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 "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "webrtc/test/mock_voe_channel_proxy.h" |
15 #include "webrtc/voice_engine/voice_engine_impl.h" | 16 #include "webrtc/voice_engine/voice_engine_impl.h" |
16 | 17 |
17 namespace webrtc { | 18 namespace webrtc { |
18 namespace test { | 19 namespace test { |
19 | 20 |
20 // NOTE: This class inherits from VoiceEngineImpl so that its clients will be | 21 // NOTE: This class inherits from VoiceEngineImpl so that its clients will be |
21 // able to get the various interfaces as usual, via T::GetInterface(). | 22 // able to get the various interfaces as usual, via T::GetInterface(). |
22 class MockVoiceEngine : public VoiceEngineImpl { | 23 class MockVoiceEngine : public VoiceEngineImpl { |
23 public: | 24 public: |
24 MockVoiceEngine() : VoiceEngineImpl(new Config(), true) { | 25 MockVoiceEngine() : VoiceEngineImpl(new Config(), true) { |
25 // Increase ref count so this object isn't automatically deleted whenever | 26 // Increase ref count so this object isn't automatically deleted whenever |
26 // interfaces are Release():d. | 27 // interfaces are Release():d. |
27 ++_ref_count; | 28 ++_ref_count; |
| 29 // We add this default behavior to make the mock easier to use in tests. It |
| 30 // will create a NiceMock of a voe::ChannelProxy. |
| 31 ON_CALL(*this, ChannelProxyFactory(testing::_)) |
| 32 .WillByDefault( |
| 33 testing::Invoke([](int channel_id) { |
| 34 return new testing::NiceMock<MockVoEChannelProxy>(); |
| 35 })); |
28 } | 36 } |
29 ~MockVoiceEngine() override { | 37 ~MockVoiceEngine() override { |
30 // Decrease ref count before base class d-tor is called; otherwise it will | 38 // Decrease ref count before base class d-tor is called; otherwise it will |
31 // trigger an assertion. | 39 // trigger an assertion. |
32 --_ref_count; | 40 --_ref_count; |
33 } | 41 } |
| 42 // Allows injecting a ChannelProxy factory. |
| 43 MOCK_METHOD1(ChannelProxyFactory, voe::ChannelProxy*(int channel_id)); |
| 44 |
| 45 // VoiceEngineImpl |
| 46 rtc::scoped_ptr<voe::ChannelProxy> GetChannelProxy(int channel_id) override { |
| 47 return rtc::scoped_ptr<voe::ChannelProxy>(ChannelProxyFactory(channel_id)); |
| 48 } |
34 | 49 |
35 // VoEAudioProcessing | 50 // VoEAudioProcessing |
36 MOCK_METHOD2(SetNsStatus, int(bool enable, NsModes mode)); | 51 MOCK_METHOD2(SetNsStatus, int(bool enable, NsModes mode)); |
37 MOCK_METHOD2(GetNsStatus, int(bool& enabled, NsModes& mode)); | 52 MOCK_METHOD2(GetNsStatus, int(bool& enabled, NsModes& mode)); |
38 MOCK_METHOD2(SetAgcStatus, int(bool enable, AgcModes mode)); | 53 MOCK_METHOD2(SetAgcStatus, int(bool enable, AgcModes mode)); |
39 MOCK_METHOD2(GetAgcStatus, int(bool& enabled, AgcModes& mode)); | 54 MOCK_METHOD2(GetAgcStatus, int(bool& enabled, AgcModes& mode)); |
40 MOCK_METHOD1(SetAgcConfig, int(AgcConfig config)); | 55 MOCK_METHOD1(SetAgcConfig, int(AgcConfig config)); |
41 MOCK_METHOD1(GetAgcConfig, int(AgcConfig& config)); | 56 MOCK_METHOD1(GetAgcConfig, int(AgcConfig& config)); |
42 MOCK_METHOD2(SetEcStatus, int(bool enable, EcModes mode)); | 57 MOCK_METHOD2(SetEcStatus, int(bool enable, EcModes mode)); |
43 MOCK_METHOD2(GetEcStatus, int(bool& enabled, EcModes& mode)); | 58 MOCK_METHOD2(GetEcStatus, int(bool& enabled, EcModes& mode)); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 int(int channel, unsigned& level)); | 328 int(int channel, unsigned& level)); |
314 MOCK_METHOD2(SetChannelOutputVolumeScaling, int(int channel, float scaling)); | 329 MOCK_METHOD2(SetChannelOutputVolumeScaling, int(int channel, float scaling)); |
315 MOCK_METHOD2(GetChannelOutputVolumeScaling, int(int channel, float& scaling)); | 330 MOCK_METHOD2(GetChannelOutputVolumeScaling, int(int channel, float& scaling)); |
316 MOCK_METHOD3(SetOutputVolumePan, int(int channel, float left, float right)); | 331 MOCK_METHOD3(SetOutputVolumePan, int(int channel, float left, float right)); |
317 MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right)); | 332 MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right)); |
318 }; | 333 }; |
319 } // namespace test | 334 } // namespace test |
320 } // namespace webrtc | 335 } // namespace webrtc |
321 | 336 |
322 #endif // WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ | 337 #endif // WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ |
OLD | NEW |