Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/chrome_elf_init_win.h" | 5 #include "chrome/browser/chrome_elf_init_win.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 TEST_F(ChromeBlacklistTrialTest, AddFinchBlacklistToRegistry) { | 158 TEST_F(ChromeBlacklistTrialTest, AddFinchBlacklistToRegistry) { |
| 159 // Create the field trial with the blacklist enabled group. | 159 // Create the field trial with the blacklist enabled group. |
| 160 base::FieldTrialList field_trial_list( | 160 base::FieldTrialList field_trial_list( |
| 161 new metrics::SHA1EntropyProvider("test")); | 161 new metrics::SHA1EntropyProvider("test")); |
| 162 | 162 |
| 163 scoped_refptr<base::FieldTrial> trial(base::FieldTrialList::CreateFieldTrial( | 163 scoped_refptr<base::FieldTrial> trial(base::FieldTrialList::CreateFieldTrial( |
| 164 kBrowserBlacklistTrialName, kBrowserBlacklistTrialEnabledGroupName)); | 164 kBrowserBlacklistTrialName, kBrowserBlacklistTrialEnabledGroupName)); |
| 165 | 165 |
| 166 // Set up the trial with the desired parameters. | 166 // Set up the trial with the desired parameters. |
| 167 std::map<std::string, std::string> desired_params; | 167 std::map<std::string, std::string> desired_params; |
| 168 desired_params["TestDllName1"] = "TestDll1.dll"; | 168 |
| 169 desired_params["TestDllName2"] = "TestDll2.dll"; | 169 desired_params[blacklist::kRegistryFinchListValueNameStr] = |
| 170 "TestDll1.dll,TestDll2.dll"; | |
| 170 | 171 |
| 171 variations::AssociateVariationParams( | 172 variations::AssociateVariationParams( |
| 172 kBrowserBlacklistTrialName, | 173 kBrowserBlacklistTrialName, |
| 173 kBrowserBlacklistTrialEnabledGroupName, | 174 kBrowserBlacklistTrialEnabledGroupName, |
| 174 desired_params); | 175 desired_params); |
| 175 | 176 |
| 176 // This should add the dlls in those parameters to the registry. | 177 // This should add the dlls in those parameters to the registry. |
| 177 AddFinchBlacklistToRegistry(); | 178 AddFinchBlacklistToRegistry(); |
| 178 | 179 |
| 179 // Check that all the values in desired_params were added to the registry. | 180 // Check that all the dll names in desired_params were added to the registry. |
| 181 std::vector<std::wstring> dlls; | |
| 182 | |
| 180 base::win::RegKey finch_blacklist_registry_key( | 183 base::win::RegKey finch_blacklist_registry_key( |
| 181 HKEY_CURRENT_USER, | 184 HKEY_CURRENT_USER, |
| 182 blacklist::kRegistryFinchListPath, | 185 blacklist::kRegistryFinchListPath, |
| 183 KEY_QUERY_VALUE | KEY_SET_VALUE); | 186 KEY_QUERY_VALUE | KEY_SET_VALUE); |
| 184 | 187 |
| 185 ASSERT_EQ(desired_params.size(), | 188 ASSERT_TRUE(finch_blacklist_registry_key.HasValue( |
| 186 finch_blacklist_registry_key.GetValueCount()); | 189 blacklist::kRegistryFinchListValueName)); |
| 190 ASSERT_EQ(ERROR_SUCCESS, finch_blacklist_registry_key.ReadValues( | |
| 191 blacklist::kRegistryFinchListValueName, &dlls)); | |
| 187 | 192 |
| 188 for (std::map<std::string, std::string>::iterator it = desired_params.begin(); | 193 ASSERT_EQ(2, /* Number of dll names passed in this test. */ dlls.size()); |
| 189 it != desired_params.end(); | 194 EXPECT_TRUE((dlls.at(0)).compare(L"TestDll1.dll") == 0); |
|
robertshield
2016/04/20 05:16:09
How about:
EXPECT_STREQ(L"TestDll.dll", dlls[0].c_
penny
2016/05/28 01:34:22
Done.
| |
| 190 ++it) { | 195 EXPECT_TRUE((dlls.at(1)).compare(L"TestDll2.dll") == 0); |
| 191 std::wstring name = base::UTF8ToWide(it->first); | |
| 192 ASSERT_TRUE(finch_blacklist_registry_key.HasValue(name.c_str())); | |
| 193 } | |
| 194 } | 196 } |
| 195 | 197 |
| 196 } // namespace | 198 } // namespace |
| OLD | NEW |