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..2050e5987f6ed13bef809e79128c843a3ba9b4b8 100644 |
| --- a/chrome/browser/chrome_elf_init_unittest_win.cc |
| +++ b/chrome/browser/chrome_elf_init_unittest_win.cc |
| @@ -14,9 +14,14 @@ |
| #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 |
| +namespace { |
| + |
| +const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled"; |
| + |
| class ChromeBlacklistTrialTest : public testing::Test { |
| protected: |
| ChromeBlacklistTrialTest() {} |
| @@ -76,7 +81,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 +176,46 @@ 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)); |
| + |
| + // 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. |
|
robertshield
2014/05/30 21:07:08
s/dll's/dlls
krstnmnlsn
2014/06/02 14:00:37
Done.
|
| + 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, |
| + 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()) { |
|
robertshield
2014/05/30 21:07:08
minor nit, this form:
for (; it != desired_params
krstnmnlsn
2014/06/02 14:00:37
Done.
|
| + std::wstring name = base::UTF8ToWide(it->first); |
| + const wchar_t* name_cstr = name.c_str(); |
|
robertshield
2014/05/30 21:07:08
why create the name_cstr temporary?
adding |name|
krstnmnlsn
2014/06/02 14:00:37
Done.
|
| + |
| + ASSERT_TRUE(finch_blacklist_registry_key.HasValue(name_cstr)); |
| + ++it; |
| + } |
| +} |
| + |
| +} // namespace |