| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <deque> | 9 #include <deque> |
| 10 | 10 |
| 11 #include "base/big_endian.h" | 11 #include "base/big_endian.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/test/simple_test_tick_clock.h" | 13 #include "base/test/simple_test_tick_clock.h" |
| 14 #include "media/base/fake_single_thread_task_runner.h" |
| 14 #include "media/cast/net/pacing/paced_sender.h" | 15 #include "media/cast/net/pacing/paced_sender.h" |
| 15 #include "media/cast/test/fake_single_thread_task_runner.h" | |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 17 | 17 |
| 18 using testing::_; | 18 using testing::_; |
| 19 | 19 |
| 20 namespace media { | 20 namespace media { |
| 21 namespace cast { | 21 namespace cast { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 const uint8_t kValue = 123; | 24 const uint8_t kValue = 123; |
| 25 const size_t kSize1 = 101; | 25 const size_t kSize1 = 101; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 int64_t bytes_sent_; | 88 int64_t bytes_sent_; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(TestPacketSender); | 90 DISALLOW_COPY_AND_ASSIGN(TestPacketSender); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 class PacedSenderTest : public ::testing::Test { | 93 class PacedSenderTest : public ::testing::Test { |
| 94 protected: | 94 protected: |
| 95 PacedSenderTest() { | 95 PacedSenderTest() { |
| 96 testing_clock_.Advance( | 96 testing_clock_.Advance( |
| 97 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | 97 base::TimeDelta::FromMilliseconds(kStartMillisecond)); |
| 98 task_runner_ = new test::FakeSingleThreadTaskRunner(&testing_clock_); | 98 task_runner_ = new FakeSingleThreadTaskRunner(&testing_clock_); |
| 99 paced_sender_.reset(new PacedSender(kTargetBurstSize, kMaxBurstSize, | 99 paced_sender_.reset(new PacedSender(kTargetBurstSize, kMaxBurstSize, |
| 100 &testing_clock_, &packet_events_, | 100 &testing_clock_, &packet_events_, |
| 101 &mock_transport_, task_runner_)); | 101 &mock_transport_, task_runner_)); |
| 102 paced_sender_->RegisterAudioSsrc(kAudioSsrc); | 102 paced_sender_->RegisterAudioSsrc(kAudioSsrc); |
| 103 paced_sender_->RegisterVideoSsrc(kVideoSsrc); | 103 paced_sender_->RegisterVideoSsrc(kVideoSsrc); |
| 104 } | 104 } |
| 105 | 105 |
| 106 static void UpdateCastTransportStatus(CastTransportStatus status) { | 106 static void UpdateCastTransportStatus(CastTransportStatus status) { |
| 107 NOTREACHED(); | 107 NOTREACHED(); |
| 108 } | 108 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 if (mock_transport_.expecting_nothing_else()) | 162 if (mock_transport_.expecting_nothing_else()) |
| 163 return true; | 163 return true; |
| 164 } | 164 } |
| 165 | 165 |
| 166 return mock_transport_.expecting_nothing_else(); | 166 return mock_transport_.expecting_nothing_else(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 std::vector<PacketEvent> packet_events_; | 169 std::vector<PacketEvent> packet_events_; |
| 170 base::SimpleTestTickClock testing_clock_; | 170 base::SimpleTestTickClock testing_clock_; |
| 171 TestPacketSender mock_transport_; | 171 TestPacketSender mock_transport_; |
| 172 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 172 scoped_refptr<FakeSingleThreadTaskRunner> task_runner_; |
| 173 scoped_ptr<PacedSender> paced_sender_; | 173 scoped_ptr<PacedSender> paced_sender_; |
| 174 | 174 |
| 175 DISALLOW_COPY_AND_ASSIGN(PacedSenderTest); | 175 DISALLOW_COPY_AND_ASSIGN(PacedSenderTest); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 } // namespace | 178 } // namespace |
| 179 | 179 |
| 180 TEST_F(PacedSenderTest, PassThroughRtcp) { | 180 TEST_F(PacedSenderTest, PassThroughRtcp) { |
| 181 SendPacketVector packets = CreateSendPacketVector(kSize1, 1, true); | 181 SendPacketVector packets = CreateSendPacketVector(kSize1, 1, true); |
| 182 | 182 |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 first_ten_packets.push_back(packets[i]); | 535 first_ten_packets.push_back(packets[i]); |
| 536 mock_transport_.AddExpectedSizesAndPacketIds(kSize1, UINT16_C(0), 2); | 536 mock_transport_.AddExpectedSizesAndPacketIds(kSize1, UINT16_C(0), 2); |
| 537 mock_transport_.AddExpectedSizesAndPacketIds(kSize1, UINT16_C(4), 6); | 537 mock_transport_.AddExpectedSizesAndPacketIds(kSize1, UINT16_C(4), 6); |
| 538 mock_transport_.AddExpectedSizesAndPacketIds(kSize1, UINT16_C(2), 2); | 538 mock_transport_.AddExpectedSizesAndPacketIds(kSize1, UINT16_C(2), 2); |
| 539 SendWithoutBursting(first_ten_packets); | 539 SendWithoutBursting(first_ten_packets); |
| 540 ASSERT_TRUE(mock_transport_.expecting_nothing_else()); | 540 ASSERT_TRUE(mock_transport_.expecting_nothing_else()); |
| 541 } | 541 } |
| 542 | 542 |
| 543 } // namespace cast | 543 } // namespace cast |
| 544 } // namespace media | 544 } // namespace media |
| OLD | NEW |