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.h" | 7 #include "content/renderer/media/media_stream.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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 | 49 |
50 void RequestUserMedia() { | 50 void RequestUserMedia() { |
51 blink::WebUserMediaRequest user_media_request; | 51 blink::WebUserMediaRequest user_media_request; |
52 state_ = REQUEST_NOT_COMPLETE; | 52 state_ = REQUEST_NOT_COMPLETE; |
53 requestUserMedia(user_media_request); | 53 requestUserMedia(user_media_request); |
54 } | 54 } |
55 | 55 |
56 virtual void CompleteGetUserMediaRequest( | 56 virtual void CompleteGetUserMediaRequest( |
57 const blink::WebMediaStream& stream, | 57 const blink::WebMediaStream& stream, |
58 blink::WebUserMediaRequest* request_info, | 58 blink::WebUserMediaRequest* request_info, |
59 bool request_succeeded) OVERRIDE { | 59 content::MediaStreamRequestResult result) OVERRIDE { |
60 last_generated_stream_ = stream; | 60 last_generated_stream_ = stream; |
61 state_ = request_succeeded ? REQUEST_SUCCEEDED : REQUEST_FAILED; | 61 state_ = result == content::OK ? REQUEST_SUCCEEDED : REQUEST_FAILED; |
62 } | 62 } |
63 | 63 |
64 virtual blink::WebMediaStream GetMediaStream( | 64 virtual blink::WebMediaStream GetMediaStream( |
65 const GURL& url) OVERRIDE { | 65 const GURL& url) OVERRIDE { |
66 return last_generated_stream_; | 66 return last_generated_stream_; |
67 } | 67 } |
68 | 68 |
69 virtual MediaStreamVideoSource* CreateVideoSource( | 69 virtual MediaStreamVideoSource* CreateVideoSource( |
70 const StreamDeviceInfo& device, | 70 const StreamDeviceInfo& device, |
71 const MediaStreamSource::SourceStoppedCallback& stop_callback) OVERRIDE { | 71 const MediaStreamSource::SourceStoppedCallback& stop_callback) OVERRIDE { |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 // In the unit test the owning frame is NULL. | 280 // In the unit test the owning frame is NULL. |
281 ms_impl_->FrameWillClose(NULL); | 281 ms_impl_->FrameWillClose(NULL); |
282 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); | 282 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); |
283 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); | 283 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); |
284 } | 284 } |
285 | 285 |
286 // This test what happens if a source to a MediaSteam fails to start. | 286 // This test what happens if a source to a MediaSteam fails to start. |
287 TEST_F(MediaStreamImplTest, MediaSourceFailToStart) { | 287 TEST_F(MediaStreamImplTest, MediaSourceFailToStart) { |
288 ms_impl_->RequestUserMedia(); | 288 ms_impl_->RequestUserMedia(); |
289 FakeMediaStreamDispatcherComplete(); | 289 FakeMediaStreamDispatcherComplete(); |
290 FailToStartMockedVideoSource(); | 290 FailToStartMockedVideoSource(); |
perkj_chrome
2014/03/04 07:27:54
Expand this to also test the result value.
Tommy Widenflycht
2014/03/04 09:59:32
Done.
| |
291 EXPECT_EQ(MediaStreamImplUnderTest::REQUEST_FAILED, | 291 EXPECT_EQ(MediaStreamImplUnderTest::REQUEST_FAILED, |
292 ms_impl_->request_state()); | 292 ms_impl_->request_state()); |
293 EXPECT_EQ(1, ms_dispatcher_->request_stream_counter()); | 293 EXPECT_EQ(1, ms_dispatcher_->request_stream_counter()); |
294 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); | 294 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); |
295 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); | 295 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); |
296 } | 296 } |
297 | 297 |
298 // This test what happens if MediaStreamImpl is deleted while the sources of a | 298 // This test what happens if MediaStreamImpl is deleted while the sources of a |
299 // MediaStream is being started. | 299 // MediaStream is being started. |
300 TEST_F(MediaStreamImplTest, MediaStreamImplShutDown) { | 300 TEST_F(MediaStreamImplTest, MediaStreamImplShutDown) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 EXPECT_EQ(1, ms_dispatcher_->request_stream_counter()); | 345 EXPECT_EQ(1, ms_dispatcher_->request_stream_counter()); |
346 ms_impl_->FrameWillClose(NULL); | 346 ms_impl_->FrameWillClose(NULL); |
347 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); | 347 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); |
348 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); | 348 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); |
349 ms_impl_->OnLocalMediaStreamStop(mixed_desc.id().utf8()); | 349 ms_impl_->OnLocalMediaStreamStop(mixed_desc.id().utf8()); |
350 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); | 350 EXPECT_EQ(1, ms_dispatcher_->stop_audio_device_counter()); |
351 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); | 351 EXPECT_EQ(1, ms_dispatcher_->stop_video_device_counter()); |
352 } | 352 } |
353 | 353 |
354 } // namespace content | 354 } // namespace content |
OLD | NEW |