| 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 // Unit tests for the SafeBrowsing storage system. | 5 // Unit tests for the SafeBrowsing storage system. |
| 6 | 6 |
| 7 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 7 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/sha1.h" | 14 #include "base/sha1.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 17 #include "base/test/test_simple_task_runner.h" | 17 #include "base/test/test_simple_task_runner.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "chrome/browser/safe_browsing/chunk.pb.h" | 19 #include "chrome/browser/safe_browsing/chunk.pb.h" |
| 20 #include "chrome/browser/safe_browsing/safe_browsing_store_file.h" | 20 #include "chrome/browser/safe_browsing/safe_browsing_store_file.h" |
| 21 #include "crypto/sha2.h" | 21 #include "crypto/sha2.h" |
| 22 #include "net/base/net_util.h" | 22 #include "net/base/ip_address_number.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "testing/platform_test.h" | 24 #include "testing/platform_test.h" |
| 25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 26 | 26 |
| 27 using base::Time; | 27 using base::Time; |
| 28 using base::TimeDelta; | 28 using base::TimeDelta; |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 const TimeDelta kCacheLifetime = TimeDelta::FromMinutes(45); | 32 const TimeDelta kCacheLifetime = TimeDelta::FromMinutes(45); |
| (...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2231 GURL(std::string("http://") + kExampleCollision), | 2231 GURL(std::string("http://") + kExampleCollision), |
| 2232 &prefix_hits, &cache_hits)); | 2232 &prefix_hits, &cache_hits)); |
| 2233 ASSERT_EQ(1U, prefix_hits.size()); | 2233 ASSERT_EQ(1U, prefix_hits.size()); |
| 2234 EXPECT_EQ(SBPrefixForString(kExampleCollision), prefix_hits[0]); | 2234 EXPECT_EQ(SBPrefixForString(kExampleCollision), prefix_hits[0]); |
| 2235 EXPECT_TRUE(cache_hits.empty()); | 2235 EXPECT_TRUE(cache_hits.empty()); |
| 2236 | 2236 |
| 2237 // This prefix collides, but no full hash match. | 2237 // This prefix collides, but no full hash match. |
| 2238 EXPECT_FALSE(database_->ContainsBrowseUrl( | 2238 EXPECT_FALSE(database_->ContainsBrowseUrl( |
| 2239 GURL(std::string("http://") + kExampleFine), &prefix_hits, &cache_hits)); | 2239 GURL(std::string("http://") + kExampleFine), &prefix_hits, &cache_hits)); |
| 2240 } | 2240 } |
| OLD | NEW |