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. |
27 MockVoiceEngine() : VoiceEngineImpl(new Config(), true) { | 31 MockVoiceEngine() : VoiceEngineImpl(new Config(), true) { |
28 // Increase ref count so this object isn't automatically deleted whenever | 32 // Increase ref count so this object isn't automatically deleted whenever |
29 // interfaces are Release():d. | 33 // interfaces are Release():d. |
30 ++_ref_count; | 34 ++_ref_count; |
31 // We add this default behavior to make the mock easier to use in tests. It | 35 // We add this default behavior to make the mock easier to use in tests. It |
32 // will create a NiceMock of a voe::ChannelProxy. | 36 // will create a NiceMock of a voe::ChannelProxy. |
33 ON_CALL(*this, ChannelProxyFactory(testing::_)) | 37 ON_CALL(*this, ChannelProxyFactory(testing::_)) |
34 .WillByDefault( | 38 .WillByDefault( |
35 testing::Invoke([](int channel_id) { | 39 testing::Invoke([](int channel_id) { |
36 return new testing::NiceMock<MockVoEChannelProxy>(); | 40 return new testing::NiceMock<MockVoEChannelProxy>(); |
37 })); | 41 })); |
38 } | 42 } |
39 ~MockVoiceEngine() override { | 43 ~MockVoiceEngine() /* override */ { |
40 // Decrease ref count before base class d-tor is called; otherwise it will | 44 // Decrease ref count before base class d-tor is called; otherwise it will |
41 // trigger an assertion. | 45 // trigger an assertion. |
42 --_ref_count; | 46 --_ref_count; |
43 } | 47 } |
44 // Allows injecting a ChannelProxy factory. | 48 // Allows injecting a ChannelProxy factory. |
45 MOCK_METHOD1(ChannelProxyFactory, voe::ChannelProxy*(int channel_id)); | 49 MOCK_METHOD1(ChannelProxyFactory, voe::ChannelProxy*(int channel_id)); |
46 | 50 |
47 // VoiceEngineImpl | 51 // VoiceEngineImpl |
48 std::unique_ptr<voe::ChannelProxy> GetChannelProxy(int channel_id) override { | 52 std::unique_ptr<voe::ChannelProxy> GetChannelProxy( |
| 53 int channel_id) /* override */ { |
49 return std::unique_ptr<voe::ChannelProxy>(ChannelProxyFactory(channel_id)); | 54 return std::unique_ptr<voe::ChannelProxy>(ChannelProxyFactory(channel_id)); |
50 } | 55 } |
51 | 56 |
52 // VoEAudioProcessing | 57 // VoEAudioProcessing |
53 MOCK_METHOD2(SetNsStatus, int(bool enable, NsModes mode)); | 58 MOCK_METHOD2(SetNsStatus, int(bool enable, NsModes mode)); |
54 MOCK_METHOD2(GetNsStatus, int(bool& enabled, NsModes& mode)); | 59 MOCK_METHOD2(GetNsStatus, int(bool& enabled, NsModes& mode)); |
55 MOCK_METHOD2(SetAgcStatus, int(bool enable, AgcModes mode)); | 60 MOCK_METHOD2(SetAgcStatus, int(bool enable, AgcModes mode)); |
56 MOCK_METHOD2(GetAgcStatus, int(bool& enabled, AgcModes& mode)); | 61 MOCK_METHOD2(GetAgcStatus, int(bool& enabled, AgcModes& mode)); |
57 MOCK_METHOD1(SetAgcConfig, int(AgcConfig config)); | 62 MOCK_METHOD1(SetAgcConfig, int(AgcConfig config)); |
58 MOCK_METHOD1(GetAgcConfig, int(AgcConfig& config)); | 63 MOCK_METHOD1(GetAgcConfig, int(AgcConfig& config)); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 int(int channel, unsigned& level)); | 319 int(int channel, unsigned& level)); |
315 MOCK_METHOD2(SetChannelOutputVolumeScaling, int(int channel, float scaling)); | 320 MOCK_METHOD2(SetChannelOutputVolumeScaling, int(int channel, float scaling)); |
316 MOCK_METHOD2(GetChannelOutputVolumeScaling, int(int channel, float& scaling)); | 321 MOCK_METHOD2(GetChannelOutputVolumeScaling, int(int channel, float& scaling)); |
317 MOCK_METHOD3(SetOutputVolumePan, int(int channel, float left, float right)); | 322 MOCK_METHOD3(SetOutputVolumePan, int(int channel, float left, float right)); |
318 MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right)); | 323 MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right)); |
319 }; | 324 }; |
320 } // namespace test | 325 } // namespace test |
321 } // namespace webrtc | 326 } // namespace webrtc |
322 | 327 |
323 #endif // WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ | 328 #endif // WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ |
OLD | NEW |