OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
13 #include "base/i18n/case_conversion.h" | 13 #include "base/i18n/case_conversion.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/scoped_native_library.h" | 16 #include "base/scoped_native_library.h" |
17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "base/test/test_reg_util_win.h" | 20 #include "base/test/test_reg_util_win.h" |
21 #include "base/win/registry.h" | 21 #include "base/win/registry.h" |
22 #include "chrome/common/chrome_version.h" | 22 #include "chrome/common/chrome_version.h" |
| 23 #include "chrome/install_static/install_util.h" |
23 #include "chrome_elf/blacklist/blacklist.h" | 24 #include "chrome_elf/blacklist/blacklist.h" |
24 #include "chrome_elf/chrome_elf_constants.h" | 25 #include "chrome_elf/chrome_elf_constants.h" |
25 #include "chrome_elf/nt_registry/nt_registry.h" | 26 #include "chrome_elf/nt_registry/nt_registry.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 | 28 |
28 const wchar_t kTestDllName1[] = L"blacklist_test_dll_1.dll"; | 29 const wchar_t kTestDllName1[] = L"blacklist_test_dll_1.dll"; |
29 const wchar_t kTestDllName2[] = L"blacklist_test_dll_2.dll"; | 30 const wchar_t kTestDllName2[] = L"blacklist_test_dll_2.dll"; |
30 const wchar_t kTestDllName3[] = L"blacklist_test_dll_3.dll"; | 31 const wchar_t kTestDllName3[] = L"blacklist_test_dll_3.dll"; |
31 | 32 |
32 const wchar_t kDll2Beacon[] = L"{F70A0100-2889-4629-9B44-610FE5C73231}"; | 33 const wchar_t kDll2Beacon[] = L"{F70A0100-2889-4629-9B44-610FE5C73231}"; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 return; | 185 return; |
185 | 186 |
186 // We have to call this exported function every time this test setup runs. | 187 // We have to call this exported function every time this test setup runs. |
187 // If the tests are running in single process mode, the test DLL does not | 188 // If the tests are running in single process mode, the test DLL does not |
188 // get reloaded everytime - but we need to make sure it updates | 189 // get reloaded everytime - but we need to make sure it updates |
189 // appropriately. | 190 // appropriately. |
190 InitTestDll(); | 191 InitTestDll(); |
191 | 192 |
192 blacklist_registry_key_.reset( | 193 blacklist_registry_key_.reset( |
193 new base::win::RegKey(HKEY_CURRENT_USER, | 194 new base::win::RegKey(HKEY_CURRENT_USER, |
194 blacklist::kRegistryBeaconPath, | 195 install_static::GetRegistryPath() |
| 196 .append(blacklist::kRegistryBeaconKeyName) |
| 197 .c_str(), |
195 KEY_QUERY_VALUE | KEY_SET_VALUE)); | 198 KEY_QUERY_VALUE | KEY_SET_VALUE)); |
196 | 199 |
197 // Find out how many dlls were blocked before the test starts. | 200 // Find out how many dlls were blocked before the test starts. |
198 TestDll_SuccessfullyBlocked(NULL, &num_initially_blocked_); | 201 TestDll_SuccessfullyBlocked(NULL, &num_initially_blocked_); |
199 } | 202 } |
200 | 203 |
201 void TearDown() override { | 204 void TearDown() override { |
202 TestDll_RemoveDllFromBlacklist(kTestDllName1); | 205 TestDll_RemoveDllFromBlacklist(kTestDllName1); |
203 TestDll_RemoveDllFromBlacklist(kTestDllName2); | 206 TestDll_RemoveDllFromBlacklist(kTestDllName2); |
204 TestDll_RemoveDllFromBlacklist(kTestDllName3); | 207 TestDll_RemoveDllFromBlacklist(kTestDllName3); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 &blacklist_state); | 383 &blacklist_state); |
381 EXPECT_EQ(blacklist_state, blacklist::BLACKLIST_SETUP_RUNNING); | 384 EXPECT_EQ(blacklist_state, blacklist::BLACKLIST_SETUP_RUNNING); |
382 | 385 |
383 DWORD attempt_count = blacklist::kBeaconMaxAttempts; | 386 DWORD attempt_count = blacklist::kBeaconMaxAttempts; |
384 blacklist_registry_key_->ReadValueDW(blacklist::kBeaconAttemptCount, | 387 blacklist_registry_key_->ReadValueDW(blacklist::kBeaconAttemptCount, |
385 &attempt_count); | 388 &attempt_count); |
386 EXPECT_EQ(static_cast<DWORD>(0), attempt_count); | 389 EXPECT_EQ(static_cast<DWORD>(0), attempt_count); |
387 } | 390 } |
388 | 391 |
389 } // namespace | 392 } // namespace |
OLD | NEW |