| 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/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "content/renderer/media/media_stream_extra_data.h" | 8 #include "content/renderer/media/media_stream_extra_data.h" |
| 9 #include "content/renderer/media/media_stream_impl.h" | 9 #include "content/renderer/media/media_stream_impl.h" |
| 10 #include "content/renderer/media/mock_media_stream_dependency_factory.h" | 10 #include "content/renderer/media/mock_media_stream_dependency_factory.h" |
| 11 #include "content/renderer/media/mock_media_stream_dispatcher.h" | 11 #include "content/renderer/media/mock_media_stream_dispatcher.h" |
| 12 #include "content/renderer/media/video_capture_impl_manager.h" | 12 #include "content/renderer/media/video_capture_impl_manager.h" |
| 13 #include "media/base/video_decoder.h" | 13 #include "media/base/video_decoder.h" |
| 14 #include "media/base/message_loop_factory.h" | 14 #include "media/base/message_loop_factory.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amComponent.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amComponent.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amDescriptor.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amDescriptor.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amSource.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amSource.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 21 | 21 |
| 22 namespace content { |
| 23 |
| 22 class MediaStreamImplUnderTest : public MediaStreamImpl { | 24 class MediaStreamImplUnderTest : public MediaStreamImpl { |
| 23 public: | 25 public: |
| 24 MediaStreamImplUnderTest(MediaStreamDispatcher* media_stream_dispatcher, | 26 MediaStreamImplUnderTest(MediaStreamDispatcher* media_stream_dispatcher, |
| 25 VideoCaptureImplManager* vc_manager, | 27 VideoCaptureImplManager* vc_manager, |
| 26 MediaStreamDependencyFactory* dependency_factory) | 28 MediaStreamDependencyFactory* dependency_factory) |
| 27 : MediaStreamImpl(NULL, media_stream_dispatcher, vc_manager, | 29 : MediaStreamImpl(NULL, media_stream_dispatcher, vc_manager, |
| 28 dependency_factory) { | 30 dependency_factory) { |
| 29 } | 31 } |
| 30 | 32 |
| 31 virtual void CompleteGetUserMediaRequest( | 33 virtual void CompleteGetUserMediaRequest( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 video ? static_cast<size_t>(1) : 0); | 72 video ? static_cast<size_t>(1) : 0); |
| 71 ms_impl_->requestUserMedia(user_media_request, audio_sources, | 73 ms_impl_->requestUserMedia(user_media_request, audio_sources, |
| 72 video_sources); | 74 video_sources); |
| 73 | 75 |
| 74 ms_impl_->OnStreamGenerated(ms_dispatcher_->request_id(), | 76 ms_impl_->OnStreamGenerated(ms_dispatcher_->request_id(), |
| 75 ms_dispatcher_->stream_label(), | 77 ms_dispatcher_->stream_label(), |
| 76 ms_dispatcher_->audio_array(), | 78 ms_dispatcher_->audio_array(), |
| 77 ms_dispatcher_->video_array()); | 79 ms_dispatcher_->video_array()); |
| 78 | 80 |
| 79 WebKit::WebMediaStreamDescriptor desc = ms_impl_->last_generated_stream(); | 81 WebKit::WebMediaStreamDescriptor desc = ms_impl_->last_generated_stream(); |
| 80 MediaStreamExtraData* extra_data = static_cast<MediaStreamExtraData*>( | 82 content::MediaStreamExtraData* extra_data = |
| 81 desc.extraData()); | 83 static_cast<content::MediaStreamExtraData*>(desc.extraData()); |
| 82 if (!extra_data || !extra_data->local_stream()) { | 84 if (!extra_data || !extra_data->local_stream()) { |
| 83 ADD_FAILURE(); | 85 ADD_FAILURE(); |
| 84 return desc; | 86 return desc; |
| 85 } | 87 } |
| 86 | 88 |
| 87 if (audio) | 89 if (audio) |
| 88 EXPECT_EQ(1u, extra_data->local_stream()->audio_tracks()->count()); | 90 EXPECT_EQ(1u, extra_data->local_stream()->audio_tracks()->count()); |
| 89 if (video) | 91 if (video) |
| 90 EXPECT_EQ(1u, extra_data->local_stream()->video_tracks()->count()); | 92 EXPECT_EQ(1u, extra_data->local_stream()->video_tracks()->count()); |
| 91 if (audio && video) { | 93 if (audio && video) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8()); | 132 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8()); |
| 131 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); | 133 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); |
| 132 ms_impl_->OnLocalMediaStreamStop(audio_desc.label().utf8()); | 134 ms_impl_->OnLocalMediaStreamStop(audio_desc.label().utf8()); |
| 133 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); | 135 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); |
| 134 | 136 |
| 135 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. | 137 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. |
| 136 // In the unit test the owning frame is NULL. | 138 // In the unit test the owning frame is NULL. |
| 137 ms_impl_->FrameWillClose(NULL); | 139 ms_impl_->FrameWillClose(NULL); |
| 138 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); | 140 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); |
| 139 } | 141 } |
| 142 |
| 143 } // namespace content |
| OLD | NEW |