Chromium Code Reviews| 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/WebVector.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 20 | 21 |
| 21 class MediaStreamImplUnderTest : public MediaStreamImpl { | 22 class MediaStreamImplUnderTest : public MediaStreamImpl { |
| 22 public: | 23 public: |
| 23 MediaStreamImplUnderTest(MediaStreamDispatcher* media_stream_dispatcher, | 24 MediaStreamImplUnderTest(MediaStreamDispatcher* media_stream_dispatcher, |
| 24 VideoCaptureImplManager* vc_manager, | 25 VideoCaptureImplManager* vc_manager, |
| 25 MediaStreamDependencyFactory* dependency_factory) | 26 MediaStreamDependencyFactory* dependency_factory) |
| 26 : MediaStreamImpl(NULL, media_stream_dispatcher, vc_manager, | 27 : MediaStreamImpl(NULL, media_stream_dispatcher, vc_manager, |
| 27 dependency_factory) { | 28 dependency_factory) { |
| 28 } | 29 } |
| 29 | 30 |
| 30 virtual void CompleteGetUserMediaRequest( | 31 virtual void CompleteGetUserMediaRequest( |
| 31 const WebKit::WebMediaStreamDescriptor& stream, | 32 const WebKit::WebMediaStreamDescriptor& stream, |
| 32 WebKit::WebUserMediaRequest* request) { | 33 WebKit::WebUserMediaRequest* request) { |
| 33 last_generated_stream_ = stream; | 34 last_generated_stream_ = stream; |
| 34 } | 35 } |
| 35 | 36 |
| 36 virtual WebKit::WebMediaStreamDescriptor GetMediaStream(const GURL& url) { | 37 virtual WebKit::WebMediaStreamDescriptor GetMediaStream(const GURL& url) { |
| 37 return last_generated_stream_; | 38 return last_generated_stream_; |
| 38 } | 39 } |
| 39 | 40 |
| 40 const WebKit::WebMediaStreamDescriptor& last_generated_stream() { | 41 const WebKit::WebMediaStreamDescriptor& last_generated_stream() { |
| 41 return last_generated_stream_; | 42 return last_generated_stream_; |
| 42 } | 43 } |
| 44 using MediaStreamImpl::OnLocalMediaStreamStop; | |
|
tommi (sloooow) - chröme
2012/09/21 09:18:03
empty line above.
Is this really needed though?
perkj_chrome
2012/09/21 10:47:10
Yes- unless I change OnLocalMediaStream to be publ
tommi (sloooow) - chröme
2012/09/21 11:23:53
Ah, it's not public in the parent class then. OK,
| |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 WebKit::WebMediaStreamDescriptor last_generated_stream_; | 47 WebKit::WebMediaStreamDescriptor last_generated_stream_; |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 class MediaStreamImplTest : public ::testing::Test { | 50 class MediaStreamImplTest : public ::testing::Test { |
| 49 public: | 51 public: |
| 50 void SetUp() { | 52 void SetUp() { |
| 51 // Create our test object. | 53 // Create our test object. |
| 52 ms_dispatcher_.reset(new MockMediaStreamDispatcher()); | 54 ms_dispatcher_.reset(new MockMediaStreamDispatcher()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 EXPECT_TRUE(audio_decoder.get() == NULL); | 119 EXPECT_TRUE(audio_decoder.get() == NULL); |
| 118 | 120 |
| 119 // Test a stream with video only. | 121 // Test a stream with video only. |
| 120 WebKit::WebMediaStreamDescriptor video_desc = RequestLocalMediaStream(false, | 122 WebKit::WebMediaStreamDescriptor video_desc = RequestLocalMediaStream(false, |
| 121 true); | 123 true); |
| 122 scoped_refptr<media::VideoDecoder> video_decoder( | 124 scoped_refptr<media::VideoDecoder> video_decoder( |
| 123 ms_impl_->GetVideoDecoder(GURL(), message_loop_factory.get())); | 125 ms_impl_->GetVideoDecoder(GURL(), message_loop_factory.get())); |
| 124 EXPECT_TRUE(video_decoder.get() != NULL); | 126 EXPECT_TRUE(video_decoder.get() != NULL); |
| 125 | 127 |
| 126 // Stop generated local streams. | 128 // Stop generated local streams. |
| 127 ms_impl_->StopLocalMediaStream(mixed_desc); | 129 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8()); |
| 128 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); | 130 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); |
| 129 ms_impl_->StopLocalMediaStream(audio_desc); | 131 ms_impl_->OnLocalMediaStreamStop(audio_desc.label().utf8()); |
| 130 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); | 132 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); |
| 131 | 133 |
| 132 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. | 134 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. |
| 133 // In the unit test the owning frame is NULL. | 135 // In the unit test the owning frame is NULL. |
| 134 ms_impl_->FrameWillClose(NULL); | 136 ms_impl_->FrameWillClose(NULL); |
| 135 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); | 137 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); |
| 136 } | 138 } |
| OLD | NEW |