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

Side by Side Diff: media/blink/webaudiosourceprovider_impl_unittest.cc

Issue 2567143002: media::SilentSinkSuspender should simulate |delay| and |delay_timestamp| (Closed)
Patch Set: build fix content_unittets & media_blink_unittsests Created 3 years, 11 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 | « media/base/silent_sink_suspender_unittest.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 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "media/base/audio_parameters.h" 11 #include "media/base/audio_parameters.h"
12 #include "media/base/fake_audio_render_callback.h" 12 #include "media/base/fake_audio_render_callback.h"
13 #include "media/base/media_log.h" 13 #include "media/base/media_log.h"
14 #include "media/base/mock_audio_renderer_sink.h" 14 #include "media/base/mock_audio_renderer_sink.h"
15 #include "media/blink/webaudiosourceprovider_impl.h" 15 #include "media/blink/webaudiosourceprovider_impl.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/WebKit/public/platform/WebAudioSourceProviderClient.h" 18 #include "third_party/WebKit/public/platform/WebAudioSourceProviderClient.h"
19 19
20 using ::testing::_; 20 using ::testing::_;
21 21
22 namespace media { 22 namespace media {
23 23
24 namespace { 24 namespace {
25 const float kTestVolume = 0.25; 25 const float kTestVolume = 0.25;
26 const int kSampleRate = 48000;
26 27
27 class WebAudioSourceProviderImplUnderTest : public WebAudioSourceProviderImpl { 28 class WebAudioSourceProviderImplUnderTest : public WebAudioSourceProviderImpl {
28 public: 29 public:
29 WebAudioSourceProviderImplUnderTest( 30 WebAudioSourceProviderImplUnderTest(
30 scoped_refptr<SwitchableAudioRendererSink> sink) 31 scoped_refptr<SwitchableAudioRendererSink> sink)
31 : WebAudioSourceProviderImpl(std::move(sink), new MediaLog()), 32 : WebAudioSourceProviderImpl(std::move(sink), new MediaLog()),
32 fallback_sink_(new MockAudioRendererSink()) {} 33 fallback_sink_(new MockAudioRendererSink()) {}
33 34
34 MockAudioRendererSink* fallback_sink() { return fallback_sink_.get(); } 35 MockAudioRendererSink* fallback_sink() { return fallback_sink_.get(); }
35 36
(...skipping 21 matching lines...) Expand all
57 58
58 } // namespace 59 } // namespace
59 60
60 class WebAudioSourceProviderImplTest 61 class WebAudioSourceProviderImplTest
61 : public testing::TestWithParam<WaspSinkStatus>, 62 : public testing::TestWithParam<WaspSinkStatus>,
62 public blink::WebAudioSourceProviderClient { 63 public blink::WebAudioSourceProviderClient {
63 public: 64 public:
64 WebAudioSourceProviderImplTest() 65 WebAudioSourceProviderImplTest()
65 : params_(AudioParameters::AUDIO_PCM_LINEAR, 66 : params_(AudioParameters::AUDIO_PCM_LINEAR,
66 CHANNEL_LAYOUT_STEREO, 67 CHANNEL_LAYOUT_STEREO,
67 48000, 68 kSampleRate,
68 16, 69 16,
69 64), 70 64),
70 fake_callback_(0.1), 71 fake_callback_(0.1, kSampleRate),
71 mock_sink_(CreateWaspMockSink(GetParam())), 72 mock_sink_(CreateWaspMockSink(GetParam())),
72 wasp_impl_(new WebAudioSourceProviderImplUnderTest(mock_sink_)), 73 wasp_impl_(new WebAudioSourceProviderImplUnderTest(mock_sink_)),
73 expected_sink_(GetParam() == WaspSinkStatus::WASP_SINK_OK 74 expected_sink_(GetParam() == WaspSinkStatus::WASP_SINK_OK
74 ? mock_sink_.get() 75 ? mock_sink_.get()
75 : wasp_impl_->fallback_sink()) {} 76 : wasp_impl_->fallback_sink()) {}
76 77
77 virtual ~WebAudioSourceProviderImplTest() {} 78 virtual ~WebAudioSourceProviderImplTest() {}
78 79
79 void CallAllSinkMethodsAndVerify(bool verify) { 80 void CallAllSinkMethodsAndVerify(bool verify) {
80 testing::InSequence s; 81 testing::InSequence s;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 253
253 wasp_impl_->Initialize(params_, &fake_callback_); 254 wasp_impl_->Initialize(params_, &fake_callback_);
254 SetClient(this); 255 SetClient(this);
255 256
256 // Verify provideInput() is muted prior to Start() and no calls to the render 257 // Verify provideInput() is muted prior to Start() and no calls to the render
257 // callback have occurred. 258 // callback have occurred.
258 bus1->channel(0)[0] = 1; 259 bus1->channel(0)[0] = 1;
259 bus2->Zero(); 260 bus2->Zero();
260 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); 261 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer());
261 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get())); 262 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get()));
262 ASSERT_EQ(fake_callback_.last_frames_delayed(), -1); 263 ASSERT_EQ(fake_callback_.last_delay(), base::TimeDelta::Max());
263 264
264 wasp_impl_->Start(); 265 wasp_impl_->Start();
265 266
266 // Ditto for Play(). 267 // Ditto for Play().
267 bus1->channel(0)[0] = 1; 268 bus1->channel(0)[0] = 1;
268 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); 269 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer());
269 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get())); 270 ASSERT_TRUE(CompareBusses(bus1.get(), bus2.get()));
270 ASSERT_EQ(fake_callback_.last_frames_delayed(), -1); 271 ASSERT_EQ(fake_callback_.last_delay(), base::TimeDelta::Max());
271 272
272 wasp_impl_->Play(); 273 wasp_impl_->Play();
273 274
274 // Now we should get real audio data. 275 // Now we should get real audio data.
275 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer()); 276 wasp_impl_->provideInput(audio_data, params_.frames_per_buffer());
276 ASSERT_FALSE(CompareBusses(bus1.get(), bus2.get())); 277 ASSERT_FALSE(CompareBusses(bus1.get(), bus2.get()));
277 278
278 // Ensure volume adjustment is working. 279 // Ensure volume adjustment is working.
279 fake_callback_.reset(); 280 fake_callback_.reset();
280 fake_callback_.Render(base::TimeDelta(), base::TimeTicks::Now(), 0, 281 fake_callback_.Render(base::TimeDelta(), base::TimeTicks::Now(), 0,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 342 }
342 343
343 INSTANTIATE_TEST_CASE_P( 344 INSTANTIATE_TEST_CASE_P(
344 /* prefix intentionally left blank due to only one parameterization */, 345 /* prefix intentionally left blank due to only one parameterization */,
345 WebAudioSourceProviderImplTest, 346 WebAudioSourceProviderImplTest,
346 testing::Values(WaspSinkStatus::WASP_SINK_OK, 347 testing::Values(WaspSinkStatus::WASP_SINK_OK,
347 WaspSinkStatus::WASP_SINK_ERROR, 348 WaspSinkStatus::WASP_SINK_ERROR,
348 WaspSinkStatus::WASP_SINK_NULL)); 349 WaspSinkStatus::WASP_SINK_NULL));
349 350
350 } // namespace media 351 } // namespace media
OLDNEW
« no previous file with comments | « media/base/silent_sink_suspender_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698