| 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/leaky_bucket.h" | 7 #include "net/quic/congestion_control/leaky_bucket.h" |
| 8 #include "net/quic/test_tools/mock_clock.h" | 8 #include "net/quic/test_tools/mock_clock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 namespace test { | 12 namespace test { |
| 13 | 13 |
| 14 class LeakyBucketTest : public ::testing::Test { | 14 class LeakyBucketTest : public ::testing::Test { |
| 15 protected: | 15 protected: |
| 16 virtual void SetUp() { | 16 void SetUp() override { |
| 17 leaky_bucket_.reset(new LeakyBucket(QuicBandwidth::Zero())); | 17 leaky_bucket_.reset(new LeakyBucket(QuicBandwidth::Zero())); |
| 18 } | 18 } |
| 19 MockClock clock_; | 19 MockClock clock_; |
| 20 scoped_ptr<LeakyBucket> leaky_bucket_; | 20 scoped_ptr<LeakyBucket> leaky_bucket_; |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 TEST_F(LeakyBucketTest, Basic) { | 23 TEST_F(LeakyBucketTest, Basic) { |
| 24 QuicBandwidth draining_rate = QuicBandwidth::FromBytesPerSecond(200000); | 24 QuicBandwidth draining_rate = QuicBandwidth::FromBytesPerSecond(200000); |
| 25 leaky_bucket_->SetDrainingRate(clock_.Now(), draining_rate); | 25 leaky_bucket_->SetDrainingRate(clock_.Now(), draining_rate); |
| 26 leaky_bucket_->Add(clock_.Now(), 2000); | 26 leaky_bucket_->Add(clock_.Now(), 2000); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 leaky_bucket_->TimeRemaining(clock_.Now())); | 66 leaky_bucket_->TimeRemaining(clock_.Now())); |
| 67 draining_rate = draining_rate.Scale(0.5f); // Cut drain rate in half. | 67 draining_rate = draining_rate.Scale(0.5f); // Cut drain rate in half. |
| 68 leaky_bucket_->SetDrainingRate(clock_.Now(), draining_rate); | 68 leaky_bucket_->SetDrainingRate(clock_.Now(), draining_rate); |
| 69 EXPECT_EQ(1000u, leaky_bucket_->BytesPending(clock_.Now())); | 69 EXPECT_EQ(1000u, leaky_bucket_->BytesPending(clock_.Now())); |
| 70 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(10), | 70 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(10), |
| 71 leaky_bucket_->TimeRemaining(clock_.Now())); | 71 leaky_bucket_->TimeRemaining(clock_.Now())); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace test | 74 } // namespace test |
| 75 } // namespace net | 75 } // namespace net |
| OLD | NEW |