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 <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 Study study = CreateStudyWithFlagGroups(100, 0, 0); | 456 Study study = CreateStudyWithFlagGroups(100, 0, 0); |
457 study.set_activation_type(Study_ActivationType_ACTIVATION_AUTO); | 457 study.set_activation_type(Study_ActivationType_ACTIVATION_AUTO); |
458 | 458 |
459 EXPECT_TRUE(CreateTrialFromStudy(&study)); | 459 EXPECT_TRUE(CreateTrialFromStudy(&study)); |
460 EXPECT_TRUE(IsFieldTrialActive(kFlagStudyName)); | 460 EXPECT_TRUE(IsFieldTrialActive(kFlagStudyName)); |
461 | 461 |
462 EXPECT_EQ(kFlagGroup1Name, | 462 EXPECT_EQ(kFlagGroup1Name, |
463 base::FieldTrialList::FindFullName(kFlagStudyName)); | 463 base::FieldTrialList::FindFullName(kFlagStudyName)); |
464 } | 464 } |
465 | 465 |
| 466 TEST_F(VariationsSeedProcessorTest, ForcingFlagAlreadyForced) { |
| 467 Study study = CreateStudyWithFlagGroups(100, 0, 0); |
| 468 ASSERT_EQ(kNonFlagGroupName, study.experiment(0).name()); |
| 469 Study_Experiment_Param* param = study.mutable_experiment(0)->add_param(); |
| 470 param->set_name("x"); |
| 471 param->set_value("y"); |
| 472 study.mutable_experiment(0)->set_google_web_experiment_id(kExperimentId); |
| 473 |
| 474 base::FieldTrialList field_trial_list(NULL); |
| 475 base::FieldTrialList::CreateFieldTrial(kFlagStudyName, kNonFlagGroupName); |
| 476 |
| 477 CommandLine::ForCurrentProcess()->AppendSwitch(kForcingFlag1); |
| 478 EXPECT_TRUE(CreateTrialFromStudy(&study)); |
| 479 // The previously forced experiment should still hold. |
| 480 EXPECT_EQ(kNonFlagGroupName, |
| 481 base::FieldTrialList::FindFullName(study.name())); |
| 482 |
| 483 // Check that params and experiment ids correspond. |
| 484 EXPECT_EQ("y", GetVariationParamValue(study.name(), "x")); |
| 485 VariationID id = GetGoogleVariationID(GOOGLE_WEB_PROPERTIES, kFlagStudyName, |
| 486 kNonFlagGroupName); |
| 487 EXPECT_EQ(kExperimentId, id); |
| 488 } |
| 489 |
466 } // namespace variations | 490 } // namespace variations |
OLD | NEW |