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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 video_config_.max_number_of_video_buffers_used = 3; | 78 video_config_.max_number_of_video_buffers_used = 3; |
79 video_config_.codec = transport::kVp8; | 79 video_config_.codec = transport::kVp8; |
80 gfx::Size size(video_config_.width, video_config_.height); | 80 gfx::Size size(video_config_.width, video_config_.height); |
81 video_frame_ = media::VideoFrame::CreateFrame(VideoFrame::I420, | 81 video_frame_ = media::VideoFrame::CreateFrame(VideoFrame::I420, |
82 size, gfx::Rect(size), size, base::TimeDelta()); | 82 size, gfx::Rect(size), size, base::TimeDelta()); |
83 PopulateVideoFrame(video_frame_, 123); | 83 PopulateVideoFrame(video_frame_, 123); |
84 } | 84 } |
85 | 85 |
86 virtual ~VideoEncoderImplTest() {} | 86 virtual ~VideoEncoderImplTest() {} |
87 | 87 |
88 virtual void SetUp() { | 88 virtual void SetUp() OVERRIDE { |
89 task_runner_ = new test::FakeTaskRunner(&testing_clock_); | 89 testing_clock_ = new base::SimpleTestTickClock(); |
90 cast_environment_ = new CastEnvironment(&testing_clock_, task_runner_, | 90 task_runner_ = new test::FakeTaskRunner(testing_clock_); |
| 91 cast_environment_ = new CastEnvironment( |
| 92 scoped_ptr<base::TickClock>(testing_clock_).Pass(), task_runner_, |
91 task_runner_, task_runner_, task_runner_, task_runner_, | 93 task_runner_, task_runner_, task_runner_, task_runner_, |
92 task_runner_, GetDefaultCastSenderLoggingConfig()); | 94 task_runner_, GetDefaultCastSenderLoggingConfig()); |
93 } | 95 } |
94 | 96 |
95 void Configure(uint8 max_unacked_frames) { | 97 void Configure(uint8 max_unacked_frames) { |
96 video_encoder_.reset(new VideoEncoderImpl(cast_environment_, video_config_, | 98 video_encoder_.reset(new VideoEncoderImpl(cast_environment_, video_config_, |
97 max_unacked_frames)); | 99 max_unacked_frames)); |
98 } | 100 } |
99 | 101 |
100 base::SimpleTestTickClock testing_clock_; | 102 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. |
101 scoped_refptr<TestVideoEncoderCallback> test_video_encoder_callback_; | 103 scoped_refptr<TestVideoEncoderCallback> test_video_encoder_callback_; |
102 VideoSenderConfig video_config_; | 104 VideoSenderConfig video_config_; |
103 scoped_refptr<test::FakeTaskRunner> task_runner_; | 105 scoped_refptr<test::FakeTaskRunner> task_runner_; |
104 scoped_ptr<VideoEncoder> video_encoder_; | 106 scoped_ptr<VideoEncoder> video_encoder_; |
105 scoped_refptr<media::VideoFrame> video_frame_; | 107 scoped_refptr<media::VideoFrame> video_frame_; |
106 | 108 |
107 scoped_refptr<CastEnvironment> cast_environment_; | 109 scoped_refptr<CastEnvironment> cast_environment_; |
108 }; | 110 }; |
109 | 111 |
110 TEST_F(VideoEncoderImplTest, EncodePattern30fpsRunningOutOfAck) { | 112 TEST_F(VideoEncoderImplTest, EncodePattern30fpsRunningOutOfAck) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 for (int i = 5; i < 17; ++i) { | 240 for (int i = 5; i < 17; ++i) { |
239 test_video_encoder_callback_->SetExpectedResult(false, i, 4, capture_time); | 241 test_video_encoder_callback_->SetExpectedResult(false, i, 4, capture_time); |
240 EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, | 242 EXPECT_TRUE(video_encoder_->EncodeVideoFrame(video_frame_, capture_time, |
241 frame_encoded_callback)); | 243 frame_encoded_callback)); |
242 task_runner_->RunTasks(); | 244 task_runner_->RunTasks(); |
243 } | 245 } |
244 } | 246 } |
245 | 247 |
246 } // namespace cast | 248 } // namespace cast |
247 } // namespace media | 249 } // namespace media |
OLD | NEW |