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

Side by Side Diff: chrome/installer/setup/setup_util_unittest.cc

Issue 2507753002: Install the chrome event log provider together with the browser. (Closed)
Patch Set: Fix RegisterEventLogProvider unit test. Created 4 years 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 (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
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 // TODO(grt): use install_static::InstallDetails::Get().install_full_name()
206 // when InstallDetails is initialized in the installer.
207 base::string16 reg_path(
208 L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\");
209 #if defined(GOOGLE_CHROME_BUILD)
210 reg_path.append(L"Chrome");
211 if (InstallUtil::IsChromeSxSProcess())
212 reg_path.append(L" SxS");
213 #else
214 reg_path.append(L"Chromium");
215 #endif
216 base::win::RegKey key;
217 ASSERT_EQ(ERROR_SUCCESS,
218 key.Open(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ));
219 EXPECT_TRUE(key.HasValue(L"CategoryCount"));
220 EXPECT_TRUE(key.HasValue(L"TypesSupported"));
221 EXPECT_TRUE(key.HasValue(L"CategoryMessageFile"));
222 EXPECT_TRUE(key.HasValue(L"EventMessageFile"));
223 EXPECT_TRUE(key.HasValue(L"ParameterMessageFile"));
224 base::string16 value;
225 EXPECT_EQ(ERROR_SUCCESS, key.ReadValue(L"CategoryMessageFile", &value));
226 const base::FilePath expected_directory(
227 install_directory.AppendASCII(version.GetString()));
228 const base::FilePath provider_path(value);
229 EXPECT_EQ(expected_directory, provider_path.DirName());
230 key.Close();
231
232 installer::DeRegisterEventLogProvider();
233
234 EXPECT_NE(ERROR_SUCCESS,
235 key.Open(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ));
236 }
237
196 const char kAdjustProcessPriority[] = "adjust-process-priority"; 238 const char kAdjustProcessPriority[] = "adjust-process-priority";
197 239
198 PriorityClassChangeResult DoProcessPriorityAdjustment() { 240 PriorityClassChangeResult DoProcessPriorityAdjustment() {
199 return installer::AdjustProcessPriority() ? PCCR_CHANGED : PCCR_UNCHANGED; 241 return installer::AdjustProcessPriority() ? PCCR_CHANGED : PCCR_UNCHANGED;
200 } 242 }
201 243
202 namespace { 244 namespace {
203 245
204 // A scoper that sets/resets the current process's priority class. 246 // A scoper that sets/resets the current process's priority class.
205 class ScopedPriorityClass { 247 class ScopedPriorityClass {
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } 711 }
670 712
671 // Ensure that all values are absent. 713 // Ensure that all values are absent.
672 { 714 {
673 base::win::RegistryValueIterator it(root_, path_.c_str()); 715 base::win::RegistryValueIterator it(root_, path_.c_str());
674 ASSERT_EQ(0u, it.ValueCount()); 716 ASSERT_EQ(0u, it.ValueCount());
675 } 717 }
676 } 718 }
677 719
678 } // namespace installer 720 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698