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 "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/process/kill.h" | 12 #include "base/process/kill.h" |
13 #include "base/process/process.h" | 13 #include "base/process/process.h" |
14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "base/single_thread_task_runner.h" |
15 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
16 #include "base/test/multiprocess_test.h" | 17 #include "base/test/multiprocess_test.h" |
17 #include "base/test/test_timeouts.h" | 18 #include "base/test/test_timeouts.h" |
| 19 #include "base/thread_task_runner_handle.h" |
18 #include "base/time/default_tick_clock.h" | 20 #include "base/time/default_tick_clock.h" |
19 #include "base/time/time.h" | 21 #include "base/time/time.h" |
20 #include "chrome/browser/chrome_content_browser_client.h" | 22 #include "chrome/browser/chrome_content_browser_client.h" |
21 #include "chrome/browser/prefs/browser_prefs.h" | 23 #include "chrome/browser/prefs/browser_prefs.h" |
22 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 24 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
23 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 25 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
24 #include "chrome/browser/service_process/service_process_control.h" | 26 #include "chrome/browser/service_process/service_process_control.h" |
25 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 27 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
26 #include "chrome/common/chrome_content_client.h" | 28 #include "chrome/common/chrome_content_client.h" |
27 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } // namespace | 98 } // namespace |
97 | 99 |
98 class TestServiceProcess : public ServiceProcess { | 100 class TestServiceProcess : public ServiceProcess { |
99 public: | 101 public: |
100 TestServiceProcess() { } | 102 TestServiceProcess() { } |
101 ~TestServiceProcess() override {} | 103 ~TestServiceProcess() override {} |
102 | 104 |
103 bool Initialize(base::MessageLoopForUI* message_loop, | 105 bool Initialize(base::MessageLoopForUI* message_loop, |
104 ServiceProcessState* state); | 106 ServiceProcessState* state); |
105 | 107 |
106 base::MessageLoopProxy* IOMessageLoopProxy() { | 108 base::SingleThreadTaskRunner* IOMessageLoopProxy() { |
107 return io_thread_->message_loop_proxy().get(); | 109 return io_thread_->task_runner().get(); |
108 } | 110 } |
109 }; | 111 }; |
110 | 112 |
111 bool TestServiceProcess::Initialize(base::MessageLoopForUI* message_loop, | 113 bool TestServiceProcess::Initialize(base::MessageLoopForUI* message_loop, |
112 ServiceProcessState* state) { | 114 ServiceProcessState* state) { |
113 main_message_loop_ = message_loop; | 115 main_message_loop_ = message_loop; |
114 | 116 |
115 service_process_state_.reset(state); | 117 service_process_state_.reset(state); |
116 | 118 |
117 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); | 119 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 #else | 457 #else |
456 base::Process process = SpawnChild(name); | 458 base::Process process = SpawnChild(name); |
457 #endif | 459 #endif |
458 EXPECT_TRUE(process.IsValid()); | 460 EXPECT_TRUE(process.IsValid()); |
459 return process.Pass(); | 461 return process.Pass(); |
460 } | 462 } |
461 | 463 |
462 void CloudPrintProxyPolicyStartupTest::WaitForConnect() { | 464 void CloudPrintProxyPolicyStartupTest::WaitForConnect() { |
463 observer_.Wait(); | 465 observer_.Wait(); |
464 EXPECT_TRUE(CheckServiceProcessReady()); | 466 EXPECT_TRUE(CheckServiceProcessReady()); |
465 EXPECT_TRUE(base::MessageLoopProxy::current().get()); | 467 EXPECT_TRUE(base::ThreadTaskRunnerHandle::Get().get()); |
466 ServiceProcessControl::GetInstance()->SetChannel( | 468 ServiceProcessControl::GetInstance()->SetChannel( |
467 IPC::ChannelProxy::Create(GetServiceProcessChannel(), | 469 IPC::ChannelProxy::Create(GetServiceProcessChannel(), |
468 IPC::Channel::MODE_NAMED_CLIENT, | 470 IPC::Channel::MODE_NAMED_CLIENT, |
469 ServiceProcessControl::GetInstance(), | 471 ServiceProcessControl::GetInstance(), |
470 IOTaskRunner())); | 472 IOTaskRunner())); |
471 } | 473 } |
472 | 474 |
473 bool CloudPrintProxyPolicyStartupTest::Send(IPC::Message* message) { | 475 bool CloudPrintProxyPolicyStartupTest::Send(IPC::Message* message) { |
474 return ServiceProcessControl::GetInstance()->Send(message); | 476 return ServiceProcessControl::GetInstance()->Send(message); |
475 } | 477 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 } | 520 } |
519 | 521 |
520 KeyedService* CloudPrintProxyServiceFactoryForPolicyTest( | 522 KeyedService* CloudPrintProxyServiceFactoryForPolicyTest( |
521 content::BrowserContext* profile) { | 523 content::BrowserContext* profile) { |
522 CloudPrintProxyService* service = | 524 CloudPrintProxyService* service = |
523 new CloudPrintProxyService(static_cast<Profile*>(profile)); | 525 new CloudPrintProxyService(static_cast<Profile*>(profile)); |
524 service->Initialize(); | 526 service->Initialize(); |
525 return service; | 527 return service; |
526 } | 528 } |
527 | 529 |
OLD | NEW |