| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/renderer/media/media_stream_extra_data.h" | 7 #include "content/renderer/media/media_stream_extra_data.h" |
| 8 #include "content/renderer/media/media_stream_impl.h" | 8 #include "content/renderer/media/media_stream_impl.h" |
| 9 #include "content/renderer/media/mock_media_stream_dependency_factory.h" | 9 #include "content/renderer/media/mock_media_stream_dependency_factory.h" |
| 10 #include "content/renderer/media/mock_media_stream_dispatcher.h" | 10 #include "content/renderer/media/mock_media_stream_dispatcher.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 last_generated_stream_ = stream; | 46 last_generated_stream_ = stream; |
| 47 state_ = request_succeeded ? REQUEST_SUCCEEDED : REQUEST_FAILED; | 47 state_ = request_succeeded ? REQUEST_SUCCEEDED : REQUEST_FAILED; |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual blink::WebMediaStream GetMediaStream( | 50 virtual blink::WebMediaStream GetMediaStream( |
| 51 const GURL& url) OVERRIDE { | 51 const GURL& url) OVERRIDE { |
| 52 return last_generated_stream_; | 52 return last_generated_stream_; |
| 53 } | 53 } |
| 54 | 54 |
| 55 using MediaStreamImpl::OnLocalMediaStreamStop; | 55 using MediaStreamImpl::OnLocalMediaStreamStop; |
| 56 using MediaStreamImpl::OnLocalSourceStop; | 56 using MediaStreamImpl::OnLocalSourceStopped; |
| 57 | 57 |
| 58 const blink::WebMediaStream& last_generated_stream() { | 58 const blink::WebMediaStream& last_generated_stream() { |
| 59 return last_generated_stream_; | 59 return last_generated_stream_; |
| 60 } | 60 } |
| 61 | 61 |
| 62 RequestState request_state() const { return state_; } | 62 RequestState request_state() const { return state_; } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 blink::WebMediaStream last_generated_stream_; | 65 blink::WebMediaStream last_generated_stream_; |
| 66 RequestState state_; | 66 RequestState state_; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // Test that the source is stopped even if there are two MediaStreams using | 229 // Test that the source is stopped even if there are two MediaStreams using |
| 230 // the same source. | 230 // the same source. |
| 231 TEST_F(MediaStreamImplTest, StopSource) { | 231 TEST_F(MediaStreamImplTest, StopSource) { |
| 232 // Generate a stream with both audio and video. | 232 // Generate a stream with both audio and video. |
| 233 blink::WebMediaStream desc1 = RequestLocalMediaStream(); | 233 blink::WebMediaStream desc1 = RequestLocalMediaStream(); |
| 234 blink::WebMediaStream desc2 = RequestLocalMediaStream(); | 234 blink::WebMediaStream desc2 = RequestLocalMediaStream(); |
| 235 | 235 |
| 236 // Stop the video source. | 236 // Stop the video source. |
| 237 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; | 237 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; |
| 238 desc1.videoTracks(video_tracks); | 238 desc1.videoTracks(video_tracks); |
| 239 ms_impl_->OnLocalSourceStop(video_tracks[0].source()); | 239 ms_impl_->OnLocalSourceStopped(video_tracks[0].source()); |
| 240 EXPECT_EQ(0, ms_dispatcher_->stop_audio_device_counter()); | 240 EXPECT_EQ(0, ms_dispatcher_->stop_audio_device_counter()); |
| 241 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); | 241 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); |
| 242 | 242 |
| 243 // Stop the audio source. | 243 // Stop the audio source. |
| 244 blink::WebVector<blink::WebMediaStreamTrack> audio_tracks; | 244 blink::WebVector<blink::WebMediaStreamTrack> audio_tracks; |
| 245 desc1.audioTracks(audio_tracks); | 245 desc1.audioTracks(audio_tracks); |
| 246 ms_impl_->OnLocalSourceStop(audio_tracks[0].source()); | 246 ms_impl_->OnLocalSourceStopped(audio_tracks[0].source()); |
| 247 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); | 247 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); |
| 248 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); | 248 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); |
| 249 } | 249 } |
| 250 | 250 |
| 251 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. | 251 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. |
| 252 // In the unit test the owning frame is NULL. | 252 // In the unit test the owning frame is NULL. |
| 253 TEST_F(MediaStreamImplTest, FrameWillClose) { | 253 TEST_F(MediaStreamImplTest, FrameWillClose) { |
| 254 // Test a stream with both audio and video. | 254 // Test a stream with both audio and video. |
| 255 blink::WebMediaStream mixed_desc = RequestLocalMediaStream(); | 255 blink::WebMediaStream mixed_desc = RequestLocalMediaStream(); |
| 256 | 256 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 EXPECT_EQ(1, ms_dispatcher_->request_stream_counter()); | 323 EXPECT_EQ(1, ms_dispatcher_->request_stream_counter()); |
| 324 ms_impl_->FrameWillClose(NULL); | 324 ms_impl_->FrameWillClose(NULL); |
| 325 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); | 325 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); |
| 326 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); | 326 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); |
| 327 ms_impl_->OnLocalMediaStreamStop(mixed_desc.id().utf8()); | 327 ms_impl_->OnLocalMediaStreamStop(mixed_desc.id().utf8()); |
| 328 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); | 328 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); |
| 329 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); | 329 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); |
| 330 } | 330 } |
| 331 | 331 |
| 332 } // namespace content | 332 } // namespace content |
| OLD | NEW |