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

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

Issue 2941773002: Added initial muted state to stream creation callback, to avoid races. (Closed)
Patch Set: Added mute information to DoCompleteCreation log message. Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/renderer_host/media/audio_input_renderer_host.h" 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 AudioInputHostMsg_CreateStream_Config DefaultConfig() { 70 AudioInputHostMsg_CreateStream_Config DefaultConfig() {
71 AudioInputHostMsg_CreateStream_Config config; 71 AudioInputHostMsg_CreateStream_Config config;
72 config.params = media::AudioParameters::UnavailableDeviceParams(); 72 config.params = media::AudioParameters::UnavailableDeviceParams();
73 config.automatic_gain_control = false; 73 config.automatic_gain_control = false;
74 config.shared_memory_count = kSharedMemoryCount; 74 config.shared_memory_count = kSharedMemoryCount;
75 return config; 75 return config;
76 } 76 }
77 77
78 class MockRenderer { 78 class MockRenderer {
79 public: 79 public:
80 MOCK_METHOD5(NotifyStreamCreated, 80 MOCK_METHOD6(NotifyStreamCreated,
81 void(int /*stream_id*/, 81 void(int /*stream_id*/,
82 base::SharedMemoryHandle /*handle*/, 82 base::SharedMemoryHandle /*handle*/,
83 base::SyncSocket::TransitDescriptor /*socket_desriptor*/, 83 base::SyncSocket::TransitDescriptor /*socket_desriptor*/,
84 uint32_t /*length*/, 84 uint32_t /*length*/,
85 uint32_t /*total_segments*/)); 85 uint32_t /*total_segments*/,
86 bool initially_muted));
86 MOCK_METHOD1(NotifyStreamError, void(int /*stream_id*/)); 87 MOCK_METHOD1(NotifyStreamError, void(int /*stream_id*/));
87 MOCK_METHOD0(WasShutDown, void()); 88 MOCK_METHOD0(WasShutDown, void());
88 }; 89 };
89 90
90 // This class overrides Send to intercept the messages that the 91 // This class overrides Send to intercept the messages that the
91 // AudioInputRendererHost sends to the renderer. They are sent to 92 // AudioInputRendererHost sends to the renderer. They are sent to
92 // the provided MockRenderer instead. 93 // the provided MockRenderer instead.
93 class AudioInputRendererHostWithInterception : public AudioInputRendererHost { 94 class AudioInputRendererHostWithInterception : public AudioInputRendererHost {
94 public: 95 public:
95 AudioInputRendererHostWithInterception( 96 AudioInputRendererHostWithInterception(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return true; 132 return true;
132 } 133 }
133 134
134 void ShutdownForBadMessage() override { renderer_->WasShutDown(); } 135 void ShutdownForBadMessage() override { renderer_->WasShutDown(); }
135 136
136 void NotifyRendererStreamCreated( 137 void NotifyRendererStreamCreated(
137 int stream_id, 138 int stream_id,
138 base::SharedMemoryHandle handle, 139 base::SharedMemoryHandle handle,
139 base::SyncSocket::TransitDescriptor socket_descriptor, 140 base::SyncSocket::TransitDescriptor socket_descriptor,
140 uint32_t length, 141 uint32_t length,
141 uint32_t total_segments) { 142 uint32_t total_segments,
143 bool initially_muted) {
142 // It's difficult to check that the sync socket and shared memory is 144 // It's difficult to check that the sync socket and shared memory is
143 // valid in the gmock macros, so we check them here. 145 // valid in the gmock macros, so we check them here.
144 EXPECT_NE(base::SyncSocket::UnwrapHandle(socket_descriptor), 146 EXPECT_NE(base::SyncSocket::UnwrapHandle(socket_descriptor),
145 base::SyncSocket::kInvalidHandle); 147 base::SyncSocket::kInvalidHandle);
146 base::SharedMemory memory(handle, /*read_only*/ true); 148 base::SharedMemory memory(handle, /*read_only*/ true);
147 EXPECT_TRUE(memory.Map(length)); 149 EXPECT_TRUE(memory.Map(length));
148 renderer_->NotifyStreamCreated(stream_id, handle, socket_descriptor, length, 150 renderer_->NotifyStreamCreated(stream_id, handle, socket_descriptor, length,
149 total_segments); 151 total_segments, initially_muted);
150 EXPECT_TRUE(memory.Unmap()); 152 EXPECT_TRUE(memory.Unmap());
151 memory.Close(); 153 memory.Close();
152 } 154 }
153 155
154 void NotifyRendererStreamError(int stream_id) { 156 void NotifyRendererStreamError(int stream_id) {
155 renderer_->NotifyStreamError(stream_id); 157 renderer_->NotifyStreamError(stream_id);
156 } 158 }
157 159
158 MockRenderer* renderer_; 160 MockRenderer* renderer_;
159 }; 161 };
(...skipping 10 matching lines...) Expand all
170 StreamType type) 172 StreamType type)
171 : AudioInputController(std::move(task_runner), 173 : AudioInputController(std::move(task_runner),
172 event_handler, 174 event_handler,
173 writer, 175 writer,
174 user_input_monitor, 176 user_input_monitor,
175 params, 177 params,
176 type) { 178 type) {
177 GetTaskRunnerForTesting()->PostTask( 179 GetTaskRunnerForTesting()->PostTask(
178 FROM_HERE, 180 FROM_HERE,
179 base::BindOnce(&AudioInputController::EventHandler::OnCreated, 181 base::BindOnce(&AudioInputController::EventHandler::OnCreated,
180 base::Unretained(event_handler), 182 base::Unretained(event_handler), base::Unretained(this),
181 base::Unretained(this))); 183 false));
182 ON_CALL(*this, EnableDebugRecording(_)) 184 ON_CALL(*this, EnableDebugRecording(_))
183 .WillByDefault(SaveArg<0>(&file_name)); 185 .WillByDefault(SaveArg<0>(&file_name));
184 } 186 }
185 187
186 EventHandler* handler() { return GetHandlerForTesting(); } 188 EventHandler* handler() { return GetHandlerForTesting(); }
187 189
188 // File name that we pretend to do a debug recording to, if any. 190 // File name that we pretend to do a debug recording to, if any.
189 base::FilePath debug_file_name() { return file_name; } 191 base::FilePath debug_file_name() { return file_name; }
190 192
191 void Close(base::OnceClosure cl) override { 193 void Close(base::OnceClosure cl) override {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHostTest); 329 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHostTest);
328 }; 330 };
329 331
330 // Checks that a controller is created and a reply is sent when creating a 332 // Checks that a controller is created and a reply is sent when creating a
331 // stream. 333 // stream.
332 TEST_F(AudioInputRendererHostTest, CreateWithDefaultDevice) { 334 TEST_F(AudioInputRendererHostTest, CreateWithDefaultDevice) {
333 int session_id = 335 int session_id =
334 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId); 336 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId);
335 337
336 EXPECT_CALL(renderer_, 338 EXPECT_CALL(renderer_,
337 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount)); 339 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount, _));
338 EXPECT_CALL(controller_factory_, ControllerCreated()); 340 EXPECT_CALL(controller_factory_, ControllerCreated());
339 341
340 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 342 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
341 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 343 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
342 344
343 base::RunLoop().RunUntilIdle(); 345 base::RunLoop().RunUntilIdle();
344 EXPECT_CALL(*controller_factory_.controller(0), DidClose()); 346 EXPECT_CALL(*controller_factory_.controller(0), DidClose());
345 } 347 }
346 348
347 // If authorization hasn't been granted, only reply with and error and do 349 // If authorization hasn't been granted, only reply with and error and do
348 // nothing else. 350 // nothing else.
349 TEST_F(AudioInputRendererHostTest, CreateWithoutAuthorization_Error) { 351 TEST_F(AudioInputRendererHostTest, CreateWithoutAuthorization_Error) {
350 EXPECT_CALL(renderer_, NotifyStreamError(kStreamId)); 352 EXPECT_CALL(renderer_, NotifyStreamError(kStreamId));
351 353
352 int session_id = 0; 354 int session_id = 0;
353 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 355 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
354 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 356 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
355 base::RunLoop().RunUntilIdle(); 357 base::RunLoop().RunUntilIdle();
356 } 358 }
357 359
358 // Like CreateWithDefaultDevice but with a nondefault device. 360 // Like CreateWithDefaultDevice but with a nondefault device.
359 TEST_F(AudioInputRendererHostTest, CreateWithNonDefaultDevice) { 361 TEST_F(AudioInputRendererHostTest, CreateWithNonDefaultDevice) {
360 int session_id = Open("Nondefault device", GetRawNondefaultId()); 362 int session_id = Open("Nondefault device", GetRawNondefaultId());
361 363
362 EXPECT_CALL(renderer_, 364 EXPECT_CALL(renderer_,
363 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount)); 365 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount, _));
364 EXPECT_CALL(controller_factory_, ControllerCreated()); 366 EXPECT_CALL(controller_factory_, ControllerCreated());
365 367
366 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 368 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
367 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 369 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
368 370
369 base::RunLoop().RunUntilIdle(); 371 base::RunLoop().RunUntilIdle();
370 EXPECT_CALL(*controller_factory_.controller(0), DidClose()); 372 EXPECT_CALL(*controller_factory_.controller(0), DidClose());
371 } 373 }
372 374
373 // Checks that stream is started when calling record. 375 // Checks that stream is started when calling record.
374 TEST_F(AudioInputRendererHostTest, CreateRecordClose) { 376 TEST_F(AudioInputRendererHostTest, CreateRecordClose) {
375 int session_id = 377 int session_id =
376 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId); 378 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId);
377 379
378 EXPECT_CALL(renderer_, 380 EXPECT_CALL(renderer_,
379 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount)); 381 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount, _));
380 EXPECT_CALL(controller_factory_, ControllerCreated()); 382 EXPECT_CALL(controller_factory_, ControllerCreated());
381 383
382 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 384 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
383 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 385 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
384 base::RunLoop().RunUntilIdle(); 386 base::RunLoop().RunUntilIdle();
385 387
386 EXPECT_CALL(*controller_factory_.controller(0), Record()); 388 EXPECT_CALL(*controller_factory_.controller(0), Record());
387 EXPECT_CALL(*controller_factory_.controller(0), DidClose()); 389 EXPECT_CALL(*controller_factory_.controller(0), DidClose());
388 390
389 airh_->OnMessageReceived(AudioInputHostMsg_RecordStream(kStreamId)); 391 airh_->OnMessageReceived(AudioInputHostMsg_RecordStream(kStreamId));
390 base::RunLoop().RunUntilIdle(); 392 base::RunLoop().RunUntilIdle();
391 airh_->OnMessageReceived(AudioInputHostMsg_CloseStream(kStreamId)); 393 airh_->OnMessageReceived(AudioInputHostMsg_CloseStream(kStreamId));
392 base::RunLoop().RunUntilIdle(); 394 base::RunLoop().RunUntilIdle();
393 } 395 }
394 396
395 // In addition to the above, also check that a SetVolume message is propagated 397 // In addition to the above, also check that a SetVolume message is propagated
396 // to the controller. 398 // to the controller.
397 TEST_F(AudioInputRendererHostTest, CreateSetVolumeRecordClose) { 399 TEST_F(AudioInputRendererHostTest, CreateSetVolumeRecordClose) {
398 int session_id = 400 int session_id =
399 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId); 401 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId);
400 402
401 EXPECT_CALL(renderer_, 403 EXPECT_CALL(renderer_,
402 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount)); 404 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount, _));
403 EXPECT_CALL(controller_factory_, ControllerCreated()); 405 EXPECT_CALL(controller_factory_, ControllerCreated());
404 406
405 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 407 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
406 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 408 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
407 base::RunLoop().RunUntilIdle(); 409 base::RunLoop().RunUntilIdle();
408 410
409 EXPECT_CALL(*controller_factory_.controller(0), SetVolume(0.5)); 411 EXPECT_CALL(*controller_factory_.controller(0), SetVolume(0.5));
410 EXPECT_CALL(*controller_factory_.controller(0), Record()); 412 EXPECT_CALL(*controller_factory_.controller(0), Record());
411 EXPECT_CALL(*controller_factory_.controller(0), DidClose()); 413 EXPECT_CALL(*controller_factory_.controller(0), DidClose());
412 414
413 airh_->OnMessageReceived(AudioInputHostMsg_SetVolume(kStreamId, 0.5)); 415 airh_->OnMessageReceived(AudioInputHostMsg_SetVolume(kStreamId, 0.5));
414 airh_->OnMessageReceived(AudioInputHostMsg_RecordStream(kStreamId)); 416 airh_->OnMessageReceived(AudioInputHostMsg_RecordStream(kStreamId));
415 airh_->OnMessageReceived(AudioInputHostMsg_CloseStream(kStreamId)); 417 airh_->OnMessageReceived(AudioInputHostMsg_CloseStream(kStreamId));
416 418
417 base::RunLoop().RunUntilIdle(); 419 base::RunLoop().RunUntilIdle();
418 } 420 }
419 421
420 // Check that a too large volume is treated like a bad message and doesn't 422 // Check that a too large volume is treated like a bad message and doesn't
421 // reach the controller. 423 // reach the controller.
422 TEST_F(AudioInputRendererHostTest, SetVolumeTooLarge_BadMessage) { 424 TEST_F(AudioInputRendererHostTest, SetVolumeTooLarge_BadMessage) {
423 int session_id = 425 int session_id =
424 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId); 426 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId);
425 427
426 EXPECT_CALL(renderer_, 428 EXPECT_CALL(renderer_,
427 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount)); 429 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount, _));
428 EXPECT_CALL(controller_factory_, ControllerCreated()); 430 EXPECT_CALL(controller_factory_, ControllerCreated());
429 431
430 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 432 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
431 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 433 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
432 base::RunLoop().RunUntilIdle(); 434 base::RunLoop().RunUntilIdle();
433 435
434 EXPECT_CALL(*controller_factory_.controller(0), DidClose()); 436 EXPECT_CALL(*controller_factory_.controller(0), DidClose());
435 EXPECT_CALL(renderer_, WasShutDown()); 437 EXPECT_CALL(renderer_, WasShutDown());
436 438
437 airh_->OnMessageReceived(AudioInputHostMsg_SetVolume(kStreamId, 5)); 439 airh_->OnMessageReceived(AudioInputHostMsg_SetVolume(kStreamId, 5));
438 440
439 base::RunLoop().RunUntilIdle(); 441 base::RunLoop().RunUntilIdle();
440 } 442 }
441 443
442 // Like above. 444 // Like above.
443 TEST_F(AudioInputRendererHostTest, SetVolumeNegative_BadMessage) { 445 TEST_F(AudioInputRendererHostTest, SetVolumeNegative_BadMessage) {
444 int session_id = 446 int session_id =
445 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId); 447 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId);
446 448
447 EXPECT_CALL(renderer_, 449 EXPECT_CALL(renderer_,
448 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount)); 450 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount, _));
449 EXPECT_CALL(controller_factory_, ControllerCreated()); 451 EXPECT_CALL(controller_factory_, ControllerCreated());
450 452
451 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 453 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
452 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 454 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
453 base::RunLoop().RunUntilIdle(); 455 base::RunLoop().RunUntilIdle();
454 456
455 EXPECT_CALL(*controller_factory_.controller(0), DidClose()); 457 EXPECT_CALL(*controller_factory_.controller(0), DidClose());
456 EXPECT_CALL(renderer_, WasShutDown()); 458 EXPECT_CALL(renderer_, WasShutDown());
457 459
458 airh_->OnMessageReceived(AudioInputHostMsg_SetVolume(kStreamId, -0.5)); 460 airh_->OnMessageReceived(AudioInputHostMsg_SetVolume(kStreamId, -0.5));
459 461
460 base::RunLoop().RunUntilIdle(); 462 base::RunLoop().RunUntilIdle();
461 } 463 }
462 464
463 // Checks that a stream_id cannot be reused. 465 // Checks that a stream_id cannot be reused.
464 TEST_F(AudioInputRendererHostTest, CreateTwice_Error) { 466 TEST_F(AudioInputRendererHostTest, CreateTwice_Error) {
465 int session_id = 467 int session_id =
466 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId); 468 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId);
467 469
468 EXPECT_CALL(renderer_, 470 EXPECT_CALL(renderer_,
469 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount)); 471 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount, _));
470 EXPECT_CALL(renderer_, NotifyStreamError(kStreamId)); 472 EXPECT_CALL(renderer_, NotifyStreamError(kStreamId));
471 EXPECT_CALL(controller_factory_, ControllerCreated()); 473 EXPECT_CALL(controller_factory_, ControllerCreated());
472 474
473 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 475 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
474 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 476 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
475 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 477 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
476 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 478 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
477 base::RunLoop().RunUntilIdle(); 479 base::RunLoop().RunUntilIdle();
478 480
479 EXPECT_CALL(*controller_factory_.controller(0), DidClose()); 481 EXPECT_CALL(*controller_factory_.controller(0), DidClose());
480 } 482 }
481 483
482 // Checks that when two streams are created, messages are routed to the correct 484 // Checks that when two streams are created, messages are routed to the correct
483 // stream. Also checks that when enabling debug recording, the streams get 485 // stream. Also checks that when enabling debug recording, the streams get
484 // different file names. 486 // different file names.
485 TEST_F(AudioInputRendererHostTest, TwoStreams) { 487 TEST_F(AudioInputRendererHostTest, TwoStreams) {
486 int session_id = 488 int session_id =
487 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId); 489 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId);
488 490
489 EXPECT_CALL(renderer_, 491 EXPECT_CALL(renderer_,
490 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount)); 492 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount, _));
491 EXPECT_CALL(renderer_, 493 EXPECT_CALL(renderer_, NotifyStreamCreated(kStreamId + 1, _, _, _,
492 NotifyStreamCreated(kStreamId + 1, _, _, _, kSharedMemoryCount)); 494 kSharedMemoryCount, _));
493 EXPECT_CALL(controller_factory_, ControllerCreated()).Times(2); 495 EXPECT_CALL(controller_factory_, ControllerCreated()).Times(2);
494 496
495 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 497 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
496 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 498 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
497 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 499 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
498 kStreamId + 1, kRenderFrameId, session_id, DefaultConfig())); 500 kStreamId + 1, kRenderFrameId, session_id, DefaultConfig()));
499 base::RunLoop().RunUntilIdle(); 501 base::RunLoop().RunUntilIdle();
500 502
501 #if BUILDFLAG(ENABLE_WEBRTC) 503 #if BUILDFLAG(ENABLE_WEBRTC)
502 EXPECT_CALL(*controller_factory_.controller(0), EnableDebugRecording(_)); 504 EXPECT_CALL(*controller_factory_.controller(0), EnableDebugRecording(_));
(...skipping 14 matching lines...) Expand all
517 EXPECT_CALL(*controller_factory_.controller(1), DidClose()); 519 EXPECT_CALL(*controller_factory_.controller(1), DidClose());
518 } 520 }
519 521
520 // Checks that the stream is properly cleaned up and a notification is sent to 522 // Checks that the stream is properly cleaned up and a notification is sent to
521 // the renderer when the stream encounters an error. 523 // the renderer when the stream encounters an error.
522 TEST_F(AudioInputRendererHostTest, Error_ClosesController) { 524 TEST_F(AudioInputRendererHostTest, Error_ClosesController) {
523 int session_id = 525 int session_id =
524 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId); 526 Open("Default device", media::AudioDeviceDescription::kDefaultDeviceId);
525 527
526 EXPECT_CALL(renderer_, 528 EXPECT_CALL(renderer_,
527 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount)); 529 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount, _));
528 EXPECT_CALL(controller_factory_, ControllerCreated()); 530 EXPECT_CALL(controller_factory_, ControllerCreated());
529 531
530 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 532 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
531 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 533 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
532 534
533 base::RunLoop().RunUntilIdle(); 535 base::RunLoop().RunUntilIdle();
534 EXPECT_CALL(*controller_factory_.controller(0), DidClose()); 536 EXPECT_CALL(*controller_factory_.controller(0), DidClose());
535 EXPECT_CALL(renderer_, NotifyStreamError(kStreamId)); 537 EXPECT_CALL(renderer_, NotifyStreamError(kStreamId));
536 538
537 controller_factory_.controller(0)->handler()->OnError( 539 controller_factory_.controller(0)->handler()->OnError(
(...skipping 11 matching lines...) Expand all
549 "web-contents-media-stream://%d:%d", kRenderProcessId, kRenderFrameId); 551 "web-contents-media-stream://%d:%d", kRenderProcessId, kRenderFrameId);
550 controls.audio.stream_source = kMediaStreamSourceTab; 552 controls.audio.stream_source = kMediaStreamSourceTab;
551 std::string request_label = media_stream_manager_->MakeMediaAccessRequest( 553 std::string request_label = media_stream_manager_->MakeMediaAccessRequest(
552 kRenderProcessId, kRenderFrameId, 0, controls, SecurityOrigin(), 554 kRenderProcessId, kRenderFrameId, 0, controls, SecurityOrigin(),
553 base::Bind([](const MediaStreamDevices& devices, 555 base::Bind([](const MediaStreamDevices& devices,
554 std::unique_ptr<MediaStreamUIProxy>) {})); 556 std::unique_ptr<MediaStreamUIProxy>) {}));
555 base::RunLoop().RunUntilIdle(); 557 base::RunLoop().RunUntilIdle();
556 int session_id = Open("Tab capture", controls.audio.device_id); 558 int session_id = Open("Tab capture", controls.audio.device_id);
557 559
558 EXPECT_CALL(renderer_, 560 EXPECT_CALL(renderer_,
559 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount)); 561 NotifyStreamCreated(kStreamId, _, _, _, kSharedMemoryCount, _));
560 EXPECT_CALL(controller_factory_, ControllerCreated()); 562 EXPECT_CALL(controller_factory_, ControllerCreated());
561 563
562 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream( 564 airh_->OnMessageReceived(AudioInputHostMsg_CreateStream(
563 kStreamId, kRenderFrameId, session_id, DefaultConfig())); 565 kStreamId, kRenderFrameId, session_id, DefaultConfig()));
564 base::RunLoop().RunUntilIdle(); 566 base::RunLoop().RunUntilIdle();
565 567
566 EXPECT_CALL(*controller_factory_.controller(0), DidClose()); 568 EXPECT_CALL(*controller_factory_.controller(0), DidClose());
567 } 569 }
568 570
569 } // namespace content 571 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/audio_input_renderer_host.cc ('k') | content/browser/speech/speech_recognizer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698