OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // And that default_group_name should ALWAYS win. | 220 // And that default_group_name should ALWAYS win. |
221 EXPECT_EQ(default_group_name, trial->group_name()); | 221 EXPECT_EQ(default_group_name, trial->group_name()); |
222 } | 222 } |
223 | 223 |
224 TEST_F(FieldTrialTest, HashName) { | 224 TEST_F(FieldTrialTest, HashName) { |
225 // Make sure hashing is stable on all platforms. | 225 // Make sure hashing is stable on all platforms. |
226 struct { | 226 struct { |
227 const char* name; | 227 const char* name; |
228 uint32 hash_value; | 228 uint32 hash_value; |
229 } known_hashes[] = { | 229 } known_hashes[] = { |
230 {"a", 937752454}, | 230 {"a", 937752454u}, |
231 {"1", 723085877}, | 231 {"1", 723085877u}, |
232 {"Trial Name", 2713117220}, | 232 {"Trial Name", 2713117220u}, |
233 {"Group Name", 3201815843}, | 233 {"Group Name", 3201815843u}, |
234 {"My Favorite Experiment", 3722155194}, | 234 {"My Favorite Experiment", 3722155194u}, |
235 {"My Awesome Group Name", 4109503236}, | 235 {"My Awesome Group Name", 4109503236u}, |
236 {"abcdefghijklmonpqrstuvwxyz", 787728696}, | 236 {"abcdefghijklmonpqrstuvwxyz", 787728696u}, |
237 {"0123456789ABCDEF", 348858318} | 237 {"0123456789ABCDEF", 348858318U} |
238 }; | 238 }; |
239 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(known_hashes); ++i) { | 239 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(known_hashes); ++i) { |
240 EXPECT_EQ(known_hashes[i].hash_value, | 240 EXPECT_EQ(known_hashes[i].hash_value, |
241 FieldTrial::HashName(known_hashes[i].name)); | 241 FieldTrial::HashName(known_hashes[i].name)); |
242 } | 242 } |
243 } | 243 } |
244 | 244 |
245 TEST_F(FieldTrialTest, NameGroupIds) { | 245 TEST_F(FieldTrialTest, NameGroupIds) { |
246 std::string no_group("No Group"); | 246 std::string no_group("No Group"); |
247 uint32 no_group_id = FieldTrial::HashName(no_group); | 247 uint32 no_group_id = FieldTrial::HashName(no_group); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 TEST_F(FieldTrialTest, DisableAfterInitialization) { | 496 TEST_F(FieldTrialTest, DisableAfterInitialization) { |
497 FieldTrial* trial = | 497 FieldTrial* trial = |
498 new FieldTrial("trial", 100, "default", next_year_, 12, 31); | 498 new FieldTrial("trial", 100, "default", next_year_, 12, 31); |
499 trial->AppendGroup("non_default", 100); | 499 trial->AppendGroup("non_default", 100); |
500 ASSERT_EQ("non_default", trial->group_name()); | 500 ASSERT_EQ("non_default", trial->group_name()); |
501 trial->Disable(); | 501 trial->Disable(); |
502 ASSERT_EQ("default", trial->group_name()); | 502 ASSERT_EQ("default", trial->group_name()); |
503 } | 503 } |
504 | 504 |
505 } // namespace base | 505 } // namespace base |
OLD | NEW |