| 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/dns/dns_session.h" | 5 #include "net/dns/dns_session.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 lease1.reset(); | 213 lease1.reset(); |
| 214 EXPECT_TRUE(DidFree(0)); | 214 EXPECT_TRUE(DidFree(0)); |
| 215 EXPECT_TRUE(NoMoreEvents()); | 215 EXPECT_TRUE(NoMoreEvents()); |
| 216 | 216 |
| 217 lease2.reset(); | 217 lease2.reset(); |
| 218 EXPECT_TRUE(DidFree(1)); | 218 EXPECT_TRUE(DidFree(1)); |
| 219 EXPECT_TRUE(NoMoreEvents()); | 219 EXPECT_TRUE(NoMoreEvents()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 // Expect default calculated timeout to be within 10ms of in DnsConfig. | 222 // Expect default calculated timeout to be within 10ms of one in DnsConfig. |
| 223 TEST_F(DnsSessionTest, HistogramTimeoutNormal) { | 223 TEST_F(DnsSessionTest, HistogramTimeoutNormal) { |
| 224 Initialize(2); | 224 Initialize(2); |
| 225 base::TimeDelta timeoutDelta = session_->NextTimeout(0, 0) - config_.timeout; | 225 base::TimeDelta delta = session_->NextTimeout(0, 0) - config_.timeout; |
| 226 EXPECT_LT(timeoutDelta.InMilliseconds(), 10); | 226 EXPECT_LE(delta.InMilliseconds(), 10); |
| 227 } | 227 } |
| 228 | 228 |
| 229 // Expect short calculated timeout to be within 10ms of in DnsConfig. | 229 // Expect short calculated timeout to be within 10ms of one in DnsConfig. |
| 230 TEST_F(DnsSessionTest, HistogramTimeoutShort) { | 230 TEST_F(DnsSessionTest, HistogramTimeoutShort) { |
| 231 config_.timeout = base::TimeDelta::FromMilliseconds(15); | 231 config_.timeout = base::TimeDelta::FromMilliseconds(15); |
| 232 Initialize(2); | 232 Initialize(2); |
| 233 base::TimeDelta timeoutDelta = session_->NextTimeout(0, 0) - config_.timeout; | 233 base::TimeDelta delta = session_->NextTimeout(0, 0) - config_.timeout; |
| 234 EXPECT_LT(timeoutDelta.InMilliseconds(), 10); | 234 EXPECT_LE(delta.InMilliseconds(), 10); |
| 235 } | 235 } |
| 236 | 236 |
| 237 // Expect long calculated timeout to be equal to one in DnsConfig. | 237 // Expect long calculated timeout to be equal to one in DnsConfig. |
| 238 // (Default max timeout is 5 seconds, so NextTimeout should return exactly |
| 239 // the config timeout.) |
| 238 TEST_F(DnsSessionTest, HistogramTimeoutLong) { | 240 TEST_F(DnsSessionTest, HistogramTimeoutLong) { |
| 239 config_.timeout = base::TimeDelta::FromSeconds(15); | 241 config_.timeout = base::TimeDelta::FromSeconds(15); |
| 240 Initialize(2); | 242 Initialize(2); |
| 241 base::TimeDelta timeout = session_->NextTimeout(0, 0); | 243 base::TimeDelta timeout = session_->NextTimeout(0, 0); |
| 242 EXPECT_EQ(config_.timeout.InMilliseconds(), timeout.InMilliseconds()); | 244 EXPECT_EQ(timeout.InMilliseconds(), config_.timeout.InMilliseconds()); |
| 243 } | 245 } |
| 244 | 246 |
| 245 } // namespace | 247 } // namespace |
| 246 | 248 |
| 247 } // namespace net | 249 } // namespace net |
| OLD | NEW |