OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/metrics/variations/variations_seed_store.h" | 5 #include "chrome/browser/metrics/variations/variations_seed_store.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/prefs/testing_pref_service.h" | 8 #include "base/prefs/testing_pref_service.h" |
9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 explicit TestVariationsSeedStore(PrefService* local_state) | 23 explicit TestVariationsSeedStore(PrefService* local_state) |
24 : VariationsSeedStore(local_state) {} | 24 : VariationsSeedStore(local_state) {} |
25 virtual ~TestVariationsSeedStore() {} | 25 virtual ~TestVariationsSeedStore() {} |
26 | 26 |
27 bool StoreSeedForTesting(const std::string& seed_data) { | 27 bool StoreSeedForTesting(const std::string& seed_data) { |
28 return StoreSeedData(seed_data, std::string(), base::Time::Now(), NULL); | 28 return StoreSeedData(seed_data, std::string(), base::Time::Now(), NULL); |
29 } | 29 } |
30 | 30 |
31 virtual VariationsSeedStore::VerifySignatureResult VerifySeedSignature( | 31 virtual VariationsSeedStore::VerifySignatureResult VerifySeedSignature( |
32 const std::string& seed_bytes, | 32 const std::string& seed_bytes, |
33 const std::string& base64_seed_signature) OVERRIDE { | 33 const std::string& base64_seed_signature) override { |
34 return VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_ENUM_SIZE; | 34 return VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_ENUM_SIZE; |
35 } | 35 } |
36 | 36 |
37 private: | 37 private: |
38 DISALLOW_COPY_AND_ASSIGN(TestVariationsSeedStore); | 38 DISALLOW_COPY_AND_ASSIGN(TestVariationsSeedStore); |
39 }; | 39 }; |
40 | 40 |
41 | 41 |
42 // Populates |seed| with simple test data. The resulting seed will contain one | 42 // Populates |seed| with simple test data. The resulting seed will contain one |
43 // study called "test", which contains one experiment called "abc" with | 43 // study called "test", which contains one experiment called "abc" with |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 seed_store.VerifySeedSignature(seed_data, base64_seed_data)); | 215 seed_store.VerifySeedSignature(seed_data, base64_seed_data)); |
216 #endif | 216 #endif |
217 | 217 |
218 // Using a different seed should not match the signature. | 218 // Using a different seed should not match the signature. |
219 seed_data[0] = 'x'; | 219 seed_data[0] = 'x'; |
220 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SEED, | 220 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SEED, |
221 seed_store.VerifySeedSignature(seed_data, base64_seed_signature)); | 221 seed_store.VerifySeedSignature(seed_data, base64_seed_signature)); |
222 } | 222 } |
223 | 223 |
224 } // namespace chrome_variations | 224 } // namespace chrome_variations |
OLD | NEW |