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

Side by Side Diff: base/field_trial_unittest.cc

Issue 3119022: Header cleanup in base.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/field_trial.h" 7 #include "base/field_trial.h"
8 8
9 #include "base/string_util.h" 9 #include "base/stringprintf.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 class FieldTrialTest : public testing::Test { 12 class FieldTrialTest : public testing::Test {
13 public: 13 public:
14 FieldTrialTest() : trial_list_() { } 14 FieldTrialTest() : trial_list_() { }
15 15
16 private: 16 private:
17 FieldTrialList trial_list_; 17 FieldTrialList trial_list_;
18 }; 18 };
19 19
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 } 70 }
71 71
72 TEST_F(FieldTrialTest, RemainingProbability) { 72 TEST_F(FieldTrialTest, RemainingProbability) {
73 // First create a test that hasn't had a winner yet. 73 // First create a test that hasn't had a winner yet.
74 const std::string winner = "Winner"; 74 const std::string winner = "Winner";
75 const std::string loser = "Loser"; 75 const std::string loser = "Loser";
76 scoped_refptr<FieldTrial> trial; 76 scoped_refptr<FieldTrial> trial;
77 int counter = 0; 77 int counter = 0;
78 do { 78 do {
79 std::string name = StringPrintf("trial%d", ++counter); 79 std::string name = base::StringPrintf("trial%d", ++counter);
80 trial = new FieldTrial(name, 10); 80 trial = new FieldTrial(name, 10);
81 trial->AppendGroup(loser, 5); // 50% chance of not being chosen. 81 trial->AppendGroup(loser, 5); // 50% chance of not being chosen.
82 } while (trial->group() != FieldTrial::kNotParticipating); 82 } while (trial->group() != FieldTrial::kNotParticipating);
83 83
84 // Now add a winner with all remaining probability. 84 // Now add a winner with all remaining probability.
85 trial->AppendGroup(winner, FieldTrial::kAllRemainingProbability); 85 trial->AppendGroup(winner, FieldTrial::kAllRemainingProbability);
86 86
87 // And that winner should ALWAYS win. 87 // And that winner should ALWAYS win.
88 EXPECT_EQ(winner, trial->group_name()); 88 EXPECT_EQ(winner, trial->group_name());
89 } 89 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // But it is an error to try to change to a different winner. 196 // But it is an error to try to change to a different winner.
197 EXPECT_FALSE(FieldTrialList::StringAugmentsState("Some name/Loser/")); 197 EXPECT_FALSE(FieldTrialList::StringAugmentsState("Some name/Loser/"));
198 } 198 }
199 199
200 TEST_F(FieldTrialTest, MakeName) { 200 TEST_F(FieldTrialTest, MakeName) {
201 FieldTrial* trial = new FieldTrial("Field Trial", 10); 201 FieldTrial* trial = new FieldTrial("Field Trial", 10);
202 trial->AppendGroup("Winner", 10); 202 trial->AppendGroup("Winner", 10);
203 EXPECT_EQ("Histogram_Winner", 203 EXPECT_EQ("Histogram_Winner",
204 FieldTrial::MakeName("Histogram", "Field Trial")); 204 FieldTrial::MakeName("Histogram", "Field Trial"));
205 } 205 }
OLDNEW
« no previous file with comments | « base/field_trial.cc ('k') | base/file_path_unittest.cc » ('j') | base/logging.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698