Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: components/variations/service/variations_service_unittest.cc

Issue 1984003002: Use low entropy for studies that send experiment IDs to Google properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/variations/service/variations_service.h" 5 #include "components/variations/service/variations_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 bool is_delta_compressed, 126 bool is_delta_compressed,
127 bool is_gzip_compressed) override { 127 bool is_gzip_compressed) override {
128 seed_stored_ = true; 128 seed_stored_ = true;
129 stored_seed_data_ = seed_data; 129 stored_seed_data_ = seed_data;
130 stored_country_ = country_code; 130 stored_country_ = country_code;
131 delta_compressed_seed_ = is_delta_compressed; 131 delta_compressed_seed_ = is_delta_compressed;
132 gzip_compressed_seed_ = is_gzip_compressed; 132 gzip_compressed_seed_ = is_gzip_compressed;
133 return true; 133 return true;
134 } 134 }
135 135
136 std::unique_ptr<const base::FieldTrial::EntropyProvider>
137 CreateLowEntropyProvider() override {
138 return std::unique_ptr<const base::FieldTrial::EntropyProvider>(nullptr);
139 }
140
136 private: 141 private:
137 bool LoadSeed(VariationsSeed* seed) override { 142 bool LoadSeed(VariationsSeed* seed) override {
138 if (!seed_stored_) 143 if (!seed_stored_)
139 return false; 144 return false;
140 return seed->ParseFromString(stored_seed_data_); 145 return seed->ParseFromString(stored_seed_data_);
141 } 146 }
142 147
143 bool intercepts_fetch_; 148 bool intercepts_fetch_;
144 bool fetch_attempted_; 149 bool fetch_attempted_;
145 bool seed_stored_; 150 bool seed_stored_;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 288
284 // Store a seed. 289 // Store a seed.
285 service.StoreSeed(SerializeSeed(CreateTestSeed()), std::string(), 290 service.StoreSeed(SerializeSeed(CreateTestSeed()), std::string(),
286 std::string(), base::Time::Now(), false, false); 291 std::string(), base::Time::Now(), false, false);
287 prefs.SetInt64(prefs::kVariationsLastFetchTime, 292 prefs.SetInt64(prefs::kVariationsLastFetchTime,
288 base::Time::Now().ToInternalValue()); 293 base::Time::Now().ToInternalValue());
289 294
290 // Check that field trials are created from the seed. Since the test study has 295 // Check that field trials are created from the seed. Since the test study has
291 // only 1 experiment with 100% probability weight, we must be part of it. 296 // only 1 experiment with 100% probability weight, we must be part of it.
292 EXPECT_TRUE(service.CreateTrialsFromSeed(base::FeatureList::GetInstance())); 297 EXPECT_TRUE(service.CreateTrialsFromSeed(base::FeatureList::GetInstance()));
293 EXPECT_EQ(base::FieldTrialList::FindFullName(kTestSeedStudyName), 298 EXPECT_EQ(kTestSeedExperimentName,
294 kTestSeedExperimentName); 299 base::FieldTrialList::FindFullName(kTestSeedStudyName));
295 } 300 }
296 301
297 TEST_F(VariationsServiceTest, CreateTrialsFromSeedNoLastFetchTime) { 302 TEST_F(VariationsServiceTest, CreateTrialsFromSeedNoLastFetchTime) {
298 TestingPrefServiceSimple prefs; 303 TestingPrefServiceSimple prefs;
299 VariationsService::RegisterPrefs(prefs.registry()); 304 VariationsService::RegisterPrefs(prefs.registry());
300 305
301 // Setup base::FeatureList. 306 // Setup base::FeatureList.
302 base::FeatureList::ClearInstanceForTesting(); 307 base::FeatureList::ClearInstanceForTesting();
303 base::FeatureList::SetInstance(base::WrapUnique(new base::FeatureList())); 308 base::FeatureList::SetInstance(base::WrapUnique(new base::FeatureList()));
304 309
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 } 790 }
786 const base::ListValue* pref_value = 791 const base::ListValue* pref_value =
787 prefs.GetList(prefs::kVariationsPermanentConsistencyCountry); 792 prefs.GetList(prefs::kVariationsPermanentConsistencyCountry);
788 EXPECT_EQ(ListValueToString(expected_list_value), 793 EXPECT_EQ(ListValueToString(expected_list_value),
789 ListValueToString(*pref_value)) 794 ListValueToString(*pref_value))
790 << test.pref_value_before << ", " << test.country_code_override; 795 << test.pref_value_before << ", " << test.country_code_override;
791 } 796 }
792 } 797 }
793 798
794 } // namespace variations 799 } // namespace variations
OLDNEW
« no previous file with comments | « components/variations/service/variations_service.cc ('k') | components/variations/variations_seed_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698