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

Side by Side Diff: content/browser/media/media_internals_unittest.cc

Issue 1304973005: Refactor AudioParameters member setting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More cross-platform. Created 5 years, 3 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/media/media_internals.h" 5 #include "content/browser/media/media_internals.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 ExpectString("captureApi", "QTKit"); 220 ExpectString("captureApi", "QTKit");
221 #elif defined(OS_ANDROID) 221 #elif defined(OS_ANDROID)
222 ExpectString("captureApi", "Camera API2 Legacy"); 222 ExpectString("captureApi", "Camera API2 Legacy");
223 #endif 223 #endif
224 } 224 }
225 225
226 class MediaInternalsAudioLogTest 226 class MediaInternalsAudioLogTest
227 : public MediaInternalsTestBase, 227 : public MediaInternalsTestBase,
228 public testing::TestWithParam<media::AudioLogFactory::AudioComponent> { 228 public testing::TestWithParam<media::AudioLogFactory::AudioComponent> {
229 public: 229 public:
230 MediaInternalsAudioLogTest() : 230 MediaInternalsAudioLogTest()
231 update_cb_(base::Bind(&MediaInternalsAudioLogTest::UpdateCallbackImpl, 231 : update_cb_(base::Bind(&MediaInternalsAudioLogTest::UpdateCallbackImpl,
232 base::Unretained(this))), 232 base::Unretained(this))),
233 test_params_(media::AudioParameters::AUDIO_PCM_LINEAR, 233 test_params_(MakeAudioParams()),
234 media::CHANNEL_LAYOUT_MONO, 234 test_component_(GetParam()),
235 48000, 235 audio_log_(media_internals_->CreateAudioLog(test_component_)) {
236 16,
237 128,
238 media::AudioParameters::ECHO_CANCELLER |
239 media::AudioParameters::DUCKING),
240 test_component_(GetParam()),
241 audio_log_(media_internals_->CreateAudioLog(test_component_)) {
242 media_internals_->AddUpdateCallback(update_cb_); 236 media_internals_->AddUpdateCallback(update_cb_);
243 } 237 }
244 238
245 virtual ~MediaInternalsAudioLogTest() { 239 virtual ~MediaInternalsAudioLogTest() {
246 media_internals_->RemoveUpdateCallback(update_cb_); 240 media_internals_->RemoveUpdateCallback(update_cb_);
247 } 241 }
248 242
249 protected: 243 protected:
250 MediaInternals::UpdateCallback update_cb_; 244 MediaInternals::UpdateCallback update_cb_;
251 const media::AudioParameters test_params_; 245 const media::AudioParameters test_params_;
252 const media::AudioLogFactory::AudioComponent test_component_; 246 const media::AudioLogFactory::AudioComponent test_component_;
253 scoped_ptr<media::AudioLog> audio_log_; 247 scoped_ptr<media::AudioLog> audio_log_;
248
249 private:
250 static media::AudioParameters MakeAudioParams() {
251 media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LINEAR,
252 media::CHANNEL_LAYOUT_MONO, 48000, 16, 128);
253 params.set_effects(media::AudioParameters::ECHO_CANCELLER |
254 media::AudioParameters::DUCKING);
255 return params;
256 }
254 }; 257 };
255 258
256 TEST_P(MediaInternalsAudioLogTest, AudioLogCreateStartStopErrorClose) { 259 TEST_P(MediaInternalsAudioLogTest, AudioLogCreateStartStopErrorClose) {
257 audio_log_->OnCreated(kTestComponentID, test_params_, kTestDeviceID); 260 audio_log_->OnCreated(kTestComponentID, test_params_, kTestDeviceID);
258 base::RunLoop().RunUntilIdle(); 261 base::RunLoop().RunUntilIdle();
259 262
260 ExpectString("channel_layout", 263 ExpectString("channel_layout",
261 media::ChannelLayoutToString(test_params_.channel_layout())); 264 media::ChannelLayoutToString(test_params_.channel_layout()));
262 ExpectInt("sample_rate", test_params_.sample_rate()); 265 ExpectInt("sample_rate", test_params_.sample_rate());
263 ExpectInt("frames_per_buffer", test_params_.frames_per_buffer()); 266 ExpectInt("frames_per_buffer", test_params_.frames_per_buffer());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 ExpectStatus("closed"); 305 ExpectStatus("closed");
303 } 306 }
304 307
305 INSTANTIATE_TEST_CASE_P( 308 INSTANTIATE_TEST_CASE_P(
306 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values( 309 MediaInternalsAudioLogTest, MediaInternalsAudioLogTest, testing::Values(
307 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, 310 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER,
308 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, 311 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER,
309 media::AudioLogFactory::AUDIO_OUTPUT_STREAM)); 312 media::AudioLogFactory::AUDIO_OUTPUT_STREAM));
310 313
311 } // namespace content 314 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698