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_extra_data.h" | 8 #include "content/renderer/media/media_stream_extra_data.h" |
9 #include "content/renderer/media/media_stream_impl.h" | 9 #include "content/renderer/media/media_stream_impl.h" |
10 #include "content/renderer/media/mock_media_stream_dependency_factory.h" | 10 #include "content/renderer/media/mock_media_stream_dependency_factory.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 protected: | 153 protected: |
154 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher_; | 154 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher_; |
155 scoped_ptr<MediaStreamImplUnderTest> ms_impl_; | 155 scoped_ptr<MediaStreamImplUnderTest> ms_impl_; |
156 scoped_ptr<MockMediaStreamDependencyFactory> dependency_factory_; | 156 scoped_ptr<MockMediaStreamDependencyFactory> dependency_factory_; |
157 }; | 157 }; |
158 | 158 |
159 TEST_F(MediaStreamImplTest, LocalMediaStream) { | 159 TEST_F(MediaStreamImplTest, LocalMediaStream) { |
160 // Test a stream with both audio and video. | 160 // Test a stream with both audio and video. |
161 WebKit::WebMediaStream mixed_desc = RequestLocalMediaStream(true, true); | 161 WebKit::WebMediaStream mixed_desc = RequestLocalMediaStream(true, true); |
162 // Create a renderer for the stream. | |
163 scoped_refptr<media::VideoDecoder> mixed_decoder( | |
164 ms_impl_->GetVideoDecoder(GURL(), base::MessageLoopProxy::current())); | |
165 EXPECT_TRUE(mixed_decoder.get() != NULL); | |
166 | 162 |
167 // Test a stream with audio only. | 163 // Test a stream with audio only. |
168 WebKit::WebMediaStream audio_desc = RequestLocalMediaStream(true, false); | 164 WebKit::WebMediaStream audio_desc = RequestLocalMediaStream(true, false); |
169 scoped_refptr<media::VideoDecoder> audio_decoder( | |
170 ms_impl_->GetVideoDecoder(GURL(), base::MessageLoopProxy::current())); | |
171 EXPECT_TRUE(audio_decoder.get() == NULL); | |
172 | 165 |
173 // Test a stream with video only. | 166 // Test a stream with video only. |
174 WebKit::WebMediaStream video_desc = RequestLocalMediaStream(false, true); | 167 WebKit::WebMediaStream video_desc = RequestLocalMediaStream(false, true); |
175 scoped_refptr<media::VideoDecoder> video_decoder( | |
176 ms_impl_->GetVideoDecoder(GURL(), base::MessageLoopProxy::current())); | |
177 EXPECT_TRUE(video_decoder.get() != NULL); | |
178 | 168 |
179 // Stop generated local streams. | 169 // Stop generated local streams. |
180 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8()); | 170 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8()); |
181 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); | 171 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); |
182 ms_impl_->OnLocalMediaStreamStop(audio_desc.label().utf8()); | 172 ms_impl_->OnLocalMediaStreamStop(audio_desc.label().utf8()); |
183 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); | 173 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); |
184 | 174 |
185 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. | 175 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. |
186 // In the unit test the owning frame is NULL. | 176 // In the unit test the owning frame is NULL. |
187 ms_impl_->FrameWillClose(NULL); | 177 ms_impl_->FrameWillClose(NULL); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 WebKit::WebMediaStream mixed_desc = RequestLocalMediaStream(true, true); | 237 WebKit::WebMediaStream mixed_desc = RequestLocalMediaStream(true, true); |
248 EXPECT_EQ(0, ms_dispatcher_->stop_stream_counter()); | 238 EXPECT_EQ(0, ms_dispatcher_->stop_stream_counter()); |
249 EXPECT_EQ(1, ms_dispatcher_->request_stream_counter()); | 239 EXPECT_EQ(1, ms_dispatcher_->request_stream_counter()); |
250 ms_impl_->FrameWillClose(NULL); | 240 ms_impl_->FrameWillClose(NULL); |
251 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); | 241 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); |
252 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8()); | 242 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8()); |
253 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); | 243 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); |
254 } | 244 } |
255 | 245 |
256 } // namespace content | 246 } // namespace content |
OLD | NEW |