OLD | NEW |
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 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 base::FeatureList::SetInstance(make_scoped_ptr(new base::FeatureList())); | 269 base::FeatureList::SetInstance(make_scoped_ptr(new base::FeatureList())); |
270 | 270 |
271 // Create a local base::FieldTrialList, to hold the field trials created in | 271 // Create a local base::FieldTrialList, to hold the field trials created in |
272 // this test. | 272 // this test. |
273 base::FieldTrialList field_trial_list(nullptr); | 273 base::FieldTrialList field_trial_list(nullptr); |
274 | 274 |
275 // Create a variations service. | 275 // Create a variations service. |
276 TestVariationsService service( | 276 TestVariationsService service( |
277 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs)), | 277 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs)), |
278 &prefs); | 278 &prefs); |
| 279 service.SetCreateTrialsFromSeedCalledForTesting(false); |
279 | 280 |
280 // Store a seed. | 281 // Store a seed. |
281 service.StoreSeed(SerializeSeed(CreateTestSeed()), std::string(), | 282 service.StoreSeed(SerializeSeed(CreateTestSeed()), std::string(), |
282 std::string(), base::Time::Now(), false, false); | 283 std::string(), base::Time::Now(), false, false); |
283 prefs.SetInt64(prefs::kVariationsLastFetchTime, | 284 prefs.SetInt64(prefs::kVariationsLastFetchTime, |
284 base::Time::Now().ToInternalValue()); | 285 base::Time::Now().ToInternalValue()); |
285 | 286 |
286 // Check that field trials are created from the seed. Since the test study has | 287 // Check that field trials are created from the seed. Since the test study has |
287 // only 1 experiment with 100% probability weight, we must be part of it. | 288 // only 1 experiment with 100% probability weight, we must be part of it. |
288 EXPECT_TRUE(service.CreateTrialsFromSeed(base::FeatureList::GetInstance())); | 289 EXPECT_TRUE(service.CreateTrialsFromSeed(base::FeatureList::GetInstance())); |
(...skipping 10 matching lines...) Expand all Loading... |
299 base::FeatureList::SetInstance(make_scoped_ptr(new base::FeatureList())); | 300 base::FeatureList::SetInstance(make_scoped_ptr(new base::FeatureList())); |
300 | 301 |
301 // Create a local base::FieldTrialList, to hold the field trials created in | 302 // Create a local base::FieldTrialList, to hold the field trials created in |
302 // this test. | 303 // this test. |
303 base::FieldTrialList field_trial_list(nullptr); | 304 base::FieldTrialList field_trial_list(nullptr); |
304 | 305 |
305 // Create a variations service | 306 // Create a variations service |
306 TestVariationsService service( | 307 TestVariationsService service( |
307 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs)), | 308 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs)), |
308 &prefs); | 309 &prefs); |
| 310 service.SetCreateTrialsFromSeedCalledForTesting(false); |
309 | 311 |
310 // Store a seed. To simulate a first run, |prefs::kVariationsLastFetchTime| | 312 // Store a seed. To simulate a first run, |prefs::kVariationsLastFetchTime| |
311 // is left empty. | 313 // is left empty. |
312 service.StoreSeed(SerializeSeed(CreateTestSeed()), std::string(), | 314 service.StoreSeed(SerializeSeed(CreateTestSeed()), std::string(), |
313 std::string(), base::Time::Now(), false, false); | 315 std::string(), base::Time::Now(), false, false); |
314 EXPECT_EQ(0, prefs.GetInt64(prefs::kVariationsLastFetchTime)); | 316 EXPECT_EQ(0, prefs.GetInt64(prefs::kVariationsLastFetchTime)); |
315 | 317 |
316 // Check that field trials are created from the seed. Since the test study has | 318 // Check that field trials are created from the seed. Since the test study has |
317 // only 1 experiment with 100% probability weight, we must be part of it. | 319 // only 1 experiment with 100% probability weight, we must be part of it. |
318 EXPECT_TRUE(service.CreateTrialsFromSeed(base::FeatureList::GetInstance())); | 320 EXPECT_TRUE(service.CreateTrialsFromSeed(base::FeatureList::GetInstance())); |
(...skipping 10 matching lines...) Expand all Loading... |
329 base::FeatureList::SetInstance(make_scoped_ptr(new base::FeatureList())); | 331 base::FeatureList::SetInstance(make_scoped_ptr(new base::FeatureList())); |
330 | 332 |
331 // Create a local base::FieldTrialList, to hold the field trials created in | 333 // Create a local base::FieldTrialList, to hold the field trials created in |
332 // this test. | 334 // this test. |
333 base::FieldTrialList field_trial_list(nullptr); | 335 base::FieldTrialList field_trial_list(nullptr); |
334 | 336 |
335 // Create a variations service. | 337 // Create a variations service. |
336 TestVariationsService service( | 338 TestVariationsService service( |
337 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs)), | 339 make_scoped_ptr(new web_resource::TestRequestAllowedNotifier(&prefs)), |
338 &prefs); | 340 &prefs); |
| 341 service.SetCreateTrialsFromSeedCalledForTesting(false); |
339 | 342 |
340 // Store a seed, with a fetch time 31 days in the past. | 343 // Store a seed, with a fetch time 31 days in the past. |
341 const base::Time seed_date = | 344 const base::Time seed_date = |
342 base::Time::Now() - base::TimeDelta::FromDays(31); | 345 base::Time::Now() - base::TimeDelta::FromDays(31); |
343 service.StoreSeed(SerializeSeed(CreateTestSeed()), std::string(), | 346 service.StoreSeed(SerializeSeed(CreateTestSeed()), std::string(), |
344 std::string(), seed_date, false, false); | 347 std::string(), seed_date, false, false); |
345 prefs.SetInt64(prefs::kVariationsLastFetchTime, seed_date.ToInternalValue()); | 348 prefs.SetInt64(prefs::kVariationsLastFetchTime, seed_date.ToInternalValue()); |
346 | 349 |
347 // Check that field trials are not created from the seed. | 350 // Check that field trials are not created from the seed. |
348 EXPECT_FALSE(service.CreateTrialsFromSeed(base::FeatureList::GetInstance())); | 351 EXPECT_FALSE(service.CreateTrialsFromSeed(base::FeatureList::GetInstance())); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 << test.pref_value_before << ", " << test.version << ", " | 722 << test.pref_value_before << ", " << test.version << ", " |
720 << test.latest_country_code; | 723 << test.latest_country_code; |
721 | 724 |
722 histogram_tester.ExpectUniqueSample( | 725 histogram_tester.ExpectUniqueSample( |
723 "Variations.LoadPermanentConsistencyCountryResult", | 726 "Variations.LoadPermanentConsistencyCountryResult", |
724 test.expected_result, 1); | 727 test.expected_result, 1); |
725 } | 728 } |
726 } | 729 } |
727 | 730 |
728 } // namespace variations | 731 } // namespace variations |
OLD | NEW |