OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/test/simple_test_tick_clock.h" | 9 #include "base/test/simple_test_tick_clock.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 : VideoSender(cast_environment, video_config, gpu_factories, | 75 : VideoSender(cast_environment, video_config, gpu_factories, |
76 transport_sender) { | 76 transport_sender) { |
77 } | 77 } |
78 using VideoSender::OnReceivedCastFeedback; | 78 using VideoSender::OnReceivedCastFeedback; |
79 }; | 79 }; |
80 } // namespace | 80 } // namespace |
81 | 81 |
82 class VideoSenderTest : public ::testing::Test { | 82 class VideoSenderTest : public ::testing::Test { |
83 protected: | 83 protected: |
84 VideoSenderTest() { | 84 VideoSenderTest() { |
85 testing_clock_.Advance( | 85 testing_clock_ = new base::SimpleTestTickClock(); |
| 86 testing_clock_->Advance( |
86 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | 87 base::TimeDelta::FromMilliseconds(kStartMillisecond)); |
87 task_runner_ = new test::FakeTaskRunner(&testing_clock_); | 88 task_runner_ = new test::FakeTaskRunner(testing_clock_); |
88 cast_environment_ = new CastEnvironment( | 89 cast_environment_ = new CastEnvironment( |
89 &testing_clock_, task_runner_, task_runner_, task_runner_, task_runner_, | 90 scoped_ptr<base::TickClock>(testing_clock_).Pass(), |
| 91 task_runner_, task_runner_, task_runner_, task_runner_, |
90 task_runner_, task_runner_, GetDefaultCastSenderLoggingConfig()); | 92 task_runner_, task_runner_, GetDefaultCastSenderLoggingConfig()); |
91 transport::CastTransportConfig transport_config; | 93 transport::CastTransportConfig transport_config; |
92 transport_sender_.reset(new transport::CastTransportSenderImpl( | 94 transport_sender_.reset(new transport::CastTransportSenderImpl( |
93 &testing_clock_, transport_config, | 95 testing_clock_, transport_config, |
94 base::Bind(&UpdateCastTransportStatus), task_runner_)); | 96 base::Bind(&UpdateCastTransportStatus), task_runner_)); |
95 transport_sender_->InsertFakeTransportForTesting(&transport_); | 97 transport_sender_->InsertFakeTransportForTesting(&transport_); |
96 } | 98 } |
97 | 99 |
98 virtual ~VideoSenderTest() {} | 100 virtual ~VideoSenderTest() {} |
99 | 101 |
100 static void UpdateCastTransportStatus(transport::CastTransportStatus status) { | 102 static void UpdateCastTransportStatus(transport::CastTransportStatus status) { |
101 } | 103 } |
102 | 104 |
103 void InitEncoder(bool external) { | 105 void InitEncoder(bool external) { |
(...skipping 30 matching lines...) Expand all Loading... |
134 scoped_refptr<media::VideoFrame> video_frame = | 136 scoped_refptr<media::VideoFrame> video_frame = |
135 media::VideoFrame::CreateFrame(VideoFrame::I420, size, gfx::Rect(size), | 137 media::VideoFrame::CreateFrame(VideoFrame::I420, size, gfx::Rect(size), |
136 size, base::TimeDelta()); | 138 size, base::TimeDelta()); |
137 PopulateVideoFrame(video_frame, kPixelValue); | 139 PopulateVideoFrame(video_frame, kPixelValue); |
138 return video_frame; | 140 return video_frame; |
139 } | 141 } |
140 | 142 |
141 void RunTasks(int during_ms) { | 143 void RunTasks(int during_ms) { |
142 for (int i = 0; i < during_ms; ++i) { | 144 for (int i = 0; i < during_ms; ++i) { |
143 // Call process the timers every 1 ms. | 145 // Call process the timers every 1 ms. |
144 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(1)); | 146 testing_clock_->Advance(base::TimeDelta::FromMilliseconds(1)); |
145 task_runner_->RunTasks(); | 147 task_runner_->RunTasks(); |
146 } | 148 } |
147 } | 149 } |
148 | 150 |
149 base::SimpleTestTickClock testing_clock_; | 151 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. |
150 TestPacketSender transport_; | 152 TestPacketSender transport_; |
151 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; | 153 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; |
152 scoped_refptr<test::FakeTaskRunner> task_runner_; | 154 scoped_refptr<test::FakeTaskRunner> task_runner_; |
153 scoped_ptr<PeerVideoSender> video_sender_; | 155 scoped_ptr<PeerVideoSender> video_sender_; |
154 scoped_refptr<CastEnvironment> cast_environment_; | 156 scoped_refptr<CastEnvironment> cast_environment_; |
155 | 157 |
156 DISALLOW_COPY_AND_ASSIGN(VideoSenderTest); | 158 DISALLOW_COPY_AND_ASSIGN(VideoSenderTest); |
157 }; | 159 }; |
158 | 160 |
159 TEST_F(VideoSenderTest, BuiltInEncoder) { | 161 TEST_F(VideoSenderTest, BuiltInEncoder) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // Make sure that we do a re-send. | 226 // Make sure that we do a re-send. |
225 RunTasks(max_resend_timeout.InMilliseconds()); | 227 RunTasks(max_resend_timeout.InMilliseconds()); |
226 // Should have sent at least 3 packets. | 228 // Should have sent at least 3 packets. |
227 EXPECT_GE( | 229 EXPECT_GE( |
228 transport_.number_of_rtp_packets() + transport_.number_of_rtcp_packets(), | 230 transport_.number_of_rtp_packets() + transport_.number_of_rtcp_packets(), |
229 3); | 231 3); |
230 } | 232 } |
231 | 233 |
232 } // namespace cast | 234 } // namespace cast |
233 } // namespace media | 235 } // namespace media |
234 | |
OLD | NEW |