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

Side by Side Diff: webrtc/test/mock_voice_engine.h

Issue 1459083007: Open backdoor in VoiceEngineImpl to get at the actual voe::Channel objects from an ID. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years 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 unified diff | Download patch
OLDNEW
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 return a NiceMock of a voe::ChannelProxy.
31 ON_CALL(*this, GetChannelProxy(testing::_))
32 .WillByDefault(
33 testing::Invoke(this, &MockVoiceEngine::CreateChannelProxy));
kwiberg-webrtc 2015/11/25 10:44:59 Lambda here too?
the sun 2015/11/25 12:28:01 Done.
28 } 34 }
29 ~MockVoiceEngine() override { 35 ~MockVoiceEngine() override {
30 // Decrease ref count before base class d-tor is called; otherwise it will 36 // Decrease ref count before base class d-tor is called; otherwise it will
31 // trigger an assertion. 37 // trigger an assertion.
32 --_ref_count; 38 --_ref_count;
33 } 39 }
34 40
41 // VoiceEngineImpl
42 MOCK_METHOD1(GetChannelProxy, voe::ChannelProxy*(int channel_id));
43
35 // VoEAudioProcessing 44 // VoEAudioProcessing
36 MOCK_METHOD2(SetNsStatus, int(bool enable, NsModes mode)); 45 MOCK_METHOD2(SetNsStatus, int(bool enable, NsModes mode));
37 MOCK_METHOD2(GetNsStatus, int(bool& enabled, NsModes& mode)); 46 MOCK_METHOD2(GetNsStatus, int(bool& enabled, NsModes& mode));
38 MOCK_METHOD2(SetAgcStatus, int(bool enable, AgcModes mode)); 47 MOCK_METHOD2(SetAgcStatus, int(bool enable, AgcModes mode));
39 MOCK_METHOD2(GetAgcStatus, int(bool& enabled, AgcModes& mode)); 48 MOCK_METHOD2(GetAgcStatus, int(bool& enabled, AgcModes& mode));
40 MOCK_METHOD1(SetAgcConfig, int(AgcConfig config)); 49 MOCK_METHOD1(SetAgcConfig, int(AgcConfig config));
41 MOCK_METHOD1(GetAgcConfig, int(AgcConfig& config)); 50 MOCK_METHOD1(GetAgcConfig, int(AgcConfig& config));
42 MOCK_METHOD2(SetEcStatus, int(bool enable, EcModes mode)); 51 MOCK_METHOD2(SetEcStatus, int(bool enable, EcModes mode));
43 MOCK_METHOD2(GetEcStatus, int(bool& enabled, EcModes& mode)); 52 MOCK_METHOD2(GetEcStatus, int(bool& enabled, EcModes& mode));
44 MOCK_METHOD1(EnableDriftCompensation, int(bool enable)); 53 MOCK_METHOD1(EnableDriftCompensation, int(bool enable));
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 MOCK_METHOD2(GetInputMute, int(int channel, bool& enabled)); 317 MOCK_METHOD2(GetInputMute, int(int channel, bool& enabled));
309 MOCK_METHOD1(GetSpeechInputLevel, int(unsigned int& level)); 318 MOCK_METHOD1(GetSpeechInputLevel, int(unsigned int& level));
310 MOCK_METHOD2(GetSpeechOutputLevel, int(int channel, unsigned int& level)); 319 MOCK_METHOD2(GetSpeechOutputLevel, int(int channel, unsigned int& level));
311 MOCK_METHOD1(GetSpeechInputLevelFullRange, int(unsigned int& level)); 320 MOCK_METHOD1(GetSpeechInputLevelFullRange, int(unsigned int& level));
312 MOCK_METHOD2(GetSpeechOutputLevelFullRange, 321 MOCK_METHOD2(GetSpeechOutputLevelFullRange,
313 int(int channel, unsigned& level)); 322 int(int channel, unsigned& level));
314 MOCK_METHOD2(SetChannelOutputVolumeScaling, int(int channel, float scaling)); 323 MOCK_METHOD2(SetChannelOutputVolumeScaling, int(int channel, float scaling));
315 MOCK_METHOD2(GetChannelOutputVolumeScaling, int(int channel, float& scaling)); 324 MOCK_METHOD2(GetChannelOutputVolumeScaling, int(int channel, float& scaling));
316 MOCK_METHOD3(SetOutputVolumePan, int(int channel, float left, float right)); 325 MOCK_METHOD3(SetOutputVolumePan, int(int channel, float left, float right));
317 MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right)); 326 MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right));
327
328 private:
329 voe::ChannelProxy* CreateChannelProxy(int channel_id) {
330 return new testing::NiceMock<MockVoEChannelProxy>();
331 }
318 }; 332 };
319 } // namespace test 333 } // namespace test
320 } // namespace webrtc 334 } // namespace webrtc
321 335
322 #endif // WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_ 336 #endif // WEBRTC_AUDIO_MOCK_VOICE_ENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698