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

Side by Side Diff: remoting/host/win/worker_process_launcher_unittest.cc

Issue 810133003: replace NULL->nullptr in src/remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/win/scoped_handle.h" 9 #include "base/win/scoped_handle.h"
10 #include "base/win/scoped_process_information.h" 10 #include "base/win/scoped_process_information.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 WorkerProcessLauncher* event_handler_; 174 WorkerProcessLauncher* event_handler_;
175 175
176 // The worker process launcher. 176 // The worker process launcher.
177 scoped_ptr<WorkerProcessLauncher> launcher_; 177 scoped_ptr<WorkerProcessLauncher> launcher_;
178 178
179 // An event that is used to emulate the worker process's handle. 179 // An event that is used to emulate the worker process's handle.
180 ScopedHandle worker_process_; 180 ScopedHandle worker_process_;
181 }; 181 };
182 182
183 WorkerProcessLauncherTest::WorkerProcessLauncherTest() : event_handler_(NULL) { 183 WorkerProcessLauncherTest::WorkerProcessLauncherTest()
184 : event_handler_(nullptr) {
184 } 185 }
185 186
186 WorkerProcessLauncherTest::~WorkerProcessLauncherTest() { 187 WorkerProcessLauncherTest::~WorkerProcessLauncherTest() {
187 } 188 }
188 189
189 void WorkerProcessLauncherTest::SetUp() { 190 void WorkerProcessLauncherTest::SetUp() {
190 task_runner_ = new AutoThreadTaskRunner( 191 task_runner_ = new AutoThreadTaskRunner(
191 message_loop_.message_loop_proxy(), 192 message_loop_.message_loop_proxy(),
192 base::Bind(&WorkerProcessLauncherTest::QuitMainMessageLoop, 193 base::Bind(&WorkerProcessLauncherTest::QuitMainMessageLoop,
193 base::Unretained(this))); 194 base::Unretained(this)));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 253
253 event_handler->OnFatalError(); 254 event_handler->OnFatalError();
254 255
255 task_runner_->PostTask( 256 task_runner_->PostTask(
256 FROM_HERE, 257 FROM_HERE,
257 base::Bind(&WorkerProcessLauncherTest::StopWorker, 258 base::Bind(&WorkerProcessLauncherTest::StopWorker,
258 base::Unretained(this))); 259 base::Unretained(this)));
259 } 260 }
260 261
261 void WorkerProcessLauncherTest::KillProcess() { 262 void WorkerProcessLauncherTest::KillProcess() {
262 event_handler_ = NULL; 263 event_handler_ = nullptr;
263 264
264 if (worker_process_.IsValid()) { 265 if (worker_process_.IsValid()) {
265 TerminateProcess(worker_process_.Get(), CONTROL_C_EXIT); 266 TerminateProcess(worker_process_.Get(), CONTROL_C_EXIT);
266 worker_process_.Close(); 267 worker_process_.Close();
267 } 268 }
268 } 269 }
269 270
270 void WorkerProcessLauncherTest::TerminateWorker(DWORD exit_code) { 271 void WorkerProcessLauncherTest::TerminateWorker(DWORD exit_code) {
271 if (worker_process_.IsValid()) 272 if (worker_process_.IsValid())
272 TerminateProcess(worker_process_.Get(), exit_code); 273 TerminateProcess(worker_process_.Get(), exit_code);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 &server_listener_)); 317 &server_listener_));
317 318
318 launcher_->SetKillProcessTimeoutForTest(base::TimeDelta::FromMilliseconds(0)); 319 launcher_->SetKillProcessTimeoutForTest(base::TimeDelta::FromMilliseconds(0));
319 } 320 }
320 321
321 void WorkerProcessLauncherTest::StopWorker() { 322 void WorkerProcessLauncherTest::StopWorker() {
322 launcher_.reset(); 323 launcher_.reset();
323 DisconnectClient(); 324 DisconnectClient();
324 channel_name_.clear(); 325 channel_name_.clear();
325 channel_server_.reset(); 326 channel_server_.reset();
326 task_runner_ = NULL; 327 task_runner_ = nullptr;
327 } 328 }
328 329
329 void WorkerProcessLauncherTest::QuitMainMessageLoop() { 330 void WorkerProcessLauncherTest::QuitMainMessageLoop() {
330 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); 331 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
331 } 332 }
332 333
333 void WorkerProcessLauncherTest::DoLaunchProcess() { 334 void WorkerProcessLauncherTest::DoLaunchProcess() {
334 EXPECT_TRUE(event_handler_); 335 EXPECT_TRUE(event_handler_);
335 EXPECT_FALSE(worker_process_.IsValid()); 336 EXPECT_FALSE(worker_process_.IsValid());
336 337
337 WCHAR notepad[MAX_PATH + 1]; 338 WCHAR notepad[MAX_PATH + 1];
338 ASSERT_GT(ExpandEnvironmentStrings( 339 ASSERT_GT(ExpandEnvironmentStrings(
339 L"\045SystemRoot\045\\system32\\notepad.exe", notepad, MAX_PATH), 0u); 340 L"\045SystemRoot\045\\system32\\notepad.exe", notepad, MAX_PATH), 0u);
340 341
341 STARTUPINFOW startup_info = { 0 }; 342 STARTUPINFOW startup_info = { 0 };
342 startup_info.cb = sizeof(startup_info); 343 startup_info.cb = sizeof(startup_info);
343 344
344 PROCESS_INFORMATION temp_process_info = {}; 345 PROCESS_INFORMATION temp_process_info = {};
345 ASSERT_TRUE(CreateProcess(NULL, 346 ASSERT_TRUE(CreateProcess(nullptr,
346 notepad, 347 notepad,
347 NULL, // default process attibutes 348 nullptr, // default process attibutes
348 NULL, // default thread attibutes 349 nullptr, // default thread attibutes
349 FALSE, // do not inherit handles 350 FALSE, // do not inherit handles
350 CREATE_SUSPENDED, 351 CREATE_SUSPENDED,
351 NULL, // no environment 352 nullptr, // no environment
352 NULL, // default current directory 353 nullptr, // default current directory
353 &startup_info, 354 &startup_info,
354 &temp_process_info)); 355 &temp_process_info));
355 base::win::ScopedProcessInformation process_information(temp_process_info); 356 base::win::ScopedProcessInformation process_information(temp_process_info);
356 worker_process_.Set(process_information.TakeProcessHandle()); 357 worker_process_.Set(process_information.TakeProcessHandle());
357 ASSERT_TRUE(worker_process_.IsValid()); 358 ASSERT_TRUE(worker_process_.IsValid());
358 359
359 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID(); 360 channel_name_ = IPC::Channel::GenerateUniqueRandomChannelID();
360 ScopedHandle pipe; 361 ScopedHandle pipe;
361 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe)); 362 ASSERT_TRUE(CreateIpcChannel(channel_name_, kIpcSecurityDescriptor, &pipe));
362 363
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 EXPECT_CALL(client_listener_, OnCrash(_, _, _)) 524 EXPECT_CALL(client_listener_, OnCrash(_, _, _))
524 .Times(1) 525 .Times(1)
525 .WillOnce(InvokeWithoutArgs( 526 .WillOnce(InvokeWithoutArgs(
526 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher)); 527 this, &WorkerProcessLauncherTest::SendFakeMessageToLauncher));
527 528
528 StartWorker(); 529 StartWorker();
529 message_loop_.Run(); 530 message_loop_.Run();
530 } 531 }
531 532
532 } // namespace remoting 533 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/win/worker_process_launcher.cc ('k') | remoting/host/win/wts_session_process_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698