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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/test/simple_test_tick_clock.h" |
6 #include "media/cast/cast_defines.h" | 7 #include "media/cast/cast_defines.h" |
| 8 #include "media/cast/cast_environment.h" |
7 #include "media/cast/pacing/paced_sender.h" | 9 #include "media/cast/pacing/paced_sender.h" |
8 #include "media/cast/rtcp/rtcp_sender.h" | 10 #include "media/cast/rtcp/rtcp_sender.h" |
9 #include "media/cast/rtcp/test_rtcp_packet_builder.h" | 11 #include "media/cast/rtcp/test_rtcp_packet_builder.h" |
| 12 #include "media/cast/test/fake_task_runner.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
11 | 14 |
12 namespace media { | 15 namespace media { |
13 namespace cast { | 16 namespace cast { |
14 | 17 |
| 18 namespace { |
15 static const uint32 kSendingSsrc = 0x12345678; | 19 static const uint32 kSendingSsrc = 0x12345678; |
16 static const uint32 kMediaSsrc = 0x87654321; | 20 static const uint32 kMediaSsrc = 0x87654321; |
17 static const std::string kCName("test@10.1.1.1"); | 21 static const std::string kCName("test@10.1.1.1"); |
| 22 } // namespace |
18 | 23 |
19 class TestRtcpTransport : public PacedPacketSender { | 24 class TestRtcpTransport : public PacedPacketSender { |
20 public: | 25 public: |
21 TestRtcpTransport() | 26 TestRtcpTransport() |
22 : expected_packet_length_(0), | 27 : expected_packet_length_(0), |
23 packet_count_(0) { | 28 packet_count_(0) { |
24 } | 29 } |
25 | 30 |
26 virtual bool SendRtcpPacket(const Packet& packet) OVERRIDE { | 31 virtual bool SendRtcpPacket(const Packet& packet) OVERRIDE { |
27 EXPECT_EQ(expected_packet_length_, packet.size()); | 32 EXPECT_EQ(expected_packet_length_, packet.size()); |
(...skipping 19 matching lines...) Expand all Loading... |
47 | 52 |
48 private: | 53 private: |
49 uint8 expected_packet_[kIpPacketSize]; | 54 uint8 expected_packet_[kIpPacketSize]; |
50 size_t expected_packet_length_; | 55 size_t expected_packet_length_; |
51 int packet_count_; | 56 int packet_count_; |
52 }; | 57 }; |
53 | 58 |
54 class RtcpSenderTest : public ::testing::Test { | 59 class RtcpSenderTest : public ::testing::Test { |
55 protected: | 60 protected: |
56 RtcpSenderTest() | 61 RtcpSenderTest() |
57 : rtcp_sender_(new RtcpSender(&test_transport_, | 62 : task_runner_(new test::FakeTaskRunner(&testing_clock_)), |
| 63 cast_environment_(new CastEnvironment(&testing_clock_, task_runner_, |
| 64 task_runner_, task_runner_, task_runner_, task_runner_, |
| 65 GetDefaultCastLoggingConfig())), |
| 66 rtcp_sender_(new RtcpSender(cast_environment_, |
| 67 &test_transport_, |
58 kSendingSsrc, | 68 kSendingSsrc, |
59 kCName)) { | 69 kCName)) { |
60 } | 70 } |
61 | 71 |
| 72 base::SimpleTestTickClock testing_clock_; |
62 TestRtcpTransport test_transport_; | 73 TestRtcpTransport test_transport_; |
| 74 scoped_refptr<test::FakeTaskRunner> task_runner_; |
| 75 scoped_refptr<CastEnvironment> cast_environment_; |
63 scoped_ptr<RtcpSender> rtcp_sender_; | 76 scoped_ptr<RtcpSender> rtcp_sender_; |
64 }; | 77 }; |
65 | 78 |
66 TEST_F(RtcpSenderTest, RtcpSenderReport) { | 79 TEST_F(RtcpSenderTest, RtcpSenderReport) { |
67 RtcpSenderInfo sender_info; | 80 RtcpSenderInfo sender_info; |
68 sender_info.ntp_seconds = kNtpHigh; | 81 sender_info.ntp_seconds = kNtpHigh; |
69 sender_info.ntp_fraction = kNtpLow; | 82 sender_info.ntp_fraction = kNtpLow; |
70 sender_info.rtp_timestamp = kRtpTimestamp; | 83 sender_info.rtp_timestamp = kRtpTimestamp; |
71 sender_info.send_packet_count = kSendPacketCount; | 84 sender_info.send_packet_count = kSendPacketCount; |
72 sender_info.send_octet_count = kSendOctetCount; | 85 sender_info.send_octet_count = kSendOctetCount; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 &report_block, | 236 &report_block, |
224 NULL, | 237 NULL, |
225 &cast_message, | 238 &cast_message, |
226 NULL); | 239 NULL); |
227 | 240 |
228 EXPECT_EQ(1, test_transport_.packet_count()); | 241 EXPECT_EQ(1, test_transport_.packet_count()); |
229 } | 242 } |
230 | 243 |
231 } // namespace cast | 244 } // namespace cast |
232 } // namespace media | 245 } // namespace media |
OLD | NEW |