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

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host_unittest.cc

Issue 12383016: Merge AssociateStreamWithProducer message into CreateStream message for both audio output and input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 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) 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/environment.h" 6 #include "base/environment.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/sync_socket.h" 10 #include "base/sync_socket.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 audio_manager_.reset(); 192 audio_manager_.reset();
193 193
194 io_thread_.reset(); 194 io_thread_.reset();
195 ui_thread_.reset(); 195 ui_thread_.reset();
196 } 196 }
197 197
198 void Create() { 198 void Create() {
199 EXPECT_CALL(*observer_, 199 EXPECT_CALL(*observer_,
200 OnSetAudioStreamStatus(_, kStreamId, "created")); 200 OnSetAudioStreamStatus(_, kStreamId, "created"));
201 // All created streams should ultimately be closed.
202 EXPECT_CALL(*observer_,
203 OnSetAudioStreamStatus(_, kStreamId, "closed"));
204
205 InSequence s;
206 // We will first receive an OnStreamCreated() signal.
207 EXPECT_CALL(*host_, OnStreamCreated(kStreamId, _)) 201 EXPECT_CALL(*host_, OnStreamCreated(kStreamId, _))
208 .WillOnce(QuitMessageLoop(message_loop_.get())); 202 .WillOnce(QuitMessageLoop(message_loop_.get()));
203 EXPECT_CALL(mirroring_manager_,
204 AddDiverter(kRenderProcessId, kRenderViewId, NotNull()))
205 .RetiresOnSaturation();
209 206
210 // Send a create stream message to the audio output stream and wait until 207 // Send a create stream message to the audio output stream and wait until
211 // we receive the created message. 208 // we receive the created message.
212 host_->OnCreateStream(kStreamId, 209 host_->OnCreateStream(kStreamId,
210 kRenderViewId,
213 media::AudioParameters( 211 media::AudioParameters(
214 media::AudioParameters::AUDIO_FAKE, 212 media::AudioParameters::AUDIO_FAKE,
215 media::CHANNEL_LAYOUT_STEREO, 213 media::CHANNEL_LAYOUT_STEREO,
216 media::AudioParameters::kAudioCDSampleRate, 16, 214 media::AudioParameters::kAudioCDSampleRate, 16,
217 media::AudioParameters::kAudioCDSampleRate / 10)); 215 media::AudioParameters::kAudioCDSampleRate / 10));
218 message_loop_->Run(); 216 message_loop_->Run();
219 217
220 // Simulate the renderer process associating a stream with a render view.
221 EXPECT_CALL(mirroring_manager_,
222 RemoveDiverter(kRenderProcessId, MSG_ROUTING_NONE, _))
223 .RetiresOnSaturation();
224 EXPECT_CALL(mirroring_manager_,
225 AddDiverter(kRenderProcessId, kRenderViewId, NotNull()))
226 .RetiresOnSaturation();
227 host_->OnAssociateStreamWithProducer(kStreamId, kRenderViewId);
228 message_loop_->RunUntilIdle();
229 // At some point in the future, a corresponding RemoveDiverter() call must 218 // At some point in the future, a corresponding RemoveDiverter() call must
230 // be made. 219 // be made.
231 EXPECT_CALL(mirroring_manager_, 220 EXPECT_CALL(mirroring_manager_,
232 RemoveDiverter(kRenderProcessId, kRenderViewId, NotNull())) 221 RemoveDiverter(kRenderProcessId, kRenderViewId, NotNull()))
233 .RetiresOnSaturation(); 222 .RetiresOnSaturation();
234 223
224 // All created streams should ultimately be closed.
225 EXPECT_CALL(*observer_,
226 OnSetAudioStreamStatus(_, kStreamId, "closed"));
227
235 // Expect the audio stream will be deleted at some later point. 228 // Expect the audio stream will be deleted at some later point.
236 EXPECT_CALL(*observer_, OnDeleteAudioStream(_, kStreamId)); 229 EXPECT_CALL(*observer_, OnDeleteAudioStream(_, kStreamId));
237 } 230 }
238 231
239 void Close() { 232 void Close() {
240 // Send a message to AudioRendererHost to tell it we want to close the 233 // Send a message to AudioRendererHost to tell it we want to close the
241 // stream. 234 // stream.
242 host_->OnCloseStream(kStreamId); 235 host_->OnCloseStream(kStreamId);
243 message_loop_->RunUntilIdle(); 236 message_loop_->RunUntilIdle();
244 } 237 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 TEST_F(AudioRendererHostTest, SimulateErrorAndClose) { 375 TEST_F(AudioRendererHostTest, SimulateErrorAndClose) {
383 Create(); 376 Create();
384 Play(); 377 Play();
385 SimulateError(); 378 SimulateError();
386 Close(); 379 Close();
387 } 380 }
388 381
389 // TODO(hclam): Add tests for data conversation in low latency mode. 382 // TODO(hclam): Add tests for data conversation in low latency mode.
390 383
391 } // namespace content 384 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/audio_renderer_host.cc ('k') | content/common/media/audio_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698