OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 protected: | 34 protected: |
35 int next_year_; | 35 int next_year_; |
36 int last_year_; | 36 int last_year_; |
37 | 37 |
38 private: | 38 private: |
39 FieldTrialList trial_list_; | 39 FieldTrialList trial_list_; |
40 }; | 40 }; |
41 | 41 |
42 // Test registration, and also check that destructors are called for trials | 42 // Test registration, and also check that destructors are called for trials |
43 // (and that Purify doesn't catch us leaking). | 43 // (and that Valgrind doesn't catch us leaking). |
44 TEST_F(FieldTrialTest, Registration) { | 44 TEST_F(FieldTrialTest, Registration) { |
45 const char* name1 = "name 1 test"; | 45 const char* name1 = "name 1 test"; |
46 const char* name2 = "name 2 test"; | 46 const char* name2 = "name 2 test"; |
47 EXPECT_FALSE(FieldTrialList::Find(name1)); | 47 EXPECT_FALSE(FieldTrialList::Find(name1)); |
48 EXPECT_FALSE(FieldTrialList::Find(name2)); | 48 EXPECT_FALSE(FieldTrialList::Find(name2)); |
49 | 49 |
50 FieldTrial* trial1 = | 50 FieldTrial* trial1 = |
51 new FieldTrial(name1, 10, "default name 1 test", next_year_, 12, 31); | 51 new FieldTrial(name1, 10, "default name 1 test", next_year_, 12, 31); |
52 EXPECT_EQ(FieldTrial::kNotFinalized, trial1->group_); | 52 EXPECT_EQ(FieldTrial::kNotFinalized, trial1->group_); |
53 EXPECT_EQ(name1, trial1->name()); | 53 EXPECT_EQ(name1, trial1->name()); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 TEST_F(FieldTrialTest, DisableAfterInitialization) { | 426 TEST_F(FieldTrialTest, DisableAfterInitialization) { |
427 FieldTrial* trial = | 427 FieldTrial* trial = |
428 new FieldTrial("trial", 100, "default", next_year_, 12, 31); | 428 new FieldTrial("trial", 100, "default", next_year_, 12, 31); |
429 trial->AppendGroup("non_default", 100); | 429 trial->AppendGroup("non_default", 100); |
430 ASSERT_EQ("non_default", trial->group_name()); | 430 ASSERT_EQ("non_default", trial->group_name()); |
431 trial->Disable(); | 431 trial->Disable(); |
432 ASSERT_EQ("default", trial->group_name()); | 432 ASSERT_EQ("default", trial->group_name()); |
433 } | 433 } |
434 | 434 |
435 } // namespace base | 435 } // namespace base |
OLD | NEW |