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_peer_connection_handler_client.h" |
13 #include "content/renderer/media/peer_connection_handler.h" | |
14 #include "content/renderer/media/peer_connection_handler_jsep.h" | 13 #include "content/renderer/media/peer_connection_handler_jsep.h" |
15 #include "content/renderer/media/video_capture_impl_manager.h" | 14 #include "content/renderer/media/video_capture_impl_manager.h" |
16 #include "content/renderer/p2p/socket_dispatcher.h" | 15 #include "content/renderer/p2p/socket_dispatcher.h" |
17 #include "media/base/message_loop_factory.h" | 16 #include "media/base/message_loop_factory.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 #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" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ction00Handler.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ction00Handler.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ctionHandler.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ctionHandler.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
23 | 22 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 106 } |
108 | 107 |
109 protected: | 108 protected: |
110 MessageLoop loop_; | 109 MessageLoop loop_; |
111 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher_; | 110 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher_; |
112 scoped_ptr<content::P2PSocketDispatcher> p2p_socket_dispatcher_; | 111 scoped_ptr<content::P2PSocketDispatcher> p2p_socket_dispatcher_; |
113 scoped_ptr<MediaStreamImplUnderTest> ms_impl_; | 112 scoped_ptr<MediaStreamImplUnderTest> ms_impl_; |
114 }; | 113 }; |
115 | 114 |
116 TEST_F(MediaStreamImplTest, CreatePeerConnection) { | 115 TEST_F(MediaStreamImplTest, CreatePeerConnection) { |
117 // Create ROAP PeerConnection.j | |
118 WebKit::MockWebPeerConnectionHandlerClient client; | |
119 scoped_ptr<WebKit::WebPeerConnectionHandler> pc_handler( | |
120 ms_impl_->CreatePeerConnectionHandler(&client)); | |
121 pc_handler.reset(); | |
122 | |
123 // Create JSEP PeerConnection. | 116 // Create JSEP PeerConnection. |
124 WebKit::MockWebPeerConnection00HandlerClient client_jsep; | 117 WebKit::MockWebPeerConnection00HandlerClient client_jsep; |
125 scoped_ptr<WebKit::WebPeerConnection00Handler> pc_handler_jsep( | 118 scoped_ptr<WebKit::WebPeerConnection00Handler> pc_handler_jsep( |
126 ms_impl_->CreatePeerConnectionHandlerJsep(&client_jsep)); | 119 ms_impl_->CreatePeerConnectionHandlerJsep(&client_jsep)); |
127 pc_handler_jsep.reset(); | 120 pc_handler_jsep.reset(); |
128 } | 121 } |
129 | 122 |
130 TEST_F(MediaStreamImplTest, LocalMediaStream) { | 123 TEST_F(MediaStreamImplTest, LocalMediaStream) { |
131 // Test a stream with both audio and video. | 124 // Test a stream with both audio and video. |
132 WebKit::WebMediaStreamDescriptor mixed_desc = RequestLocalMediaStream(true, | 125 WebKit::WebMediaStreamDescriptor mixed_desc = RequestLocalMediaStream(true, |
(...skipping 23 matching lines...) Expand all Loading... |
156 ms_impl_->StopLocalMediaStream(mixed_desc); | 149 ms_impl_->StopLocalMediaStream(mixed_desc); |
157 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); | 150 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); |
158 ms_impl_->StopLocalMediaStream(audio_desc); | 151 ms_impl_->StopLocalMediaStream(audio_desc); |
159 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); | 152 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); |
160 | 153 |
161 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. | 154 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. |
162 // In the unit test the owning frame is NULL. | 155 // In the unit test the owning frame is NULL. |
163 ms_impl_->FrameWillClose(NULL); | 156 ms_impl_->FrameWillClose(NULL); |
164 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); | 157 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); |
165 } | 158 } |
OLD | NEW |