Chromium Code Reviews| 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 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1139 TEST(FieldTrialListTest, TestCopyFieldTrialStateToFlags) { | 1139 TEST(FieldTrialListTest, TestCopyFieldTrialStateToFlags) { |
| 1140 base::FieldTrialList field_trial_list( | 1140 base::FieldTrialList field_trial_list( |
| 1141 base::MakeUnique<base::MockEntropyProvider>()); | 1141 base::MakeUnique<base::MockEntropyProvider>()); |
| 1142 base::FieldTrialList::CreateFieldTrial("Trial1", "Group1"); | 1142 base::FieldTrialList::CreateFieldTrial("Trial1", "Group1"); |
| 1143 base::FilePath test_file_path = base::FilePath(FILE_PATH_LITERAL("Program")); | 1143 base::FilePath test_file_path = base::FilePath(FILE_PATH_LITERAL("Program")); |
| 1144 base::CommandLine cmd_line = base::CommandLine(test_file_path); | 1144 base::CommandLine cmd_line = base::CommandLine(test_file_path); |
| 1145 const char field_trial_handle[] = "test-field-trial-handle"; | 1145 const char field_trial_handle[] = "test-field-trial-handle"; |
| 1146 | 1146 |
| 1147 base::FieldTrialList::CopyFieldTrialStateToFlags(field_trial_handle, | 1147 base::FieldTrialList::CopyFieldTrialStateToFlags(field_trial_handle, |
| 1148 &cmd_line); | 1148 &cmd_line); |
| 1149 #if defined(OS_WIN) | |
| 1150 EXPECT_TRUE(cmd_line.HasSwitch(field_trial_handle) || | 1149 EXPECT_TRUE(cmd_line.HasSwitch(field_trial_handle) || |
| 1151 cmd_line.HasSwitch(switches::kForceFieldTrials)); | 1150 cmd_line.HasSwitch(switches::kForceFieldTrials)); |
| 1152 #else | |
| 1153 EXPECT_TRUE(cmd_line.HasSwitch(switches::kForceFieldTrials)); | |
| 1154 #endif | |
| 1155 } | 1151 } |
|
Alexei Svitkine (slow)
2016/11/29 17:38:27
Suggest keeping this test and just make it Windows
lawrencewu
2016/11/29 19:11:01
Done.
| |
| 1156 | 1152 |
| 1157 TEST(FieldTrialListTest, InstantiateAllocator) { | 1153 TEST(FieldTrialListTest, InstantiateAllocator) { |
| 1158 FieldTrialList field_trial_list(nullptr); | 1154 FieldTrialList field_trial_list(nullptr); |
| 1159 FieldTrialList::CreateFieldTrial("Trial1", "Group1"); | 1155 FieldTrialList::CreateFieldTrial("Trial1", "Group1"); |
| 1160 | 1156 |
| 1161 FieldTrialList::InstantiateFieldTrialAllocatorIfNeeded(); | 1157 FieldTrialList::InstantiateFieldTrialAllocatorIfNeeded(); |
| 1162 void* memory = field_trial_list.field_trial_allocator_->shared_memory(); | 1158 void* memory = field_trial_list.field_trial_allocator_->shared_memory(); |
| 1163 size_t used = field_trial_list.field_trial_allocator_->used(); | 1159 size_t used = field_trial_list.field_trial_allocator_->used(); |
| 1164 | 1160 |
| 1165 // Ensure that the function is idempotent. | 1161 // Ensure that the function is idempotent. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1224 std::unique_ptr<base::SharedMemory> shm(new SharedMemory(handle, true)); | 1220 std::unique_ptr<base::SharedMemory> shm(new SharedMemory(handle, true)); |
| 1225 // 4 KiB is enough to hold the trials only created for this test. | 1221 // 4 KiB is enough to hold the trials only created for this test. |
| 1226 shm.get()->Map(4 << 10); | 1222 shm.get()->Map(4 << 10); |
| 1227 FieldTrialList::CreateTrialsFromSharedMemory(std::move(shm)); | 1223 FieldTrialList::CreateTrialsFromSharedMemory(std::move(shm)); |
| 1228 std::string check_string; | 1224 std::string check_string; |
| 1229 FieldTrialList::AllStatesToString(&check_string); | 1225 FieldTrialList::AllStatesToString(&check_string); |
| 1230 ASSERT_EQ(check_string.find("Simulated"), std::string::npos); | 1226 ASSERT_EQ(check_string.find("Simulated"), std::string::npos); |
| 1231 } | 1227 } |
| 1232 | 1228 |
| 1233 } // namespace base | 1229 } // namespace base |
| OLD | NEW |