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

Side by Side Diff: media/base/audio_renderer_mixer_unittest.cc

Issue 301223012: Deliver RenderCallbackErrors even when mixer inputs are paused. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: List! Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « media/base/audio_renderer_mixer_input.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 half_fill_(false) { 44 half_fill_(false) {
45 // Create input and output parameters based on test parameters. 45 // Create input and output parameters based on test parameters.
46 input_parameters_ = AudioParameters( 46 input_parameters_ = AudioParameters(
47 AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, 47 AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout,
48 std::tr1::get<0>(GetParam()), kBitsPerChannel, kHighLatencyBufferSize); 48 std::tr1::get<0>(GetParam()), kBitsPerChannel, kHighLatencyBufferSize);
49 output_parameters_ = AudioParameters( 49 output_parameters_ = AudioParameters(
50 AudioParameters::AUDIO_PCM_LOW_LATENCY, kChannelLayout, 50 AudioParameters::AUDIO_PCM_LOW_LATENCY, kChannelLayout,
51 std::tr1::get<1>(GetParam()), 16, kLowLatencyBufferSize); 51 std::tr1::get<1>(GetParam()), 16, kLowLatencyBufferSize);
52 52
53 sink_ = new MockAudioRendererSink(); 53 sink_ = new MockAudioRendererSink();
54 EXPECT_CALL(*sink_.get(), Start()); 54 EXPECT_CALL(*sink_, Start());
55 EXPECT_CALL(*sink_.get(), Stop()); 55 EXPECT_CALL(*sink_, Stop());
56 56
57 mixer_.reset(new AudioRendererMixer( 57 mixer_.reset(new AudioRendererMixer(
58 input_parameters_, output_parameters_, sink_)); 58 input_parameters_, output_parameters_, sink_));
59 mixer_callback_ = sink_->callback(); 59 mixer_callback_ = sink_->callback();
60 60
61 audio_bus_ = AudioBus::Create(output_parameters_); 61 audio_bus_ = AudioBus::Create(output_parameters_);
62 expected_audio_bus_ = AudioBus::Create(output_parameters_); 62 expected_audio_bus_ = AudioBus::Create(output_parameters_);
63 63
64 // Allocate one callback for generating expected results. 64 // Allocate one callback for generating expected results.
65 double step = kSineCycles / static_cast<double>( 65 double step = kSineCycles / static_cast<double>(
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 mixer_inputs_[i]->Start(); 386 mixer_inputs_[i]->Start();
387 mixer_inputs_[i]->Play(); 387 mixer_inputs_[i]->Play();
388 EXPECT_CALL(*fake_callbacks_[i], OnRenderError()).Times(1); 388 EXPECT_CALL(*fake_callbacks_[i], OnRenderError()).Times(1);
389 } 389 }
390 390
391 mixer_callback_->OnRenderError(); 391 mixer_callback_->OnRenderError();
392 for (size_t i = 0; i < mixer_inputs_.size(); ++i) 392 for (size_t i = 0; i < mixer_inputs_.size(); ++i)
393 mixer_inputs_[i]->Stop(); 393 mixer_inputs_[i]->Stop();
394 } 394 }
395 395
396 TEST_P(AudioRendererMixerBehavioralTest, OnRenderErrorPausedInput) {
397 InitializeInputs(kMixerInputs);
398
399 for (size_t i = 0; i < mixer_inputs_.size(); ++i)
400 EXPECT_CALL(*fake_callbacks_[i], OnRenderError()).Times(1);
401
402 // Fire the error before attaching any inputs. Ensure an error is recieved
403 // even if the input is not connected.
404 mixer_callback_->OnRenderError();
405
406 for (size_t i = 0; i < mixer_inputs_.size(); ++i)
407 mixer_inputs_[i]->Stop();
408 }
409
396 // Ensure constructing an AudioRendererMixerInput, but not initializing it does 410 // Ensure constructing an AudioRendererMixerInput, but not initializing it does
397 // not call RemoveMixer(). 411 // not call RemoveMixer().
398 TEST_P(AudioRendererMixerBehavioralTest, NoInitialize) { 412 TEST_P(AudioRendererMixerBehavioralTest, NoInitialize) {
399 EXPECT_CALL(*this, RemoveMixer(testing::_)).Times(0); 413 EXPECT_CALL(*this, RemoveMixer(testing::_)).Times(0);
400 scoped_refptr<AudioRendererMixerInput> audio_renderer_mixer = 414 scoped_refptr<AudioRendererMixerInput> audio_renderer_mixer =
401 new AudioRendererMixerInput( 415 new AudioRendererMixerInput(
402 base::Bind(&AudioRendererMixerTest::GetMixer, 416 base::Bind(&AudioRendererMixerTest::GetMixer,
403 base::Unretained(this)), 417 base::Unretained(this)),
404 base::Bind(&AudioRendererMixerTest::RemoveMixer, 418 base::Bind(&AudioRendererMixerTest::RemoveMixer,
405 base::Unretained(this))); 419 base::Unretained(this)));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 472
459 // Test cases for behavior which is independent of parameters. Values() doesn't 473 // Test cases for behavior which is independent of parameters. Values() doesn't
460 // support single item lists and we don't want these test cases to run for every 474 // support single item lists and we don't want these test cases to run for every
461 // parameter set. 475 // parameter set.
462 INSTANTIATE_TEST_CASE_P( 476 INSTANTIATE_TEST_CASE_P(
463 AudioRendererMixerBehavioralTest, AudioRendererMixerBehavioralTest, 477 AudioRendererMixerBehavioralTest, AudioRendererMixerBehavioralTest,
464 testing::ValuesIn(std::vector<AudioRendererMixerTestData>( 478 testing::ValuesIn(std::vector<AudioRendererMixerTestData>(
465 1, std::tr1::make_tuple(44100, 44100, 0)))); 479 1, std::tr1::make_tuple(44100, 44100, 0))));
466 480
467 } // namespace media 481 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_renderer_mixer_input.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698