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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 void VerifyWroteExitCode(base::ProcessId proc_id, int exit_code) { | 91 void VerifyWroteExitCode(base::ProcessId proc_id, int exit_code) { |
92 base::win::RegistryValueIterator it( | 92 base::win::RegistryValueIterator it( |
93 HKEY_CURRENT_USER, kRegistryPath); | 93 HKEY_CURRENT_USER, kRegistryPath); |
94 | 94 |
95 ASSERT_EQ(1, it.ValueCount()); | 95 ASSERT_EQ(1, it.ValueCount()); |
96 base::win::RegKey key(HKEY_CURRENT_USER, | 96 base::win::RegKey key(HKEY_CURRENT_USER, |
97 kRegistryPath, | 97 kRegistryPath, |
98 KEY_QUERY_VALUE); | 98 KEY_QUERY_VALUE); |
99 | 99 |
100 // The value name should encode the process id at the start. | 100 // The value name should encode the process id at the start. |
101 EXPECT_TRUE(base::StartsWith(it.Name(), base::StringPrintf(L"%d-", proc_id), | 101 EXPECT_TRUE(base::StartsWith( |
102 false)); | 102 it.Name(), |
| 103 base::StringPrintf(L"%d-", proc_id), |
| 104 base::CompareCase::SENSITIVE)); |
103 DWORD value = 0; | 105 DWORD value = 0; |
104 ASSERT_EQ(ERROR_SUCCESS, key.ReadValueDW(it.Name(), &value)); | 106 ASSERT_EQ(ERROR_SUCCESS, key.ReadValueDW(it.Name(), &value)); |
105 ASSERT_EQ(exit_code, value); | 107 ASSERT_EQ(exit_code, value); |
106 } | 108 } |
107 | 109 |
108 protected: | 110 protected: |
109 base::CommandLine cmd_line_; | 111 base::CommandLine cmd_line_; |
110 registry_util::RegistryOverrideManager override_manager_; | 112 registry_util::RegistryOverrideManager override_manager_; |
111 }; | 113 }; |
112 | 114 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // 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. |
160 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); | 162 ASSERT_NO_FATAL_FAILURE(sleeper.Kill(kExitCode, true)); |
161 | 163 |
162 watcher.WaitForExit(); | 164 watcher.WaitForExit(); |
163 EXPECT_EQ(kExitCode, watcher.exit_code()); | 165 EXPECT_EQ(kExitCode, watcher.exit_code()); |
164 | 166 |
165 VerifyWroteExitCode(sleeper.process().Pid(), kExitCode); | 167 VerifyWroteExitCode(sleeper.process().Pid(), kExitCode); |
166 } | 168 } |
167 | 169 |
168 } // namespace browser_watcher | 170 } // namespace browser_watcher |
OLD | NEW |