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

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

Issue 983963002: Redefine base::Process:Terminate so that it can replace base::KillProcess (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add const Created 5 years, 9 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
« no previous file with comments | « base/process/process_win.cc ('k') | content/browser/child_process_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 20 matching lines...) Expand all
31 return 1; 31 return 1;
32 } 32 }
33 33
34 class ScopedSleeperProcess { 34 class ScopedSleeperProcess {
35 public: 35 public:
36 ScopedSleeperProcess() : is_killed_(false) { 36 ScopedSleeperProcess() : is_killed_(false) {
37 } 37 }
38 38
39 ~ScopedSleeperProcess() { 39 ~ScopedSleeperProcess() {
40 if (process_.IsValid()) { 40 if (process_.IsValid()) {
41 process_.Terminate(-1); 41 process_.Terminate(-1, false);
42 int exit_code = 0; 42 int exit_code = 0;
43 EXPECT_TRUE(process_.WaitForExit(&exit_code)); 43 EXPECT_TRUE(process_.WaitForExit(&exit_code));
44 } 44 }
45 } 45 }
46 46
47 void Launch() { 47 void Launch() {
48 ASSERT_FALSE(process_.IsValid()); 48 ASSERT_FALSE(process_.IsValid());
49 49
50 base::CommandLine cmd_line(base::GetMultiProcessTestChildBaseCommandLine()); 50 base::CommandLine cmd_line(base::GetMultiProcessTestChildBaseCommandLine());
51 base::LaunchOptions options; 51 base::LaunchOptions options;
52 options.start_hidden = true; 52 options.start_hidden = true;
53 process_ = base::SpawnMultiProcessTestChild("Sleeper", cmd_line, options); 53 process_ = base::SpawnMultiProcessTestChild("Sleeper", cmd_line, options);
54 ASSERT_TRUE(process_.IsValid()); 54 ASSERT_TRUE(process_.IsValid());
55 } 55 }
56 56
57 void Kill(int exit_code, bool wait) { 57 void Kill(int exit_code, bool wait) {
58 ASSERT_TRUE(process_.IsValid()); 58 ASSERT_TRUE(process_.IsValid());
59 ASSERT_FALSE(is_killed_); 59 ASSERT_FALSE(is_killed_);
60 process_.Terminate(exit_code); 60 process_.Terminate(exit_code, false);
61 int seen_exit_code = 0; 61 int seen_exit_code = 0;
62 EXPECT_TRUE(process_.WaitForExit(&seen_exit_code)); 62 EXPECT_TRUE(process_.WaitForExit(&seen_exit_code));
63 EXPECT_EQ(exit_code, seen_exit_code); 63 EXPECT_EQ(exit_code, seen_exit_code);
64 is_killed_ = true; 64 is_killed_ = true;
65 } 65 }
66 66
67 const base::Process& process() const { return process_; } 67 const base::Process& process() const { return process_; }
68 68
69 private: 69 private:
70 base::Process process_; 70 base::Process process_;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // Kill the sleeper, and make sure it's exited before we continue. 161 // Kill the sleeper, and make sure it's exited before we continue.
162 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); 162 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true));
163 163
164 watcher.WaitForExit(); 164 watcher.WaitForExit();
165 EXPECT_EQ(kExitCode, watcher.exit_code()); 165 EXPECT_EQ(kExitCode, watcher.exit_code());
166 166
167 VerifyWroteExitCode(sleeper.process().Pid(), kExitCode); 167 VerifyWroteExitCode(sleeper.process().Pid(), kExitCode);
168 } 168 }
169 169
170 } // namespace browser_watcher 170 } // namespace browser_watcher
OLDNEW
« no previous file with comments | « base/process/process_win.cc ('k') | content/browser/child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698