OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 10 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 TEST_F(MediaStreamDispatcherHostTest, StopGeneratedStreamsOnChannelClosing) { | 365 TEST_F(MediaStreamDispatcherHostTest, StopGeneratedStreamsOnChannelClosing) { |
366 StreamOptions options(false, true); | 366 StreamOptions options(false, true); |
367 | 367 |
368 EXPECT_CALL(*host_, GetMediaObserver()) | 368 EXPECT_CALL(*host_, GetMediaObserver()) |
369 .WillRepeatedly(Return(media_observer_.get())); | 369 .WillRepeatedly(Return(media_observer_.get())); |
370 | 370 |
371 // Create first group of streams. | 371 // Create first group of streams. |
372 size_t generated_streams = 3; | 372 size_t generated_streams = 3; |
373 for (size_t i = 0; i < generated_streams; ++i) { | 373 for (size_t i = 0; i < generated_streams; ++i) { |
374 EXPECT_CALL(*host_, OnStreamGenerated(kRenderId, kPageRequestId + i, 0, 1)); | 374 EXPECT_CALL(*host_, OnStreamGenerated(kRenderId, kPageRequestId + i, 0, 1)); |
| 375 EXPECT_CALL(*media_observer_.get(), OnCaptureDevicesOpened(_, _, _)); |
375 host_->OnGenerateStream(kPageRequestId + i, options); | 376 host_->OnGenerateStream(kPageRequestId + i, options); |
| 377 |
| 378 // Wait until the stream is generated. |
| 379 WaitForResult(); |
376 } | 380 } |
377 EXPECT_EQ(host_->NumberOfStreams(), generated_streams); | 381 EXPECT_EQ(host_->NumberOfStreams(), generated_streams); |
378 EXPECT_CALL(*media_observer_.get(), OnCaptureDevicesOpened(_, _, _)) | |
379 .Times(3); | |
380 // Wait until the streams are all generated. | |
381 WaitForResult(); | |
382 | 382 |
383 // Calling OnChannelClosing() to cancel all the pending/generated streams. | 383 // Calling OnChannelClosing() to cancel all the pending/generated streams. |
384 EXPECT_CALL(*media_observer_.get(), OnCaptureDevicesClosed(_, _, _)) | 384 EXPECT_CALL(*media_observer_.get(), OnCaptureDevicesClosed(_, _, _)) |
385 .Times(3); | 385 .Times(3); |
386 host_->OnChannelClosing(); | 386 host_->OnChannelClosing(); |
387 | 387 |
388 // Streams should have been cleaned up. | 388 // Streams should have been cleaned up. |
389 EXPECT_EQ(host_->NumberOfStreams(), 0u); | 389 EXPECT_EQ(host_->NumberOfStreams(), 0u); |
390 } | 390 } |
391 | 391 |
392 }; // namespace media_stream | 392 }; // namespace media_stream |
OLD | NEW |