OLD | NEW |
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 21 matching lines...) Expand all Loading... |
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, false); | 41 process_.Terminate(-1, false); |
42 int exit_code = 0; | 42 EXPECT_TRUE(process_.WaitForExit(NULL)); |
43 EXPECT_TRUE(process_.WaitForExit(&exit_code)); | |
44 } | 43 } |
45 } | 44 } |
46 | 45 |
47 void Launch() { | 46 void Launch() { |
48 ASSERT_FALSE(process_.IsValid()); | 47 ASSERT_FALSE(process_.IsValid()); |
49 | 48 |
50 base::CommandLine cmd_line(base::GetMultiProcessTestChildBaseCommandLine()); | 49 base::CommandLine cmd_line(base::GetMultiProcessTestChildBaseCommandLine()); |
51 base::LaunchOptions options; | 50 base::LaunchOptions options; |
52 options.start_hidden = true; | 51 options.start_hidden = true; |
53 process_ = base::SpawnMultiProcessTestChild("Sleeper", cmd_line, options); | 52 process_ = base::SpawnMultiProcessTestChild("Sleeper", cmd_line, options); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // Kill the sleeper, and make sure it's exited before we continue. | 160 // Kill the sleeper, and make sure it's exited before we continue. |
162 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); | 161 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); |
163 | 162 |
164 watcher.WaitForExit(); | 163 watcher.WaitForExit(); |
165 EXPECT_EQ(kExitCode, watcher.exit_code()); | 164 EXPECT_EQ(kExitCode, watcher.exit_code()); |
166 | 165 |
167 VerifyWroteExitCode(sleeper.process().Pid(), kExitCode); | 166 VerifyWroteExitCode(sleeper.process().Pid(), kExitCode); |
168 } | 167 } |
169 | 168 |
170 } // namespace browser_watcher | 169 } // namespace browser_watcher |
OLD | NEW |