OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/variations_seed_processor.h" | 5 #include "components/variations/variations_seed_processor.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups); | 66 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups); |
67 for (size_t i = 0; i < active_groups.size(); ++i) { | 67 for (size_t i = 0; i < active_groups.size(); ++i) { |
68 if (active_groups[i].trial_name == trial_name) | 68 if (active_groups[i].trial_name == trial_name) |
69 return true; | 69 return true; |
70 } | 70 } |
71 return false; | 71 return false; |
72 } | 72 } |
73 | 73 |
74 } // namespace | 74 } // namespace |
75 | 75 |
76 TEST(VariationsSeedProcessorTest, CheckStudyChannel) { | 76 class VariationsSeedProcessorTest : public ::testing::Test { |
| 77 public: |
| 78 VariationsSeedProcessorTest() { |
| 79 } |
| 80 |
| 81 virtual ~VariationsSeedProcessorTest() { |
| 82 // Ensure that the maps are cleared between tests, since they are stored as |
| 83 // process singletons. |
| 84 testing::ClearAllVariationIDs(); |
| 85 testing::ClearAllVariationParams(); |
| 86 } |
| 87 |
| 88 private: |
| 89 DISALLOW_COPY_AND_ASSIGN(VariationsSeedProcessorTest); |
| 90 }; |
| 91 |
| 92 TEST_F(VariationsSeedProcessorTest, CheckStudyChannel) { |
77 VariationsSeedProcessor seed_processor; | 93 VariationsSeedProcessor seed_processor; |
78 | 94 |
79 const Study_Channel channels[] = { | 95 const Study_Channel channels[] = { |
80 Study_Channel_CANARY, | 96 Study_Channel_CANARY, |
81 Study_Channel_DEV, | 97 Study_Channel_DEV, |
82 Study_Channel_BETA, | 98 Study_Channel_BETA, |
83 Study_Channel_STABLE, | 99 Study_Channel_STABLE, |
84 }; | 100 }; |
85 bool channel_added[arraysize(channels)] = { 0 }; | 101 bool channel_added[arraysize(channels)] = { 0 }; |
86 | 102 |
(...skipping 25 matching lines...) Expand all Loading... |
112 } | 128 } |
113 | 129 |
114 if (i < arraysize(channels)) { | 130 if (i < arraysize(channels)) { |
115 const int index = arraysize(channels) - i - 1; | 131 const int index = arraysize(channels) - i - 1; |
116 filter.add_channel(channels[index]); | 132 filter.add_channel(channels[index]); |
117 channel_added[index] = true; | 133 channel_added[index] = true; |
118 } | 134 } |
119 } | 135 } |
120 } | 136 } |
121 | 137 |
122 TEST(VariationsSeedProcessorTest, CheckStudyLocale) { | 138 TEST_F(VariationsSeedProcessorTest, CheckStudyLocale) { |
123 VariationsSeedProcessor seed_processor; | 139 VariationsSeedProcessor seed_processor; |
124 | 140 |
125 struct { | 141 struct { |
126 const char* filter_locales; | 142 const char* filter_locales; |
127 bool en_us_result; | 143 bool en_us_result; |
128 bool en_ca_result; | 144 bool en_ca_result; |
129 bool fr_result; | 145 bool fr_result; |
130 } test_cases[] = { | 146 } test_cases[] = { |
131 {"en-US", true, false, false}, | 147 {"en-US", true, false, false}, |
132 {"en-US,en-CA,fr", true, true, true}, | 148 {"en-US,en-CA,fr", true, true, true}, |
(...skipping 12 matching lines...) Expand all Loading... |
145 filter.add_locale(filter_locales[j]); | 161 filter.add_locale(filter_locales[j]); |
146 EXPECT_EQ(test_cases[i].en_us_result, | 162 EXPECT_EQ(test_cases[i].en_us_result, |
147 seed_processor.CheckStudyLocale(filter, "en-US")); | 163 seed_processor.CheckStudyLocale(filter, "en-US")); |
148 EXPECT_EQ(test_cases[i].en_ca_result, | 164 EXPECT_EQ(test_cases[i].en_ca_result, |
149 seed_processor.CheckStudyLocale(filter, "en-CA")); | 165 seed_processor.CheckStudyLocale(filter, "en-CA")); |
150 EXPECT_EQ(test_cases[i].fr_result, | 166 EXPECT_EQ(test_cases[i].fr_result, |
151 seed_processor.CheckStudyLocale(filter, "fr")); | 167 seed_processor.CheckStudyLocale(filter, "fr")); |
152 } | 168 } |
153 } | 169 } |
154 | 170 |
155 TEST(VariationsSeedProcessorTest, CheckStudyPlatform) { | 171 TEST_F(VariationsSeedProcessorTest, CheckStudyPlatform) { |
156 VariationsSeedProcessor seed_processor; | 172 VariationsSeedProcessor seed_processor; |
157 | 173 |
158 const Study_Platform platforms[] = { | 174 const Study_Platform platforms[] = { |
159 Study_Platform_PLATFORM_WINDOWS, | 175 Study_Platform_PLATFORM_WINDOWS, |
160 Study_Platform_PLATFORM_MAC, | 176 Study_Platform_PLATFORM_MAC, |
161 Study_Platform_PLATFORM_LINUX, | 177 Study_Platform_PLATFORM_LINUX, |
162 Study_Platform_PLATFORM_CHROMEOS, | 178 Study_Platform_PLATFORM_CHROMEOS, |
163 Study_Platform_PLATFORM_ANDROID, | 179 Study_Platform_PLATFORM_ANDROID, |
164 Study_Platform_PLATFORM_IOS, | 180 Study_Platform_PLATFORM_IOS, |
165 }; | 181 }; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 213 } |
198 | 214 |
199 if (i < arraysize(platforms)) { | 215 if (i < arraysize(platforms)) { |
200 const int index = arraysize(platforms) - i - 1; | 216 const int index = arraysize(platforms) - i - 1; |
201 filter.add_platform(platforms[index]); | 217 filter.add_platform(platforms[index]); |
202 platform_added[index] = true; | 218 platform_added[index] = true; |
203 } | 219 } |
204 } | 220 } |
205 } | 221 } |
206 | 222 |
207 TEST(VariationsSeedProcessorTest, CheckStudyStartDate) { | 223 TEST_F(VariationsSeedProcessorTest, CheckStudyStartDate) { |
208 VariationsSeedProcessor seed_processor; | 224 VariationsSeedProcessor seed_processor; |
209 | 225 |
210 const base::Time now = base::Time::Now(); | 226 const base::Time now = base::Time::Now(); |
211 const base::TimeDelta delta = base::TimeDelta::FromHours(1); | 227 const base::TimeDelta delta = base::TimeDelta::FromHours(1); |
212 const struct { | 228 const struct { |
213 const base::Time start_date; | 229 const base::Time start_date; |
214 bool expected_result; | 230 bool expected_result; |
215 } start_test_cases[] = { | 231 } start_test_cases[] = { |
216 { now - delta, true }, | 232 { now - delta, true }, |
217 { now, true }, | 233 { now, true }, |
218 { now + delta, false }, | 234 { now + delta, false }, |
219 }; | 235 }; |
220 | 236 |
221 Study_Filter filter; | 237 Study_Filter filter; |
222 | 238 |
223 // Start date not set should result in true. | 239 // Start date not set should result in true. |
224 EXPECT_TRUE(seed_processor.CheckStudyStartDate(filter, now)); | 240 EXPECT_TRUE(seed_processor.CheckStudyStartDate(filter, now)); |
225 | 241 |
226 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(start_test_cases); ++i) { | 242 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(start_test_cases); ++i) { |
227 filter.set_start_date(TimeToProtoTime(start_test_cases[i].start_date)); | 243 filter.set_start_date(TimeToProtoTime(start_test_cases[i].start_date)); |
228 const bool result = seed_processor.CheckStudyStartDate(filter, now); | 244 const bool result = seed_processor.CheckStudyStartDate(filter, now); |
229 EXPECT_EQ(start_test_cases[i].expected_result, result) | 245 EXPECT_EQ(start_test_cases[i].expected_result, result) |
230 << "Case " << i << " failed!"; | 246 << "Case " << i << " failed!"; |
231 } | 247 } |
232 } | 248 } |
233 | 249 |
234 TEST(VariationsSeedProcessorTest, CheckStudyVersion) { | 250 TEST_F(VariationsSeedProcessorTest, CheckStudyVersion) { |
235 VariationsSeedProcessor seed_processor; | 251 VariationsSeedProcessor seed_processor; |
236 | 252 |
237 const struct { | 253 const struct { |
238 const char* min_version; | 254 const char* min_version; |
239 const char* version; | 255 const char* version; |
240 bool expected_result; | 256 bool expected_result; |
241 } min_test_cases[] = { | 257 } min_test_cases[] = { |
242 { "1.2.2", "1.2.3", true }, | 258 { "1.2.2", "1.2.3", true }, |
243 { "1.2.3", "1.2.3", true }, | 259 { "1.2.3", "1.2.3", true }, |
244 { "1.2.4", "1.2.3", false }, | 260 { "1.2.4", "1.2.3", false }, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 const bool result = | 332 const bool result = |
317 seed_processor.CheckStudyVersion( | 333 seed_processor.CheckStudyVersion( |
318 filter, Version(max_test_cases[j].version)); | 334 filter, Version(max_test_cases[j].version)); |
319 EXPECT_FALSE(result) << "Case " << i << "," << j << " failed!"; | 335 EXPECT_FALSE(result) << "Case " << i << "," << j << " failed!"; |
320 } | 336 } |
321 } | 337 } |
322 } | 338 } |
323 } | 339 } |
324 | 340 |
325 // Test that the group for kForcingFlag1 is forced. | 341 // Test that the group for kForcingFlag1 is forced. |
326 TEST(VariationsSeedProcessorTest, ForceGroupWithFlag1) { | 342 TEST_F(VariationsSeedProcessorTest, ForceGroupWithFlag1) { |
327 CommandLine::ForCurrentProcess()->AppendSwitch(kForcingFlag1); | 343 CommandLine::ForCurrentProcess()->AppendSwitch(kForcingFlag1); |
328 | 344 |
329 base::FieldTrialList field_trial_list(NULL); | 345 base::FieldTrialList field_trial_list(NULL); |
330 | 346 |
331 Study study = CreateStudyWithFlagGroups(100, 0, 0); | 347 Study study = CreateStudyWithFlagGroups(100, 0, 0); |
332 VariationsSeedProcessor().CreateTrialFromStudy(study, false); | 348 VariationsSeedProcessor().CreateTrialFromStudy(study, false); |
333 | 349 |
334 EXPECT_EQ(kFlagGroup1Name, | 350 EXPECT_EQ(kFlagGroup1Name, |
335 base::FieldTrialList::FindFullName(kFlagStudyName)); | 351 base::FieldTrialList::FindFullName(kFlagStudyName)); |
336 } | 352 } |
337 | 353 |
338 // Test that the group for kForcingFlag2 is forced. | 354 // Test that the group for kForcingFlag2 is forced. |
339 TEST(VariationsSeedProcessorTest, ForceGroupWithFlag2) { | 355 TEST_F(VariationsSeedProcessorTest, ForceGroupWithFlag2) { |
340 CommandLine::ForCurrentProcess()->AppendSwitch(kForcingFlag2); | 356 CommandLine::ForCurrentProcess()->AppendSwitch(kForcingFlag2); |
341 | 357 |
342 base::FieldTrialList field_trial_list(NULL); | 358 base::FieldTrialList field_trial_list(NULL); |
343 | 359 |
344 Study study = CreateStudyWithFlagGroups(100, 0, 0); | 360 Study study = CreateStudyWithFlagGroups(100, 0, 0); |
345 VariationsSeedProcessor().CreateTrialFromStudy(study, false); | 361 VariationsSeedProcessor().CreateTrialFromStudy(study, false); |
346 | 362 |
347 EXPECT_EQ(kFlagGroup2Name, | 363 EXPECT_EQ(kFlagGroup2Name, |
348 base::FieldTrialList::FindFullName(kFlagStudyName)); | 364 base::FieldTrialList::FindFullName(kFlagStudyName)); |
349 } | 365 } |
350 | 366 |
351 TEST(VariationsSeedProcessorTest, ForceGroup_ChooseFirstGroupWithFlag) { | 367 TEST_F(VariationsSeedProcessorTest, ForceGroup_ChooseFirstGroupWithFlag) { |
352 // Add the flag to the command line arguments so the flag group is forced. | 368 // Add the flag to the command line arguments so the flag group is forced. |
353 CommandLine::ForCurrentProcess()->AppendSwitch(kForcingFlag1); | 369 CommandLine::ForCurrentProcess()->AppendSwitch(kForcingFlag1); |
354 CommandLine::ForCurrentProcess()->AppendSwitch(kForcingFlag2); | 370 CommandLine::ForCurrentProcess()->AppendSwitch(kForcingFlag2); |
355 | 371 |
356 base::FieldTrialList field_trial_list(NULL); | 372 base::FieldTrialList field_trial_list(NULL); |
357 | 373 |
358 Study study = CreateStudyWithFlagGroups(100, 0, 0); | 374 Study study = CreateStudyWithFlagGroups(100, 0, 0); |
359 VariationsSeedProcessor().CreateTrialFromStudy(study, false); | 375 VariationsSeedProcessor().CreateTrialFromStudy(study, false); |
360 | 376 |
361 EXPECT_EQ(kFlagGroup1Name, | 377 EXPECT_EQ(kFlagGroup1Name, |
362 base::FieldTrialList::FindFullName(kFlagStudyName)); | 378 base::FieldTrialList::FindFullName(kFlagStudyName)); |
363 } | 379 } |
364 | 380 |
365 TEST(VariationsSeedProcessorTest, ForceGroup_DontChooseGroupWithFlag) { | 381 TEST_F(VariationsSeedProcessorTest, ForceGroup_DontChooseGroupWithFlag) { |
366 base::FieldTrialList field_trial_list(NULL); | 382 base::FieldTrialList field_trial_list(NULL); |
367 | 383 |
368 // The two flag groups are given high probability, which would normally make | 384 // The two flag groups are given high probability, which would normally make |
369 // them very likely to be chosen. They won't be chosen since flag groups are | 385 // them very likely to be chosen. They won't be chosen since flag groups are |
370 // never chosen when their flag isn't present. | 386 // never chosen when their flag isn't present. |
371 Study study = CreateStudyWithFlagGroups(1, 999, 999); | 387 Study study = CreateStudyWithFlagGroups(1, 999, 999); |
372 VariationsSeedProcessor().CreateTrialFromStudy(study, false); | 388 VariationsSeedProcessor().CreateTrialFromStudy(study, false); |
373 EXPECT_EQ(kNonFlagGroupName, | 389 EXPECT_EQ(kNonFlagGroupName, |
374 base::FieldTrialList::FindFullName(kFlagStudyName)); | 390 base::FieldTrialList::FindFullName(kFlagStudyName)); |
375 } | 391 } |
376 | 392 |
377 TEST(VariationsSeedProcessorTest, IsStudyExpired) { | 393 TEST_F(VariationsSeedProcessorTest, IsStudyExpired) { |
378 VariationsSeedProcessor seed_processor; | 394 VariationsSeedProcessor seed_processor; |
379 | 395 |
380 const base::Time now = base::Time::Now(); | 396 const base::Time now = base::Time::Now(); |
381 const base::TimeDelta delta = base::TimeDelta::FromHours(1); | 397 const base::TimeDelta delta = base::TimeDelta::FromHours(1); |
382 const struct { | 398 const struct { |
383 const base::Time expiry_date; | 399 const base::Time expiry_date; |
384 bool expected_result; | 400 bool expected_result; |
385 } expiry_test_cases[] = { | 401 } expiry_test_cases[] = { |
386 { now - delta, true }, | 402 { now - delta, true }, |
387 { now, true }, | 403 { now, true }, |
388 { now + delta, false }, | 404 { now + delta, false }, |
389 }; | 405 }; |
390 | 406 |
391 Study study; | 407 Study study; |
392 | 408 |
393 // Expiry date not set should result in false. | 409 // Expiry date not set should result in false. |
394 EXPECT_FALSE(seed_processor.IsStudyExpired(study, now)); | 410 EXPECT_FALSE(seed_processor.IsStudyExpired(study, now)); |
395 | 411 |
396 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expiry_test_cases); ++i) { | 412 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expiry_test_cases); ++i) { |
397 study.set_expiry_date(TimeToProtoTime(expiry_test_cases[i].expiry_date)); | 413 study.set_expiry_date(TimeToProtoTime(expiry_test_cases[i].expiry_date)); |
398 const bool result = seed_processor.IsStudyExpired(study, now); | 414 const bool result = seed_processor.IsStudyExpired(study, now); |
399 EXPECT_EQ(expiry_test_cases[i].expected_result, result) | 415 EXPECT_EQ(expiry_test_cases[i].expected_result, result) |
400 << "Case " << i << " failed!"; | 416 << "Case " << i << " failed!"; |
401 } | 417 } |
402 } | 418 } |
403 | 419 |
404 TEST(VariationsSeedProcessorTest, NonExpiredStudyPrioritizedOverExpiredStudy) { | 420 TEST_F(VariationsSeedProcessorTest, |
| 421 NonExpiredStudyPrioritizedOverExpiredStudy) { |
405 VariationsSeedProcessor seed_processor; | 422 VariationsSeedProcessor seed_processor; |
406 | 423 |
407 const std::string kTrialName = "A"; | 424 const std::string kTrialName = "A"; |
408 const std::string kGroup1Name = "Group1"; | 425 const std::string kGroup1Name = "Group1"; |
409 | 426 |
410 VariationsSeed seed; | 427 VariationsSeed seed; |
411 Study* study1 = seed.add_study(); | 428 Study* study1 = seed.add_study(); |
412 study1->set_name(kTrialName); | 429 study1->set_name(kTrialName); |
413 study1->set_default_experiment_name("Default"); | 430 study1->set_default_experiment_name("Default"); |
414 AddExperiment(kGroup1Name, 100, study1); | 431 AddExperiment(kGroup1Name, 100, study1); |
(...skipping 22 matching lines...) Expand all Loading... |
437 { | 454 { |
438 base::FieldTrialList field_trial_list(NULL); | 455 base::FieldTrialList field_trial_list(NULL); |
439 study1->clear_expiry_date(); | 456 study1->clear_expiry_date(); |
440 study2->set_expiry_date(TimeToProtoTime(year_ago)); | 457 study2->set_expiry_date(TimeToProtoTime(year_ago)); |
441 seed_processor.CreateTrialsFromSeed(seed, "en-CA", base::Time::Now(), | 458 seed_processor.CreateTrialsFromSeed(seed, "en-CA", base::Time::Now(), |
442 version, Study_Channel_STABLE); | 459 version, Study_Channel_STABLE); |
443 EXPECT_EQ(kGroup1Name, base::FieldTrialList::FindFullName(kTrialName)); | 460 EXPECT_EQ(kGroup1Name, base::FieldTrialList::FindFullName(kTrialName)); |
444 } | 461 } |
445 } | 462 } |
446 | 463 |
447 TEST(VariationsSeedProcessorTest, ValidateStudy) { | 464 TEST_F(VariationsSeedProcessorTest, ValidateStudy) { |
448 VariationsSeedProcessor seed_processor; | 465 VariationsSeedProcessor seed_processor; |
449 | 466 |
450 Study study; | 467 Study study; |
451 study.set_default_experiment_name("def"); | 468 study.set_default_experiment_name("def"); |
452 AddExperiment("abc", 100, &study); | 469 AddExperiment("abc", 100, &study); |
453 Study_Experiment* default_group = AddExperiment("def", 200, &study); | 470 Study_Experiment* default_group = AddExperiment("def", 200, &study); |
454 | 471 |
455 base::FieldTrial::Probability total_probability = 0; | 472 base::FieldTrial::Probability total_probability = 0; |
456 bool valid = seed_processor.ValidateStudyAndComputeTotalProbability( | 473 bool valid = seed_processor.ValidateStudyAndComputeTotalProbability( |
457 study, &total_probability); | 474 study, &total_probability); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 &total_probability); | 524 &total_probability); |
508 ASSERT_TRUE(valid); | 525 ASSERT_TRUE(valid); |
509 Study_Experiment* repeated_group = study.add_experiment(); | 526 Study_Experiment* repeated_group = study.add_experiment(); |
510 repeated_group->set_name("abc"); | 527 repeated_group->set_name("abc"); |
511 repeated_group->set_probability_weight(1); | 528 repeated_group->set_probability_weight(1); |
512 valid = seed_processor.ValidateStudyAndComputeTotalProbability(study, | 529 valid = seed_processor.ValidateStudyAndComputeTotalProbability(study, |
513 &total_probability); | 530 &total_probability); |
514 EXPECT_FALSE(valid); | 531 EXPECT_FALSE(valid); |
515 } | 532 } |
516 | 533 |
517 TEST(VariationsSeedProcessorTest, VariationParams) { | 534 TEST_F(VariationsSeedProcessorTest, VariationParams) { |
518 base::FieldTrialList field_trial_list(NULL); | 535 base::FieldTrialList field_trial_list(NULL); |
519 VariationsSeedProcessor seed_processor; | 536 VariationsSeedProcessor seed_processor; |
520 | 537 |
521 Study study; | 538 Study study; |
522 study.set_name("Study1"); | 539 study.set_name("Study1"); |
523 study.set_default_experiment_name("B"); | 540 study.set_default_experiment_name("B"); |
524 | 541 |
525 Study_Experiment* experiment1 = AddExperiment("A", 1, &study); | 542 Study_Experiment* experiment1 = AddExperiment("A", 1, &study); |
526 Study_Experiment_Param* param = experiment1->add_param(); | 543 Study_Experiment_Param* param = experiment1->add_param(); |
527 param->set_name("x"); | 544 param->set_name("x"); |
528 param->set_value("y"); | 545 param->set_value("y"); |
529 | 546 |
530 Study_Experiment* experiment2 = AddExperiment("B", 0, &study); | 547 Study_Experiment* experiment2 = AddExperiment("B", 0, &study); |
531 | 548 |
532 seed_processor.CreateTrialFromStudy(study, false); | 549 seed_processor.CreateTrialFromStudy(study, false); |
533 EXPECT_EQ("y", GetVariationParamValue("Study1", "x")); | 550 EXPECT_EQ("y", GetVariationParamValue("Study1", "x")); |
534 | 551 |
535 study.set_name("Study2"); | 552 study.set_name("Study2"); |
536 experiment1->set_probability_weight(0); | 553 experiment1->set_probability_weight(0); |
537 experiment2->set_probability_weight(1); | 554 experiment2->set_probability_weight(1); |
538 seed_processor.CreateTrialFromStudy(study, false); | 555 seed_processor.CreateTrialFromStudy(study, false); |
539 EXPECT_EQ(std::string(), GetVariationParamValue("Study2", "x")); | 556 EXPECT_EQ(std::string(), GetVariationParamValue("Study2", "x")); |
540 } | 557 } |
541 | 558 |
542 TEST(VariationsSeedProcessorTest, StartsActive) { | 559 TEST_F(VariationsSeedProcessorTest, VariationParamsWithForcingFlag) { |
| 560 Study study = CreateStudyWithFlagGroups(100, 0, 0); |
| 561 ASSERT_EQ(kForcingFlag1, study.experiment(1).forcing_flag()); |
| 562 Study_Experiment_Param* param = study.mutable_experiment(1)->add_param(); |
| 563 param->set_name("x"); |
| 564 param->set_value("y"); |
| 565 |
| 566 CommandLine::ForCurrentProcess()->AppendSwitch(kForcingFlag1); |
| 567 base::FieldTrialList field_trial_list(NULL); |
| 568 VariationsSeedProcessor().CreateTrialFromStudy(study, false); |
| 569 EXPECT_EQ(kFlagGroup1Name, base::FieldTrialList::FindFullName(study.name())); |
| 570 EXPECT_EQ("y", GetVariationParamValue(study.name(), "x")); |
| 571 } |
| 572 |
| 573 TEST_F(VariationsSeedProcessorTest, StartsActive) { |
543 base::FieldTrialList field_trial_list(NULL); | 574 base::FieldTrialList field_trial_list(NULL); |
544 | 575 |
545 VariationsSeed seed; | 576 VariationsSeed seed; |
546 Study* study1 = seed.add_study(); | 577 Study* study1 = seed.add_study(); |
547 study1->set_name("A"); | 578 study1->set_name("A"); |
548 study1->set_default_experiment_name("Default"); | 579 study1->set_default_experiment_name("Default"); |
549 AddExperiment("AA", 100, study1); | 580 AddExperiment("AA", 100, study1); |
550 AddExperiment("Default", 0, study1); | 581 AddExperiment("Default", 0, study1); |
551 | 582 |
552 Study* study2 = seed.add_study(); | 583 Study* study2 = seed.add_study(); |
(...skipping 25 matching lines...) Expand all Loading... |
578 EXPECT_EQ("BB", base::FieldTrialList::FindFullName("B")); | 609 EXPECT_EQ("BB", base::FieldTrialList::FindFullName("B")); |
579 EXPECT_EQ("CC", base::FieldTrialList::FindFullName("C")); | 610 EXPECT_EQ("CC", base::FieldTrialList::FindFullName("C")); |
580 | 611 |
581 // Now, all studies should be active. | 612 // Now, all studies should be active. |
582 EXPECT_TRUE(IsFieldTrialActive("A")); | 613 EXPECT_TRUE(IsFieldTrialActive("A")); |
583 EXPECT_TRUE(IsFieldTrialActive("B")); | 614 EXPECT_TRUE(IsFieldTrialActive("B")); |
584 EXPECT_TRUE(IsFieldTrialActive("C")); | 615 EXPECT_TRUE(IsFieldTrialActive("C")); |
585 } | 616 } |
586 | 617 |
587 } // namespace chrome_variations | 618 } // namespace chrome_variations |
OLD | NEW |