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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/test/simple_test_tick_clock.h" | 11 #include "base/test/simple_test_tick_clock.h" |
12 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
13 #include "media/cast/cast_environment.h" | 13 #include "media/cast/cast_environment.h" |
14 #include "media/cast/logging/simple_event_subscriber.h" | 14 #include "media/cast/logging/simple_event_subscriber.h" |
15 #include "media/cast/test/fake_single_thread_task_runner.h" | 15 #include "media/cast/test/fake_single_thread_task_runner.h" |
16 #include "media/cast/test/fake_video_encode_accelerator.h" | 16 #include "media/cast/test/fake_video_encode_accelerator.h" |
17 #include "media/cast/test/utility/default_config.h" | 17 #include "media/cast/test/utility/default_config.h" |
18 #include "media/cast/test/utility/video_utility.h" | 18 #include "media/cast/test/utility/video_utility.h" |
19 #include "media/cast/transport/cast_transport_config.h" | 19 #include "media/cast/transport/cast_transport_config.h" |
20 #include "media/cast/transport/cast_transport_sender_impl.h" | 20 #include "media/cast/transport/cast_transport_sender_impl.h" |
21 #include "media/cast/transport/pacing/paced_sender.h" | 21 #include "media/cast/transport/pacing/paced_sender.h" |
22 #include "media/cast/video_sender/video_sender.h" | 22 #include "media/cast/video_sender/video_sender.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 | 25 |
26 namespace media { | 26 namespace media { |
27 namespace cast { | 27 namespace cast { |
28 | 28 |
29 namespace { | 29 namespace { |
30 static const int64 kStartMillisecond = INT64_C(12345678900000); | |
31 static const uint8 kPixelValue = 123; | 30 static const uint8 kPixelValue = 123; |
32 static const int kWidth = 320; | 31 static const int kWidth = 320; |
33 static const int kHeight = 240; | 32 static const int kHeight = 240; |
34 | 33 |
35 using testing::_; | 34 using testing::_; |
36 using testing::AtLeast; | 35 using testing::AtLeast; |
37 | 36 |
38 void CreateVideoEncodeAccelerator( | 37 void CreateVideoEncodeAccelerator( |
39 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 38 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
40 scoped_ptr<VideoEncodeAccelerator> fake_vea, | 39 scoped_ptr<VideoEncodeAccelerator> fake_vea, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 cast_initialization_cb, | 93 cast_initialization_cb, |
95 transport_sender) {} | 94 transport_sender) {} |
96 using VideoSender::OnReceivedCastFeedback; | 95 using VideoSender::OnReceivedCastFeedback; |
97 }; | 96 }; |
98 } // namespace | 97 } // namespace |
99 | 98 |
100 class VideoSenderTest : public ::testing::Test { | 99 class VideoSenderTest : public ::testing::Test { |
101 protected: | 100 protected: |
102 VideoSenderTest() { | 101 VideoSenderTest() { |
103 testing_clock_ = new base::SimpleTestTickClock(); | 102 testing_clock_ = new base::SimpleTestTickClock(); |
104 testing_clock_->Advance( | 103 testing_clock_->Advance(base::TimeTicks::Now() - base::TimeTicks()); |
105 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | |
106 task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); | 104 task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); |
107 cast_environment_ = | 105 cast_environment_ = |
108 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), | 106 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), |
109 task_runner_, | 107 task_runner_, |
110 task_runner_, | 108 task_runner_, |
111 task_runner_); | 109 task_runner_); |
112 net::IPEndPoint dummy_endpoint; | 110 net::IPEndPoint dummy_endpoint; |
113 transport_sender_.reset(new transport::CastTransportSenderImpl( | 111 transport_sender_.reset(new transport::CastTransportSenderImpl( |
114 NULL, | 112 NULL, |
115 testing_clock_, | 113 testing_clock_, |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 // Empty the pipeline. | 358 // Empty the pipeline. |
361 RunTasks(100); | 359 RunTasks(100); |
362 // Should have sent at least 7 packets. | 360 // Should have sent at least 7 packets. |
363 EXPECT_GE( | 361 EXPECT_GE( |
364 transport_.number_of_rtp_packets() + transport_.number_of_rtcp_packets(), | 362 transport_.number_of_rtp_packets() + transport_.number_of_rtcp_packets(), |
365 7); | 363 7); |
366 } | 364 } |
367 | 365 |
368 } // namespace cast | 366 } // namespace cast |
369 } // namespace media | 367 } // namespace media |
OLD | NEW |