| OLD | NEW |
| 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 // Create a service process that uses a Mock to respond to the browser in order | 5 // Create a service process that uses a Mock to respond to the browser in order |
| 6 // to test launching the browser using the cloud print policy check command | 6 // to test launching the browser using the cloud print policy check command |
| 7 // line switch. | 7 // line switch. |
| 8 | 8 |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 457 |
| 458 base::Process CloudPrintProxyPolicyStartupTest::Launch( | 458 base::Process CloudPrintProxyPolicyStartupTest::Launch( |
| 459 const std::string& name) { | 459 const std::string& name) { |
| 460 EXPECT_FALSE(CheckServiceProcessReady()); | 460 EXPECT_FALSE(CheckServiceProcessReady()); |
| 461 | 461 |
| 462 startup_channel_handle_ = mojo::edk::NamedPlatformHandle( | 462 startup_channel_handle_ = mojo::edk::NamedPlatformHandle( |
| 463 base::StringPrintf("%d.%p.%d", base::GetCurrentProcId(), this, | 463 base::StringPrintf("%d.%p.%d", base::GetCurrentProcId(), this, |
| 464 base::RandInt(0, std::numeric_limits<int>::max()))); | 464 base::RandInt(0, std::numeric_limits<int>::max()))); |
| 465 startup_channel_ = IPC::ChannelProxy::Create( | 465 startup_channel_ = IPC::ChannelProxy::Create( |
| 466 mojo::edk::ConnectToPeerProcess( | 466 mojo::edk::ConnectToPeerProcess( |
| 467 mojo::edk::CreateServerHandle(startup_channel_handle_, false)) | 467 mojo::edk::CreateServerHandle(startup_channel_handle_)) |
| 468 .release(), | 468 .release(), |
| 469 IPC::Channel::MODE_SERVER, this, IOTaskRunner()); | 469 IPC::Channel::MODE_SERVER, this, IOTaskRunner()); |
| 470 | 470 |
| 471 base::Process process = SpawnChild(name); | 471 base::Process process = SpawnChild(name); |
| 472 EXPECT_TRUE(process.IsValid()); | 472 EXPECT_TRUE(process.IsValid()); |
| 473 return process; | 473 return process; |
| 474 } | 474 } |
| 475 | 475 |
| 476 void CloudPrintProxyPolicyStartupTest::WaitForConnect() { | 476 void CloudPrintProxyPolicyStartupTest::WaitForConnect() { |
| 477 observer_.Wait(); | 477 observer_.Wait(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 // constructed. | 534 // constructed. |
| 535 chrome::TestingIOThreadState testing_io_thread_state; | 535 chrome::TestingIOThreadState testing_io_thread_state; |
| 536 | 536 |
| 537 base::Process process = | 537 base::Process process = |
| 538 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); | 538 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); |
| 539 WaitForConnect(); | 539 WaitForConnect(); |
| 540 ShutdownAndWaitForExitWithTimeout(std::move(process)); | 540 ShutdownAndWaitForExitWithTimeout(std::move(process)); |
| 541 ServiceProcessControl::GetInstance()->Disconnect(); | 541 ServiceProcessControl::GetInstance()->Disconnect(); |
| 542 content::RunAllPendingInMessageLoop(); | 542 content::RunAllPendingInMessageLoop(); |
| 543 } | 543 } |
| OLD | NEW |