OLD | NEW |
1 // Copyright (c) 2012 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 #include "base/metrics/field_trial.h" | 5 #include "base/metrics/field_trial.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/build_time.h" | 10 #include "base/build_time.h" |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 } | 1137 } |
1138 | 1138 |
1139 #if defined(OS_WIN) | 1139 #if defined(OS_WIN) |
1140 TEST(FieldTrialListTest, TestCopyFieldTrialStateToFlags) { | 1140 TEST(FieldTrialListTest, TestCopyFieldTrialStateToFlags) { |
1141 base::FieldTrialList field_trial_list( | 1141 base::FieldTrialList field_trial_list( |
1142 base::MakeUnique<base::MockEntropyProvider>()); | 1142 base::MakeUnique<base::MockEntropyProvider>()); |
1143 base::FieldTrialList::CreateFieldTrial("Trial1", "Group1"); | 1143 base::FieldTrialList::CreateFieldTrial("Trial1", "Group1"); |
1144 base::FilePath test_file_path = base::FilePath(FILE_PATH_LITERAL("Program")); | 1144 base::FilePath test_file_path = base::FilePath(FILE_PATH_LITERAL("Program")); |
1145 base::CommandLine cmd_line = base::CommandLine(test_file_path); | 1145 base::CommandLine cmd_line = base::CommandLine(test_file_path); |
1146 const char field_trial_handle[] = "test-field-trial-handle"; | 1146 const char field_trial_handle[] = "test-field-trial-handle"; |
| 1147 const char enable_features_switch[] = "test-enable-features"; |
| 1148 const char disable_features_switch[] = "test-disable-features"; |
1147 | 1149 |
1148 base::FieldTrialList::CopyFieldTrialStateToFlags(field_trial_handle, | 1150 base::FieldTrialList::CopyFieldTrialStateToFlags( |
1149 &cmd_line); | 1151 field_trial_handle, enable_features_switch, disable_features_switch, |
| 1152 &cmd_line); |
1150 EXPECT_TRUE(cmd_line.HasSwitch(field_trial_handle) || | 1153 EXPECT_TRUE(cmd_line.HasSwitch(field_trial_handle) || |
1151 cmd_line.HasSwitch(switches::kForceFieldTrials)); | 1154 cmd_line.HasSwitch(switches::kForceFieldTrials)); |
1152 } | 1155 } |
1153 #endif | 1156 #endif |
1154 | 1157 |
1155 TEST(FieldTrialListTest, InstantiateAllocator) { | 1158 TEST(FieldTrialListTest, InstantiateAllocator) { |
1156 FieldTrialList field_trial_list(nullptr); | 1159 FieldTrialList field_trial_list(nullptr); |
1157 FieldTrialList::CreateFieldTrial("Trial1", "Group1"); | 1160 FieldTrialList::CreateFieldTrial("Trial1", "Group1"); |
1158 | 1161 |
1159 FieldTrialList::InstantiateFieldTrialAllocatorIfNeeded(); | 1162 FieldTrialList::InstantiateFieldTrialAllocatorIfNeeded(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 std::unique_ptr<base::SharedMemory> shm(new SharedMemory(handle, true)); | 1225 std::unique_ptr<base::SharedMemory> shm(new SharedMemory(handle, true)); |
1223 // 4 KiB is enough to hold the trials only created for this test. | 1226 // 4 KiB is enough to hold the trials only created for this test. |
1224 shm.get()->Map(4 << 10); | 1227 shm.get()->Map(4 << 10); |
1225 FieldTrialList::CreateTrialsFromSharedMemory(std::move(shm)); | 1228 FieldTrialList::CreateTrialsFromSharedMemory(std::move(shm)); |
1226 std::string check_string; | 1229 std::string check_string; |
1227 FieldTrialList::AllStatesToString(&check_string); | 1230 FieldTrialList::AllStatesToString(&check_string); |
1228 ASSERT_EQ(check_string.find("Simulated"), std::string::npos); | 1231 ASSERT_EQ(check_string.find("Simulated"), std::string::npos); |
1229 } | 1232 } |
1230 | 1233 |
1231 } // namespace base | 1234 } // namespace base |
OLD | NEW |