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

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

Issue 2985633002: Avoid that previous settings in APM are overwritten by WebRtcVoiceEngine (Closed)
Patch Set: Corrected unittest behavior relying on sticky settings Created 3 years, 4 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
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 } // namespace 119 } // namespace
120 120
121 // Tests that our stub library "works". 121 // Tests that our stub library "works".
122 TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) { 122 TEST(WebRtcVoiceEngineTestStubLibrary, StartupShutdown) {
123 StrictMock<webrtc::test::MockAudioDeviceModule> adm; 123 StrictMock<webrtc::test::MockAudioDeviceModule> adm;
124 AdmSetupExpectations(&adm); 124 AdmSetupExpectations(&adm);
125 rtc::scoped_refptr<StrictMock<webrtc::test::MockAudioProcessing>> apm = 125 rtc::scoped_refptr<StrictMock<webrtc::test::MockAudioProcessing>> apm =
126 new rtc::RefCountedObject< 126 new rtc::RefCountedObject<
127 StrictMock<webrtc::test::MockAudioProcessing>>(); 127 StrictMock<webrtc::test::MockAudioProcessing>>();
128 EXPECT_CALL(*apm, ApplyConfig(testing::_));
129 EXPECT_CALL(*apm, SetExtraOptions(testing::_)); 128 EXPECT_CALL(*apm, SetExtraOptions(testing::_));
130 EXPECT_CALL(*apm, Initialize()).WillOnce(Return(0)); 129 EXPECT_CALL(*apm, Initialize()).WillOnce(Return(0));
131 EXPECT_CALL(*apm, DetachAecDump()); 130 EXPECT_CALL(*apm, DetachAecDump());
132 StrictMock<MockTransmitMixer> transmit_mixer; 131 StrictMock<MockTransmitMixer> transmit_mixer;
133 EXPECT_CALL(transmit_mixer, EnableStereoChannelSwapping(false)); 132 EXPECT_CALL(transmit_mixer, EnableStereoChannelSwapping(false));
134 cricket::FakeWebRtcVoiceEngine voe(&transmit_mixer); 133 cricket::FakeWebRtcVoiceEngine voe(&transmit_mixer);
135 EXPECT_FALSE(voe.IsInited()); 134 EXPECT_FALSE(voe.IsInited());
136 { 135 {
137 cricket::WebRtcVoiceEngine engine( 136 cricket::WebRtcVoiceEngine engine(
138 &adm, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(), 137 &adm, webrtc::MockAudioEncoderFactory::CreateUnusedFactory(),
(...skipping 24 matching lines...) Expand all
163 apm_gc_(*apm_->gain_control()), 162 apm_gc_(*apm_->gain_control()),
164 apm_ec_(*apm_->echo_cancellation()), 163 apm_ec_(*apm_->echo_cancellation()),
165 apm_ns_(*apm_->noise_suppression()), 164 apm_ns_(*apm_->noise_suppression()),
166 apm_vd_(*apm_->voice_detection()), 165 apm_vd_(*apm_->voice_detection()),
167 call_(webrtc::Call::Config(&event_log_)), 166 call_(webrtc::Call::Config(&event_log_)),
168 voe_(&transmit_mixer_), 167 voe_(&transmit_mixer_),
169 override_field_trials_(field_trials) { 168 override_field_trials_(field_trials) {
170 // AudioDeviceModule. 169 // AudioDeviceModule.
171 AdmSetupExpectations(&adm_); 170 AdmSetupExpectations(&adm_);
172 // AudioProcessing. 171 // AudioProcessing.
173 EXPECT_CALL(*apm_, ApplyConfig(testing::_));
174 EXPECT_CALL(*apm_, SetExtraOptions(testing::_)); 172 EXPECT_CALL(*apm_, SetExtraOptions(testing::_));
175 EXPECT_CALL(*apm_, Initialize()).WillOnce(Return(0)); 173 EXPECT_CALL(*apm_, Initialize()).WillOnce(Return(0));
176 EXPECT_CALL(*apm_, DetachAecDump()); 174 EXPECT_CALL(*apm_, DetachAecDump());
177 // Default Options. 175 // Default Options.
178 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0)); 176 EXPECT_CALL(apm_ec_, Enable(true)).WillOnce(Return(0));
179 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0)); 177 EXPECT_CALL(apm_ec_, enable_metrics(true)).WillOnce(Return(0));
180 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0)); 178 EXPECT_CALL(apm_gc_, Enable(true)).WillOnce(Return(0));
181 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0)); 179 EXPECT_CALL(apm_ns_, Enable(true)).WillOnce(Return(0));
182 EXPECT_CALL(apm_vd_, Enable(true)).WillOnce(Return(0)); 180 EXPECT_CALL(apm_vd_, Enable(true)).WillOnce(Return(0));
183 EXPECT_CALL(transmit_mixer_, EnableStereoChannelSwapping(false)); 181 EXPECT_CALL(transmit_mixer_, EnableStereoChannelSwapping(false));
(...skipping 13 matching lines...) Expand all
197 decoder_factory, nullptr, apm_, 195 decoder_factory, nullptr, apm_,
198 new FakeVoEWrapper(&voe_))); 196 new FakeVoEWrapper(&voe_)));
199 engine_->Init(); 197 engine_->Init();
200 send_parameters_.codecs.push_back(kPcmuCodec); 198 send_parameters_.codecs.push_back(kPcmuCodec);
201 recv_parameters_.codecs.push_back(kPcmuCodec); 199 recv_parameters_.codecs.push_back(kPcmuCodec);
202 // Default Options. 200 // Default Options.
203 EXPECT_TRUE(IsHighPassFilterEnabled()); 201 EXPECT_TRUE(IsHighPassFilterEnabled());
204 } 202 }
205 203
206 bool SetupChannel() { 204 bool SetupChannel() {
207 EXPECT_CALL(*apm_, ApplyConfig(testing::_));
208 EXPECT_CALL(*apm_, SetExtraOptions(testing::_)); 205 EXPECT_CALL(*apm_, SetExtraOptions(testing::_));
209 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), 206 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(),
210 cricket::AudioOptions()); 207 cricket::AudioOptions());
211 return (channel_ != nullptr); 208 return (channel_ != nullptr);
212 } 209 }
213 210
214 bool SetupRecvStream() { 211 bool SetupRecvStream() {
215 if (!SetupChannel()) { 212 if (!SetupChannel()) {
216 return false; 213 return false;
217 } 214 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 const webrtc::AudioReceiveStream::Config& GetRecvStreamConfig(uint32_t ssrc) { 268 const webrtc::AudioReceiveStream::Config& GetRecvStreamConfig(uint32_t ssrc) {
272 return GetRecvStream(ssrc).GetConfig(); 269 return GetRecvStream(ssrc).GetConfig();
273 } 270 }
274 271
275 void SetSend(bool enable) { 272 void SetSend(bool enable) {
276 ASSERT_TRUE(channel_); 273 ASSERT_TRUE(channel_);
277 if (enable) { 274 if (enable) {
278 EXPECT_CALL(adm_, RecordingIsInitialized()).WillOnce(Return(false)); 275 EXPECT_CALL(adm_, RecordingIsInitialized()).WillOnce(Return(false));
279 EXPECT_CALL(adm_, Recording()).WillOnce(Return(false)); 276 EXPECT_CALL(adm_, Recording()).WillOnce(Return(false));
280 EXPECT_CALL(adm_, InitRecording()).WillOnce(Return(0)); 277 EXPECT_CALL(adm_, InitRecording()).WillOnce(Return(0));
281 EXPECT_CALL(*apm_, ApplyConfig(testing::_));
282 EXPECT_CALL(*apm_, SetExtraOptions(testing::_)); 278 EXPECT_CALL(*apm_, SetExtraOptions(testing::_));
283 } 279 }
284 channel_->SetSend(enable); 280 channel_->SetSend(enable);
285 } 281 }
286 282
287 void SetSendParameters(const cricket::AudioSendParameters& params) { 283 void SetSendParameters(const cricket::AudioSendParameters& params) {
288 EXPECT_CALL(*apm_, ApplyConfig(testing::_));
289 EXPECT_CALL(*apm_, SetExtraOptions(testing::_)); 284 EXPECT_CALL(*apm_, SetExtraOptions(testing::_));
290 ASSERT_TRUE(channel_); 285 ASSERT_TRUE(channel_);
291 EXPECT_TRUE(channel_->SetSendParameters(params)); 286 EXPECT_TRUE(channel_->SetSendParameters(params));
292 } 287 }
293 288
294 void SetAudioSend(uint32_t ssrc, bool enable, cricket::AudioSource* source, 289 void SetAudioSend(uint32_t ssrc, bool enable, cricket::AudioSource* source,
295 const cricket::AudioOptions* options = nullptr) { 290 const cricket::AudioOptions* options = nullptr) {
296 EXPECT_CALL(*apm_, set_output_will_be_muted(!enable)); 291 EXPECT_CALL(*apm_, set_output_will_be_muted(!enable));
297 ASSERT_TRUE(channel_); 292 ASSERT_TRUE(channel_);
298 if (enable && options) { 293 if (enable && options) {
299 EXPECT_CALL(*apm_, ApplyConfig(testing::_));
300 EXPECT_CALL(*apm_, SetExtraOptions(testing::_)); 294 EXPECT_CALL(*apm_, SetExtraOptions(testing::_));
301 } 295 }
302 EXPECT_TRUE(channel_->SetAudioSend(ssrc, enable, options, source)); 296 EXPECT_TRUE(channel_->SetAudioSend(ssrc, enable, options, source));
303 } 297 }
304 298
305 void TestInsertDtmf(uint32_t ssrc, bool caller, 299 void TestInsertDtmf(uint32_t ssrc, bool caller,
306 const cricket::AudioCodec& codec) { 300 const cricket::AudioCodec& codec) {
307 EXPECT_TRUE(SetupChannel()); 301 EXPECT_TRUE(SetupChannel());
308 if (caller) { 302 if (caller) {
309 // If this is a caller, local description will be applied and add the 303 // If this is a caller, local description will be applied and add the
(...skipping 2485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2795 EXPECT_CALL(adm_, 2789 EXPECT_CALL(adm_,
2796 BuiltInAECIsAvailable()).Times(8).WillRepeatedly(Return(false)); 2790 BuiltInAECIsAvailable()).Times(8).WillRepeatedly(Return(false));
2797 EXPECT_CALL(adm_, 2791 EXPECT_CALL(adm_,
2798 BuiltInAGCIsAvailable()).Times(8).WillRepeatedly(Return(false)); 2792 BuiltInAGCIsAvailable()).Times(8).WillRepeatedly(Return(false));
2799 EXPECT_CALL(adm_, 2793 EXPECT_CALL(adm_,
2800 BuiltInNSIsAvailable()).Times(8).WillRepeatedly(Return(false)); 2794 BuiltInNSIsAvailable()).Times(8).WillRepeatedly(Return(false));
2801 EXPECT_CALL(adm_, 2795 EXPECT_CALL(adm_,
2802 RecordingIsInitialized()).Times(2).WillRepeatedly(Return(false)); 2796 RecordingIsInitialized()).Times(2).WillRepeatedly(Return(false));
2803 EXPECT_CALL(adm_, Recording()).Times(2).WillRepeatedly(Return(false)); 2797 EXPECT_CALL(adm_, Recording()).Times(2).WillRepeatedly(Return(false));
2804 EXPECT_CALL(adm_, InitRecording()).Times(2).WillRepeatedly(Return(0)); 2798 EXPECT_CALL(adm_, InitRecording()).Times(2).WillRepeatedly(Return(0));
2805 EXPECT_CALL(*apm_, ApplyConfig(testing::_)).Times(10);
2806 EXPECT_CALL(*apm_, SetExtraOptions(testing::_)).Times(10); 2799 EXPECT_CALL(*apm_, SetExtraOptions(testing::_)).Times(10);
2807 2800
2808 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel1( 2801 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel1(
2809 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel( 2802 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel(
2810 &call_, cricket::MediaConfig(), cricket::AudioOptions()))); 2803 &call_, cricket::MediaConfig(), cricket::AudioOptions())));
2811 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel2( 2804 std::unique_ptr<cricket::WebRtcVoiceMediaChannel> channel2(
2812 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel( 2805 static_cast<cricket::WebRtcVoiceMediaChannel*>(engine_->CreateChannel(
2813 &call_, cricket::MediaConfig(), cricket::AudioOptions()))); 2806 &call_, cricket::MediaConfig(), cricket::AudioOptions())));
2814 2807
2815 // Have to add a stream to make SetSend work. 2808 // Have to add a stream to make SetSend work.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 EXPECT_EQ(expected_options, channel2->options()); 2899 EXPECT_EQ(expected_options, channel2->options());
2907 } 2900 }
2908 2901
2909 // This test verifies DSCP settings are properly applied on voice media channel. 2902 // This test verifies DSCP settings are properly applied on voice media channel.
2910 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { 2903 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
2911 EXPECT_TRUE(SetupSendStream()); 2904 EXPECT_TRUE(SetupSendStream());
2912 cricket::FakeNetworkInterface network_interface; 2905 cricket::FakeNetworkInterface network_interface;
2913 cricket::MediaConfig config; 2906 cricket::MediaConfig config;
2914 std::unique_ptr<cricket::VoiceMediaChannel> channel; 2907 std::unique_ptr<cricket::VoiceMediaChannel> channel;
2915 2908
2916 EXPECT_CALL(*apm_, ApplyConfig(testing::_)).Times(3);
2917 EXPECT_CALL(*apm_, SetExtraOptions(testing::_)).Times(3); 2909 EXPECT_CALL(*apm_, SetExtraOptions(testing::_)).Times(3);
2918 2910
2919 channel.reset( 2911 channel.reset(
2920 engine_->CreateChannel(&call_, config, cricket::AudioOptions())); 2912 engine_->CreateChannel(&call_, config, cricket::AudioOptions()));
2921 channel->SetInterface(&network_interface); 2913 channel->SetInterface(&network_interface);
2922 // Default value when DSCP is disabled should be DSCP_DEFAULT. 2914 // Default value when DSCP is disabled should be DSCP_DEFAULT.
2923 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp()); 2915 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface.dscp());
2924 2916
2925 config.enable_dscp = true; 2917 config.enable_dscp = true;
2926 channel.reset( 2918 channel.reset(
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
3482 // Without this cast, the comparison turned unsigned and, thus, failed for -1. 3474 // Without this cast, the comparison turned unsigned and, thus, failed for -1.
3483 const int num_specs = static_cast<int>(specs.size()); 3475 const int num_specs = static_cast<int>(specs.size());
3484 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); 3476 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs);
3485 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); 3477 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs);
3486 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); 3478 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1);
3487 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); 3479 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs);
3488 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); 3480 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs);
3489 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); 3481 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs);
3490 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); 3482 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs);
3491 } 3483 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698