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

Unified Diff: base/metrics/field_trial_unittest.cc

Issue 10382018: Added a SetForced method to allow forcing a new set of group bucketting. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Better wording for the header comments of the new method. Created 8 years, 7 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 | « base/metrics/field_trial.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/field_trial_unittest.cc
diff --git a/base/metrics/field_trial_unittest.cc b/base/metrics/field_trial_unittest.cc
index 51e9aaa6794eef5856621eb1d74bbcee150961e0..f5c03c425754244d151abc47787ae7f08259ca66 100644
--- a/base/metrics/field_trial_unittest.cc
+++ b/base/metrics/field_trial_unittest.cc
@@ -522,4 +522,36 @@ TEST_F(FieldTrialTest, ForcedFieldTrials) {
EXPECT_NE(new_other_group, factory_trial->group());
}
+TEST_F(FieldTrialTest, SetForced) {
+ // Start by setting a trial for which we ensure a winner...
+ int default_group_number = -1;
+ FieldTrial* forced_trial = FieldTrialList::FactoryGetFieldTrial(
+ "Use the", 1, "default", next_year_, 12, 31, &default_group_number);
+ EXPECT_EQ(forced_trial, forced_trial);
+
+ int forced_group = forced_trial->AppendGroup("Force", 1);
+ EXPECT_EQ(forced_group, forced_trial->group());
+
+ // Now force it.
+ forced_trial->SetForced();
+
+ // Now try to set it up differently as a hard coded registration would.
+ FieldTrial* hard_coded_trial = FieldTrialList::FactoryGetFieldTrial(
+ "Use the", 1, "default", next_year_, 12, 31, &default_group_number);
+ EXPECT_EQ(hard_coded_trial, forced_trial);
+
+ int would_lose_group = hard_coded_trial->AppendGroup("Force", 0);
+ EXPECT_EQ(forced_group, hard_coded_trial->group());
+ EXPECT_EQ(forced_group, would_lose_group);
+
+ // Same thing if we would have done it to win again.
+ FieldTrial* other_hard_coded_trial = FieldTrialList::FactoryGetFieldTrial(
+ "Use the", 1, "default", next_year_, 12, 31, &default_group_number);
+ EXPECT_EQ(other_hard_coded_trial, forced_trial);
+
+ int would_win_group = other_hard_coded_trial->AppendGroup("Force", 1);
+ EXPECT_EQ(forced_group, other_hard_coded_trial->group());
+ EXPECT_EQ(forced_group, would_win_group);
+}
+
} // namespace base
« no previous file with comments | « base/metrics/field_trial.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698