OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 5 |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "chrome/browser/safe_browsing/protocol_manager.h" | 9 #include "chrome/browser/safe_browsing/protocol_manager.h" |
10 | 10 |
| 11 using base::Time; |
| 12 using base::TimeDelta; |
| 13 |
11 class SafeBrowsingProtocolManagerTest : public testing::Test { | 14 class SafeBrowsingProtocolManagerTest : public testing::Test { |
12 }; | 15 }; |
13 | 16 |
14 // Ensure that we respect section 5 of the SafeBrowsing protocol specification. | 17 // Ensure that we respect section 5 of the SafeBrowsing protocol specification. |
15 TEST_F(SafeBrowsingProtocolManagerTest, TestBackOffTimes) { | 18 TEST_F(SafeBrowsingProtocolManagerTest, TestBackOffTimes) { |
16 SafeBrowsingProtocolManager pm(NULL, NULL, "", ""); | 19 SafeBrowsingProtocolManager pm(NULL, NULL, "", ""); |
17 pm.next_update_sec_ = 1800; | 20 pm.next_update_sec_ = 1800; |
18 DCHECK(pm.back_off_fuzz_ >= 0.0 && pm.back_off_fuzz_ <= 1.0); | 21 DCHECK(pm.back_off_fuzz_ >= 0.0 && pm.back_off_fuzz_ <= 1.0); |
19 | 22 |
20 // No errors received so far. | 23 // No errors received so far. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // 6 errors, reached max backoff. | 130 // 6 errors, reached max backoff. |
128 pm.HandleGetHashError(); | 131 pm.HandleGetHashError(); |
129 EXPECT_EQ(pm.gethash_error_count_, 6); | 132 EXPECT_EQ(pm.gethash_error_count_, 6); |
130 EXPECT_TRUE(pm.next_gethash_time_ == now + TimeDelta::FromMinutes(480)); | 133 EXPECT_TRUE(pm.next_gethash_time_ == now + TimeDelta::FromMinutes(480)); |
131 | 134 |
132 // 7 errors. | 135 // 7 errors. |
133 pm.HandleGetHashError(); | 136 pm.HandleGetHashError(); |
134 EXPECT_EQ(pm.gethash_error_count_, 7); | 137 EXPECT_EQ(pm.gethash_error_count_, 7); |
135 EXPECT_TRUE(pm.next_gethash_time_== now + TimeDelta::FromMinutes(480)); | 138 EXPECT_TRUE(pm.next_gethash_time_== now + TimeDelta::FromMinutes(480)); |
136 } | 139 } |
OLD | NEW |