summaryrefslogtreecommitdiffstats
path: root/base/field_trial_unittest.cc
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 01:14:56 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 01:14:56 +0000
commitb37fdaafc215e5fea29b7f66fb866a0400ca47bb (patch)
tree6cf4a612fe7f2c95260f3c7a540816cf22570d04 /base/field_trial_unittest.cc
parente7aa9ec4e73aef9681c5bccb83b9d88aaab304fe (diff)
downloadchromium_src-b37fdaafc215e5fea29b7f66fb866a0400ca47bb.zip
chromium_src-b37fdaafc215e5fea29b7f66fb866a0400ca47bb.tar.gz
chromium_src-b37fdaafc215e5fea29b7f66fb866a0400ca47bb.tar.bz2
Implement shortcut for finalizing a trial with all remaining probability
It is helpful when defining experiments to put all remaining probability on the final (often the "control" group), without having to keep a careful tally of assignments of probabilities. This CL implements that functionality. r=rvargas Review URL: http://codereview.chromium.org/150141 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/field_trial_unittest.cc')
-rw-r--r--base/field_trial_unittest.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/base/field_trial_unittest.cc b/base/field_trial_unittest.cc
index 59d8e15..430fd67 100644
--- a/base/field_trial_unittest.cc
+++ b/base/field_trial_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -69,6 +69,25 @@ TEST_F(FieldTrialTest, AbsoluteProbabilities) {
}
}
+TEST_F(FieldTrialTest, RemainingProbability) {
+ // First create a test that hasn't had a winner yet.
+ const std::string winner = "Winner";
+ const std::string loser = "Loser";
+ scoped_refptr<FieldTrial> trial;
+ int counter = 0;
+ do {
+ std::string name = StringPrintf("trial%d", ++counter);
+ trial = new FieldTrial(name, 10);
+ trial->AppendGroup(loser, 5); // 50% chance of not being chosen.
+ } while (trial->group() != FieldTrial::kNotParticipating);
+
+ // Now add a winner with all remaining probability.
+ trial->AppendGroup(winner, FieldTrial::kAllRemainingProbability);
+
+ // And that winner should ALWAYS win.
+ EXPECT_EQ(winner, trial->group_name());
+}
+
TEST_F(FieldTrialTest, MiddleProbabilities) {
char name[] = " same name";
bool false_event_seen = false;