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

Side by Side Diff: chrome/browser/chrome_elf_init_unittest_win.cc

Issue 444543002: Add export to query for blacklisted-ness. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing include. Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chrome_elf_init_win.h » ('j') | chrome_elf/blacklist/blacklist.cc » ('J')
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/chrome_elf_init_win.h" 5 #include "chrome/browser/chrome_elf_init_win.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/files/file_path.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
11 #include "base/path_service.h"
12 #include "base/scoped_native_library.h"
10 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
11 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
13 #include "base/test/test_reg_util_win.h" 16 #include "base/test/test_reg_util_win.h"
14 #include "chrome/common/chrome_version_info.h" 17 #include "chrome/common/chrome_version_info.h"
18 #include "chrome_elf/blacklist/blacklist.h"
15 #include "chrome_elf/chrome_elf_constants.h" 19 #include "chrome_elf/chrome_elf_constants.h"
16 #include "components/variations/entropy_provider.h" 20 #include "components/variations/entropy_provider.h"
17 #include "components/variations/variations_associated_data.h" 21 #include "components/variations/variations_associated_data.h"
18 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
19 #include "version.h" // NOLINT 23 #include "version.h" // NOLINT
20 24
21 namespace { 25 namespace {
22 26
23 const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled"; 27 const char kBrowserBlacklistTrialEnabledGroupName[] = "Enabled";
28 const wchar_t kTestDllName[] = L"blacklist_test_dll_1.dll";
24 29
25 class ChromeBlacklistTrialTest : public testing::Test { 30 class ChromeBlacklistTrialTest : public testing::Test {
26 protected: 31 protected:
27 ChromeBlacklistTrialTest() {} 32 ChromeBlacklistTrialTest() {}
28 virtual ~ChromeBlacklistTrialTest() {} 33 virtual ~ChromeBlacklistTrialTest() {}
29 34
30 virtual void SetUp() OVERRIDE { 35 virtual void SetUp() OVERRIDE {
31 testing::Test::SetUp(); 36 testing::Test::SetUp();
32 37
33 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, 38 override_manager_.OverrideRegistry(HKEY_CURRENT_USER,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 finch_blacklist_registry_key.GetValueCount()); 193 finch_blacklist_registry_key.GetValueCount());
189 194
190 for (std::map<std::string, std::string>::iterator it = desired_params.begin(); 195 for (std::map<std::string, std::string>::iterator it = desired_params.begin();
191 it != desired_params.end(); 196 it != desired_params.end();
192 ++it) { 197 ++it) {
193 std::wstring name = base::UTF8ToWide(it->first); 198 std::wstring name = base::UTF8ToWide(it->first);
194 ASSERT_TRUE(finch_blacklist_registry_key.HasValue(name.c_str())); 199 ASSERT_TRUE(finch_blacklist_registry_key.HasValue(name.c_str()));
195 } 200 }
196 } 201 }
197 202
203 TEST_F(ChromeBlacklistTrialTest, TestBlacklistBypass) {
204 base::FilePath current_dir;
205 ASSERT_TRUE(PathService::Get(base::DIR_EXE, &current_dir));
206
207 // Load test dll.
208 base::ScopedNativeLibrary dll1(current_dir.Append(kTestDllName));
209
210 // No blacklisted dll should be found.
211 std::vector<base::string16> module_names;
212 EXPECT_TRUE(GetLoadedBlacklistedModules(&module_names));
213 EXPECT_TRUE(module_names.empty());
214 // For posterity, print any that are.
215 std::vector<base::string16>::const_iterator module_iter(module_names.begin());
216 for (; module_iter != module_names.end(); ++module_iter) {
217 LOG(ERROR) << "Found blacklisted module: " << *module_iter;
218 }
219
220 // Add test dll to blacklist
221 blacklist::AddDllToBlacklist(kTestDllName);
222
223 // Check that the test dll appears in list.
224 module_names.clear();
225 EXPECT_TRUE(GetLoadedBlacklistedModules(&module_names));
226 ASSERT_EQ(1, module_names.size());
227 EXPECT_STREQ(kTestDllName,
228 StringToLowerASCII(
229 base::FilePath(module_names[0]).BaseName().value()).c_str());
230 }
231
198 } // namespace 232 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_elf_init_win.h » ('j') | chrome_elf/blacklist/blacklist.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698