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

Unified Diff: components/variations/variations_seed_processor_unittest.cc

Issue 1809633003: Allow trials to associate without overriding a feature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 d2a2959529aa06fc3f96d641140e0cb7564b29b7..cccacfc45df35ecfe585fef4527ab11a348484af 100644
--- a/components/variations/variations_seed_processor_unittest.cc
+++ b/components/variations/variations_seed_processor_unittest.cc
@@ -359,6 +359,47 @@ TEST_F(VariationsSeedProcessorTest, ValidateStudy) {
EXPECT_FALSE(processed_study.Init(&study, false));
}
+TEST_F(VariationsSeedProcessorTest, ValidateStudySingleFeature) {
+ Study study;
+ study.set_default_experiment_name("def");
+ Study_Experiment* exp1 = AddExperiment("exp1", 100, &study);
+ Study_Experiment* exp2 = AddExperiment("exp2", 100, &study);
+ Study_Experiment* exp3 = AddExperiment("exp3", 100, &study);
+ AddExperiment("def", 100, &study);
+
+ ProcessedStudy processed_study;
+ EXPECT_TRUE(processed_study.Init(&study, false));
+ EXPECT_EQ(400, processed_study.total_probability());
+
+ EXPECT_EQ(std::string(), processed_study.single_feature_name());
+
+ const char kFeature1Name[] = "Feature1";
+ const char kFeature2Name[] = "Feature2";
+
+ exp1->mutable_feature_association()->add_enable_feature(kFeature1Name);
+ EXPECT_TRUE(processed_study.Init(&study, false));
+ EXPECT_EQ(kFeature1Name, processed_study.single_feature_name());
+
+ exp1->clear_feature_association();
+ exp1->mutable_feature_association()->add_enable_feature(kFeature1Name);
+ exp1->mutable_feature_association()->add_enable_feature(kFeature2Name);
+ EXPECT_TRUE(processed_study.Init(&study, false));
+ EXPECT_EQ(std::string(), processed_study.single_feature_name());
rkaplow 2016/03/17 15:08:48 maybe note what this is testing (multiple features
Alexei Svitkine (slow) 2016/03/17 15:24:59 Done.
+
+ exp1->clear_feature_association();
+ exp1->mutable_feature_association()->add_enable_feature(kFeature1Name);
+ exp2->mutable_feature_association()->add_enable_feature(kFeature1Name);
+ exp3->mutable_feature_association()->add_disable_feature(kFeature1Name);
+ EXPECT_TRUE(processed_study.Init(&study, false));
+ EXPECT_EQ(kFeature1Name, processed_study.single_feature_name());
+
+ // Setting a different feature name on exp2 should cause |single_feature_name|
+ // to be not set.
+ exp2->mutable_feature_association()->set_enable_feature(0, kFeature2Name);
+ EXPECT_TRUE(processed_study.Init(&study, false));
+ EXPECT_EQ(std::string(), processed_study.single_feature_name());
+}
+
TEST_F(VariationsSeedProcessorTest, ProcessedStudyAllAssignmentsToOneGroup) {
Study study;
study.set_default_experiment_name("def");
@@ -613,14 +654,13 @@ TEST_F(VariationsSeedProcessorTest, FeatureAssociationAndForcing) {
// Check what happens without and command-line forcing flags - that the
// |one_hundred_percent_group| gets correctly selected and does the right
// thing w.r.t. to affecting the feature / activating the trial.
- {kFeatureOffByDefault, "", "", DEFAULT_GROUP, kDefaultGroup, false,
- false},
+ {kFeatureOffByDefault, "", "", DEFAULT_GROUP, kDefaultGroup, false, true},
{kFeatureOffByDefault, "", "", ENABLE_GROUP, kEnabledGroup, true, true},
{kFeatureOffByDefault, "", "", DISABLE_GROUP, kDisabledGroup, false,
true},
// Do the same as above, but for kFeatureOnByDefault feature.
- {kFeatureOnByDefault, "", "", DEFAULT_GROUP, kDefaultGroup, true, false},
+ {kFeatureOnByDefault, "", "", DEFAULT_GROUP, kDefaultGroup, true, true},
{kFeatureOnByDefault, "", "", ENABLE_GROUP, kEnabledGroup, true, true},
{kFeatureOnByDefault, "", "", DISABLE_GROUP, kDisabledGroup, false, true},
« 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