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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 }; | 72 }; |
73 | 73 |
74 class ExitCodeWatcherTest : public testing::Test { | 74 class ExitCodeWatcherTest : public testing::Test { |
75 public: | 75 public: |
76 typedef testing::Test Super; | 76 typedef testing::Test Super; |
77 | 77 |
78 static const int kExitCode = 0xCAFEBABE; | 78 static const int kExitCode = 0xCAFEBABE; |
79 | 79 |
80 ExitCodeWatcherTest() : cmd_line_(base::CommandLine::NO_PROGRAM) {} | 80 ExitCodeWatcherTest() : cmd_line_(base::CommandLine::NO_PROGRAM) {} |
81 | 81 |
82 virtual void SetUp() override { | 82 void SetUp() override { |
83 Super::SetUp(); | 83 Super::SetUp(); |
84 | 84 |
85 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); | 85 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); |
86 } | 86 } |
87 | 87 |
88 base::Process OpenSelfWithAccess(uint32 access) { | 88 base::Process OpenSelfWithAccess(uint32 access) { |
89 return base::Process::OpenWithAccess(base::GetCurrentProcId(), access); | 89 return base::Process::OpenWithAccess(base::GetCurrentProcId(), access); |
90 } | 90 } |
91 | 91 |
92 void VerifyWroteExitCode(base::ProcessId proc_id, int exit_code) { | 92 void VerifyWroteExitCode(base::ProcessId proc_id, int exit_code) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |