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" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 bool g_good_shutdown = false; | 83 bool g_good_shutdown = false; |
84 | 84 |
85 void ShutdownTask() { | 85 void ShutdownTask() { |
86 g_good_shutdown = true; | 86 g_good_shutdown = true; |
87 g_service_process->Shutdown(); | 87 g_service_process->Shutdown(); |
88 } | 88 } |
89 | 89 |
90 class TestStartupClientChannelListener : public IPC::Listener { | 90 class TestStartupClientChannelListener : public IPC::Listener { |
91 public: | 91 public: |
92 virtual bool OnMessageReceived(const IPC::Message& message) override { | 92 bool OnMessageReceived(const IPC::Message& message) override { return false; } |
93 return false; | |
94 } | |
95 }; | 93 }; |
96 | 94 |
97 } // namespace | 95 } // namespace |
98 | 96 |
99 class TestServiceProcess : public ServiceProcess { | 97 class TestServiceProcess : public ServiceProcess { |
100 public: | 98 public: |
101 TestServiceProcess() { } | 99 TestServiceProcess() { } |
102 virtual ~TestServiceProcess() { } | 100 ~TestServiceProcess() override {} |
103 | 101 |
104 bool Initialize(base::MessageLoopForUI* message_loop, | 102 bool Initialize(base::MessageLoopForUI* message_loop, |
105 ServiceProcessState* state); | 103 ServiceProcessState* state); |
106 | 104 |
107 base::MessageLoopProxy* IOMessageLoopProxy() { | 105 base::MessageLoopProxy* IOMessageLoopProxy() { |
108 return io_thread_->message_loop_proxy().get(); | 106 return io_thread_->message_loop_proxy().get(); |
109 } | 107 } |
110 }; | 108 }; |
111 | 109 |
112 bool TestServiceProcess::Initialize(base::MessageLoopForUI* message_loop, | 110 bool TestServiceProcess::Initialize(base::MessageLoopForUI* message_loop, |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 307 |
310 scoped_refptr<base::MessageLoopProxy> IOMessageLoopProxy() { | 308 scoped_refptr<base::MessageLoopProxy> IOMessageLoopProxy() { |
311 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 309 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
312 } | 310 } |
313 base::ProcessHandle Launch(const std::string& name); | 311 base::ProcessHandle Launch(const std::string& name); |
314 void WaitForConnect(); | 312 void WaitForConnect(); |
315 bool Send(IPC::Message* message); | 313 bool Send(IPC::Message* message); |
316 void ShutdownAndWaitForExitWithTimeout(base::ProcessHandle handle); | 314 void ShutdownAndWaitForExitWithTimeout(base::ProcessHandle handle); |
317 | 315 |
318 // IPC::Listener implementation | 316 // IPC::Listener implementation |
319 virtual bool OnMessageReceived(const IPC::Message& message) override { | 317 bool OnMessageReceived(const IPC::Message& message) override { return false; } |
320 return false; | 318 void OnChannelConnected(int32 peer_pid) override; |
321 } | |
322 virtual void OnChannelConnected(int32 peer_pid) override; | |
323 | 319 |
324 // MultiProcessTest implementation. | 320 // MultiProcessTest implementation. |
325 virtual CommandLine MakeCmdLine(const std::string& procname) override; | 321 CommandLine MakeCmdLine(const std::string& procname) override; |
326 | 322 |
327 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) { | 323 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) { |
328 int return_code = 0; | 324 int return_code = 0; |
329 StartupBrowserCreator browser_creator; | 325 StartupBrowserCreator browser_creator; |
330 return StartupBrowserCreator::ProcessCmdLineImpl( | 326 return StartupBrowserCreator::ProcessCmdLineImpl( |
331 command_line, base::FilePath(), false, profile, | 327 command_line, base::FilePath(), false, profile, |
332 StartupBrowserCreator::Profiles(), &return_code, &browser_creator); | 328 StartupBrowserCreator::Profiles(), &return_code, &browser_creator); |
333 } | 329 } |
334 | 330 |
335 protected: | 331 protected: |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 // condition. | 619 // condition. |
624 if (should_run_loop) | 620 if (should_run_loop) |
625 run_loop.Run(); | 621 run_loop.Run(); |
626 | 622 |
627 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); | 623 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); |
628 | 624 |
629 ShutdownAndWaitForExitWithTimeout(handle); | 625 ShutdownAndWaitForExitWithTimeout(handle); |
630 content::RunAllPendingInMessageLoop(); | 626 content::RunAllPendingInMessageLoop(); |
631 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); | 627 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); |
632 } | 628 } |
OLD | NEW |