| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "net/quic/congestion_control/paced_sender.h" | 7 #include "net/quic/congestion_control/paced_sender.h" |
| 8 #include "net/quic/quic_protocol.h" | 8 #include "net/quic/quic_protocol.h" |
| 9 #include "net/quic/test_tools/mock_clock.h" | 9 #include "net/quic/test_tools/mock_clock.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 namespace test { | 14 namespace test { |
| 15 | 15 |
| 16 const int kHundredKBytesPerS = 100000; | 16 const int kHundredKBytesPerS = 100000; |
| 17 | 17 |
| 18 class PacedSenderTest : public ::testing::Test { | 18 class PacedSenderTest : public ::testing::Test { |
| 19 protected: | 19 protected: |
| 20 PacedSenderTest() | 20 PacedSenderTest() |
| 21 : paced_sender_(new PacedSender(&clock_, kHundredKBytesPerS)) { | 21 : zero_time_(QuicTime::Delta::Zero()), |
| 22 paced_sender_(new PacedSender(&clock_, kHundredKBytesPerS)) { |
| 22 } | 23 } |
| 23 | 24 |
| 24 const QuicTime::Delta zero_time_; | 25 const QuicTime::Delta zero_time_; |
| 25 MockClock clock_; | 26 MockClock clock_; |
| 26 scoped_ptr<PacedSender> paced_sender_; | 27 scoped_ptr<PacedSender> paced_sender_; |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 TEST_F(PacedSenderTest, Basic) { | 30 TEST_F(PacedSenderTest, Basic) { |
| 30 paced_sender_->UpdateBandwidthEstimate(kHundredKBytesPerS * 10); | 31 paced_sender_->UpdateBandwidthEstimate(kHundredKBytesPerS * 10); |
| 31 EXPECT_TRUE(paced_sender_->TimeUntilSend(zero_time_).IsZero()); | 32 EXPECT_TRUE(paced_sender_->TimeUntilSend(zero_time_).IsZero()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 EXPECT_EQ(0u, paced_sender_->AvailableWindow(kMaxPacketSize * 100)); | 75 EXPECT_EQ(0u, paced_sender_->AvailableWindow(kMaxPacketSize * 100)); |
| 75 EXPECT_EQ(2040, paced_sender_->TimeUntilSend(zero_time_).ToMicroseconds()); | 76 EXPECT_EQ(2040, paced_sender_->TimeUntilSend(zero_time_).ToMicroseconds()); |
| 76 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(20400)); | 77 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(20400)); |
| 77 EXPECT_TRUE(paced_sender_->TimeUntilSend(zero_time_).IsZero()); | 78 EXPECT_TRUE(paced_sender_->TimeUntilSend(zero_time_).IsZero()); |
| 78 EXPECT_EQ(bandwidth_estimate / 500u, | 79 EXPECT_EQ(bandwidth_estimate / 500u, |
| 79 paced_sender_->AvailableWindow(kMaxPacketSize * 100)); | 80 paced_sender_->AvailableWindow(kMaxPacketSize * 100)); |
| 80 } | 81 } |
| 81 | 82 |
| 82 } // namespace test | 83 } // namespace test |
| 83 } // namespace net | 84 } // namespace net |
| OLD | NEW |