| Index: components/browser_watcher/watcher_client_win_unittest.cc
|
| diff --git a/components/browser_watcher/watcher_client_win_unittest.cc b/components/browser_watcher/watcher_client_win_unittest.cc
|
| index 2e19f42064140d6d2b017580496e8bfcdf1b1719..ca24e8157308891b76185cf19fff641d24c2a1b9 100644
|
| --- a/components/browser_watcher/watcher_client_win_unittest.cc
|
| +++ b/components/browser_watcher/watcher_client_win_unittest.cc
|
| @@ -137,25 +137,11 @@ class WatcherClientTest : public base::MultiProcessTest {
|
| base::Unretained(this), handle_policy);
|
| }
|
|
|
| - void AssertSuccessfulExitCode(base::ProcessHandle handle) {
|
| - ASSERT_NE(base::kNullProcessHandle, handle);
|
| -
|
| - // Duplicate the process handle to work around the fact that
|
| - // WaitForExitCode closes it(!!!).
|
| - base::ProcessHandle dupe = NULL;
|
| - ASSERT_TRUE(::DuplicateHandle(base::GetCurrentProcessHandle(),
|
| - handle,
|
| - base::GetCurrentProcessHandle(),
|
| - &dupe,
|
| - SYNCHRONIZE | PROCESS_QUERY_INFORMATION,
|
| - FALSE,
|
| - 0));
|
| - ASSERT_NE(base::kNullProcessHandle, dupe);
|
| + void AssertSuccessfulExitCode(base::Process process) {
|
| + ASSERT_TRUE(process.IsValid());
|
| int exit_code = 0;
|
| - if (!base::WaitForExitCode(dupe, &exit_code)) {
|
| - base::CloseProcessHandle(dupe);
|
| - FAIL() << "WaitForExitCode failed.";
|
| - }
|
| + if (!process.WaitForExit(&exit_code))
|
| + FAIL() << "Process::WaitForExit failed.";
|
| ASSERT_EQ(0, exit_code);
|
| }
|
|
|
| @@ -177,7 +163,8 @@ TEST_F(WatcherClientTest, LaunchWatcherSucceeds) {
|
|
|
| client.LaunchWatcher();
|
|
|
| - ASSERT_NO_FATAL_FAILURE(AssertSuccessfulExitCode(client.process()));
|
| + ASSERT_NO_FATAL_FAILURE(
|
| + AssertSuccessfulExitCode(client.process().Duplicate()));
|
| }
|
|
|
| TEST_F(WatcherClientTest, LaunchWatcherLegacyModeSucceeds) {
|
| @@ -190,7 +177,8 @@ TEST_F(WatcherClientTest, LaunchWatcherLegacyModeSucceeds) {
|
|
|
| client.LaunchWatcher();
|
|
|
| - ASSERT_NO_FATAL_FAILURE(AssertSuccessfulExitCode(client.process()));
|
| + ASSERT_NO_FATAL_FAILURE(
|
| + AssertSuccessfulExitCode(client.process().Duplicate()));
|
| }
|
|
|
| TEST_F(WatcherClientTest, LegacyModeDetectedOnXP) {
|
| @@ -205,7 +193,8 @@ TEST_F(WatcherClientTest, LegacyModeDetectedOnXP) {
|
|
|
| client.LaunchWatcher();
|
|
|
| - ASSERT_NO_FATAL_FAILURE(AssertSuccessfulExitCode(client.process()));
|
| + ASSERT_NO_FATAL_FAILURE(
|
| + AssertSuccessfulExitCode(client.process().Duplicate()));
|
| }
|
|
|
| } // namespace browser_watcher
|
|
|