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

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

Issue 10917167: Refactor the P2PSocketDispatcher to be created on the RenderThread instead of the RenderView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change P2PSocketDispatcher to take the io message loop as input to fix existing unit tests Created 8 years, 3 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 "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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 private: 47 private:
48 WebKit::WebMediaStreamDescriptor last_generated_stream_; 48 WebKit::WebMediaStreamDescriptor last_generated_stream_;
49 }; 49 };
50 50
51 class MediaStreamImplTest : public ::testing::Test { 51 class MediaStreamImplTest : public ::testing::Test {
52 public: 52 public:
53 void SetUp() { 53 void SetUp() {
54 // Create our test object. 54 // Create our test object.
55 ms_dispatcher_.reset(new MockMediaStreamDispatcher()); 55 ms_dispatcher_.reset(new MockMediaStreamDispatcher());
56 p2p_socket_dispatcher_.reset(new content::P2PSocketDispatcher(NULL)); 56 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(
57 loop_.message_loop_proxy());
57 scoped_refptr<VideoCaptureImplManager> vc_manager( 58 scoped_refptr<VideoCaptureImplManager> vc_manager(
58 new VideoCaptureImplManager()); 59 new VideoCaptureImplManager());
59 MockMediaStreamDependencyFactory* dependency_factory = 60 MockMediaStreamDependencyFactory* dependency_factory =
60 new MockMediaStreamDependencyFactory(vc_manager); 61 new MockMediaStreamDependencyFactory(vc_manager);
61 ms_impl_.reset(new MediaStreamImplUnderTest(ms_dispatcher_.get(), 62 ms_impl_.reset(new MediaStreamImplUnderTest(ms_dispatcher_.get(),
62 p2p_socket_dispatcher_.get(), 63 p2p_socket_dispatcher_.get(),
63 vc_manager.get(), 64 vc_manager.get(),
64 dependency_factory)); 65 dependency_factory));
65 } 66 }
66 67
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (audio && video) { 102 if (audio && video) {
102 EXPECT_NE(extra_data->local_stream()->audio_tracks()->at(0)->label(), 103 EXPECT_NE(extra_data->local_stream()->audio_tracks()->at(0)->label(),
103 extra_data->local_stream()->video_tracks()->at(0)->label()); 104 extra_data->local_stream()->video_tracks()->at(0)->label());
104 } 105 }
105 return desc; 106 return desc;
106 } 107 }
107 108
108 protected: 109 protected:
109 MessageLoop loop_; 110 MessageLoop loop_;
110 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher_; 111 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher_;
111 scoped_ptr<content::P2PSocketDispatcher> p2p_socket_dispatcher_; 112 scoped_refptr<content::P2PSocketDispatcher> p2p_socket_dispatcher_;
112 scoped_ptr<MediaStreamImplUnderTest> ms_impl_; 113 scoped_ptr<MediaStreamImplUnderTest> ms_impl_;
113 }; 114 };
114 115
115 TEST_F(MediaStreamImplTest, CreatePeerConnection) { 116 TEST_F(MediaStreamImplTest, CreatePeerConnection) {
116 // Create JSEP PeerConnection. 117 // Create JSEP PeerConnection.
117 WebKit::MockWebPeerConnection00HandlerClient client_jsep; 118 WebKit::MockWebPeerConnection00HandlerClient client_jsep;
118 scoped_ptr<WebKit::WebPeerConnection00Handler> pc_handler_jsep( 119 scoped_ptr<WebKit::WebPeerConnection00Handler> pc_handler_jsep(
119 ms_impl_->CreatePeerConnectionHandlerJsep(&client_jsep)); 120 ms_impl_->CreatePeerConnectionHandlerJsep(&client_jsep));
120 pc_handler_jsep.reset(); 121 pc_handler_jsep.reset();
121 } 122 }
(...skipping 27 matching lines...) Expand all
149 ms_impl_->StopLocalMediaStream(mixed_desc); 150 ms_impl_->StopLocalMediaStream(mixed_desc);
150 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); 151 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter());
151 ms_impl_->StopLocalMediaStream(audio_desc); 152 ms_impl_->StopLocalMediaStream(audio_desc);
152 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); 153 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter());
153 154
154 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. 155 // Test that the MediaStreams are deleted if the owning WebFrame is deleted.
155 // In the unit test the owning frame is NULL. 156 // In the unit test the owning frame is NULL.
156 ms_impl_->FrameWillClose(NULL); 157 ms_impl_->FrameWillClose(NULL);
157 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); 158 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter());
158 } 159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698