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

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

Issue 2453933004: Fix deadlock issue with AllStatesToString (Closed)
Patch Set: turn flag back off 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
« base/metrics/field_trial.cc ('K') | « 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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 1145
1146 base::FieldTrialList::CopyFieldTrialStateToFlags("field-trial-handle", 1146 base::FieldTrialList::CopyFieldTrialStateToFlags("field-trial-handle",
1147 &cmd_line); 1147 &cmd_line);
1148 1148 #if defined(OS_WIN)
1149 EXPECT_TRUE(cmd_line.HasSwitch("field-trial-handle") ||
Alexei Svitkine (slow) 2016/10/28 18:57:34 Please reference the flag via it's switches:: cons
lawrencewu 2016/10/31 18:59:25 The flag is in content_switches.cc so I don't thin
Alexei Svitkine (slow) 2016/10/31 19:01:40 Ah, I see - you're specifying it manually on line
lawrencewu 2016/10/31 21:09:09 Done.
1150 cmd_line.HasSwitch(switches::kForceFieldTrials));
1151 #else
1149 EXPECT_TRUE(cmd_line.HasSwitch(switches::kForceFieldTrials)); 1152 EXPECT_TRUE(cmd_line.HasSwitch(switches::kForceFieldTrials));
1153 #endif
1150 } 1154 }
1151 1155
1152 TEST(FieldTrialListTest, InstantiateAllocator) { 1156 TEST(FieldTrialListTest, InstantiateAllocator) {
1153 FieldTrialList field_trial_list(nullptr); 1157 FieldTrialList field_trial_list(nullptr);
1154 FieldTrialList::CreateFieldTrial("Trial1", "Group1"); 1158 FieldTrialList::CreateFieldTrial("Trial1", "Group1");
1155 1159
1156 FieldTrialList::InstantiateFieldTrialAllocatorIfNeeded(); 1160 FieldTrialList::InstantiateFieldTrialAllocatorIfNeeded();
1157 void* memory = field_trial_list.field_trial_allocator_->shared_memory(); 1161 void* memory = field_trial_list.field_trial_allocator_->shared_memory();
1158 size_t used = field_trial_list.field_trial_allocator_->used(); 1162 size_t used = field_trial_list.field_trial_allocator_->used();
1159 1163
(...skipping 23 matching lines...) Expand all
1183 FieldTrialList field_trial_list2(nullptr); 1187 FieldTrialList field_trial_list2(nullptr);
1184 std::unique_ptr<base::SharedMemory> shm(new SharedMemory(handle, true)); 1188 std::unique_ptr<base::SharedMemory> shm(new SharedMemory(handle, true));
1185 shm.get()->Map(4 << 10); // Hardcoded, equal to kFieldTrialAllocationSize. 1189 shm.get()->Map(4 << 10); // Hardcoded, equal to kFieldTrialAllocationSize.
1186 FieldTrialList::CreateTrialsFromSharedMemory(std::move(shm)); 1190 FieldTrialList::CreateTrialsFromSharedMemory(std::move(shm));
1187 std::string check_string; 1191 std::string check_string;
1188 FieldTrialList::AllStatesToString(&check_string); 1192 FieldTrialList::AllStatesToString(&check_string);
1189 EXPECT_EQ(save_string, check_string); 1193 EXPECT_EQ(save_string, check_string);
1190 } 1194 }
1191 1195
1192 } // namespace base 1196 } // namespace base
OLDNEW
« base/metrics/field_trial.cc ('K') | « base/metrics/field_trial.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698