| 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 // Unit tests for the SafeBrowsing storage system (specific to the | 5 // Unit tests for the SafeBrowsing storage system (specific to the |
| 6 // SafeBrowsingDatabaseImpl implementation). | 6 // SafeBrowsingDatabaseImpl implementation). |
| 7 | 7 |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 #include "base/sha2.h" | 12 #include "base/sha2.h" |
| 13 #include "base/stats_counters.h" | 13 #include "base/stats_counters.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "chrome/browser/safe_browsing/protocol_parser.h" | 16 #include "chrome/browser/safe_browsing/protocol_parser.h" |
| 17 #include "chrome/browser/safe_browsing/safe_browsing_database_impl.h" | 17 #include "chrome/browser/safe_browsing/safe_browsing_database_impl.h" |
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 using base::Time; |
| 22 using base::TimeDelta; |
| 23 |
| 21 namespace { | 24 namespace { |
| 22 SBPrefix Sha256Prefix(const std::string& str) { | 25 SBPrefix Sha256Prefix(const std::string& str) { |
| 23 SBPrefix hash; | 26 SBPrefix hash; |
| 24 base::SHA256HashString(str, &hash, sizeof(hash)); | 27 base::SHA256HashString(str, &hash, sizeof(hash)); |
| 25 return hash; | 28 return hash; |
| 26 } | 29 } |
| 27 | 30 |
| 28 // Helper function to do an AddDel or SubDel command. | 31 // Helper function to do an AddDel or SubDel command. |
| 29 void DelChunk(SafeBrowsingDatabase* db, | 32 void DelChunk(SafeBrowsingDatabase* db, |
| 30 const std::string& list, | 33 const std::string& list, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 221 |
| 219 // Prefixes with no full results are misses. | 222 // Prefixes with no full results are misses. |
| 220 EXPECT_EQ(database.prefix_miss_cache_.size(), 2U); | 223 EXPECT_EQ(database.prefix_miss_cache_.size(), 2U); |
| 221 | 224 |
| 222 // Update the database. | 225 // Update the database. |
| 223 PopulateDatabaseForCacheTest(&database); | 226 PopulateDatabaseForCacheTest(&database); |
| 224 | 227 |
| 225 // Prefix miss cache should be cleared. | 228 // Prefix miss cache should be cleared. |
| 226 EXPECT_EQ(database.prefix_miss_cache_.size(), 0U); | 229 EXPECT_EQ(database.prefix_miss_cache_.size(), 0U); |
| 227 } | 230 } |
| OLD | NEW |