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 "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "webrtc/test/mock_voe_channel_proxy.h" | 17 #include "webrtc/test/mock_voe_channel_proxy.h" |
18 #include "webrtc/voice_engine/voice_engine_impl.h" | 18 #include "webrtc/voice_engine/voice_engine_impl.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 namespace test { | 21 namespace test { |
22 | 22 |
23 // NOTE: This class inherits from VoiceEngineImpl so that its clients will be | 23 // NOTE: This class inherits from VoiceEngineImpl so that its clients will be |
24 // able to get the various interfaces as usual, via T::GetInterface(). | 24 // able to get the various interfaces as usual, via T::GetInterface(). |
25 class MockVoiceEngine : public VoiceEngineImpl { | 25 class MockVoiceEngine : public VoiceEngineImpl { |
26 public: | 26 public: |
27 // TODO(nisse): Valid overrides commented out, because the gmock | |
28 // methods don't use any override declarations, and we want to avoid | |
29 // warnings from -Winconsistent-missing-override. See | |
30 // http://crbug.com/428099. | |
31 MockVoiceEngine() : VoiceEngineImpl(new Config(), true) { | 27 MockVoiceEngine() : VoiceEngineImpl(new Config(), true) { |
32 // Increase ref count so this object isn't automatically deleted whenever | 28 // Increase ref count so this object isn't automatically deleted whenever |
33 // interfaces are Release():d. | 29 // interfaces are Release():d. |
34 ++_ref_count; | 30 ++_ref_count; |
35 // We add this default behavior to make the mock easier to use in tests. It | 31 // We add this default behavior to make the mock easier to use in tests. It |
36 // will create a NiceMock of a voe::ChannelProxy. | 32 // will create a NiceMock of a voe::ChannelProxy. |
37 ON_CALL(*this, ChannelProxyFactory(testing::_)) | 33 ON_CALL(*this, ChannelProxyFactory(testing::_)) |
38 .WillByDefault( | 34 .WillByDefault( |
39 testing::Invoke([](int channel_id) { | 35 testing::Invoke([](int channel_id) { |
40 return new testing::NiceMock<MockVoEChannelProxy>(); | 36 return new testing::NiceMock<MockVoEChannelProxy>(); |
41 })); | 37 })); |
42 } | 38 } |
43 ~MockVoiceEngine() /* override */ { | 39 ~MockVoiceEngine() override { |
44 // Decrease ref count before base class d-tor is called; otherwise it will | 40 // Decrease ref count before base class d-tor is called; otherwise it will |
45 // trigger an assertion. | 41 // trigger an assertion. |
46 --_ref_count; | 42 --_ref_count; |
47 } | 43 } |
48 // Allows injecting a ChannelProxy factory. | 44 // Allows injecting a ChannelProxy factory. |
49 MOCK_METHOD1(ChannelProxyFactory, voe::ChannelProxy*(int channel_id)); | 45 MOCK_METHOD1(ChannelProxyFactory, voe::ChannelProxy*(int channel_id)); |
50 | 46 |
51 // VoiceEngineImpl | 47 // VoiceEngineImpl |
52 std::unique_ptr<voe::ChannelProxy> GetChannelProxy( | 48 std::unique_ptr<voe::ChannelProxy> GetChannelProxy(int channel_id) override { |
53 int channel_id) /* override */ { | |
54 return std::unique_ptr<voe::ChannelProxy>(ChannelProxyFactory(channel_id)); | 49 return std::unique_ptr<voe::ChannelProxy>(ChannelProxyFactory(channel_id)); |
55 } | 50 } |
56 | 51 |
57 // VoEAudioProcessing | 52 // VoEAudioProcessing |
58 MOCK_METHOD2(SetNsStatus, int(bool enable, NsModes mode)); | 53 MOCK_METHOD2(SetNsStatus, int(bool enable, NsModes mode)); |
59 MOCK_METHOD2(GetNsStatus, int(bool& enabled, NsModes& mode)); | 54 MOCK_METHOD2(GetNsStatus, int(bool& enabled, NsModes& mode)); |
60 MOCK_METHOD2(SetAgcStatus, int(bool enable, AgcModes mode)); | 55 MOCK_METHOD2(SetAgcStatus, int(bool enable, AgcModes mode)); |
61 MOCK_METHOD2(GetAgcStatus, int(bool& enabled, AgcModes& mode)); | 56 MOCK_METHOD2(GetAgcStatus, int(bool& enabled, AgcModes& mode)); |
62 MOCK_METHOD1(SetAgcConfig, int(AgcConfig config)); | 57 MOCK_METHOD1(SetAgcConfig, int(AgcConfig config)); |
63 MOCK_METHOD1(GetAgcConfig, int(AgcConfig& config)); | 58 MOCK_METHOD1(GetAgcConfig, int(AgcConfig& config)); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 int(int channel, unsigned& level)); | 314 int(int channel, unsigned& level)); |
320 MOCK_METHOD2(SetChannelOutputVolumeScaling, int(int channel, float scaling)); | 315 MOCK_METHOD2(SetChannelOutputVolumeScaling, int(int channel, float scaling)); |
321 MOCK_METHOD2(GetChannelOutputVolumeScaling, int(int channel, float& scaling)); | 316 MOCK_METHOD2(GetChannelOutputVolumeScaling, int(int channel, float& scaling)); |
322 MOCK_METHOD3(SetOutputVolumePan, int(int channel, float left, float right)); | 317 MOCK_METHOD3(SetOutputVolumePan, int(int channel, float left, float right)); |
323 MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right)); | 318 MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right)); |
324 }; | 319 }; |
325 } // namespace test | 320 } // namespace test |
326 } // namespace webrtc | 321 } // namespace webrtc |
327 | 322 |
328 #endif // WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ | 323 #endif // WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ |
OLD | NEW |