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" |
11 #include "content/renderer/media/mock_web_peer_connection_00_handler_client.h" | 11 #include "content/renderer/media/mock_web_peer_connection_00_handler_client.h" |
12 #include "content/renderer/media/mock_web_peer_connection_handler_client.h" | 12 #include "content/renderer/media/mock_web_rtc_peer_connection_handler_client.h" |
13 #include "content/renderer/media/peer_connection_handler_jsep.h" | 13 #include "content/renderer/media/peer_connection_handler_jsep.h" |
14 #include "content/renderer/media/video_capture_impl_manager.h" | 14 #include "content/renderer/media/video_capture_impl_manager.h" |
15 #include "content/renderer/p2p/socket_dispatcher.h" | 15 #include "content/renderer/p2p/socket_dispatcher.h" |
16 #include "media/base/message_loop_factory.h" | 16 #include "media/base/message_loop_factory.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amSource.h" | 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc
e.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ction00Handler.h" | 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebPeerConnection00
Handler.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ctionHandler.h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCPeerConnectio
nHandler.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" |
22 | 22 |
23 class MediaStreamImplUnderTest : public MediaStreamImpl { | 23 class MediaStreamImplUnderTest : public MediaStreamImpl { |
24 public: | 24 public: |
25 MediaStreamImplUnderTest(MediaStreamDispatcher* media_stream_dispatcher, | 25 MediaStreamImplUnderTest(MediaStreamDispatcher* media_stream_dispatcher, |
26 content::P2PSocketDispatcher* p2p_socket_dispatcher, | 26 content::P2PSocketDispatcher* p2p_socket_dispatcher, |
27 VideoCaptureImplManager* vc_manager, | 27 VideoCaptureImplManager* vc_manager, |
28 MediaStreamDependencyFactory* dependency_factory) | 28 MediaStreamDependencyFactory* dependency_factory) |
29 : MediaStreamImpl(NULL, media_stream_dispatcher, p2p_socket_dispatcher, | 29 : MediaStreamImpl(NULL, media_stream_dispatcher, p2p_socket_dispatcher, |
30 vc_manager, dependency_factory) { | 30 vc_manager, dependency_factory) { |
31 } | 31 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 }; | 113 }; |
114 | 114 |
115 TEST_F(MediaStreamImplTest, CreatePeerConnection) { | 115 TEST_F(MediaStreamImplTest, CreatePeerConnection) { |
116 // Create JSEP PeerConnection. | 116 // Create JSEP PeerConnection. |
117 WebKit::MockWebPeerConnection00HandlerClient client_jsep; | 117 WebKit::MockWebPeerConnection00HandlerClient client_jsep; |
118 scoped_ptr<WebKit::WebPeerConnection00Handler> pc_handler_jsep( | 118 scoped_ptr<WebKit::WebPeerConnection00Handler> pc_handler_jsep( |
119 ms_impl_->CreatePeerConnectionHandlerJsep(&client_jsep)); | 119 ms_impl_->CreatePeerConnectionHandlerJsep(&client_jsep)); |
120 pc_handler_jsep.reset(); | 120 pc_handler_jsep.reset(); |
121 } | 121 } |
122 | 122 |
| 123 TEST_F(MediaStreamImplTest, CreateRTCPeerConnection) { |
| 124 // Create JSEP PeerConnection. |
| 125 WebKit::MockWebRTCPeerConnectionHandlerClient client; |
| 126 scoped_ptr<WebKit::WebRTCPeerConnectionHandler> pc_handler( |
| 127 ms_impl_->CreateRTCPeerConnectionHandler(&client)); |
| 128 EXPECT_TRUE(pc_handler.get() != NULL); |
| 129 pc_handler.reset(); |
| 130 } |
| 131 |
123 TEST_F(MediaStreamImplTest, LocalMediaStream) { | 132 TEST_F(MediaStreamImplTest, LocalMediaStream) { |
124 // Test a stream with both audio and video. | 133 // Test a stream with both audio and video. |
125 WebKit::WebMediaStreamDescriptor mixed_desc = RequestLocalMediaStream(true, | 134 WebKit::WebMediaStreamDescriptor mixed_desc = RequestLocalMediaStream(true, |
126 true); | 135 true); |
127 // Create a renderer for the stream. | 136 // Create a renderer for the stream. |
128 scoped_ptr<media::MessageLoopFactory> message_loop_factory( | 137 scoped_ptr<media::MessageLoopFactory> message_loop_factory( |
129 new media::MessageLoopFactory()); | 138 new media::MessageLoopFactory()); |
130 scoped_refptr<media::VideoDecoder> mixed_decoder( | 139 scoped_refptr<media::VideoDecoder> mixed_decoder( |
131 ms_impl_->GetVideoDecoder(GURL(), message_loop_factory.get())); | 140 ms_impl_->GetVideoDecoder(GURL(), message_loop_factory.get())); |
132 EXPECT_TRUE(mixed_decoder.get() != NULL); | 141 EXPECT_TRUE(mixed_decoder.get() != NULL); |
(...skipping 16 matching lines...) Expand all Loading... |
149 ms_impl_->StopLocalMediaStream(mixed_desc); | 158 ms_impl_->StopLocalMediaStream(mixed_desc); |
150 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); | 159 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); |
151 ms_impl_->StopLocalMediaStream(audio_desc); | 160 ms_impl_->StopLocalMediaStream(audio_desc); |
152 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); | 161 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); |
153 | 162 |
154 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. | 163 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. |
155 // In the unit test the owning frame is NULL. | 164 // In the unit test the owning frame is NULL. |
156 ms_impl_->FrameWillClose(NULL); | 165 ms_impl_->FrameWillClose(NULL); |
157 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); | 166 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); |
158 } | 167 } |
OLD | NEW |