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

Side by Side Diff: components/browser_watcher/exit_code_watcher_win_unittest.cc

Issue 860453002: Move OpenProcessHandleWithAccess to Process::OpenWithAccess. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ServiceProcessControlBrowserTest.Setup again Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "components/browser_watcher/exit_code_watcher_win.h" 5 #include "components/browser_watcher/exit_code_watcher_win.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/process/process.h" 8 #include "base/process/process.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 virtual void TearDown() override { 91 virtual void TearDown() override {
92 if (process_ != base::kNullProcessHandle) { 92 if (process_ != base::kNullProcessHandle) {
93 base::CloseProcessHandle(process_); 93 base::CloseProcessHandle(process_);
94 process_ = base::kNullProcessHandle; 94 process_ = base::kNullProcessHandle;
95 } 95 }
96 96
97 Super::TearDown(); 97 Super::TearDown();
98 } 98 }
99 99
100 base::Process OpenSelfWithAccess(uint32 access) { 100 base::Process OpenSelfWithAccess(uint32 access) {
101 HANDLE self = nullptr; 101 return base::Process::OpenWithAccess(base::GetCurrentProcId(), access);
102 EXPECT_TRUE(base::OpenProcessHandleWithAccess(base::GetCurrentProcId(),
103 access, &self));
104 return base::Process(self);
105 } 102 }
106 103
107 void VerifyWroteExitCode(base::ProcessId proc_id, int exit_code) { 104 void VerifyWroteExitCode(base::ProcessId proc_id, int exit_code) {
108 base::win::RegistryValueIterator it( 105 base::win::RegistryValueIterator it(
109 HKEY_CURRENT_USER, kRegistryPath); 106 HKEY_CURRENT_USER, kRegistryPath);
110 107
111 ASSERT_EQ(1, it.ValueCount()); 108 ASSERT_EQ(1, it.ValueCount());
112 base::win::RegKey key(HKEY_CURRENT_USER, 109 base::win::RegKey key(HKEY_CURRENT_USER,
113 kRegistryPath, 110 kRegistryPath,
114 KEY_QUERY_VALUE); 111 KEY_QUERY_VALUE);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // Kill the sleeper, and make sure it's exited before we continue. 174 // Kill the sleeper, and make sure it's exited before we continue.
178 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); 175 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true));
179 176
180 watcher.WaitForExit(); 177 watcher.WaitForExit();
181 EXPECT_EQ(kExitCode, watcher.exit_code()); 178 EXPECT_EQ(kExitCode, watcher.exit_code());
182 179
183 VerifyWroteExitCode(sleeper.process().pid(), kExitCode); 180 VerifyWroteExitCode(sleeper.process().pid(), kExitCode);
184 } 181 }
185 182
186 } // namespace browser_watcher 183 } // namespace browser_watcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698