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

Side by Side Diff: components/browser_watcher/watcher_client_win_unittest.cc

Issue 2950153002: Improve process launch handle sharing API. (Closed)
Patch Set: Fix Mojo launcher, review comments Created 3 years, 5 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 unified diff | Download patch
OLDNEW
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/watcher_client_win.h" 5 #include "components/browser_watcher/watcher_client_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 // Inheritable process handle used for testing. 155 // Inheritable process handle used for testing.
156 base::win::ScopedHandle self_; 156 base::win::ScopedHandle self_;
157 }; 157 };
158 158
159 } // namespace 159 } // namespace
160 160
161 // TODO(siggi): More testing - test WatcherClient base implementation. 161 // TODO(siggi): More testing - test WatcherClient base implementation.
162 162
163 TEST_F(WatcherClientTest, LaunchWatcherSucceeds) { 163 TEST_F(WatcherClientTest, LaunchWatcherSucceeds) {
164 // We can only use the non-legacy launch method on Windows Vista or better.
165 if (base::win::GetVersion() < base::win::VERSION_VISTA)
166 return;
167
168 WatcherClient client(GetBaseCommandLineGenerator(NO_LEAK_HANDLE)); 164 WatcherClient client(GetBaseCommandLineGenerator(NO_LEAK_HANDLE));
169 ASSERT_FALSE(client.use_legacy_launch());
170
171 client.LaunchWatcher(); 165 client.LaunchWatcher();
172 166
173 ASSERT_NO_FATAL_FAILURE( 167 ASSERT_NO_FATAL_FAILURE(
174 AssertSuccessfulExitCode(client.process().Duplicate()));
175 }
176
177 TEST_F(WatcherClientTest, LaunchWatcherLegacyModeSucceeds) {
178 // Test the XP-compatible legacy launch mode. This is expected to leak
179 // a handle to the child process.
180 WatcherClient client(GetBaseCommandLineGenerator(LEAK_HANDLE));
181
182 // Use the legacy launch mode.
183 client.set_use_legacy_launch(true);
184
185 client.LaunchWatcher();
186
187 ASSERT_NO_FATAL_FAILURE(
188 AssertSuccessfulExitCode(client.process().Duplicate()));
189 }
190
191 TEST_F(WatcherClientTest, LegacyModeDetectedOnXP) {
192 // This test only works on Windows XP.
193 if (base::win::GetVersion() > base::win::VERSION_XP)
194 return;
195
196 // Test that the client detects the need to use legacy launch mode, and that
197 // it works on Windows XP.
198 WatcherClient client(GetBaseCommandLineGenerator(LEAK_HANDLE));
199 ASSERT_TRUE(client.use_legacy_launch());
200
201 client.LaunchWatcher();
202
203 ASSERT_NO_FATAL_FAILURE(
204 AssertSuccessfulExitCode(client.process().Duplicate())); 168 AssertSuccessfulExitCode(client.process().Duplicate()));
205 } 169 }
206 170
207 } // namespace browser_watcher 171 } // namespace browser_watcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698