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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine_unittest.cc

Issue 2737633002: Remove VoEHardware interface usage. (Closed)
Patch Set: comments + compile issue Created 3 years, 9 months 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
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.cc ('k') | webrtc/test/mock_voice_engine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2008 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
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const uint32_t kSsrcZ = 0x42; 57 const uint32_t kSsrcZ = 0x42;
58 const uint32_t kSsrcW = 0x02; 58 const uint32_t kSsrcW = 0x02;
59 const uint32_t kSsrcs4[] = { 11, 200, 30, 44 }; 59 const uint32_t kSsrcs4[] = { 11, 200, 30, 44 };
60 60
61 constexpr int kRtpHistoryMs = 5000; 61 constexpr int kRtpHistoryMs = 5000;
62 62
63 class FakeVoEWrapper : public cricket::VoEWrapper { 63 class FakeVoEWrapper : public cricket::VoEWrapper {
64 public: 64 public:
65 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) 65 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine)
66 : cricket::VoEWrapper(engine, // base 66 : cricket::VoEWrapper(engine, // base
67 engine, // codec 67 engine) { // codec
68 engine) { // hw
69 } 68 }
70 }; 69 };
71 70
72 class MockTransmitMixer : public webrtc::voe::TransmitMixer { 71 class MockTransmitMixer : public webrtc::voe::TransmitMixer {
73 public: 72 public:
74 MockTransmitMixer() = default; 73 MockTransmitMixer() = default;
75 virtual ~MockTransmitMixer() = default; 74 virtual ~MockTransmitMixer() = default;
76 75
77 MOCK_METHOD1(EnableStereoChannelSwapping, void(bool enable)); 76 MOCK_METHOD1(EnableStereoChannelSwapping, void(bool enable));
78 }; 77 };
78
79 void AdmSetupExpectations(webrtc::test::MockAudioDeviceModule* adm) {
80 RTC_DCHECK(adm);
81 EXPECT_CALL(*adm, AddRef()).WillOnce(Return(0));
82 EXPECT_CALL(*adm, Release()).WillOnce(Return(0));
83 #if !defined(WEBRTC_IOS)
84 EXPECT_CALL(*adm, Recording()).WillOnce(Return(false));
85 EXPECT_CALL(*adm, SetRecordingChannel(webrtc::AudioDeviceModule::
86 ChannelType::kChannelBoth)).WillOnce(Return(0));
87 #if defined(WEBRTC_WIN)
88 EXPECT_CALL(*adm, SetRecordingDevice(
89 testing::Matcher<webrtc::AudioDeviceModule::WindowsDeviceType>(
90 webrtc::AudioDeviceModule::kDefaultCommunicationDevice)))
91 .WillOnce(Return(0));
92 #else
93 EXPECT_CALL(*adm, SetRecordingDevice(0)).WillOnce(Return(0));
94 #endif // #if defined(WEBRTC_WIN)
95 EXPECT_CALL(*adm, InitMicrophone()).WillOnce(Return(0));
96 EXPECT_CALL(*adm, StereoRecordingIsAvailable(testing::_)).WillOnce(Return(0));
97 EXPECT_CALL(*adm, SetStereoRecording(false)).WillOnce(Return(0));
98 EXPECT_CALL(*adm, Playing()).WillOnce(Return(false));
99 #if defined(WEBRTC_WIN)
100 EXPECT_CALL(*adm, SetPlayoutDevice(
101 testing::Matcher<webrtc::AudioDeviceModule::WindowsDeviceType>(
102 webrtc::AudioDeviceModule::kDefaultCommunicationDevice)))
103 .WillOnce(Return(0));
104 #else
105 EXPECT_CALL(*adm, SetPlayoutDevice(0)).WillOnce(Return(0));
106 #endif // #if defined(WEBRTC_WIN)
107 EXPECT_CALL(*adm, InitSpeaker()).WillOnce(Return(0));
108 EXPECT_CALL(*adm, StereoPlayoutIsAvailable(testing::_)).WillOnce(Return(0));
109 EXPECT_CALL(*adm, SetStereoPlayout(false)).WillOnce(Return(0));
110 #endif // #if !defined(WEBRTC_IOS)
111 EXPECT_CALL(*adm, BuiltInAECIsAvailable()).WillOnce(Return(false));
112 EXPECT_CALL(*adm, BuiltInAGCIsAvailable()).WillOnce(Return(false));
113 EXPECT_CALL(*adm, BuiltInNSIsAvailable()).WillOnce(Return(false));
114 EXPECT_CALL(*adm, SetAGC(true)).WillOnce(Return(0));
115 }
79 } // namespace 116 } // namespace
80 117
81 // Tests that our stub library "works". 118 // Tests that our stub library "works".
82 TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) { 119 TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) {
83 StrictMock<webrtc::test::MockAudioDeviceModule> adm; 120 StrictMock<webrtc::test::MockAudioDeviceModule> adm;
84 EXPECT_CALL(adm, AddRef()).WillOnce(Return(0)); 121 AdmSetupExpectations(&adm);
85 EXPECT_CALL(adm, Release()).WillOnce(Return(0));
86 EXPECT_CALL(adm, BuiltInAECIsAvailable()).WillOnce(Return(false));
87 EXPECT_CALL(adm, BuiltInAGCIsAvailable()).WillOnce(Return(false));
88 EXPECT_CALL(adm, BuiltInNSIsAvailable()).WillOnce(Return(false));
89 EXPECT_CALL(adm, SetAGC(true)).WillOnce(Return(0));
90 StrictMock<webrtc::test::MockAudioProcessing> apm; 122 StrictMock<webrtc::test::MockAudioProcessing> apm;
91 EXPECT_CALL(apm, ApplyConfig(testing::_)); 123 EXPECT_CALL(apm, ApplyConfig(testing::_));
92 EXPECT_CALL(apm, SetExtraOptions(testing::_)); 124 EXPECT_CALL(apm, SetExtraOptions(testing::_));
93 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0)); 125 EXPECT_CALL(apm, Initialize()).WillOnce(Return(0));
94 StrictMock<MockTransmitMixer> transmit_mixer; 126 StrictMock<MockTransmitMixer> transmit_mixer;
95 EXPECT_CALL(transmit_mixer, EnableStereoChannelSwapping(false)); 127 EXPECT_CALL(transmit_mixer, EnableStereoChannelSwapping(false));
96 cricket::FakeWebRtcVoiceEngine voe(&apm, &transmit_mixer); 128 cricket::FakeWebRtcVoiceEngine voe(&apm, &transmit_mixer);
97 EXPECT_FALSE(voe.IsInited()); 129 EXPECT_FALSE(voe.IsInited());
98 { 130 {
99 cricket::WebRtcVoiceEngine engine( 131 cricket::WebRtcVoiceEngine engine(
(...skipping 16 matching lines...) Expand all
116 class WebRtcVoiceEngineTestFake : public testing::Test { 148 class WebRtcVoiceEngineTestFake : public testing::Test {
117 public: 149 public:
118 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} 150 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {}
119 151
120 explicit WebRtcVoiceEngineTestFake(const char* field_trials) 152 explicit WebRtcVoiceEngineTestFake(const char* field_trials)
121 : apm_gc_(*apm_.gain_control()), apm_ec_(*apm_.echo_cancellation()), 153 : apm_gc_(*apm_.gain_control()), apm_ec_(*apm_.echo_cancellation()),
122 apm_ns_(*apm_.noise_suppression()), apm_vd_(*apm_.voice_detection()), 154 apm_ns_(*apm_.noise_suppression()), apm_vd_(*apm_.voice_detection()),
123 call_(webrtc::Call::Config(&event_log_)), voe_(&apm_, &transmit_mixer_), 155 call_(webrtc::Call::Config(&event_log_)), voe_(&apm_, &transmit_mixer_),
124 override_field_trials_(field_trials) { 156 override_field_trials_(field_trials) {
125 // AudioDeviceModule. 157 // AudioDeviceModule.
126 EXPECT_CALL(adm_, AddRef()).WillOnce(Return(0)); 158 AdmSetupExpectations(&adm_);
127 EXPECT_CALL(adm_, Release()).WillOnce(Return(0));
128 EXPECT_CALL(adm_, BuiltInAECIsAvailable()).WillOnce(Return(false));
129 EXPECT_CALL(adm_, BuiltInAGCIsAvailable()).WillOnce(Return(false));
130 EXPECT_CALL(adm_, BuiltInNSIsAvailable()).WillOnce(Return(false));
131 EXPECT_CALL(adm_, SetAGC(true)).WillOnce(Return(0));
132 // AudioProcessing. 159 // AudioProcessing.
133 EXPECT_CALL(apm_, ApplyConfig(testing::_)); 160 EXPECT_CALL(apm_, ApplyConfig(testing::_));
134 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); 161 EXPECT_CALL(apm_, SetExtraOptions(testing::_));
135 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0)); 162 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0));
136 // Default Options. 163 // Default Options.
137 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); 164 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0));
138 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); 165 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0));
139 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0)); 166 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0));
140 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0)); 167 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0));
141 EXPECT_CALL(apm_vd_, Enable(true)).WillOnce(Return(0)); 168 EXPECT_CALL(apm_vd_, Enable(true)).WillOnce(Return(0));
(...skipping 3667 matching lines...) Expand 10 before | Expand all | Expand 10 after
3809 // Without this cast, the comparison turned unsigned and, thus, failed for -1. 3836 // Without this cast, the comparison turned unsigned and, thus, failed for -1.
3810 const int num_specs = static_cast<int>(specs.size()); 3837 const int num_specs = static_cast<int>(specs.size());
3811 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); 3838 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs);
3812 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); 3839 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs);
3813 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); 3840 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1);
3814 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); 3841 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs);
3815 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); 3842 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs);
3816 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); 3843 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs);
3817 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); 3844 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs);
3818 } 3845 }
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.cc ('k') | webrtc/test/mock_voice_engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698