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" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 247 } |
248 | 248 |
249 return false; | 249 return false; |
250 } | 250 } |
251 }; | 251 }; |
252 | 252 |
253 } // namespace | 253 } // namespace |
254 | 254 |
255 class SafeBrowsingDatabaseTest : public PlatformTest { | 255 class SafeBrowsingDatabaseTest : public PlatformTest { |
256 public: | 256 public: |
257 virtual void SetUp() { | 257 void SetUp() override { |
258 PlatformTest::SetUp(); | 258 PlatformTest::SetUp(); |
259 | 259 |
260 // Setup a database in a temporary directory. | 260 // Setup a database in a temporary directory. |
261 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 261 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
262 database_.reset(new SafeBrowsingDatabaseNew); | 262 database_.reset(new SafeBrowsingDatabaseNew); |
263 database_filename_ = | 263 database_filename_ = |
264 temp_dir_.path().AppendASCII("SafeBrowsingTestDatabase"); | 264 temp_dir_.path().AppendASCII("SafeBrowsingTestDatabase"); |
265 database_->Init(database_filename_); | 265 database_->Init(database_filename_); |
266 } | 266 } |
267 | 267 |
268 virtual void TearDown() { | 268 void TearDown() override { |
269 database_.reset(); | 269 database_.reset(); |
270 | 270 |
271 PlatformTest::TearDown(); | 271 PlatformTest::TearDown(); |
272 } | 272 } |
273 | 273 |
274 void GetListsInfo(std::vector<SBListChunkRanges>* lists) { | 274 void GetListsInfo(std::vector<SBListChunkRanges>* lists) { |
275 lists->clear(); | 275 lists->clear(); |
276 ASSERT_TRUE(database_->UpdateStarted(lists)); | 276 ASSERT_TRUE(database_->UpdateStarted(lists)); |
277 database_->UpdateFinished(true); | 277 database_->UpdateFinished(true); |
278 } | 278 } |
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2129 GURL(std::string("http://") + kExampleCollision), | 2129 GURL(std::string("http://") + kExampleCollision), |
2130 &prefix_hits, &cache_hits)); | 2130 &prefix_hits, &cache_hits)); |
2131 ASSERT_EQ(1U, prefix_hits.size()); | 2131 ASSERT_EQ(1U, prefix_hits.size()); |
2132 EXPECT_EQ(SBPrefixForString(kExampleCollision), prefix_hits[0]); | 2132 EXPECT_EQ(SBPrefixForString(kExampleCollision), prefix_hits[0]); |
2133 EXPECT_TRUE(cache_hits.empty()); | 2133 EXPECT_TRUE(cache_hits.empty()); |
2134 | 2134 |
2135 // This prefix collides, but no full hash match. | 2135 // This prefix collides, but no full hash match. |
2136 EXPECT_FALSE(database_->ContainsBrowseUrl( | 2136 EXPECT_FALSE(database_->ContainsBrowseUrl( |
2137 GURL(std::string("http://") + kExampleFine), &prefix_hits, &cache_hits)); | 2137 GURL(std::string("http://") + kExampleFine), &prefix_hits, &cache_hits)); |
2138 } | 2138 } |
OLD | NEW |