Chromium Code Reviews| 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" |
|
perkj_chrome
2013/04/18 13:36:20
Can you add a unit test to test that the WebKit so
| |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "content/renderer/media/media_stream_extra_data.h" | 7 #include "content/renderer/media/media_stream_extra_data.h" |
| 8 #include "content/renderer/media/media_stream_impl.h" | 8 #include "content/renderer/media/media_stream_impl.h" |
| 9 #include "content/renderer/media/media_stream_source_extra_data.h" | |
| 9 #include "content/renderer/media/mock_media_stream_dependency_factory.h" | 10 #include "content/renderer/media/mock_media_stream_dependency_factory.h" |
| 10 #include "content/renderer/media/mock_media_stream_dispatcher.h" | 11 #include "content/renderer/media/mock_media_stream_dispatcher.h" |
| 11 #include "content/renderer/media/video_capture_impl_manager.h" | 12 #include "content/renderer/media/video_capture_impl_manager.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h" | 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc e.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc e.h" |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack .h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack .h" |
| 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
| 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" | 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" |
| 18 | 19 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 // Stop generated local streams. | 168 // Stop generated local streams. |
| 168 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8()); | 169 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8()); |
| 169 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); | 170 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); |
| 170 ms_impl_->OnLocalMediaStreamStop(audio_desc.label().utf8()); | 171 ms_impl_->OnLocalMediaStreamStop(audio_desc.label().utf8()); |
| 171 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); | 172 EXPECT_EQ(2, ms_dispatcher_->stop_stream_counter()); |
| 172 | 173 |
| 173 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. | 174 // Test that the MediaStreams are deleted if the owning WebFrame is deleted. |
| 174 // In the unit test the owning frame is NULL. | 175 // In the unit test the owning frame is NULL. |
| 175 ms_impl_->FrameWillClose(NULL); | 176 ms_impl_->FrameWillClose(NULL); |
| 176 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); | 177 EXPECT_EQ(3, ms_dispatcher_->stop_stream_counter()); |
| 178 MediaStreamImpl::ReleaseSourceObservers(mixed_desc); | |
|
perkj_chrome
2013/04/18 13:36:20
You should not have to do this since you call Medi
| |
| 179 MediaStreamImpl::ReleaseSourceObservers(audio_desc); | |
| 180 MediaStreamImpl::ReleaseSourceObservers(video_desc); | |
| 177 } | 181 } |
| 178 | 182 |
| 179 // This test what happens if a source to a MediaSteam fails to start. | 183 // This test what happens if a source to a MediaSteam fails to start. |
| 180 TEST_F(MediaStreamImplTest, MediaSourceFailToStart) { | 184 TEST_F(MediaStreamImplTest, MediaSourceFailToStart) { |
| 181 ms_impl_->RequestUserMedia(true, true); | 185 ms_impl_->RequestUserMedia(true, true); |
| 182 FakeMediaStreamDispatcherComplete(); | 186 FakeMediaStreamDispatcherComplete(); |
| 183 ChangeVideoSourceStateToEnded(); | 187 ChangeVideoSourceStateToEnded(); |
| 184 ChangeAudioSourceStateToEnded(); | 188 ChangeAudioSourceStateToEnded(); |
| 185 EXPECT_EQ(MediaStreamImplUnderTest::REQUEST_FAILED, | 189 EXPECT_EQ(MediaStreamImplUnderTest::REQUEST_FAILED, |
| 186 ms_impl_->request_state()); | 190 ms_impl_->request_state()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 // This test what happens if stop is called on a stream after the frame has | 236 // This test what happens if stop is called on a stream after the frame has |
| 233 // been reloaded. | 237 // been reloaded. |
| 234 TEST_F(MediaStreamImplTest, StopStreamAfterReload) { | 238 TEST_F(MediaStreamImplTest, StopStreamAfterReload) { |
| 235 WebKit::WebMediaStream mixed_desc = RequestLocalMediaStream(true, true); | 239 WebKit::WebMediaStream mixed_desc = RequestLocalMediaStream(true, true); |
| 236 EXPECT_EQ(0, ms_dispatcher_->stop_stream_counter()); | 240 EXPECT_EQ(0, ms_dispatcher_->stop_stream_counter()); |
| 237 EXPECT_EQ(1, ms_dispatcher_->request_stream_counter()); | 241 EXPECT_EQ(1, ms_dispatcher_->request_stream_counter()); |
| 238 ms_impl_->FrameWillClose(NULL); | 242 ms_impl_->FrameWillClose(NULL); |
| 239 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); | 243 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); |
| 240 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8()); | 244 ms_impl_->OnLocalMediaStreamStop(mixed_desc.label().utf8()); |
| 241 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); | 245 EXPECT_EQ(1, ms_dispatcher_->stop_stream_counter()); |
| 246 MediaStreamImpl::ReleaseSourceObservers(mixed_desc); | |
| 242 } | 247 } |
| 243 | 248 |
| 244 } // namespace content | 249 } // namespace content |
| OLD | NEW |