summaryrefslogtreecommitdiffstats
path: root/base/metrics/field_trial_unittest.cc
diff options
context:
space:
mode:
authorasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 20:25:57 +0000
committerasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-13 20:25:57 +0000
commitbf4d4efcd977d9f4438725d77e6bc9e02aac4b1c (patch)
treeb31c02bd721120e75bd0d885f81e015a0798dac1 /base/metrics/field_trial_unittest.cc
parent79ccf65145690b1516784414da14a78eee70a3ff (diff)
downloadchromium_src-bf4d4efcd977d9f4438725d77e6bc9e02aac4b1c.zip
chromium_src-bf4d4efcd977d9f4438725d77e6bc9e02aac4b1c.tar.gz
chromium_src-bf4d4efcd977d9f4438725d77e6bc9e02aac4b1c.tar.bz2
Remove a DCHECK() in FieldTrial::SetForced().
The DCHECK() was added under the assumption that it doesn't make sense to force a trial that only has the default group. However, with VariationsService, which is general-purpose, one could create a server-side trial of this sort, and this works correctly other than the DCHECK(). BUG=160766 TEST=New unit tests in field_trial_unittest.cc. Review URL: https://codereview.chromium.org/11366205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/metrics/field_trial_unittest.cc')
-rw-r--r--base/metrics/field_trial_unittest.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/base/metrics/field_trial_unittest.cc b/base/metrics/field_trial_unittest.cc
index 1ab8467..a77b5ef 100644
--- a/base/metrics/field_trial_unittest.cc
+++ b/base/metrics/field_trial_unittest.cc
@@ -588,6 +588,42 @@ TEST_F(FieldTrialTest, SetForced) {
EXPECT_EQ(forced_group, would_win_group);
}
+TEST_F(FieldTrialTest, SetForcedDefaultOnly) {
+ const char kTrialName[] = "SetForcedDefaultOnly";
+ ASSERT_FALSE(FieldTrialList::TrialExists(kTrialName));
+
+ int default_group = -1;
+ FieldTrial* trial =
+ FieldTrialList::FactoryGetFieldTrial(kTrialName, 100, kDefaultGroupName,
+ next_year_, 12, 31, &default_group);
+ trial->SetForced();
+
+ trial = FieldTrialList::FactoryGetFieldTrial(kTrialName, 100,
+ kDefaultGroupName, next_year_,
+ 12, 31, NULL);
+ EXPECT_EQ(default_group, trial->group());
+ EXPECT_EQ(kDefaultGroupName, trial->group_name());
+}
+
+TEST_F(FieldTrialTest, SetForcedDefaultWithExtraGroup) {
+ const char kTrialName[] = "SetForcedDefaultWithExtraGroup";
+ ASSERT_FALSE(FieldTrialList::TrialExists(kTrialName));
+
+ int default_group = -1;
+ FieldTrial* trial =
+ FieldTrialList::FactoryGetFieldTrial(kTrialName, 100, kDefaultGroupName,
+ next_year_, 12, 31, &default_group);
+ trial->SetForced();
+
+ trial = FieldTrialList::FactoryGetFieldTrial(kTrialName, 100,
+ kDefaultGroupName, next_year_,
+ 12, 31, NULL);
+ const int extra_group = trial->AppendGroup("Extra", 100);
+ EXPECT_EQ(default_group, trial->group());
+ EXPECT_NE(extra_group, trial->group());
+ EXPECT_EQ(kDefaultGroupName, trial->group_name());
+}
+
TEST_F(FieldTrialTest, Observe) {
const char kTrialName[] = "TrialToObserve1";
const char kSecondaryGroupName[] = "SecondaryGroup";