| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 MediaStreamVideoTrack::CreateVideoTrack( | 75 MediaStreamVideoTrack::CreateVideoTrack( |
| 76 mock_source_, constraints, | 76 mock_source_, constraints, |
| 77 MediaStreamSource::ConstraintsCallback(), enabled); | 77 MediaStreamSource::ConstraintsCallback(), enabled); |
| 78 if (!source_started_) { | 78 if (!source_started_) { |
| 79 mock_source_->StartMockedSource(); | 79 mock_source_->StartMockedSource(); |
| 80 source_started_ = true; | 80 source_started_ = true; |
| 81 } | 81 } |
| 82 return track; | 82 return track; |
| 83 } | 83 } |
| 84 | 84 |
| 85 void UpdateVideoSourceToRespondToRequestRefreshFrame() { |
| 86 blink_source_.reset(); |
| 87 mock_source_ = new MockMediaStreamVideoSource(false, true); |
| 88 blink_source_.initialize(base::UTF8ToUTF16("dummy_source_id"), |
| 89 blink::WebMediaStreamSource::TypeVideo, |
| 90 base::UTF8ToUTF16("dummy_source_name"), |
| 91 false /* remote */, true /* readonly */); |
| 92 blink_source_.setExtraData(mock_source_); |
| 93 } |
| 94 |
| 85 MockMediaStreamVideoSource* mock_source() { return mock_source_; } | 95 MockMediaStreamVideoSource* mock_source() { return mock_source_; } |
| 86 const blink::WebMediaStreamSource& blink_source() const { | 96 const blink::WebMediaStreamSource& blink_source() const { |
| 87 return blink_source_; | 97 return blink_source_; |
| 88 } | 98 } |
| 89 | 99 |
| 90 private: | 100 private: |
| 91 const base::MessageLoopForUI message_loop_; | 101 const base::MessageLoopForUI message_loop_; |
| 92 const scoped_ptr<ChildProcess> child_process_; | 102 const scoped_ptr<ChildProcess> child_process_; |
| 93 blink::WebMediaStreamSource blink_source_; | 103 blink::WebMediaStreamSource blink_source_; |
| 94 // |mock_source_| is owned by |webkit_source_|. | 104 // |mock_source_| is owned by |webkit_source_|. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 235 |
| 226 MediaStreamVideoTrack* const native_track2 = | 236 MediaStreamVideoTrack* const native_track2 = |
| 227 MediaStreamVideoTrack::GetVideoTrack(track2); | 237 MediaStreamVideoTrack::GetVideoTrack(track2); |
| 228 native_track2->Stop(); | 238 native_track2->Stop(); |
| 229 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, sink2.state()); | 239 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, sink2.state()); |
| 230 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, | 240 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, |
| 231 blink_source().getReadyState()); | 241 blink_source().getReadyState()); |
| 232 MediaStreamVideoSink::RemoveFromVideoTrack(&sink2, track2); | 242 MediaStreamVideoSink::RemoveFromVideoTrack(&sink2, track2); |
| 233 } | 243 } |
| 234 | 244 |
| 245 TEST_F(MediaStreamVideoTrackTest, CheckTrackRequestsFrame) { |
| 246 UpdateVideoSourceToRespondToRequestRefreshFrame(); |
| 247 blink::WebMediaStreamTrack track = CreateTrack(); |
| 248 |
| 249 // Add sink and expect to get a frame. |
| 250 MockMediaStreamVideoSink sink; |
| 251 base::RunLoop run_loop; |
| 252 base::Closure quit_closure = run_loop.QuitClosure(); |
| 253 EXPECT_CALL(sink, OnVideoFrame()).WillOnce(RunClosure(quit_closure)); |
| 254 MediaStreamVideoSink::AddToVideoTrack(&sink, sink.GetDeliverFrameCB(), track); |
| 255 run_loop.Run(); |
| 256 EXPECT_EQ(1, sink.number_of_frames()); |
| 257 |
| 258 MediaStreamVideoSink::RemoveFromVideoTrack(&sink, track); |
| 259 } |
| 260 |
| 235 } // namespace content | 261 } // namespace content |
| OLD | NEW |