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

Side by Side Diff: content/renderer/media/media_stream_audio_processor_unittest.cc

Issue 190643003: Fix/Add content_unittests to work for the code behind --enable-audio-track-processing (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: removed an empty line. Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "content/public/common/content_switches.h" 11 #include "content/public/common/content_switches.h"
12 #include "content/public/common/media_stream_request.h" 12 #include "content/public/common/media_stream_request.h"
13 #include "content/renderer/media/media_stream_audio_processor.h" 13 #include "content/renderer/media/media_stream_audio_processor.h"
14 #include "content/renderer/media/mock_media_constraint_factory.h"
14 #include "media/audio/audio_parameters.h" 15 #include "media/audio/audio_parameters.h"
15 #include "media/base/audio_bus.h" 16 #include "media/base/audio_bus.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 19 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
19 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" 20 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
20 21
21 using ::testing::_; 22 using ::testing::_;
22 using ::testing::AnyNumber; 23 using ::testing::AnyNumber;
23 using ::testing::AtLeast; 24 using ::testing::AtLeast;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 ProcessDataAndVerifyFormat(audio_processor, 166 ProcessDataAndVerifyFormat(audio_processor,
166 params_.sample_rate(), 167 params_.sample_rate(),
167 params_.channels(), 168 params_.channels(),
168 params_.sample_rate() / 100); 169 params_.sample_rate() / 100);
169 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives 170 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives
170 // |audio_processor|. 171 // |audio_processor|.
171 audio_processor = NULL; 172 audio_processor = NULL;
172 } 173 }
173 174
174 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { 175 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) {
175 // Setup the audio processor with enabling the flag. 176 // Setup the audio processor with the flag enabled.
176 CommandLine::ForCurrentProcess()->AppendSwitch( 177 CommandLine::ForCurrentProcess()->AppendSwitch(
177 switches::kEnableAudioTrackProcessing); 178 switches::kEnableAudioTrackProcessing);
178 blink::WebMediaConstraints constraints; 179 blink::WebMediaConstraints constraints;
179 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( 180 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
180 new WebRtcAudioDeviceImpl()); 181 new WebRtcAudioDeviceImpl());
181 scoped_refptr<MediaStreamAudioProcessor> audio_processor( 182 scoped_refptr<MediaStreamAudioProcessor> audio_processor(
182 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( 183 new talk_base::RefCountedObject<MediaStreamAudioProcessor>(
183 constraints, 0, MEDIA_DEVICE_AUDIO_CAPTURE, 184 constraints, 0, MEDIA_DEVICE_AUDIO_CAPTURE,
184 webrtc_audio_device.get())); 185 webrtc_audio_device.get()));
185 EXPECT_TRUE(audio_processor->has_audio_processing()); 186 EXPECT_TRUE(audio_processor->has_audio_processing());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( 221 new talk_base::RefCountedObject<MediaStreamAudioProcessor>(
221 constraints, 0, MEDIA_LOOPBACK_AUDIO_CAPTURE, 222 constraints, 0, MEDIA_LOOPBACK_AUDIO_CAPTURE,
222 webrtc_audio_device.get()); 223 webrtc_audio_device.get());
223 EXPECT_FALSE(audio_processor->has_audio_processing()); 224 EXPECT_FALSE(audio_processor->has_audio_processing());
224 225
225 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives 226 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives
226 // |audio_processor|. 227 // |audio_processor|.
227 audio_processor = NULL; 228 audio_processor = NULL;
228 } 229 }
229 230
231 TEST_F(MediaStreamAudioProcessorTest, TurnOffDefaultConstraints) {
232 // Setup the audio processor with enabling the flag.
233 CommandLine::ForCurrentProcess()->AppendSwitch(
234 switches::kEnableAudioTrackProcessing);
235
236 // Turn off the default constraints and pass it to MediaStreamAudioProcessor.
237 MockMediaConstraintFactory constraint_factory;
238 constraint_factory.DisableDefaultAudioConstraints();
239 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
240 new WebRtcAudioDeviceImpl());
241 scoped_refptr<MediaStreamAudioProcessor> audio_processor(
242 new talk_base::RefCountedObject<MediaStreamAudioProcessor>(
243 constraint_factory.CreateWebMediaConstraints(), 0,
244 MEDIA_DEVICE_AUDIO_CAPTURE, webrtc_audio_device.get()));
245 EXPECT_FALSE(audio_processor->has_audio_processing());
246 audio_processor->OnCaptureFormatChanged(params_);
247
248 ProcessDataAndVerifyFormat(audio_processor,
249 params_.sample_rate(),
250 params_.channels(),
251 params_.sample_rate() / 100);
252 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives
253 // |audio_processor|.
254 audio_processor = NULL;
255 }
256
230 } // namespace content 257 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_audio_processor.cc ('k') | content/renderer/media/media_stream_video_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698