| 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 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/process/kill.h" | 17 #include "base/process/kill.h" |
| 18 #include "base/process/process.h" | 18 #include "base/process/process.h" |
| 19 #include "base/rand_util.h" | 19 #include "base/rand_util.h" |
| 20 #include "base/run_loop.h" |
| 20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 21 #include "base/synchronization/waitable_event.h" | 22 #include "base/synchronization/waitable_event.h" |
| 22 #include "base/test/multiprocess_test.h" | 23 #include "base/test/multiprocess_test.h" |
| 23 #include "base/test/test_timeouts.h" | 24 #include "base/test/test_timeouts.h" |
| 24 #include "base/threading/platform_thread.h" | 25 #include "base/threading/platform_thread.h" |
| 25 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
| 26 #include "base/time/default_tick_clock.h" | 27 #include "base/time/default_tick_clock.h" |
| 27 #include "base/time/time.h" | 28 #include "base/time/time.h" |
| 28 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 29 #include "chrome/browser/chrome_content_browser_client.h" | 30 #include "chrome/browser/chrome_content_browser_client.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 std::string startup_channel_name = | 277 std::string startup_channel_name = |
| 277 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 278 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 278 switches::kProcessChannelID); | 279 switches::kProcessChannelID); |
| 279 std::unique_ptr<IPC::ChannelProxy> startup_channel; | 280 std::unique_ptr<IPC::ChannelProxy> startup_channel; |
| 280 startup_channel = | 281 startup_channel = |
| 281 IPC::ChannelProxy::Create(startup_channel_name, | 282 IPC::ChannelProxy::Create(startup_channel_name, |
| 282 IPC::Channel::MODE_CLIENT, | 283 IPC::Channel::MODE_CLIENT, |
| 283 &listener, | 284 &listener, |
| 284 service_process.io_task_runner()); | 285 service_process.io_task_runner()); |
| 285 | 286 |
| 286 main_message_loop.Run(); | 287 base::RunLoop().Run(); |
| 287 if (!Mock::VerifyAndClearExpectations(&server)) | 288 if (!Mock::VerifyAndClearExpectations(&server)) |
| 288 return kExpectationsNotMet; | 289 return kExpectationsNotMet; |
| 289 if (!g_good_shutdown) | 290 if (!g_good_shutdown) |
| 290 return kShutdownNotGood; | 291 return kShutdownNotGood; |
| 291 return 0; | 292 return 0; |
| 292 } | 293 } |
| 293 | 294 |
| 294 void SetServiceEnabledExpectations(MockServiceIPCServer* server) { | 295 void SetServiceEnabledExpectations(MockServiceIPCServer* server) { |
| 295 server->SetServiceEnabledExpectations(); | 296 server->SetServiceEnabledExpectations(); |
| 296 } | 297 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 // LocalState for the BrowserProcess. Must be created before profiles are | 521 // LocalState for the BrowserProcess. Must be created before profiles are |
| 521 // constructed. | 522 // constructed. |
| 522 chrome::TestingIOThreadState testing_io_thread_state; | 523 chrome::TestingIOThreadState testing_io_thread_state; |
| 523 | 524 |
| 524 base::Process process = | 525 base::Process process = |
| 525 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); | 526 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); |
| 526 WaitForConnect(); | 527 WaitForConnect(); |
| 527 ShutdownAndWaitForExitWithTimeout(std::move(process)); | 528 ShutdownAndWaitForExitWithTimeout(std::move(process)); |
| 528 content::RunAllPendingInMessageLoop(); | 529 content::RunAllPendingInMessageLoop(); |
| 529 } | 530 } |
| OLD | NEW |