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 "net/base/backoff_entry.h" | 5 #include "net/base/backoff_entry.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 namespace { | 8 namespace { |
9 | 9 |
10 using base::TimeDelta; | 10 using base::TimeDelta; |
11 using base::TimeTicks; | 11 using base::TimeTicks; |
12 using net::BackoffEntry; | 12 using net::BackoffEntry; |
13 | 13 |
14 BackoffEntry::Policy base_policy = { 0, 1000, 2.0, 0.0, 20000, 2000, false }; | 14 BackoffEntry::Policy base_policy = { 0, 1000, 2.0, 0.0, 20000, 2000, false }; |
15 | 15 |
16 class TestBackoffEntry : public BackoffEntry { | 16 class TestBackoffEntry : public BackoffEntry { |
17 public: | 17 public: |
18 explicit TestBackoffEntry(const Policy* const policy) | 18 explicit TestBackoffEntry(const Policy* const policy) |
19 : BackoffEntry(policy), | 19 : BackoffEntry(policy), |
20 now_(TimeTicks()) { | 20 now_(TimeTicks()) { |
21 // Work around initialization in constructor not picking up | 21 // Work around initialization in constructor not picking up |
22 // fake time. | 22 // fake time. |
23 SetCustomReleaseTime(TimeTicks()); | 23 SetCustomReleaseTime(TimeTicks()); |
24 } | 24 } |
25 | 25 |
26 virtual ~TestBackoffEntry() {} | 26 virtual ~TestBackoffEntry() {} |
27 | 27 |
28 virtual TimeTicks ImplGetTimeNow() const OVERRIDE { | 28 virtual TimeTicks ImplGetTimeNow() const override { |
29 return now_; | 29 return now_; |
30 } | 30 } |
31 | 31 |
32 void set_now(const TimeTicks& now) { | 32 void set_now(const TimeTicks& now) { |
33 now_ = now; | 33 now_ = now; |
34 } | 34 } |
35 | 35 |
36 private: | 36 private: |
37 TimeTicks now_; | 37 TimeTicks now_; |
38 | 38 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 custom.set_now(custom.ImplGetTimeNow() + custom.GetTimeUntilRelease()); | 305 custom.set_now(custom.ImplGetTimeNow() + custom.GetTimeUntilRelease()); |
306 custom.InformOfRequest(false); | 306 custom.InformOfRequest(false); |
307 ASSERT_TRUE(custom.ShouldRejectRequest()); | 307 ASSERT_TRUE(custom.ShouldRejectRequest()); |
308 } | 308 } |
309 | 309 |
310 // Max delay should still be respected. | 310 // Max delay should still be respected. |
311 EXPECT_EQ(20000, custom.GetTimeUntilRelease().InMilliseconds()); | 311 EXPECT_EQ(20000, custom.GetTimeUntilRelease().InMilliseconds()); |
312 } | 312 } |
313 | 313 |
314 } // namespace | 314 } // namespace |
OLD | NEW |