| 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/entropy_provider.h" | 5 #include "components/variations/entropy_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 TEST(EntropyProviderTest, UseOneTimeRandomizationWithCustomSeedPermuted) { | 244 TEST(EntropyProviderTest, UseOneTimeRandomizationWithCustomSeedPermuted) { |
| 245 // Ensures that two trials with different names but the same custom seed used | 245 // Ensures that two trials with different names but the same custom seed used |
| 246 // for one time randomization produce the same group assignments. | 246 // for one time randomization produce the same group assignments. |
| 247 base::FieldTrialList field_trial_list( | 247 base::FieldTrialList field_trial_list( |
| 248 new PermutedEntropyProvider(1234, kMaxLowEntropySize)); | 248 new PermutedEntropyProvider(1234, kMaxLowEntropySize)); |
| 249 const int kNoExpirationYear = base::FieldTrialList::kNoExpirationYear; | 249 const int kNoExpirationYear = base::FieldTrialList::kNoExpirationYear; |
| 250 const uint32_t kCustomSeed = 9001; | 250 const uint32_t kCustomSeed = 9001; |
| 251 scoped_refptr<base::FieldTrial> trials[] = { | 251 scoped_refptr<base::FieldTrial> trials[] = { |
| 252 base::FieldTrialList::FactoryGetFieldTrialWithRandomizationSeed( | 252 base::FieldTrialList::FactoryGetFieldTrialWithRandomizationSeed( |
| 253 "one", 100, "default", kNoExpirationYear, 1, 1, | 253 "one", 100, "default", kNoExpirationYear, 1, 1, |
| 254 base::FieldTrial::ONE_TIME_RANDOMIZED, kCustomSeed, NULL), | 254 base::FieldTrial::ONE_TIME_RANDOMIZED, kCustomSeed, NULL, NULL), |
| 255 base::FieldTrialList::FactoryGetFieldTrialWithRandomizationSeed( | 255 base::FieldTrialList::FactoryGetFieldTrialWithRandomizationSeed( |
| 256 "two", 100, "default", kNoExpirationYear, 1, 1, | 256 "two", 100, "default", kNoExpirationYear, 1, 1, |
| 257 base::FieldTrial::ONE_TIME_RANDOMIZED, kCustomSeed, NULL), | 257 base::FieldTrial::ONE_TIME_RANDOMIZED, kCustomSeed, NULL, NULL), |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 for (size_t i = 0; i < arraysize(trials); ++i) { | 260 for (size_t i = 0; i < arraysize(trials); ++i) { |
| 261 for (int j = 0; j < 100; ++j) | 261 for (int j = 0; j < 100; ++j) |
| 262 trials[i]->AppendGroup(std::string(), 1); | 262 trials[i]->AppendGroup(std::string(), 1); |
| 263 } | 263 } |
| 264 | 264 |
| 265 // Normally, these trials should produce different groups, but if the same | 265 // Normally, these trials should produce different groups, but if the same |
| 266 // custom seed is used, they should produce the same group assignment. | 266 // custom seed is used, they should produce the same group assignment. |
| 267 EXPECT_EQ(trials[0]->group(), trials[1]->group()); | 267 EXPECT_EQ(trials[0]->group(), trials[1]->group()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 ++count; | 361 ++count; |
| 362 } | 362 } |
| 363 | 363 |
| 364 ASSERT_LT(count, kMaxAttempts) << "Expected average was " << | 364 ASSERT_LT(count, kMaxAttempts) << "Expected average was " << |
| 365 kExpectedAverage << ", average ended at " << cumulative_average << | 365 kExpectedAverage << ", average ended at " << cumulative_average << |
| 366 ", for trial " << kTestTrialNames[i]; | 366 ", for trial " << kTestTrialNames[i]; |
| 367 } | 367 } |
| 368 } | 368 } |
| 369 | 369 |
| 370 } // namespace metrics | 370 } // namespace metrics |
| OLD | NEW |