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 #include <utility> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
14 #include "base/process/kill.h" | 15 #include "base/process/kill.h" |
15 #include "base/process/process.h" | 16 #include "base/process/process.h" |
16 #include "base/rand_util.h" | 17 #include "base/rand_util.h" |
17 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
18 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
19 #include "base/test/multiprocess_test.h" | 20 #include "base/test/multiprocess_test.h" |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 ipc_file_list.push_back(std::make_pair( | 453 ipc_file_list.push_back(std::make_pair( |
453 startup_channel_->TakeClientFileDescriptor().release(), | 454 startup_channel_->TakeClientFileDescriptor().release(), |
454 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); | 455 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); |
455 base::LaunchOptions options; | 456 base::LaunchOptions options; |
456 options.fds_to_remap = &ipc_file_list; | 457 options.fds_to_remap = &ipc_file_list; |
457 base::Process process = SpawnChildWithOptions(name, options); | 458 base::Process process = SpawnChildWithOptions(name, options); |
458 #else | 459 #else |
459 base::Process process = SpawnChild(name); | 460 base::Process process = SpawnChild(name); |
460 #endif | 461 #endif |
461 EXPECT_TRUE(process.IsValid()); | 462 EXPECT_TRUE(process.IsValid()); |
462 return process.Pass(); | 463 return process; |
463 } | 464 } |
464 | 465 |
465 void CloudPrintProxyPolicyStartupTest::WaitForConnect() { | 466 void CloudPrintProxyPolicyStartupTest::WaitForConnect() { |
466 observer_.Wait(); | 467 observer_.Wait(); |
467 EXPECT_TRUE(CheckServiceProcessReady()); | 468 EXPECT_TRUE(CheckServiceProcessReady()); |
468 EXPECT_TRUE(base::ThreadTaskRunnerHandle::Get().get()); | 469 EXPECT_TRUE(base::ThreadTaskRunnerHandle::Get().get()); |
469 ServiceProcessControl::GetInstance()->SetChannel( | 470 ServiceProcessControl::GetInstance()->SetChannel( |
470 IPC::ChannelProxy::Create(GetServiceProcessChannel(), | 471 IPC::ChannelProxy::Create(GetServiceProcessChannel(), |
471 IPC::Channel::MODE_NAMED_CLIENT, | 472 IPC::Channel::MODE_NAMED_CLIENT, |
472 ServiceProcessControl::GetInstance(), | 473 ServiceProcessControl::GetInstance(), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 ASSERT_TRUE(profile_manager.SetUp()); | 510 ASSERT_TRUE(profile_manager.SetUp()); |
510 | 511 |
511 // Must be created after the TestingProfileManager since that creates the | 512 // Must be created after the TestingProfileManager since that creates the |
512 // LocalState for the BrowserProcess. Must be created before profiles are | 513 // LocalState for the BrowserProcess. Must be created before profiles are |
513 // constructed. | 514 // constructed. |
514 chrome::TestingIOThreadState testing_io_thread_state; | 515 chrome::TestingIOThreadState testing_io_thread_state; |
515 | 516 |
516 base::Process process = | 517 base::Process process = |
517 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); | 518 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); |
518 WaitForConnect(); | 519 WaitForConnect(); |
519 ShutdownAndWaitForExitWithTimeout(process.Pass()); | 520 ShutdownAndWaitForExitWithTimeout(std::move(process)); |
520 content::RunAllPendingInMessageLoop(); | 521 content::RunAllPendingInMessageLoop(); |
521 } | 522 } |
OLD | NEW |