Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: components/browser_watcher/watcher_client_win_unittest.cc

Issue 886613002: Introduce the ability to wait for the watcher process to initialize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/browser_watcher/watcher_client_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « components/browser_watcher/watcher_client_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698