| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "content/child/child_process.h" | 7 #include "content/child/child_process.h" |
| 8 #include "content/renderer/media/media_stream.h" | 8 #include "content/renderer/media/media_stream.h" |
| 9 #include "content/renderer/media/media_stream_audio_source.h" | 9 #include "content/renderer/media/media_stream_audio_source.h" |
| 10 #include "content/renderer/media/media_stream_video_source.h" | 10 #include "content/renderer/media/media_stream_video_source.h" |
| 11 #include "content/renderer/media/media_stream_video_track.h" | 11 #include "content/renderer/media/media_stream_video_track.h" |
| 12 #include "content/renderer/media/mock_media_stream_dependency_factory.h" | |
| 13 #include "content/renderer/media/mock_media_stream_video_source.h" | 12 #include "content/renderer/media/mock_media_stream_video_source.h" |
| 13 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory.
h" |
| 14 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 14 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
| 15 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" | 15 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 17 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 18 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 18 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 20 #include "third_party/WebKit/public/platform/WebVector.h" | 20 #include "third_party/WebKit/public/platform/WebVector.h" |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 class WebRtcMediaStreamAdapterTest : public ::testing::Test { | 24 class WebRtcMediaStreamAdapterTest : public ::testing::Test { |
| 25 public: | 25 public: |
| 26 virtual void SetUp() { | 26 virtual void SetUp() { |
| 27 child_process_.reset(new ChildProcess()); | 27 child_process_.reset(new ChildProcess()); |
| 28 dependency_factory_.reset(new MockMediaStreamDependencyFactory()); | 28 dependency_factory_.reset(new MockPeerConnectionDependencyFactory()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 blink::WebMediaStream CreateBlinkMediaStream(bool audio, bool video) { | 31 blink::WebMediaStream CreateBlinkMediaStream(bool audio, bool video) { |
| 32 blink::WebVector<blink::WebMediaStreamTrack> audio_track_vector( | 32 blink::WebVector<blink::WebMediaStreamTrack> audio_track_vector( |
| 33 audio ? static_cast<size_t>(1) : 0); | 33 audio ? static_cast<size_t>(1) : 0); |
| 34 if (audio) { | 34 if (audio) { |
| 35 blink::WebMediaStreamSource audio_source; | 35 blink::WebMediaStreamSource audio_source; |
| 36 audio_source.initialize("audio", | 36 audio_source.initialize("audio", |
| 37 blink::WebMediaStreamSource::TypeAudio, | 37 blink::WebMediaStreamSource::TypeAudio, |
| 38 "audio"); | 38 "audio"); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 adapter_->webrtc_media_stream()->label()); | 87 adapter_->webrtc_media_stream()->label()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 webrtc::MediaStreamInterface* webrtc_stream() { | 90 webrtc::MediaStreamInterface* webrtc_stream() { |
| 91 return adapter_->webrtc_media_stream(); | 91 return adapter_->webrtc_media_stream(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 protected: | 94 protected: |
| 95 base::MessageLoop message_loop_; | 95 base::MessageLoop message_loop_; |
| 96 scoped_ptr<ChildProcess> child_process_; | 96 scoped_ptr<ChildProcess> child_process_; |
| 97 scoped_ptr<MockMediaStreamDependencyFactory> dependency_factory_; | 97 scoped_ptr<MockPeerConnectionDependencyFactory> dependency_factory_; |
| 98 scoped_ptr<WebRtcMediaStreamAdapter> adapter_; | 98 scoped_ptr<WebRtcMediaStreamAdapter> adapter_; |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 TEST_F(WebRtcMediaStreamAdapterTest, CreateWebRtcMediaStream) { | 101 TEST_F(WebRtcMediaStreamAdapterTest, CreateWebRtcMediaStream) { |
| 102 blink::WebMediaStream blink_stream = CreateBlinkMediaStream(true, true); | 102 blink::WebMediaStream blink_stream = CreateBlinkMediaStream(true, true); |
| 103 CreateWebRtcMediaStream(blink_stream, 1, 1); | 103 CreateWebRtcMediaStream(blink_stream, 1, 1); |
| 104 } | 104 } |
| 105 | 105 |
| 106 // Test that we don't crash if a MediaStream is created in Blink with an unknown | 106 // Test that we don't crash if a MediaStream is created in Blink with an unknown |
| 107 // audio sources. This can happen if a MediaStream is created with | 107 // audio sources. This can happen if a MediaStream is created with |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 EXPECT_TRUE(webrtc_stream()->GetVideoTracks().empty()); | 146 EXPECT_TRUE(webrtc_stream()->GetVideoTracks().empty()); |
| 147 | 147 |
| 148 native_stream->AddTrack(audio_tracks[0]); | 148 native_stream->AddTrack(audio_tracks[0]); |
| 149 EXPECT_EQ(1u, webrtc_stream()->GetAudioTracks().size()); | 149 EXPECT_EQ(1u, webrtc_stream()->GetAudioTracks().size()); |
| 150 | 150 |
| 151 native_stream->AddTrack(video_tracks[0]); | 151 native_stream->AddTrack(video_tracks[0]); |
| 152 EXPECT_EQ(1u, webrtc_stream()->GetVideoTracks().size()); | 152 EXPECT_EQ(1u, webrtc_stream()->GetVideoTracks().size()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace content | 155 } // namespace content |
| OLD | NEW |