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

Side by Side Diff: chrome/browser/win/chrome_elf_init_unittest.cc

Issue 1841573002: [Chrome ELF] New NT registry API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: PRESUBMIT to allow chrome_elf directory files to use wstring. Created 4 years, 5 months 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 | « chrome/browser/win/chrome_elf_init.cc ('k') | chrome/chrome_installer.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/win/chrome_elf_init.h" 5 #include "chrome/browser/win/chrome_elf_init.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 TEST_F(ChromeBlacklistTrialTest, AddFinchBlacklistToRegistry) { 159 TEST_F(ChromeBlacklistTrialTest, AddFinchBlacklistToRegistry) {
160 // Create the field trial with the blacklist enabled group. 160 // Create the field trial with the blacklist enabled group.
161 base::FieldTrialList field_trial_list( 161 base::FieldTrialList field_trial_list(
162 new metrics::SHA1EntropyProvider("test")); 162 new metrics::SHA1EntropyProvider("test"));
163 163
164 scoped_refptr<base::FieldTrial> trial(base::FieldTrialList::CreateFieldTrial( 164 scoped_refptr<base::FieldTrial> trial(base::FieldTrialList::CreateFieldTrial(
165 kBrowserBlacklistTrialName, kBrowserBlacklistTrialEnabledGroupName)); 165 kBrowserBlacklistTrialName, kBrowserBlacklistTrialEnabledGroupName));
166 166
167 // Set up the trial with the desired parameters. 167 // Set up the trial with the desired parameters.
168 std::map<std::string, std::string> desired_params; 168 std::map<std::string, std::string> desired_params;
169 desired_params["TestDllName1"] = "TestDll1.dll"; 169
170 desired_params["TestDllName2"] = "TestDll2.dll"; 170 desired_params[blacklist::kRegistryFinchListValueNameStr] =
171 "TestDll1.dll,TestDll2.dll";
171 172
172 variations::AssociateVariationParams( 173 variations::AssociateVariationParams(
173 kBrowserBlacklistTrialName, 174 kBrowserBlacklistTrialName,
174 kBrowserBlacklistTrialEnabledGroupName, 175 kBrowserBlacklistTrialEnabledGroupName,
175 desired_params); 176 desired_params);
176 177
177 // This should add the dlls in those parameters to the registry. 178 // This should add the dlls in those parameters to the registry.
178 AddFinchBlacklistToRegistry(); 179 AddFinchBlacklistToRegistry();
179 180
180 // Check that all the values in desired_params were added to the registry. 181 // Check that all the dll names in desired_params were added to the registry.
182 std::vector<std::wstring> dlls;
183
181 base::win::RegKey finch_blacklist_registry_key( 184 base::win::RegKey finch_blacklist_registry_key(
182 HKEY_CURRENT_USER, 185 HKEY_CURRENT_USER,
183 blacklist::kRegistryFinchListPath, 186 blacklist::kRegistryFinchListPath,
184 KEY_QUERY_VALUE | KEY_SET_VALUE); 187 KEY_QUERY_VALUE | KEY_SET_VALUE);
185 188
186 ASSERT_EQ(desired_params.size(), 189 ASSERT_TRUE(finch_blacklist_registry_key.HasValue(
187 finch_blacklist_registry_key.GetValueCount()); 190 blacklist::kRegistryFinchListValueName));
191 ASSERT_EQ(ERROR_SUCCESS, finch_blacklist_registry_key.ReadValues(
192 blacklist::kRegistryFinchListValueName, &dlls));
188 193
189 for (std::map<std::string, std::string>::iterator it = desired_params.begin(); 194 ASSERT_EQ((size_t)2,
190 it != desired_params.end(); 195 /* Number of dll names passed in this test. */ dlls.size());
191 ++it) { 196 EXPECT_STREQ(L"TestDll1.dll", dlls[0].c_str());
192 std::wstring name = base::UTF8ToWide(it->first); 197 EXPECT_STREQ(L"TestDll2.dll", dlls[1].c_str());
193 ASSERT_TRUE(finch_blacklist_registry_key.HasValue(name.c_str()));
194 }
195 } 198 }
196 199
197 } // namespace 200 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/win/chrome_elf_init.cc ('k') | chrome/chrome_installer.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698