| 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/child/child_process.h" | 8 #include "content/child/child_process.h" |
| 9 #include "content/renderer/media/media_stream_video_track.h" | 9 #include "content/renderer/media/media_stream_video_track.h" |
| 10 #include "content/renderer/media/mock_media_stream_video_sink.h" | 10 #include "content/renderer/media/mock_media_stream_video_sink.h" |
| 11 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h" | 11 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h" |
| 12 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory.
h" | 12 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory.
h" |
| 13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/WebKit/public/web/WebHeap.h" |
| 15 #include "third_party/libjingle/source/talk/media/webrtc/webrtcvideoframe.h" | 16 #include "third_party/libjingle/source/talk/media/webrtc/webrtcvideoframe.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 ACTION_P(RunClosure, closure) { | 20 ACTION_P(RunClosure, closure) { |
| 20 closure.Run(); | 21 closure.Run(); |
| 21 } | 22 } |
| 22 | 23 |
| 23 class MediaStreamRemoteVideoSourceUnderTest | 24 class MediaStreamRemoteVideoSourceUnderTest |
| 24 : public MediaStreamRemoteVideoSource { | 25 : public MediaStreamRemoteVideoSource { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 41 remote_source_(new MediaStreamRemoteVideoSourceUnderTest( | 42 remote_source_(new MediaStreamRemoteVideoSourceUnderTest( |
| 42 webrtc_video_track_.get())), | 43 webrtc_video_track_.get())), |
| 43 number_of_successful_constraints_applied_(0), | 44 number_of_successful_constraints_applied_(0), |
| 44 number_of_failed_constraints_applied_(0) { | 45 number_of_failed_constraints_applied_(0) { |
| 45 webkit_source_.initialize(base::UTF8ToUTF16("dummy_source_id"), | 46 webkit_source_.initialize(base::UTF8ToUTF16("dummy_source_id"), |
| 46 blink::WebMediaStreamSource::TypeVideo, | 47 blink::WebMediaStreamSource::TypeVideo, |
| 47 base::UTF8ToUTF16("dummy_source_name")); | 48 base::UTF8ToUTF16("dummy_source_name")); |
| 48 webkit_source_.setExtraData(remote_source_); | 49 webkit_source_.setExtraData(remote_source_); |
| 49 } | 50 } |
| 50 | 51 |
| 52 virtual void TearDown() OVERRIDE { |
| 53 webkit_source_.reset(); |
| 54 blink::WebHeap::collectAllGarbageForTesting(); |
| 55 } |
| 56 |
| 51 MediaStreamRemoteVideoSourceUnderTest* source() { | 57 MediaStreamRemoteVideoSourceUnderTest* source() { |
| 52 return remote_source_; | 58 return remote_source_; |
| 53 } | 59 } |
| 54 | 60 |
| 55 MediaStreamVideoTrack* CreateTrack() { | 61 MediaStreamVideoTrack* CreateTrack() { |
| 56 bool enabled = true; | 62 bool enabled = true; |
| 57 blink::WebMediaConstraints constraints; | 63 blink::WebMediaConstraints constraints; |
| 58 constraints.initialize(); | 64 constraints.initialize(); |
| 59 return new MediaStreamVideoTrack( | 65 return new MediaStreamVideoTrack( |
| 60 source(), | 66 source(), |
| 61 constraints, | 67 constraints, |
| 62 base::Bind( | 68 base::Bind( |
| 63 &MediaStreamRemoteVideoSourceTest::OnConstraintsApplied, | 69 &MediaStreamRemoteVideoSourceTest::OnConstraintsApplied, |
| 64 base::Unretained(this)), | 70 base::Unretained(this)), |
| 65 enabled); | 71 enabled); |
| 66 } | 72 } |
| 67 | 73 |
| 68 int NumberOfSuccessConstraintsCallbacks() const { | 74 int NumberOfSuccessConstraintsCallbacks() const { |
| 69 return number_of_successful_constraints_applied_; | 75 return number_of_successful_constraints_applied_; |
| 70 } | 76 } |
| 71 | 77 |
| 72 int NumberOfFailedConstraintsCallbacks() const { | 78 int NumberOfFailedConstraintsCallbacks() const { |
| 73 return number_of_failed_constraints_applied_; | 79 return number_of_failed_constraints_applied_; |
| 74 } | 80 } |
| 75 | 81 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 webkit_source().readyState()); | 139 webkit_source().readyState()); |
| 134 StopWebRtcTrack(); | 140 StopWebRtcTrack(); |
| 135 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, | 141 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, |
| 136 webkit_source().readyState()); | 142 webkit_source().readyState()); |
| 137 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, sink.state()); | 143 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, sink.state()); |
| 138 | 144 |
| 139 track->RemoveSink(&sink); | 145 track->RemoveSink(&sink); |
| 140 } | 146 } |
| 141 | 147 |
| 142 } // namespace content | 148 } // namespace content |
| OLD | NEW |