| OLD | NEW |
| 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_UNITTEST_HELPER_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_UNITTEST_HELPER_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_UNITTEST_HELPER_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_UNITTEST_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/safe_browsing/safe_browsing_store.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_store.h" |
| 10 | 10 |
| 11 #include "base/sha2.h" | 11 #include "crypto/sha2.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 // Helper code for testing that a SafeBrowsingStore implementation | 14 // Helper code for testing that a SafeBrowsingStore implementation |
| 15 // works to spec. | 15 // works to spec. |
| 16 | 16 |
| 17 // Helper to make it easy to initialize SBFullHash constants. | 17 // Helper to make it easy to initialize SBFullHash constants. |
| 18 inline const SBFullHash SBFullHashFromString(const char* str) { | 18 inline const SBFullHash SBFullHashFromString(const char* str) { |
| 19 SBFullHash h; | 19 SBFullHash h; |
| 20 base::SHA256HashString(str, &h.full_hash, sizeof(h.full_hash)); | 20 crypto::SHA256HashString(str, &h.full_hash, sizeof(h.full_hash)); |
| 21 return h; | 21 return h; |
| 22 } | 22 } |
| 23 | 23 |
| 24 // TODO(shess): There's an == operator defined in | 24 // TODO(shess): There's an == operator defined in |
| 25 // safe_browsing_utils.h, but using it gives me the heebie-jeebies. | 25 // safe_browsing_utils.h, but using it gives me the heebie-jeebies. |
| 26 inline bool SBFullHashEq(const SBFullHash& a, const SBFullHash& b) { | 26 inline bool SBFullHashEq(const SBFullHash& a, const SBFullHash& b) { |
| 27 return !memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)); | 27 return !memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)); |
| 28 } | 28 } |
| 29 | 29 |
| 30 // Test that the empty store looks empty. | 30 // Test that the empty store looks empty. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 60 SafeBrowsingStoreTestSubKnockout(instance_name); \ | 60 SafeBrowsingStoreTestSubKnockout(instance_name); \ |
| 61 } \ | 61 } \ |
| 62 TEST_F(test_fixture, DeleteChunks) { \ | 62 TEST_F(test_fixture, DeleteChunks) { \ |
| 63 SafeBrowsingStoreTestDeleteChunks(instance_name); \ | 63 SafeBrowsingStoreTestDeleteChunks(instance_name); \ |
| 64 } \ | 64 } \ |
| 65 TEST_F(test_fixture, Delete) { \ | 65 TEST_F(test_fixture, Delete) { \ |
| 66 SafeBrowsingStoreTestDelete(instance_name, filename); \ | 66 SafeBrowsingStoreTestDelete(instance_name, filename); \ |
| 67 } | 67 } |
| 68 | 68 |
| 69 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_UNITTEST_HELPER_H_ | 69 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_UNITTEST_HELPER_H_ |
| OLD | NEW |