Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(749)

Side by Side Diff: base/metrics/field_trial_unittest.cc

Issue 2453933004: Fix deadlock issue with AllStatesToString (Closed)
Patch Set: fix nit Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/metrics/field_trial.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 base::FieldTrial::ONE_TIME_RANDOMIZED, NULL), 1135 base::FieldTrial::ONE_TIME_RANDOMIZED, NULL),
1136 ""); 1136 "");
1137 } 1137 }
1138 1138
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 1146
1146 base::FieldTrialList::CopyFieldTrialStateToFlags("field-trial-handle", 1147 base::FieldTrialList::CopyFieldTrialStateToFlags(field_trial_handle,
1147 &cmd_line); 1148 &cmd_line);
1148 1149 #if defined(OS_WIN)
1150 EXPECT_TRUE(cmd_line.HasSwitch(field_trial_handle) ||
1151 cmd_line.HasSwitch(switches::kForceFieldTrials));
1152 #else
1149 EXPECT_TRUE(cmd_line.HasSwitch(switches::kForceFieldTrials)); 1153 EXPECT_TRUE(cmd_line.HasSwitch(switches::kForceFieldTrials));
1154 #endif
1150 } 1155 }
1151 1156
1152 TEST(FieldTrialListTest, InstantiateAllocator) { 1157 TEST(FieldTrialListTest, InstantiateAllocator) {
1153 FieldTrialList field_trial_list(nullptr); 1158 FieldTrialList field_trial_list(nullptr);
1154 FieldTrialList::CreateFieldTrial("Trial1", "Group1"); 1159 FieldTrialList::CreateFieldTrial("Trial1", "Group1");
1155 1160
1156 FieldTrialList::InstantiateFieldTrialAllocatorIfNeeded(); 1161 FieldTrialList::InstantiateFieldTrialAllocatorIfNeeded();
1157 void* memory = field_trial_list.field_trial_allocator_->shared_memory(); 1162 void* memory = field_trial_list.field_trial_allocator_->shared_memory();
1158 size_t used = field_trial_list.field_trial_allocator_->used(); 1163 size_t used = field_trial_list.field_trial_allocator_->used();
1159 1164
(...skipping 23 matching lines...) Expand all
1183 FieldTrialList field_trial_list2(nullptr); 1188 FieldTrialList field_trial_list2(nullptr);
1184 std::unique_ptr<base::SharedMemory> shm(new SharedMemory(handle, true)); 1189 std::unique_ptr<base::SharedMemory> shm(new SharedMemory(handle, true));
1185 shm.get()->Map(4 << 10); // Hardcoded, equal to kFieldTrialAllocationSize. 1190 shm.get()->Map(4 << 10); // Hardcoded, equal to kFieldTrialAllocationSize.
1186 FieldTrialList::CreateTrialsFromSharedMemory(std::move(shm)); 1191 FieldTrialList::CreateTrialsFromSharedMemory(std::move(shm));
1187 std::string check_string; 1192 std::string check_string;
1188 FieldTrialList::AllStatesToString(&check_string); 1193 FieldTrialList::AllStatesToString(&check_string);
1189 EXPECT_EQ(save_string, check_string); 1194 EXPECT_EQ(save_string, check_string);
1190 } 1195 }
1191 1196
1192 } // namespace base 1197 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/field_trial.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698