Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: content/renderer/media/media_stream_impl_unittest.cc

Issue 9699069: Adding JSEP PeerConnection glue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed missing export. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/renderer/media/media_stream_impl.h" 7 #include "content/renderer/media/media_stream_impl.h"
8 #include "content/renderer/media/mock_media_stream_dependency_factory.h" 8 #include "content/renderer/media/mock_media_stream_dependency_factory.h"
9 #include "content/renderer/media/mock_media_stream_dispatcher.h" 9 #include "content/renderer/media/mock_media_stream_dispatcher.h"
10 #include "content/renderer/media/mock_web_peer_connection_00_handler_client.h"
10 #include "content/renderer/media/mock_web_peer_connection_handler_client.h" 11 #include "content/renderer/media/mock_web_peer_connection_handler_client.h"
12 #include "content/renderer/media/peer_connection_handler.h"
13 #include "content/renderer/media/peer_connection_handler_jsep.h"
11 #include "content/renderer/media/video_capture_impl_manager.h" 14 #include "content/renderer/media/video_capture_impl_manager.h"
12 #include "content/renderer/p2p/socket_dispatcher.h" 15 #include "content/renderer/p2p/socket_dispatcher.h"
13 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ction00Handler.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ctionHandler.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ctionHandler.h"
15 19
16 // Disabled due to http://crbug.com/112408 . 20 // Disabled due to http://crbug.com/112408 .
17 TEST(MediaStreamImplTest, DISABLED_Basic) { 21 TEST(MediaStreamImplTest, DISABLED_Basic) {
18 MessageLoop loop; 22 MessageLoop loop;
19 23
20 // Create our test object. 24 // Create our test object.
21 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher( 25 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher(
22 new MockMediaStreamDispatcher()); 26 new MockMediaStreamDispatcher());
23 scoped_ptr<content::P2PSocketDispatcher> p2p_socket_dispatcher( 27 scoped_ptr<content::P2PSocketDispatcher> p2p_socket_dispatcher(
24 new content::P2PSocketDispatcher(NULL)); 28 new content::P2PSocketDispatcher(NULL));
25 scoped_refptr<VideoCaptureImplManager> vc_manager( 29 scoped_refptr<VideoCaptureImplManager> vc_manager(
26 new VideoCaptureImplManager()); 30 new VideoCaptureImplManager());
27 MockMediaStreamDependencyFactory* dependency_factory = 31 MockMediaStreamDependencyFactory* dependency_factory =
28 new MockMediaStreamDependencyFactory(); 32 new MockMediaStreamDependencyFactory();
29 scoped_refptr<MediaStreamImpl> ms_impl(new MediaStreamImpl( 33 scoped_refptr<MediaStreamImpl> ms_impl(new MediaStreamImpl(
30 ms_dispatcher.get(), 34 ms_dispatcher.get(),
31 p2p_socket_dispatcher.get(), 35 p2p_socket_dispatcher.get(),
32 vc_manager.get(), 36 vc_manager.get(),
33 dependency_factory)); 37 dependency_factory));
34 38
35 // TODO(grunell): Add tests for WebKit::WebUserMediaClient and 39 // TODO(grunell): Add tests for WebKit::WebUserMediaClient and
36 // MediaStreamDispatcherEventHandler implementations. 40 // MediaStreamDispatcherEventHandler implementations.
37 41
38 WebKit::MockWebPeerConnectionHandlerClient client; 42 WebKit::MockWebPeerConnectionHandlerClient client;
39 WebKit::WebPeerConnectionHandler* pc_handler = 43 WebKit::WebPeerConnectionHandler* pc_handler =
40 ms_impl->CreatePeerConnectionHandler(&client); 44 ms_impl->CreatePeerConnectionHandler(&client);
41 EXPECT_TRUE(ms_impl->peer_connection_handler_); 45 EXPECT_EQ(1u, ms_impl->peer_connection_handlers_.size());
42 46
43 ms_impl->ClosePeerConnection(); 47 // Delete PC handler explicitly after closing to mimic WebKit behavior.
44 EXPECT_FALSE(ms_impl->peer_connection_handler_); 48 ms_impl->ClosePeerConnection(
49 static_cast<PeerConnectionHandler*>(pc_handler));
50 EXPECT_TRUE(ms_impl->peer_connection_handlers_.empty());
45 delete pc_handler; 51 delete pc_handler;
52
53 WebKit::MockWebPeerConnection00HandlerClient client_jsep;
54 WebKit::WebPeerConnection00Handler* pc_handler_jsep =
55 ms_impl->CreatePeerConnectionHandlerJsep(&client_jsep);
56 EXPECT_EQ(1u, ms_impl->peer_connection_handlers_.size());
57
58 // Delete PC handler explicitly after closing to mimic WebKit behavior.
59 ms_impl->ClosePeerConnection(
60 static_cast<PeerConnectionHandlerJsep*>(pc_handler_jsep));
61 EXPECT_TRUE(ms_impl->peer_connection_handlers_.empty());
62 delete pc_handler_jsep;
46 } 63 }
64
65 // Disabled due to http://crbug.com/112408 .
66 TEST(MediaStreamImplTest, DISABLED_MultiplePeerConnections) {
67 MessageLoop loop;
68
69 // Create our test object.
70 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher(
71 new MockMediaStreamDispatcher());
72 scoped_ptr<content::P2PSocketDispatcher> p2p_socket_dispatcher(
73 new content::P2PSocketDispatcher(NULL));
74 scoped_refptr<VideoCaptureImplManager> vc_manager(
75 new VideoCaptureImplManager());
76 MockMediaStreamDependencyFactory* dependency_factory =
77 new MockMediaStreamDependencyFactory();
78 scoped_refptr<MediaStreamImpl> ms_impl(new MediaStreamImpl(
79 ms_dispatcher.get(),
80 p2p_socket_dispatcher.get(),
81 vc_manager.get(),
82 dependency_factory));
83
84 // TODO(grunell): Add tests for WebKit::WebUserMediaClient and
85 // MediaStreamDispatcherEventHandler implementations.
86
87 WebKit::MockWebPeerConnectionHandlerClient client;
88 WebKit::WebPeerConnectionHandler* pc_handler =
89 ms_impl->CreatePeerConnectionHandler(&client);
90 EXPECT_EQ(1u, ms_impl->peer_connection_handlers_.size());
91
92 WebKit::MockWebPeerConnection00HandlerClient client_jsep;
93 WebKit::WebPeerConnection00Handler* pc_handler_jsep =
94 ms_impl->CreatePeerConnectionHandlerJsep(&client_jsep);
95 EXPECT_EQ(2u, ms_impl->peer_connection_handlers_.size());
96
97 // Delete PC handler explicitly after closing to mimic WebKit behavior.
98 ms_impl->ClosePeerConnection(
99 static_cast<PeerConnectionHandler*>(pc_handler));
100 EXPECT_EQ(1u, ms_impl->peer_connection_handlers_.size());
101 delete pc_handler;
102
103 // Delete PC handler explicitly after closing to mimic WebKit behavior.
104 ms_impl->ClosePeerConnection(
105 static_cast<PeerConnectionHandlerJsep*>(pc_handler_jsep));
106 EXPECT_TRUE(ms_impl->peer_connection_handlers_.empty());
107 delete pc_handler_jsep;
108 }
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_impl.cc ('k') | content/renderer/media/mock_media_stream_dependency_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698