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 "media/cast/net/rtcp/rtcp_utility.h" |
| 6 |
5 #include <stdint.h> | 7 #include <stdint.h> |
6 | 8 |
| 9 #include <memory> |
| 10 |
7 #include "base/macros.h" | 11 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/test/simple_test_tick_clock.h" | 12 #include "base/test/simple_test_tick_clock.h" |
10 #include "media/base/fake_single_thread_task_runner.h" | 13 #include "media/base/fake_single_thread_task_runner.h" |
11 #include "media/cast/cast_environment.h" | 14 #include "media/cast/cast_environment.h" |
12 #include "media/cast/net/cast_transport_defines.h" | 15 #include "media/cast/net/cast_transport_defines.h" |
13 #include "media/cast/net/rtcp/rtcp_utility.h" | |
14 #include "media/cast/net/rtcp/test_rtcp_packet_builder.h" | 16 #include "media/cast/net/rtcp/test_rtcp_packet_builder.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
16 | 18 |
17 namespace media { | 19 namespace media { |
18 namespace cast { | 20 namespace cast { |
19 | 21 |
20 static const uint32_t kRemoteSsrc = 0x10203; | 22 static const uint32_t kRemoteSsrc = 0x10203; |
21 static const uint32_t kLocalSsrc = 0x40506; | 23 static const uint32_t kLocalSsrc = 0x40506; |
22 static const uint32_t kUnknownSsrc = 0xDEAD; | 24 static const uint32_t kUnknownSsrc = 0xDEAD; |
23 static const base::TimeDelta kTargetDelay = | 25 static const base::TimeDelta kTargetDelay = |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (event_expected_it->type == PACKET_RECEIVED) { | 129 if (event_expected_it->type == PACKET_RECEIVED) { |
128 EXPECT_EQ(event_expected_it->packet_id, event_incoming_it->packet_id); | 130 EXPECT_EQ(event_expected_it->packet_id, event_incoming_it->packet_id); |
129 } else { | 131 } else { |
130 EXPECT_EQ(event_expected_it->delay_delta, | 132 EXPECT_EQ(event_expected_it->delay_delta, |
131 event_incoming_it->delay_delta); | 133 event_incoming_it->delay_delta); |
132 } | 134 } |
133 } | 135 } |
134 } | 136 } |
135 } | 137 } |
136 | 138 |
137 scoped_ptr<base::SimpleTestTickClock> testing_clock_; | 139 std::unique_ptr<base::SimpleTestTickClock> testing_clock_; |
138 scoped_refptr<FakeSingleThreadTaskRunner> task_runner_; | 140 scoped_refptr<FakeSingleThreadTaskRunner> task_runner_; |
139 | 141 |
140 private: | 142 private: |
141 DISALLOW_COPY_AND_ASSIGN(RtcpParserTest); | 143 DISALLOW_COPY_AND_ASSIGN(RtcpParserTest); |
142 }; | 144 }; |
143 | 145 |
144 TEST_F(RtcpParserTest, BrokenPacketIsIgnored) { | 146 TEST_F(RtcpParserTest, BrokenPacketIsIgnored) { |
145 const char bad_packet[] = {0, 0, 0, 0}; | 147 const char bad_packet[] = {0, 0, 0, 0}; |
146 RtcpParser parser(kLocalSsrc, kRemoteSsrc); | 148 RtcpParser parser(kLocalSsrc, kRemoteSsrc); |
147 base::BigEndianReader reader(bad_packet, sizeof(bad_packet)); | 149 base::BigEndianReader reader(bad_packet, sizeof(bad_packet)); |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fraction_3); | 547 base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fraction_3); |
546 EXPECT_EQ(input_time, out_3); // Verify inverse. | 548 EXPECT_EQ(input_time, out_3); // Verify inverse. |
547 | 549 |
548 // Verify delta. | 550 // Verify delta. |
549 EXPECT_EQ((out_3 - out_2), time_delta); | 551 EXPECT_EQ((out_3 - out_2), time_delta); |
550 EXPECT_NEAR((ntp_fraction_3 - ntp_fraction_2), 0xffffffff / 2, 1); | 552 EXPECT_NEAR((ntp_fraction_3 - ntp_fraction_2), 0xffffffff / 2, 1); |
551 } | 553 } |
552 | 554 |
553 } // namespace cast | 555 } // namespace cast |
554 } // namespace media | 556 } // namespace media |
OLD | NEW |