cros: Remove default pinned apps trial.
[chromium-blink-merge.git] / chrome / browser / safe_browsing / safe_browsing_store_unittest_helper.h
blob5854523072f694ce64d128c0b1cc32869a1e0be4
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_UNITTEST_HELPER_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_UNITTEST_HELPER_H_
8 #include "chrome/browser/safe_browsing/safe_browsing_store.h"
10 #include "crypto/sha2.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 // Helper code for testing that a SafeBrowsingStore implementation
14 // works to spec.
16 // Helper to make it easy to initialize SBFullHash constants.
17 inline const SBFullHash SBFullHashFromString(const char* str) {
18 SBFullHash h;
19 crypto::SHA256HashString(str, &h.full_hash, sizeof(h.full_hash));
20 return h;
23 // TODO(shess): There's an == operator defined in
24 // safe_browsing_utils.h, but using it gives me the heebie-jeebies.
25 inline bool SBFullHashEq(const SBFullHash& a, const SBFullHash& b) {
26 return !memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash));
29 // Test that the empty store looks empty.
30 void SafeBrowsingStoreTestEmpty(SafeBrowsingStore* store);
32 // Write some prefix data to the store and verify that it looks like
33 // it is still there after the transaction completes.
34 void SafeBrowsingStoreTestStorePrefix(SafeBrowsingStore* store);
36 // Test that subs knockout adds.
37 void SafeBrowsingStoreTestSubKnockout(SafeBrowsingStore* store);
39 // Test that deletes delete the chunk's data.
40 void SafeBrowsingStoreTestDeleteChunks(SafeBrowsingStore* store);
42 // Test that deleting the store deletes the store.
43 void SafeBrowsingStoreTestDelete(SafeBrowsingStore* store,
44 const base::FilePath& filename);
46 // Wrap all the tests up for implementation subclasses.
47 // |test_fixture| is the class that would be passed to TEST_F(),
48 // |instance_name| is the name of the SafeBrowsingStore instance
49 // within the class, as a pointer, and |filename| is that store's
50 // filename, for the Delete() test.
51 #define TEST_STORE(test_fixture, instance_name, filename) \
52 TEST_F(test_fixture, Empty) { \
53 SafeBrowsingStoreTestEmpty(instance_name); \
54 } \
55 TEST_F(test_fixture, StorePrefix) { \
56 SafeBrowsingStoreTestStorePrefix(instance_name); \
57 } \
58 TEST_F(test_fixture, SubKnockout) { \
59 SafeBrowsingStoreTestSubKnockout(instance_name); \
60 } \
61 TEST_F(test_fixture, DeleteChunks) { \
62 SafeBrowsingStoreTestDeleteChunks(instance_name); \
63 } \
64 TEST_F(test_fixture, Delete) { \
65 SafeBrowsingStoreTestDelete(instance_name, filename); \
68 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_UNITTEST_HELPER_H_