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 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 | 1081 |
1082 // Start an update. The insert will fail due to corruption. | 1082 // Start an update. The insert will fail due to corruption. |
1083 ASSERT_TRUE(database_->UpdateStarted(&lists)); | 1083 ASSERT_TRUE(database_->UpdateStarted(&lists)); |
1084 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks.get()); | 1084 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks.get()); |
1085 database_->UpdateFinished(true); | 1085 database_->UpdateFinished(true); |
1086 | 1086 |
1087 // Database file still exists until the corruption handler has run. | 1087 // Database file still exists until the corruption handler has run. |
1088 EXPECT_TRUE(base::PathExists(database_filename_)); | 1088 EXPECT_TRUE(base::PathExists(database_filename_)); |
1089 | 1089 |
1090 // Flush through the corruption-handler task. | 1090 // Flush through the corruption-handler task. |
1091 VLOG(1) << "Expect failed check on: SafeBrowsing database reset"; | 1091 DVLOG(1) << "Expect failed check on: SafeBrowsing database reset"; |
1092 base::MessageLoop::current()->RunUntilIdle(); | 1092 base::MessageLoop::current()->RunUntilIdle(); |
1093 } | 1093 } |
1094 | 1094 |
1095 // Database file should not exist. | 1095 // Database file should not exist. |
1096 EXPECT_FALSE(base::PathExists(database_filename_)); | 1096 EXPECT_FALSE(base::PathExists(database_filename_)); |
1097 | 1097 |
1098 // Run the update again successfully. | 1098 // Run the update again successfully. |
1099 ASSERT_TRUE(database_->UpdateStarted(&lists)); | 1099 ASSERT_TRUE(database_->UpdateStarted(&lists)); |
1100 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks.get()); | 1100 database_->InsertChunks(safe_browsing_util::kMalwareList, chunks.get()); |
1101 database_->UpdateFinished(true); | 1101 database_->UpdateFinished(true); |
(...skipping 1027 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 |