OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/installer/setup/setup_util_unittest.h" | 5 #include "chrome/installer/setup/setup_util_unittest.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 186 } |
187 | 187 |
188 ASSERT_FALSE(CurrentProcessHasPrivilege(kTestedPrivilege)); | 188 ASSERT_FALSE(CurrentProcessHasPrivilege(kTestedPrivilege)); |
189 } | 189 } |
190 | 190 |
191 TEST(SetupUtilTest, GuidToSquid) { | 191 TEST(SetupUtilTest, GuidToSquid) { |
192 ASSERT_EQ(installer::GuidToSquid(L"EDA620E3-AA98-3846-B81E-3493CB2E0E02"), | 192 ASSERT_EQ(installer::GuidToSquid(L"EDA620E3-AA98-3846-B81E-3493CB2E0E02"), |
193 L"3E026ADE89AA64838BE14339BCE2E020"); | 193 L"3E026ADE89AA64838BE14339BCE2E020"); |
194 } | 194 } |
195 | 195 |
| 196 TEST(SetupUtilTest, RegisterEventLogProvider) { |
| 197 registry_util::RegistryOverrideManager registry_override_manager; |
| 198 registry_override_manager.OverrideRegistry(HKEY_LOCAL_MACHINE); |
| 199 |
| 200 const base::Version version("1.2.3.4"); |
| 201 const base::FilePath install_directory( |
| 202 FILE_PATH_LITERAL("c:\\some_path\\test")); |
| 203 installer::RegisterEventLogProvider(install_directory, version); |
| 204 |
| 205 base::win::RegKey key; |
| 206 static constexpr wchar_t kRegistryLocation[] = |
| 207 L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\chrome"; |
| 208 ASSERT_EQ(ERROR_SUCCESS, |
| 209 key.Open(HKEY_LOCAL_MACHINE, kRegistryLocation, KEY_READ)); |
| 210 EXPECT_TRUE(key.HasValue(L"CategoryCount")); |
| 211 EXPECT_TRUE(key.HasValue(L"TypesSupported")); |
| 212 EXPECT_TRUE(key.HasValue(L"CategoryMessageFile")); |
| 213 EXPECT_TRUE(key.HasValue(L"EventMessageFile")); |
| 214 EXPECT_TRUE(key.HasValue(L"ParameterMessageFile")); |
| 215 base::string16 value; |
| 216 EXPECT_EQ(ERROR_SUCCESS, key.ReadValue(L"CategoryMessageFile", &value)); |
| 217 const base::FilePath expected_directory( |
| 218 install_directory.AppendASCII(version.GetString())); |
| 219 const base::FilePath provider_path(value); |
| 220 EXPECT_EQ(expected_directory, provider_path.DirName()); |
| 221 key.Close(); |
| 222 |
| 223 installer::DeRegisterEventLogProvider(); |
| 224 |
| 225 EXPECT_NE(ERROR_SUCCESS, |
| 226 key.Open(HKEY_LOCAL_MACHINE, kRegistryLocation, KEY_READ)); |
| 227 } |
| 228 |
196 const char kAdjustProcessPriority[] = "adjust-process-priority"; | 229 const char kAdjustProcessPriority[] = "adjust-process-priority"; |
197 | 230 |
198 PriorityClassChangeResult DoProcessPriorityAdjustment() { | 231 PriorityClassChangeResult DoProcessPriorityAdjustment() { |
199 return installer::AdjustProcessPriority() ? PCCR_CHANGED : PCCR_UNCHANGED; | 232 return installer::AdjustProcessPriority() ? PCCR_CHANGED : PCCR_UNCHANGED; |
200 } | 233 } |
201 | 234 |
202 namespace { | 235 namespace { |
203 | 236 |
204 // A scoper that sets/resets the current process's priority class. | 237 // A scoper that sets/resets the current process's priority class. |
205 class ScopedPriorityClass { | 238 class ScopedPriorityClass { |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 } | 702 } |
670 | 703 |
671 // Ensure that all values are absent. | 704 // Ensure that all values are absent. |
672 { | 705 { |
673 base::win::RegistryValueIterator it(root_, path_.c_str()); | 706 base::win::RegistryValueIterator it(root_, path_.c_str()); |
674 ASSERT_EQ(0u, it.ValueCount()); | 707 ASSERT_EQ(0u, it.ValueCount()); |
675 } | 708 } |
676 } | 709 } |
677 | 710 |
678 } // namespace installer | 711 } // namespace installer |
OLD | NEW |