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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "components/variations/proto/study.pb.h" | 13 #include "components/variations/proto/study.pb.h" |
14 #include "components/variations/proto/variations_seed.pb.h" | 14 #include "components/variations/proto/variations_seed.pb.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace chrome_variations { | 17 namespace chrome_variations { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 class TestVariationsSeedStore : public VariationsSeedStore { | 21 class TestVariationsSeedStore : public VariationsSeedStore { |
22 public: | 22 public: |
23 explicit TestVariationsSeedStore(PrefService* local_state) | 23 explicit TestVariationsSeedStore(PrefService* local_state) |
24 : VariationsSeedStore(local_state) {} | 24 : VariationsSeedStore(local_state) {} |
25 virtual ~TestVariationsSeedStore() {} | 25 ~TestVariationsSeedStore() override {} |
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 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 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 seed_store.VerifySeedSignature(seed_data, base64_seed_data)); | 269 seed_store.VerifySeedSignature(seed_data, base64_seed_data)); |
270 #endif | 270 #endif |
271 | 271 |
272 // Using a different seed should not match the signature. | 272 // Using a different seed should not match the signature. |
273 seed_data[0] = 'x'; | 273 seed_data[0] = 'x'; |
274 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SEED, | 274 EXPECT_EQ(VariationsSeedStore::VARIATIONS_SEED_SIGNATURE_INVALID_SEED, |
275 seed_store.VerifySeedSignature(seed_data, base64_seed_signature)); | 275 seed_store.VerifySeedSignature(seed_data, base64_seed_signature)); |
276 } | 276 } |
277 | 277 |
278 } // namespace chrome_variations | 278 } // namespace chrome_variations |
OLD | NEW |