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

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

Issue 8980008: Integrate HTMLMediaElement with Web Audio API's MediaElementAudioSourceNode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/process_util.h" 8 #include "base/process_util.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // This callback can be posted on the IO thread and will signal an event when 47 // This callback can be posted on the IO thread and will signal an event when
48 // done. The caller can then wait for this signal to ensure that no 48 // done. The caller can then wait for this signal to ensure that no
49 // additional tasks remain in the task queue. 49 // additional tasks remain in the task queue.
50 void WaitCallback(base::WaitableEvent* event) { 50 void WaitCallback(base::WaitableEvent* event) {
51 event->Signal(); 51 event->Signal();
52 } 52 }
53 53
54 // Class we would be testing. 54 // Class we would be testing.
55 class TestAudioRendererImpl : public AudioRendererImpl { 55 class TestAudioRendererImpl : public AudioRendererImpl {
56 public: 56 public:
57 explicit TestAudioRendererImpl() 57 explicit TestAudioRendererImpl(media::AudioRendererSink* sink)
58 : AudioRendererImpl() { 58 : AudioRendererImpl(sink) {
59 } 59 }
60 }; 60 };
61 61
62 class AudioRendererImplTest 62 class AudioRendererImplTest
63 : public ::testing::Test, 63 : public ::testing::Test,
64 public IPC::Channel::Listener { 64 public IPC::Channel::Listener {
65 public: 65 public:
66 // IPC::Channel::Listener implementation. 66 // IPC::Channel::Listener implementation.
67 virtual bool OnMessageReceived(const IPC::Message& message) { 67 virtual bool OnMessageReceived(const IPC::Message& message) {
68 NOTIMPLEMENTED(); 68 NOTIMPLEMENTED();
(...skipping 24 matching lines...) Expand all
93 // Setup expectations for initialization. 93 // Setup expectations for initialization.
94 decoder_ = new media::MockAudioDecoder(); 94 decoder_ = new media::MockAudioDecoder();
95 95
96 EXPECT_CALL(*decoder_, bits_per_channel()) 96 EXPECT_CALL(*decoder_, bits_per_channel())
97 .WillRepeatedly(Return(16)); 97 .WillRepeatedly(Return(16));
98 EXPECT_CALL(*decoder_, channel_layout()) 98 EXPECT_CALL(*decoder_, channel_layout())
99 .WillRepeatedly(Return(CHANNEL_LAYOUT_MONO)); 99 .WillRepeatedly(Return(CHANNEL_LAYOUT_MONO));
100 EXPECT_CALL(*decoder_, samples_per_second()) 100 EXPECT_CALL(*decoder_, samples_per_second())
101 .WillRepeatedly(Return(44100)); 101 .WillRepeatedly(Return(44100));
102 102
103 // Create a sink for the audio renderer.
104 scoped_refptr<media::AudioRendererSink> default_sink =
105 new AudioDevice();
106
103 // Create and initialize the audio renderer. 107 // Create and initialize the audio renderer.
104 renderer_ = new TestAudioRendererImpl(); 108 renderer_ = new TestAudioRendererImpl(default_sink.get());
105 renderer_->Initialize(decoder_, media::NewExpectedClosure(), 109 renderer_->Initialize(decoder_, media::NewExpectedClosure(),
106 NewUnderflowClosure()); 110 NewUnderflowClosure());
107 111
108 // We need an event to verify that all tasks are done before leaving 112 // We need an event to verify that all tasks are done before leaving
109 // our tests. 113 // our tests.
110 event_.reset(new base::WaitableEvent(false, false)); 114 event_.reset(new base::WaitableEvent(false, false));
111 } 115 }
112 116
113 virtual void TearDown() { 117 virtual void TearDown() {
114 mock_process_.reset(); 118 mock_process_.reset();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 base::Time time_now = base::Time(); // Null time by default. 178 base::Time time_now = base::Time(); // Null time by default.
175 renderer_->set_earliest_end_time(time_now); 179 renderer_->set_earliest_end_time(time_now);
176 renderer_->UpdateEarliestEndTime(renderer_->bytes_per_second(), 180 renderer_->UpdateEarliestEndTime(renderer_->bytes_per_second(),
177 base::TimeDelta::FromMilliseconds(100), 181 base::TimeDelta::FromMilliseconds(100),
178 time_now); 182 time_now);
179 int time_delta = (renderer_->earliest_end_time() - time_now).InMilliseconds(); 183 int time_delta = (renderer_->earliest_end_time() - time_now).InMilliseconds();
180 EXPECT_EQ(1100, time_delta); 184 EXPECT_EQ(1100, time_delta);
181 renderer_->Stop(media::NewExpectedClosure()); 185 renderer_->Stop(media::NewExpectedClosure());
182 WaitForIOThreadCompletion(); 186 WaitForIOThreadCompletion();
183 } 187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698