Chromium Code Reviews| Index: chrome/browser/chrome_elf_init_unittest_win.cc |
| diff --git a/chrome/browser/chrome_elf_init_unittest_win.cc b/chrome/browser/chrome_elf_init_unittest_win.cc |
| index 441f73665707f1f8dbc3bddc08729fb3ef70f91c..334dbe486c9735659643ef882a15cf9e1ca8d5b0 100644 |
| --- a/chrome/browser/chrome_elf_init_unittest_win.cc |
| +++ b/chrome/browser/chrome_elf_init_unittest_win.cc |
| @@ -14,6 +14,7 @@ |
| #include "chrome/common/chrome_version_info.h" |
| #include "chrome_elf/chrome_elf_constants.h" |
| #include "components/variations/entropy_provider.h" |
| +#include "components/variations/variations_associated_data.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "version.h" // NOLINT |
| @@ -76,7 +77,6 @@ TEST_F(ChromeBlacklistTrialTest, DefaultRun) { |
| ASSERT_EQ(version, GetBlacklistVersion()); |
| } |
| - |
| // Ensure that the blacklist is disabled for any users in the |
| // "BlacklistDisabled" finch group. |
| TEST_F(ChromeBlacklistTrialTest, BlacklistDisabledRun) { |
| @@ -172,3 +172,47 @@ TEST_F(ChromeBlacklistTrialTest, VersionChanged) { |
| base::string16 expected_version(base::UTF8ToUTF16(version_info.Version())); |
| ASSERT_EQ(expected_version, GetBlacklistVersion()); |
| } |
| + |
| +TEST_F(ChromeBlacklistTrialTest, AddFinchBlacklistToRegistry) { |
| + // Create the field trial with the blacklist enabled group. |
| + base::FieldTrialList field_trial_list( |
| + new metrics::SHA1EntropyProvider("test")); |
| + |
| + scoped_refptr<base::FieldTrial> trial( |
| + base::FieldTrialList::CreateFieldTrial( |
| + kBrowserBlacklistTrialName, kBrowserBlacklistTrialEnabledGroupName)); |
|
csharp
2014/05/29 20:51:52
Since this is only used in this file (I think), ju
krstnmnlsn
2014/05/30 14:09:13
Done.
|
| + |
| + // Set up the trial with the desired parameters. |
| + std::map<std::string, std::string> desired_params; |
| + desired_params["TestDllName1"] = "TestDll1.dll"; |
| + desired_params["TestDllName2"] = "TestDll2.dll"; |
| + |
| + chrome_variations::AssociateVariationParams(kBrowserBlacklistTrialName, |
| + kBrowserBlacklistTrialEnabledGroupName, desired_params); |
| + |
| + // This should add the dll's in those parameters to the registry. |
| + AddFinchBlacklistToRegistry(); |
| + |
| + // Check that the set of values in the registry is the same |
| + // as those in desired_params by comparing size and containment one way. |
| + base::win::RegKey finch_blacklist_registry_key(HKEY_CURRENT_USER, |
| + blacklist::kRegistryFinchListPath, |
|
csharp
2014/05/29 20:51:52
nit: These lines need to line up H, or all the arg
krstnmnlsn
2014/05/30 14:09:13
Done.
|
| + KEY_QUERY_VALUE | KEY_SET_VALUE); |
| + |
| + ASSERT_EQ(desired_params.size(), |
| + finch_blacklist_registry_key.GetValueCount()); |
| + |
| + std::map<std::string, std::string>::iterator it = desired_params.begin(); |
| + while (it != desired_params.end()) { |
| + const char* name_str = (it->first).c_str(); |
|
csharp
2014/05/29 20:51:52
Same comment here about using wstring
krstnmnlsn
2014/05/30 14:09:13
Done.
|
| + size_t name_len = MultiByteToWideChar(CP_UTF8, 0, name_str, -1, NULL, 0); |
| + wchar_t* name_wstr = new wchar_t[name_len]; |
| + MultiByteToWideChar(CP_UTF8, 0, name_str, -1, name_wstr, name_len); |
| + |
| + LONG ret = ::RegQueryValueEx(HKEY_CURRENT_USER, name_wstr, |
| + NULL, NULL, NULL, NULL); |
| + |
| + ASSERT_TRUE(finch_blacklist_registry_key.HasValue(name_wstr)); |
| + ++it; |
| + } |
| +} |