| 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_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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 WebKit::WebMediaStreamDescriptor last_generated_stream_; | 49 WebKit::WebMediaStreamDescriptor last_generated_stream_; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class MediaStreamImplTest : public ::testing::Test { | 52 class MediaStreamImplTest : public ::testing::Test { |
| 53 public: | 53 public: |
| 54 void SetUp() { | 54 void SetUp() { |
| 55 // Create our test object. | 55 // Create our test object. |
| 56 ms_dispatcher_.reset(new MockMediaStreamDispatcher()); | 56 ms_dispatcher_.reset(new MockMediaStreamDispatcher()); |
| 57 p2p_socket_dispatcher_.reset(new content::P2PSocketDispatcher(NULL)); | 57 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher( |
| 58 loop_.message_loop_proxy()); |
| 58 scoped_refptr<VideoCaptureImplManager> vc_manager( | 59 scoped_refptr<VideoCaptureImplManager> vc_manager( |
| 59 new VideoCaptureImplManager()); | 60 new VideoCaptureImplManager()); |
| 60 MockMediaStreamDependencyFactory* dependency_factory = | 61 MockMediaStreamDependencyFactory* dependency_factory = |
| 61 new MockMediaStreamDependencyFactory(vc_manager); | 62 new MockMediaStreamDependencyFactory(vc_manager); |
| 62 ms_impl_.reset(new MediaStreamImplUnderTest(ms_dispatcher_.get(), | 63 ms_impl_.reset(new MediaStreamImplUnderTest(ms_dispatcher_.get(), |
| 63 p2p_socket_dispatcher_.get(), | 64 p2p_socket_dispatcher_.get(), |
| 64 vc_manager.get(), | 65 vc_manager.get(), |
| 65 dependency_factory)); | 66 dependency_factory)); |
| 66 } | 67 } |
| 67 | 68 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if (audio && video) { | 103 if (audio && video) { |
| 103 EXPECT_NE(extra_data->local_stream()->audio_tracks()->at(0)->label(), | 104 EXPECT_NE(extra_data->local_stream()->audio_tracks()->at(0)->label(), |
| 104 extra_data->local_stream()->video_tracks()->at(0)->label()); | 105 extra_data->local_stream()->video_tracks()->at(0)->label()); |
| 105 } | 106 } |
| 106 return desc; | 107 return desc; |
| 107 } | 108 } |
| 108 | 109 |
| 109 protected: | 110 protected: |
| 110 MessageLoop loop_; | 111 MessageLoop loop_; |
| 111 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher_; | 112 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher_; |
| 112 scoped_ptr<content::P2PSocketDispatcher> p2p_socket_dispatcher_; | 113 scoped_refptr<content::P2PSocketDispatcher> p2p_socket_dispatcher_; |
| 113 scoped_ptr<MediaStreamImplUnderTest> ms_impl_; | 114 scoped_ptr<MediaStreamImplUnderTest> ms_impl_; |
| 114 }; | 115 }; |
| 115 | 116 |
| 116 TEST_F(MediaStreamImplTest, CreatePeerConnection) { | 117 TEST_F(MediaStreamImplTest, CreatePeerConnection) { |
| 117 // Create JSEP PeerConnection. | 118 // Create JSEP PeerConnection. |
| 118 WebKit::MockWebPeerConnection00HandlerClient client_jsep; | 119 WebKit::MockWebPeerConnection00HandlerClient client_jsep; |
| 119 scoped_ptr<WebKit::WebPeerConnection00Handler> pc_handler_jsep( | 120 scoped_ptr<WebKit::WebPeerConnection00Handler> pc_handler_jsep( |
| 120 ms_impl_->CreatePeerConnectionHandlerJsep(&client_jsep)); | 121 ms_impl_->CreatePeerConnectionHandlerJsep(&client_jsep)); |
| 121 pc_handler_jsep.reset(); | 122 pc_handler_jsep.reset(); |
| 122 } | 123 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 desc.initialize("new stream", audio_sources, video_sources); | 217 desc.initialize("new stream", audio_sources, video_sources); |
| 217 | 218 |
| 218 ms_impl_->CreateMediaStream(NULL, &desc); | 219 ms_impl_->CreateMediaStream(NULL, &desc); |
| 219 MediaStreamExtraData* extra_data = static_cast<MediaStreamExtraData*>( | 220 MediaStreamExtraData* extra_data = static_cast<MediaStreamExtraData*>( |
| 220 desc.extraData()); | 221 desc.extraData()); |
| 221 | 222 |
| 222 ASSERT_TRUE(extra_data && extra_data->local_stream()); | 223 ASSERT_TRUE(extra_data && extra_data->local_stream()); |
| 223 EXPECT_EQ(0u, extra_data->local_stream()->video_tracks()->count()); | 224 EXPECT_EQ(0u, extra_data->local_stream()->video_tracks()->count()); |
| 224 EXPECT_EQ(0u, extra_data->local_stream()->audio_tracks()->count()); | 225 EXPECT_EQ(0u, extra_data->local_stream()->audio_tracks()->count()); |
| 225 } | 226 } |
| OLD | NEW |