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/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/threading/thread_checker_impl.h" | 11 #include "base/threading/thread_checker_impl.h" |
12 #include "content/child/child_process.h" | 12 #include "content/child/child_process.h" |
13 #include "content/renderer/media/media_stream_video_track.h" | 13 #include "content/renderer/media/media_stream_video_track.h" |
14 #include "content/renderer/media/mock_media_stream_video_sink.h" | 14 #include "content/renderer/media/mock_media_stream_video_sink.h" |
15 #include "content/renderer/media/mock_media_stream_video_source.h" | 15 #include "content/renderer/media/mock_media_stream_video_source.h" |
16 #include "media/base/video_frame.h" | 16 #include "media/base/video_frame.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "third_party/WebKit/public/web/WebHeap.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 const uint8 kBlackValue = 0x00; | 22 const uint8 kBlackValue = 0x00; |
22 const uint8 kColorValue = 0xAB; | 23 const uint8 kColorValue = 0xAB; |
23 | 24 |
24 ACTION_P(RunClosure, closure) { | 25 ACTION_P(RunClosure, closure) { |
25 closure.Run(); | 26 closure.Run(); |
26 } | 27 } |
27 | 28 |
28 class MediaStreamVideoTrackTest : public ::testing::Test { | 29 class MediaStreamVideoTrackTest : public ::testing::Test { |
29 public: | 30 public: |
30 MediaStreamVideoTrackTest() | 31 MediaStreamVideoTrackTest() |
31 : child_process_(new ChildProcess()), | 32 : child_process_(new ChildProcess()), |
32 mock_source_(new MockMediaStreamVideoSource(false)), | 33 mock_source_(new MockMediaStreamVideoSource(false)), |
33 source_started_(false) { | 34 source_started_(false) { |
34 blink_source_.initialize(base::UTF8ToUTF16("dummy_source_id"), | 35 blink_source_.initialize(base::UTF8ToUTF16("dummy_source_id"), |
35 blink::WebMediaStreamSource::TypeVideo, | 36 blink::WebMediaStreamSource::TypeVideo, |
36 base::UTF8ToUTF16("dummy_source_name")); | 37 base::UTF8ToUTF16("dummy_source_name")); |
37 blink_source_.setExtraData(mock_source_); | 38 blink_source_.setExtraData(mock_source_); |
38 } | 39 } |
39 | 40 |
40 virtual ~MediaStreamVideoTrackTest() { | 41 virtual ~MediaStreamVideoTrackTest() { |
41 } | 42 } |
42 | 43 |
| 44 virtual void TearDown() OVERRIDE { |
| 45 blink_source_.reset(); |
| 46 blink::WebHeap::collectAllGarbageForTesting(); |
| 47 } |
| 48 |
43 void DeliverVideoFrameAndWaitForRenderer(MockMediaStreamVideoSink* sink) { | 49 void DeliverVideoFrameAndWaitForRenderer(MockMediaStreamVideoSink* sink) { |
44 base::RunLoop run_loop; | 50 base::RunLoop run_loop; |
45 base::Closure quit_closure = run_loop.QuitClosure(); | 51 base::Closure quit_closure = run_loop.QuitClosure(); |
46 EXPECT_CALL(*sink, OnVideoFrame()).WillOnce( | 52 EXPECT_CALL(*sink, OnVideoFrame()).WillOnce( |
47 RunClosure(quit_closure)); | 53 RunClosure(quit_closure)); |
48 scoped_refptr<media::VideoFrame> frame = | 54 scoped_refptr<media::VideoFrame> frame = |
49 media::VideoFrame::CreateColorFrame( | 55 media::VideoFrame::CreateColorFrame( |
50 gfx::Size(MediaStreamVideoSource::kDefaultWidth, | 56 gfx::Size(MediaStreamVideoSource::kDefaultWidth, |
51 MediaStreamVideoSource::kDefaultHeight), | 57 MediaStreamVideoSource::kDefaultHeight), |
52 kColorValue, kColorValue, kColorValue, base::TimeDelta()); | 58 kColorValue, kColorValue, kColorValue, base::TimeDelta()); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 MediaStreamVideoTrack* native_track2 = | 229 MediaStreamVideoTrack* native_track2 = |
224 MediaStreamVideoTrack::GetVideoTrack(track2); | 230 MediaStreamVideoTrack::GetVideoTrack(track2); |
225 native_track2->Stop(); | 231 native_track2->Stop(); |
226 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, sink2.state()); | 232 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, sink2.state()); |
227 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, | 233 EXPECT_EQ(blink::WebMediaStreamSource::ReadyStateEnded, |
228 blink_source().readyState()); | 234 blink_source().readyState()); |
229 MediaStreamVideoSink::RemoveFromVideoTrack(&sink2, track2); | 235 MediaStreamVideoSink::RemoveFromVideoTrack(&sink2, track2); |
230 } | 236 } |
231 | 237 |
232 } // namespace content | 238 } // namespace content |
OLD | NEW |