OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "app/sql/connection.h" | 7 #include "app/sql/connection.h" |
8 #include "app/sql/statement.h" | 8 #include "app/sql/statement.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_temp_dir.h" | 11 #include "base/memory/scoped_temp_dir.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/sha2.h" | |
14 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "crypto/sha2.h" |
15 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 15 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
16 #include "chrome/browser/safe_browsing/safe_browsing_store_file.h" | 16 #include "chrome/browser/safe_browsing/safe_browsing_store_file.h" |
17 #include "chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h" | 17 #include "chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h" |
18 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "testing/platform_test.h" | 21 #include "testing/platform_test.h" |
22 | 22 |
23 using base::Time; | 23 using base::Time; |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 SBPrefix Sha256Prefix(const std::string& str) { | 27 SBPrefix Sha256Prefix(const std::string& str) { |
28 SBPrefix prefix; | 28 SBPrefix prefix; |
29 base::SHA256HashString(str, &prefix, sizeof(prefix)); | 29 crypto::SHA256HashString(str, &prefix, sizeof(prefix)); |
30 return prefix; | 30 return prefix; |
31 } | 31 } |
32 | 32 |
33 SBFullHash Sha256Hash(const std::string& str) { | 33 SBFullHash Sha256Hash(const std::string& str) { |
34 SBFullHash hash; | 34 SBFullHash hash; |
35 base::SHA256HashString(str, &hash, sizeof(hash)); | 35 crypto::SHA256HashString(str, &hash, sizeof(hash)); |
36 return hash; | 36 return hash; |
37 } | 37 } |
38 | 38 |
39 // Same as InsertAddChunkHostPrefixUrl, but with pre-computed | 39 // Same as InsertAddChunkHostPrefixUrl, but with pre-computed |
40 // prefix values. | 40 // prefix values. |
41 void InsertAddChunkHostPrefixValue(SBChunk* chunk, | 41 void InsertAddChunkHostPrefixValue(SBChunk* chunk, |
42 int chunk_number, | 42 int chunk_number, |
43 const SBPrefix& host_prefix, | 43 const SBPrefix& host_prefix, |
44 const SBPrefix& url_prefix) { | 44 const SBPrefix& url_prefix) { |
45 chunk->chunk_number = chunk_number; | 45 chunk->chunk_number = chunk_number; |
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 | 1490 |
1491 // Simply calling |UpdateStarted()| then |UpdateFinished()| does not | 1491 // Simply calling |UpdateStarted()| then |UpdateFinished()| does not |
1492 // update the database file. | 1492 // update the database file. |
1493 ASSERT_TRUE(file_util::SetLastModifiedTime(filename, old_last_modified)); | 1493 ASSERT_TRUE(file_util::SetLastModifiedTime(filename, old_last_modified)); |
1494 ASSERT_TRUE(file_util::GetFileInfo(filename, &before_info)); | 1494 ASSERT_TRUE(file_util::GetFileInfo(filename, &before_info)); |
1495 EXPECT_TRUE(database_->UpdateStarted(&lists)); | 1495 EXPECT_TRUE(database_->UpdateStarted(&lists)); |
1496 database_->UpdateFinished(true); | 1496 database_->UpdateFinished(true); |
1497 ASSERT_TRUE(file_util::GetFileInfo(filename, &after_info)); | 1497 ASSERT_TRUE(file_util::GetFileInfo(filename, &after_info)); |
1498 EXPECT_EQ(before_info.last_modified, after_info.last_modified); | 1498 EXPECT_EQ(before_info.last_modified, after_info.last_modified); |
1499 } | 1499 } |
OLD | NEW |