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

Unified Diff: components/variations/variations_seed_processor_unittest.cc

Issue 529183002: Fix crash with forcing variations when the trial exists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/variations/variations_seed_processor.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/variations_seed_processor_unittest.cc
diff --git a/components/variations/variations_seed_processor_unittest.cc b/components/variations/variations_seed_processor_unittest.cc
index 07eed692b9cbab43c24c42ea5c2fd1fe95090656..fe58842b405b6657c4e24ecac2a764519adf5e62 100644
--- a/components/variations/variations_seed_processor_unittest.cc
+++ b/components/variations/variations_seed_processor_unittest.cc
@@ -463,4 +463,28 @@ TEST_F(VariationsSeedProcessorTest, StartsActiveWithFlag) {
base::FieldTrialList::FindFullName(kFlagStudyName));
}
+TEST_F(VariationsSeedProcessorTest, ForcingFlagAlreadyForced) {
+ Study study = CreateStudyWithFlagGroups(100, 0, 0);
+ ASSERT_EQ(kNonFlagGroupName, study.experiment(0).name());
+ Study_Experiment_Param* param = study.mutable_experiment(0)->add_param();
+ param->set_name("x");
+ param->set_value("y");
+ study.mutable_experiment(0)->set_google_web_experiment_id(kExperimentId);
+
+ base::FieldTrialList field_trial_list(NULL);
+ base::FieldTrialList::CreateFieldTrial(kFlagStudyName, kNonFlagGroupName);
+
+ CommandLine::ForCurrentProcess()->AppendSwitch(kForcingFlag1);
+ EXPECT_TRUE(CreateTrialFromStudy(&study));
+ // The previously forced experiment should still hold.
+ EXPECT_EQ(kNonFlagGroupName,
+ base::FieldTrialList::FindFullName(study.name()));
+
+ // Check that params and experiment ids correspond.
+ EXPECT_EQ("y", GetVariationParamValue(study.name(), "x"));
+ VariationID id = GetGoogleVariationID(GOOGLE_WEB_PROPERTIES, kFlagStudyName,
+ kNonFlagGroupName);
+ EXPECT_EQ(kExperimentId, id);
+}
+
} // namespace variations
« no previous file with comments | « components/variations/variations_seed_processor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698