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

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

Issue 2163803003: [chrome_elf] Removing blacklist finch for dynamic dll changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another clang fix. 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
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"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/test/test_reg_util_win.h" 13 #include "base/test/test_reg_util_win.h"
14 #include "chrome/common/chrome_version.h" 14 #include "chrome/common/chrome_version.h"
15 #include "chrome_elf/chrome_elf_constants.h" 15 #include "chrome_elf/chrome_elf_constants.h"
16 #include "components/variations/entropy_provider.h" 16 #include "components/variations/entropy_provider.h"
17 #include "components/variations/variations_associated_data.h" 17 #include "components/variations/variations_associated_data.h"
18 #include "components/version_info/version_info.h" 18 #include "components/version_info/version_info.h"
19 #include "content/public/test/test_browser_thread_bundle.h" 19 #include "content/public/test/test_browser_thread_bundle.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 namespace { 22 namespace {
23 23
24 const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled";
25
26 class ChromeBlacklistTrialTest : public testing::Test { 24 class ChromeBlacklistTrialTest : public testing::Test {
27 protected: 25 protected:
28 ChromeBlacklistTrialTest() {} 26 ChromeBlacklistTrialTest() {}
29 ~ChromeBlacklistTrialTest() override {} 27 ~ChromeBlacklistTrialTest() override {}
30 28
31 void SetUp() override { 29 void SetUp() override {
32 testing::Test::SetUp(); 30 testing::Test::SetUp();
33 31
34 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); 32 override_manager_.OverrideRegistry(HKEY_CURRENT_USER);
35 33
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 base::UTF8ToUTF16(version_info::GetVersionNumber())); 147 base::UTF8ToUTF16(version_info::GetVersionNumber()));
150 ASSERT_EQ(expected_version, GetBlacklistVersion()); 148 ASSERT_EQ(expected_version, GetBlacklistVersion());
151 149
152 // The counter should be reset. 150 // The counter should be reset.
153 DWORD attempt_count = blacklist::kBeaconMaxAttempts; 151 DWORD attempt_count = blacklist::kBeaconMaxAttempts;
154 blacklist_registry_key_->ReadValueDW(blacklist::kBeaconAttemptCount, 152 blacklist_registry_key_->ReadValueDW(blacklist::kBeaconAttemptCount,
155 &attempt_count); 153 &attempt_count);
156 ASSERT_EQ(static_cast<DWORD>(0), attempt_count); 154 ASSERT_EQ(static_cast<DWORD>(0), attempt_count);
157 } 155 }
158 156
159 TEST_F(ChromeBlacklistTrialTest, AddFinchBlacklistToRegistry) {
160 // Create the field trial with the blacklist enabled group.
161 base::FieldTrialList field_trial_list(
162 new metrics::SHA1EntropyProvider("test"));
163
164 scoped_refptr<base::FieldTrial> trial(base::FieldTrialList::CreateFieldTrial(
165 kBrowserBlacklistTrialName, kBrowserBlacklistTrialEnabledGroupName));
166
167 // Set up the trial with the desired parameters.
168 std::map<std::string, std::string> desired_params;
169
170 desired_params[blacklist::kRegistryFinchListValueNameStr] =
171 "TestDll1.dll,TestDll2.dll";
172
173 variations::AssociateVariationParams(
174 kBrowserBlacklistTrialName,
175 kBrowserBlacklistTrialEnabledGroupName,
176 desired_params);
177
178 // This should add the dlls in those parameters to the registry.
179 AddFinchBlacklistToRegistry();
180
181 // Check that all the dll names in desired_params were added to the registry.
182 std::vector<std::wstring> dlls;
183
184 base::win::RegKey finch_blacklist_registry_key(
185 HKEY_CURRENT_USER,
186 blacklist::kRegistryFinchListPath,
187 KEY_QUERY_VALUE | KEY_SET_VALUE);
188
189 ASSERT_TRUE(finch_blacklist_registry_key.HasValue(
190 blacklist::kRegistryFinchListValueName));
191 ASSERT_EQ(ERROR_SUCCESS, finch_blacklist_registry_key.ReadValues(
192 blacklist::kRegistryFinchListValueName, &dlls));
193
194 ASSERT_EQ((size_t)2,
195 /* Number of dll names passed in this test. */ dlls.size());
196 EXPECT_STREQ(L"TestDll1.dll", dlls[0].c_str());
197 EXPECT_STREQ(L"TestDll2.dll", dlls[1].c_str());
198 }
199
200 } // namespace 157 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698