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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::Process( | 53 process_ = base::SpawnMultiProcessTestChild("Sleeper", cmd_line, options); |
54 base::SpawnMultiProcessTestChild("Sleeper", cmd_line, options)); | |
55 ASSERT_TRUE(process_.IsValid()); | 54 ASSERT_TRUE(process_.IsValid()); |
56 } | 55 } |
57 | 56 |
58 void Kill(int exit_code, bool wait) { | 57 void Kill(int exit_code, bool wait) { |
59 ASSERT_TRUE(process_.IsValid()); | 58 ASSERT_TRUE(process_.IsValid()); |
60 ASSERT_FALSE(is_killed_); | 59 ASSERT_FALSE(is_killed_); |
61 process_.Terminate(exit_code); | 60 process_.Terminate(exit_code); |
62 int seen_exit_code = 0; | 61 int seen_exit_code = 0; |
63 EXPECT_TRUE(process_.WaitForExit(&seen_exit_code)); | 62 EXPECT_TRUE(process_.WaitForExit(&seen_exit_code)); |
64 EXPECT_EQ(exit_code, seen_exit_code); | 63 EXPECT_EQ(exit_code, seen_exit_code); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // Kill the sleeper, and make sure it's exited before we continue. | 218 // Kill the sleeper, and make sure it's exited before we continue. |
220 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); | 219 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); |
221 | 220 |
222 watcher.WaitForExit(); | 221 watcher.WaitForExit(); |
223 EXPECT_EQ(kExitCode, watcher.exit_code()); | 222 EXPECT_EQ(kExitCode, watcher.exit_code()); |
224 | 223 |
225 VerifyWroteExitCode(sleeper.process().pid(), kExitCode); | 224 VerifyWroteExitCode(sleeper.process().pid(), kExitCode); |
226 } | 225 } |
227 | 226 |
228 } // namespace browser_watcher | 227 } // namespace browser_watcher |
OLD | NEW |