| 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> |
| 8 |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #include "base/process/process.h" | 10 #include "base/process/process.h" |
| 9 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 12 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 13 #include "base/test/multiprocess_test.h" | 15 #include "base/test/multiprocess_test.h" |
| 14 #include "base/test/test_reg_util_win.h" | 16 #include "base/test/test_reg_util_win.h" |
| 15 #include "base/threading/platform_thread.h" | 17 #include "base/threading/platform_thread.h" |
| 16 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 static const int kExitCode = 0xCAFEBABE; | 79 static const int kExitCode = 0xCAFEBABE; |
| 78 | 80 |
| 79 ExitCodeWatcherTest() : cmd_line_(base::CommandLine::NO_PROGRAM) {} | 81 ExitCodeWatcherTest() : cmd_line_(base::CommandLine::NO_PROGRAM) {} |
| 80 | 82 |
| 81 void SetUp() override { | 83 void SetUp() override { |
| 82 Super::SetUp(); | 84 Super::SetUp(); |
| 83 | 85 |
| 84 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); | 86 override_manager_.OverrideRegistry(HKEY_CURRENT_USER); |
| 85 } | 87 } |
| 86 | 88 |
| 87 base::Process OpenSelfWithAccess(uint32 access) { | 89 base::Process OpenSelfWithAccess(uint32_t access) { |
| 88 return base::Process::OpenWithAccess(base::GetCurrentProcId(), access); | 90 return base::Process::OpenWithAccess(base::GetCurrentProcId(), access); |
| 89 } | 91 } |
| 90 | 92 |
| 91 void VerifyWroteExitCode(base::ProcessId proc_id, int exit_code) { | 93 void VerifyWroteExitCode(base::ProcessId proc_id, int exit_code) { |
| 92 base::win::RegistryValueIterator it( | 94 base::win::RegistryValueIterator it( |
| 93 HKEY_CURRENT_USER, kRegistryPath); | 95 HKEY_CURRENT_USER, kRegistryPath); |
| 94 | 96 |
| 95 ASSERT_EQ(1u, it.ValueCount()); | 97 ASSERT_EQ(1u, it.ValueCount()); |
| 96 base::win::RegKey key(HKEY_CURRENT_USER, | 98 base::win::RegKey key(HKEY_CURRENT_USER, |
| 97 kRegistryPath, | 99 kRegistryPath, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // Kill the sleeper, and make sure it's exited before we continue. | 163 // Kill the sleeper, and make sure it's exited before we continue. |
| 162 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); | 164 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); |
| 163 | 165 |
| 164 watcher.WaitForExit(); | 166 watcher.WaitForExit(); |
| 165 EXPECT_EQ(kExitCode, watcher.exit_code()); | 167 EXPECT_EQ(kExitCode, watcher.exit_code()); |
| 166 | 168 |
| 167 VerifyWroteExitCode(sleeper.process().Pid(), kExitCode); | 169 VerifyWroteExitCode(sleeper.process().Pid(), kExitCode); |
| 168 } | 170 } |
| 169 | 171 |
| 170 } // namespace browser_watcher | 172 } // namespace browser_watcher |
| OLD | NEW |