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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 257 |
258 TestServiceProcess service_process; | 258 TestServiceProcess service_process; |
259 EXPECT_EQ(&service_process, g_service_process); | 259 EXPECT_EQ(&service_process, g_service_process); |
260 | 260 |
261 // Takes ownership of the pointer, but we can use it since we have the same | 261 // Takes ownership of the pointer, but we can use it since we have the same |
262 // lifetime. | 262 // lifetime. |
263 EXPECT_TRUE(service_process.Initialize(&main_message_loop, state)); | 263 EXPECT_TRUE(service_process.Initialize(&main_message_loop, state)); |
264 | 264 |
265 // Needed for IPC. | 265 // Needed for IPC. |
266 mojo::edk::Init(); | 266 mojo::edk::Init(); |
267 mojo::edk::ScopedIPCSupport ipc_support(service_process.io_task_runner()); | 267 mojo::edk::ScopedIPCSupport ipc_support( |
| 268 service_process.io_task_runner(), |
| 269 mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST); |
268 | 270 |
269 MockServiceIPCServer server(&service_process, | 271 MockServiceIPCServer server(&service_process, |
270 service_process.io_task_runner(), | 272 service_process.io_task_runner(), |
271 service_process.GetShutdownEventForTesting()); | 273 service_process.GetShutdownEventForTesting()); |
272 | 274 |
273 // Here is where the expectations/mock responses need to be set up. | 275 // Here is where the expectations/mock responses need to be set up. |
274 set_expectations.Run(&server); | 276 set_expectations.Run(&server); |
275 | 277 |
276 EXPECT_TRUE(server.Init()); | 278 EXPECT_TRUE(server.Init()); |
277 EXPECT_TRUE(state->SignalReady(service_process.io_task_runner().get(), | 279 EXPECT_TRUE(state->SignalReady(service_process.io_task_runner().get(), |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 cl.AppendSwitchNative(kProcessChannelID, startup_channel_handle_.name); | 515 cl.AppendSwitchNative(kProcessChannelID, startup_channel_handle_.name); |
514 #if defined(OS_MACOSX) | 516 #if defined(OS_MACOSX) |
515 cl.AppendSwitchASCII(kTestExecutablePath, executable_path_.value()); | 517 cl.AppendSwitchASCII(kTestExecutablePath, executable_path_.value()); |
516 #endif | 518 #endif |
517 return cl; | 519 return cl; |
518 } | 520 } |
519 | 521 |
520 TEST_F(CloudPrintProxyPolicyStartupTest, StartAndShutdown) { | 522 TEST_F(CloudPrintProxyPolicyStartupTest, StartAndShutdown) { |
521 mojo::edk::Init(); | 523 mojo::edk::Init(); |
522 mojo::edk::ScopedIPCSupport ipc_support( | 524 mojo::edk::ScopedIPCSupport ipc_support( |
523 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); | 525 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
| 526 mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST); |
524 | 527 |
525 TestingBrowserProcess* browser_process = | 528 TestingBrowserProcess* browser_process = |
526 TestingBrowserProcess::GetGlobal(); | 529 TestingBrowserProcess::GetGlobal(); |
527 TestingProfileManager profile_manager(browser_process); | 530 TestingProfileManager profile_manager(browser_process); |
528 ASSERT_TRUE(profile_manager.SetUp()); | 531 ASSERT_TRUE(profile_manager.SetUp()); |
529 | 532 |
530 // Must be created after the TestingProfileManager since that creates the | 533 // Must be created after the TestingProfileManager since that creates the |
531 // LocalState for the BrowserProcess. Must be created before profiles are | 534 // LocalState for the BrowserProcess. Must be created before profiles are |
532 // constructed. | 535 // constructed. |
533 chrome::TestingIOThreadState testing_io_thread_state; | 536 chrome::TestingIOThreadState testing_io_thread_state; |
534 | 537 |
535 base::Process process = | 538 base::Process process = |
536 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); | 539 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); |
537 WaitForConnect(); | 540 WaitForConnect(); |
538 ShutdownAndWaitForExitWithTimeout(std::move(process)); | 541 ShutdownAndWaitForExitWithTimeout(std::move(process)); |
539 ServiceProcessControl::GetInstance()->Disconnect(); | 542 ServiceProcessControl::GetInstance()->Disconnect(); |
540 content::RunAllPendingInMessageLoop(); | 543 content::RunAllPendingInMessageLoop(); |
541 } | 544 } |
OLD | NEW |