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

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: Pre-review cleanup. 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
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 // Call RetrieveBlacklistedModules, test dll should not be in the list.
211 std::vector<base::string16> module_names;
212 RetrieveBlacklistedModules(&module_names);
csharp 2014/08/05 21:08:59 Shouldn't this just return an empty list? Could we
robertshield 2014/08/06 16:38:31 Done (also added logging to help identify any non-
213 std::vector<base::string16>::const_iterator module_iter(module_names.begin());
214 for (; module_iter != module_names.end(); ++module_iter) {
215 EXPECT_STRNE(
216 StringToLowerASCII(
217 base::FilePath(*module_iter).BaseName().value()).c_str(),
218 kTestDllName);
219 }
220
221 // Add test dll to blacklist
222 blacklist::AddDllToBlacklist(kTestDllName);
223
224 // Call RetrieveBlacklistedModules, check that the test dll appears in list.
225 module_names.clear();
226 EXPECT_TRUE(RetrieveBlacklistedModules(&module_names));
227 bool found_test_module = false;
csharp 2014/08/05 21:08:59 lines 227-236 can probably be replace by just chec
robertshield 2014/08/06 16:38:32 Done.
228 for (module_iter = module_names.begin(); module_iter != module_names.end();
229 ++module_iter) {
230 if (StringToLowerASCII(
231 base::FilePath(*module_iter).BaseName().value()) == kTestDllName) {
232 found_test_module = true;
233 break;
234 }
235 }
236 EXPECT_TRUE(found_test_module);
237 }
238
198 } // namespace 239 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_elf_init_win.h » ('j') | chrome/browser/chrome_elf_init_win.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698