| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback_helpers.h" | 6 #include "base/callback_helpers.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/child/child_process.h" | 10 #include "content/child/child_process.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 MockVideoCapturerDelegate& mock_delegate() { | 70 MockVideoCapturerDelegate& mock_delegate() { |
| 71 return *static_cast<MockVideoCapturerDelegate*>(delegate_.get()); | 71 return *static_cast<MockVideoCapturerDelegate*>(delegate_.get()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void OnSourceStopped(const blink::WebMediaStreamSource& source) { | 74 void OnSourceStopped(const blink::WebMediaStreamSource& source) { |
| 75 source_stopped_ = true; | 75 source_stopped_ = true; |
| 76 EXPECT_EQ(source.id(), webkit_source_.id()); | 76 EXPECT_EQ(source.id(), webkit_source_.id()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 protected: | 79 protected: |
| 80 void OnConstraintsApplied(MediaStreamSource* source, bool success) { | 80 void OnConstraintsApplied(MediaStreamSource* source, |
| 81 MediaStreamRequestResult result, |
| 82 const blink::WebString& result_name) { |
| 81 } | 83 } |
| 82 | 84 |
| 83 base::MessageLoopForUI message_loop_; | 85 base::MessageLoopForUI message_loop_; |
| 84 scoped_ptr<ChildProcess> child_process_; | 86 scoped_ptr<ChildProcess> child_process_; |
| 85 blink::WebMediaStreamSource webkit_source_; | 87 blink::WebMediaStreamSource webkit_source_; |
| 86 MediaStreamVideoCapturerSource* source_; // owned by webkit_source. | 88 MediaStreamVideoCapturerSource* source_; // owned by webkit_source. |
| 87 scoped_refptr<VideoCapturerDelegate> delegate_; | 89 scoped_refptr<VideoCapturerDelegate> delegate_; |
| 88 bool source_stopped_; | 90 bool source_stopped_; |
| 89 }; | 91 }; |
| 90 | 92 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 179 |
| 178 EXPECT_CALL(mock_delegate(), StartCapture( | 180 EXPECT_CALL(mock_delegate(), StartCapture( |
| 179 testing::_, | 181 testing::_, |
| 180 testing::_, | 182 testing::_, |
| 181 testing::_)) | 183 testing::_)) |
| 182 .Times(1) | 184 .Times(1) |
| 183 .WillOnce(testing::DoAll(testing::SaveArg<1>(&deliver_frame_cb), | 185 .WillOnce(testing::DoAll(testing::SaveArg<1>(&deliver_frame_cb), |
| 184 testing::SaveArg<2>(&running_cb))); | 186 testing::SaveArg<2>(&running_cb))); |
| 185 EXPECT_CALL(mock_delegate(), StopCapture()); | 187 EXPECT_CALL(mock_delegate(), StopCapture()); |
| 186 blink::WebMediaStreamTrack track = StartSource(); | 188 blink::WebMediaStreamTrack track = StartSource(); |
| 187 running_cb.Run(true); | 189 running_cb.Run(MEDIA_DEVICE_OK); |
| 188 | 190 |
| 189 base::RunLoop run_loop; | 191 base::RunLoop run_loop; |
| 190 base::TimeTicks reference_capture_time = | 192 base::TimeTicks reference_capture_time = |
| 191 base::TimeTicks::FromInternalValue(60013); | 193 base::TimeTicks::FromInternalValue(60013); |
| 192 base::TimeTicks capture_time; | 194 base::TimeTicks capture_time; |
| 193 FakeMediaStreamVideoSink fake_sink( | 195 FakeMediaStreamVideoSink fake_sink( |
| 194 &capture_time, | 196 &capture_time, |
| 195 media::BindToCurrentLoop(run_loop.QuitClosure())); | 197 media::BindToCurrentLoop(run_loop.QuitClosure())); |
| 196 FakeMediaStreamVideoSink::AddToVideoTrack( | 198 FakeMediaStreamVideoSink::AddToVideoTrack( |
| 197 &fake_sink, | 199 &fake_sink, |
| 198 base::Bind(&FakeMediaStreamVideoSink::OnVideoFrame, | 200 base::Bind(&FakeMediaStreamVideoSink::OnVideoFrame, |
| 199 base::Unretained(&fake_sink)), | 201 base::Unretained(&fake_sink)), |
| 200 track); | 202 track); |
| 201 child_process_->io_message_loop()->PostTask( | 203 child_process_->io_message_loop()->PostTask( |
| 202 FROM_HERE, | 204 FROM_HERE, |
| 203 base::Bind(deliver_frame_cb, | 205 base::Bind(deliver_frame_cb, |
| 204 media::VideoFrame::CreateBlackFrame(gfx::Size(2, 2)), | 206 media::VideoFrame::CreateBlackFrame(gfx::Size(2, 2)), |
| 205 media::VideoCaptureFormat(), | 207 media::VideoCaptureFormat(), |
| 206 reference_capture_time)); | 208 reference_capture_time)); |
| 207 run_loop.Run(); | 209 run_loop.Run(); |
| 208 FakeMediaStreamVideoSink::RemoveFromVideoTrack(&fake_sink, track); | 210 FakeMediaStreamVideoSink::RemoveFromVideoTrack(&fake_sink, track); |
| 209 EXPECT_EQ(reference_capture_time, capture_time); | 211 EXPECT_EQ(reference_capture_time, capture_time); |
| 210 } | 212 } |
| 211 | 213 |
| 212 } // namespace content | 214 } // namespace content |
| OLD | NEW |