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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 public: | 78 public: |
79 typedef testing::Test Super; | 79 typedef testing::Test Super; |
80 | 80 |
81 static const int kExitCode = 0xCAFEBABE; | 81 static const int kExitCode = 0xCAFEBABE; |
82 | 82 |
83 ExitCodeWatcherTest() : cmd_line_(base::CommandLine::NO_PROGRAM) {} | 83 ExitCodeWatcherTest() : cmd_line_(base::CommandLine::NO_PROGRAM) {} |
84 | 84 |
85 void SetUp() override { | 85 void SetUp() override { |
86 Super::SetUp(); | 86 Super::SetUp(); |
87 | 87 |
88 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); | 88 ASSERT_NO_FATAL_FAILURE( |
| 89 override_manager_.OverrideRegistry(HKEY_CURRENT_USER)); |
89 } | 90 } |
90 | 91 |
91 base::Process OpenSelfWithAccess(uint32_t access) { | 92 base::Process OpenSelfWithAccess(uint32_t access) { |
92 return base::Process::OpenWithAccess(base::GetCurrentProcId(), access); | 93 return base::Process::OpenWithAccess(base::GetCurrentProcId(), access); |
93 } | 94 } |
94 | 95 |
95 void VerifyWroteExitCode(base::ProcessId proc_id, int exit_code) { | 96 void VerifyWroteExitCode(base::ProcessId proc_id, int exit_code) { |
96 base::win::RegistryValueIterator it( | 97 base::win::RegistryValueIterator it( |
97 HKEY_CURRENT_USER, kRegistryPath); | 98 HKEY_CURRENT_USER, kRegistryPath); |
98 | 99 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // Kill the sleeper, and make sure it's exited before we continue. | 166 // Kill the sleeper, and make sure it's exited before we continue. |
166 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); | 167 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); |
167 | 168 |
168 watcher.WaitForExit(); | 169 watcher.WaitForExit(); |
169 EXPECT_EQ(kExitCode, watcher.exit_code()); | 170 EXPECT_EQ(kExitCode, watcher.exit_code()); |
170 | 171 |
171 VerifyWroteExitCode(sleeper.process().Pid(), kExitCode); | 172 VerifyWroteExitCode(sleeper.process().Pid(), kExitCode); |
172 } | 173 } |
173 | 174 |
174 } // namespace browser_watcher | 175 } // namespace browser_watcher |
OLD | NEW |