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

Side by Side Diff: base/metrics/field_trial_unittest.cc

Issue 6213001: disable field trials if the build is 30 days or older (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« base/metrics/field_trial.cc ('K') | « base/metrics/field_trial.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Test of FieldTrial class 5 // Test of FieldTrial class
6 6
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 8
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 winner_index = might_win; 153 winner_index = might_win;
154 StringAppendF(&winner_name, "%d", might_win); 154 StringAppendF(&winner_name, "%d", might_win);
155 EXPECT_EQ(winner_name, trial->group_name()); 155 EXPECT_EQ(winner_name, trial->group_name());
156 } 156 }
157 } 157 }
158 EXPECT_GE(winner_index, 0); 158 EXPECT_GE(winner_index, 0);
159 EXPECT_EQ(trial->group(), winner_index); 159 EXPECT_EQ(trial->group(), winner_index);
160 EXPECT_EQ(trial->group_name(), winner_name); 160 EXPECT_EQ(trial->group_name(), winner_name);
161 } 161 }
162 162
163 TEST_F(FieldTrialTest, DisableProbability) {
164 // First create a test that hasn't had a winner yet.
165 const std::string winner = "Winner";
166 const std::string loser = "Loser";
167 scoped_refptr<FieldTrial> trial;
168 std::string name = StringPrintf("trial");
169 trial = new FieldTrial(name, 100000);
170 trial->SetDurationAfterWhichDisableFieldTrials(base::TimeDelta::FromDays(-1));
171 trial->AppendGroup(loser, 99999); // 99.999% chance of being chosen.
jar (doing other things) 2011/01/09 07:00:04 This seems pretty good.... we may as well make it
rtenneti 2011/01/09 23:16:42 Done.
172 // Now add a winner with all remaining probability.
173 trial->AppendGroup(winner, FieldTrial::kAllRemainingProbability);
174
175 // And that winner should ALWAYS win.
176 EXPECT_EQ(winner, trial->group_name());
177 }
178
163 TEST_F(FieldTrialTest, Save) { 179 TEST_F(FieldTrialTest, Save) {
164 std::string save_string; 180 std::string save_string;
165 181
166 FieldTrial* trial = new FieldTrial("Some name", 10); 182 FieldTrial* trial = new FieldTrial("Some name", 10);
167 // There is no winner yet, so no textual group name is associated with trial. 183 // There is no winner yet, so no textual group name is associated with trial.
168 EXPECT_EQ("", trial->group_name()); 184 EXPECT_EQ("", trial->group_name());
169 FieldTrialList::StatesToString(&save_string); 185 FieldTrialList::StatesToString(&save_string);
170 EXPECT_EQ("", save_string); 186 EXPECT_EQ("", save_string);
171 save_string.clear(); 187 save_string.clear();
172 188
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 240 }
225 241
226 TEST_F(FieldTrialTest, MakeName) { 242 TEST_F(FieldTrialTest, MakeName) {
227 FieldTrial* trial = new FieldTrial("Field Trial", 10); 243 FieldTrial* trial = new FieldTrial("Field Trial", 10);
228 trial->AppendGroup("Winner", 10); 244 trial->AppendGroup("Winner", 10);
229 EXPECT_EQ("Histogram_Winner", 245 EXPECT_EQ("Histogram_Winner",
230 FieldTrial::MakeName("Histogram", "Field Trial")); 246 FieldTrial::MakeName("Histogram", "Field Trial"));
231 } 247 }
232 248
233 } // namespace base 249 } // namespace base
OLDNEW
« base/metrics/field_trial.cc ('K') | « base/metrics/field_trial.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698