OLD | NEW |
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/string_util.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 Loading... |
153 // Create a second trial and winning group. | 153 // Create a second trial and winning group. |
154 FieldTrial* trial2 = new FieldTrial("xxx", 10); | 154 FieldTrial* trial2 = new FieldTrial("xxx", 10); |
155 trial2->AppendGroup("yyyy", 10); | 155 trial2->AppendGroup("yyyy", 10); |
156 | 156 |
157 FieldTrialList::StatesToString(&save_string); | 157 FieldTrialList::StatesToString(&save_string); |
158 // We assume names are alphabetized... though this is not critical. | 158 // We assume names are alphabetized... though this is not critical. |
159 EXPECT_EQ(save_string, "Some name/Winner/xxx/yyyy/"); | 159 EXPECT_EQ(save_string, "Some name/Winner/xxx/yyyy/"); |
160 } | 160 } |
161 | 161 |
162 TEST_F(FieldTrialTest, Restore) { | 162 TEST_F(FieldTrialTest, Restore) { |
163 EXPECT_TRUE(NULL == FieldTrialList::Find("Some_name")); | 163 EXPECT_EQ(NULL, FieldTrialList::Find("Some_name")); |
164 EXPECT_TRUE(NULL == FieldTrialList::Find("xxx")); | 164 EXPECT_EQ(NULL, FieldTrialList::Find("xxx")); |
165 | 165 |
166 FieldTrialList::StringAugmentsState("Some_name/Winner/xxx/yyyy/"); | 166 FieldTrialList::StringAugmentsState("Some_name/Winner/xxx/yyyy/"); |
167 | 167 |
168 FieldTrial* trial = FieldTrialList::Find("Some_name"); | 168 FieldTrial* trial = FieldTrialList::Find("Some_name"); |
169 ASSERT_NE(static_cast<FieldTrial*>(NULL), trial); | 169 ASSERT_NE(static_cast<FieldTrial*>(NULL), trial); |
170 EXPECT_EQ(trial->group_name(), "Winner"); | 170 EXPECT_EQ(trial->group_name(), "Winner"); |
171 EXPECT_EQ(trial->name(), "Some_name"); | 171 EXPECT_EQ(trial->name(), "Some_name"); |
172 | 172 |
173 trial = FieldTrialList::Find("xxx"); | 173 trial = FieldTrialList::Find("xxx"); |
174 ASSERT_NE(static_cast<FieldTrial*>(NULL), trial); | 174 ASSERT_NE(static_cast<FieldTrial*>(NULL), trial); |
(...skipping 14 matching lines...) Expand all Loading... |
189 std::string save_string; | 189 std::string save_string; |
190 FieldTrialList::StatesToString(&save_string); | 190 FieldTrialList::StatesToString(&save_string); |
191 EXPECT_EQ("Some name/Winner/", save_string); | 191 EXPECT_EQ("Some name/Winner/", save_string); |
192 | 192 |
193 // It is OK if we redundantly specify a winner. | 193 // It is OK if we redundantly specify a winner. |
194 EXPECT_TRUE(FieldTrialList::StringAugmentsState(save_string)); | 194 EXPECT_TRUE(FieldTrialList::StringAugmentsState(save_string)); |
195 | 195 |
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 } |
OLD | NEW |