| 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. | 5 // Unit tests for the SafeBrowsing storage system. |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 void SubDelChunk(SafeBrowsingDatabase* db, | 55 void SubDelChunk(SafeBrowsingDatabase* db, |
| 56 const std::string& list, | 56 const std::string& list, |
| 57 int chunk_id) { | 57 int chunk_id) { |
| 58 DelChunk(db, list, chunk_id, true); | 58 DelChunk(db, list, chunk_id, true); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Common database test set up code. | 61 // Common database test set up code. |
| 62 std::wstring GetTestDatabaseName() { | 62 std::wstring GetTestDatabaseName() { |
| 63 FilePath filename; | 63 FilePath filename; |
| 64 PathService::Get(base::DIR_TEMP, &filename); | 64 PathService::Get(base::DIR_TEMP, &filename); |
| 65 filename = filename.Append(FILE_PATH_LITERAL("SafeBrowsingTestDatabase")); | 65 filename = filename.AppendASCII("SafeBrowsingTestDatabase"); |
| 66 return filename.ToWStringHack(); | 66 return filename.ToWStringHack(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 SafeBrowsingDatabase* SetupTestDatabase() { | 69 SafeBrowsingDatabase* SetupTestDatabase() { |
| 70 std::wstring filename = GetTestDatabaseName(); | 70 std::wstring filename = GetTestDatabaseName(); |
| 71 | 71 |
| 72 // In case it existed from a previous run. | 72 // In case it existed from a previous run. |
| 73 file_util::Delete(filename + kBloomSuffix, false); | 73 file_util::Delete(filename + kBloomSuffix, false); |
| 74 file_util::Delete(filename, false); | 74 file_util::Delete(filename, false); |
| 75 | 75 |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 const std::vector<ChunksInfo>& chunks, | 1041 const std::vector<ChunksInfo>& chunks, |
| 1042 std::vector<SBChunkDelete>* deletes) { | 1042 std::vector<SBChunkDelete>* deletes) { |
| 1043 // TODO(pinkerton): I don't think posix has any concept of IO counters, but | 1043 // TODO(pinkerton): I don't think posix has any concept of IO counters, but |
| 1044 // we can uncomment this when we implement ProcessMetrics::GetIOCounters | 1044 // we can uncomment this when we implement ProcessMetrics::GetIOCounters |
| 1045 #if defined(OS_WIN) || defined(OS_LINUX) | 1045 #if defined(OS_WIN) || defined(OS_LINUX) |
| 1046 IoCounters before, after; | 1046 IoCounters before, after; |
| 1047 #endif | 1047 #endif |
| 1048 | 1048 |
| 1049 FilePath path; | 1049 FilePath path; |
| 1050 PathService::Get(base::DIR_TEMP, &path); | 1050 PathService::Get(base::DIR_TEMP, &path); |
| 1051 path = path.Append(FILE_PATH_LITERAL("SafeBrowsingTestDatabase")); | 1051 path = path.AppendASCII("SafeBrowsingTestDatabase"); |
| 1052 std::wstring filename = path.ToWStringHack(); | 1052 std::wstring filename = path.ToWStringHack(); |
| 1053 | 1053 |
| 1054 // In case it existed from a previous run. | 1054 // In case it existed from a previous run. |
| 1055 file_util::Delete(filename, false); | 1055 file_util::Delete(filename, false); |
| 1056 | 1056 |
| 1057 if (!initial_db.empty()) { | 1057 if (!initial_db.empty()) { |
| 1058 std::wstring full_initial_db = GetFullSBDataPath(initial_db); | 1058 std::wstring full_initial_db = GetFullSBDataPath(initial_db); |
| 1059 ASSERT_TRUE(file_util::CopyFile(full_initial_db, filename)); | 1059 ASSERT_TRUE(file_util::CopyFile(full_initial_db, filename)); |
| 1060 } | 1060 } |
| 1061 | 1061 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldLotsofDeletesIO) { | 1239 TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldLotsofDeletesIO) { |
| 1240 std::vector<ChunksInfo> chunks; | 1240 std::vector<ChunksInfo> chunks; |
| 1241 std::vector<SBChunkDelete>* deletes = new std::vector<SBChunkDelete>; | 1241 std::vector<SBChunkDelete>* deletes = new std::vector<SBChunkDelete>; |
| 1242 SBChunkDelete del; | 1242 SBChunkDelete del; |
| 1243 del.is_sub_del = false; | 1243 del.is_sub_del = false; |
| 1244 del.list_name = safe_browsing_util::kMalwareList; | 1244 del.list_name = safe_browsing_util::kMalwareList; |
| 1245 del.chunk_del.push_back(ChunkRange(3539, 3579)); | 1245 del.chunk_del.push_back(ChunkRange(3539, 3579)); |
| 1246 deletes->push_back(del); | 1246 deletes->push_back(del); |
| 1247 PeformUpdate(GetOldSafeBrowsingPath(), chunks, deletes); | 1247 PeformUpdate(GetOldSafeBrowsingPath(), chunks, deletes); |
| 1248 } | 1248 } |
| OLD | NEW |