| 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 virtual bool OnMessageReceived(const IPC::Message& message) override { |
| 93 return false; | 93 return false; |
| 94 } | 94 } |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace | 97 } // namespace |
| 98 | 98 |
| 99 class TestServiceProcess : public ServiceProcess { | 99 class TestServiceProcess : public ServiceProcess { |
| 100 public: | 100 public: |
| 101 TestServiceProcess() { } | 101 TestServiceProcess() { } |
| 102 virtual ~TestServiceProcess() { } | 102 virtual ~TestServiceProcess() { } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 return CloudPrintMockService_Main( | 297 return CloudPrintMockService_Main( |
| 298 base::Bind(&SetServiceWillBeDisabledExpectations)); | 298 base::Bind(&SetServiceWillBeDisabledExpectations)); |
| 299 } | 299 } |
| 300 | 300 |
| 301 class CloudPrintProxyPolicyStartupTest : public base::MultiProcessTest, | 301 class CloudPrintProxyPolicyStartupTest : public base::MultiProcessTest, |
| 302 public IPC::Listener { | 302 public IPC::Listener { |
| 303 public: | 303 public: |
| 304 CloudPrintProxyPolicyStartupTest(); | 304 CloudPrintProxyPolicyStartupTest(); |
| 305 virtual ~CloudPrintProxyPolicyStartupTest(); | 305 virtual ~CloudPrintProxyPolicyStartupTest(); |
| 306 | 306 |
| 307 virtual void SetUp() OVERRIDE; | 307 virtual void SetUp() override; |
| 308 virtual void TearDown() OVERRIDE; | 308 virtual void TearDown() override; |
| 309 | 309 |
| 310 scoped_refptr<base::MessageLoopProxy> IOMessageLoopProxy() { | 310 scoped_refptr<base::MessageLoopProxy> IOMessageLoopProxy() { |
| 311 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 311 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 312 } | 312 } |
| 313 base::ProcessHandle Launch(const std::string& name); | 313 base::ProcessHandle Launch(const std::string& name); |
| 314 void WaitForConnect(); | 314 void WaitForConnect(); |
| 315 bool Send(IPC::Message* message); | 315 bool Send(IPC::Message* message); |
| 316 void ShutdownAndWaitForExitWithTimeout(base::ProcessHandle handle); | 316 void ShutdownAndWaitForExitWithTimeout(base::ProcessHandle handle); |
| 317 | 317 |
| 318 // IPC::Listener implementation | 318 // IPC::Listener implementation |
| 319 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | 319 virtual bool OnMessageReceived(const IPC::Message& message) override { |
| 320 return false; | 320 return false; |
| 321 } | 321 } |
| 322 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 322 virtual void OnChannelConnected(int32 peer_pid) override; |
| 323 | 323 |
| 324 // MultiProcessTest implementation. | 324 // MultiProcessTest implementation. |
| 325 virtual CommandLine MakeCmdLine(const std::string& procname) OVERRIDE; | 325 virtual CommandLine MakeCmdLine(const std::string& procname) override; |
| 326 | 326 |
| 327 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) { | 327 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) { |
| 328 int return_code = 0; | 328 int return_code = 0; |
| 329 StartupBrowserCreator browser_creator; | 329 StartupBrowserCreator browser_creator; |
| 330 return StartupBrowserCreator::ProcessCmdLineImpl( | 330 return StartupBrowserCreator::ProcessCmdLineImpl( |
| 331 command_line, base::FilePath(), false, profile, | 331 command_line, base::FilePath(), false, profile, |
| 332 StartupBrowserCreator::Profiles(), &return_code, &browser_creator); | 332 StartupBrowserCreator::Profiles(), &return_code, &browser_creator); |
| 333 } | 333 } |
| 334 | 334 |
| 335 protected: | 335 protected: |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 // condition. | 623 // condition. |
| 624 if (should_run_loop) | 624 if (should_run_loop) |
| 625 run_loop.Run(); | 625 run_loop.Run(); |
| 626 | 626 |
| 627 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); | 627 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); |
| 628 | 628 |
| 629 ShutdownAndWaitForExitWithTimeout(handle); | 629 ShutdownAndWaitForExitWithTimeout(handle); |
| 630 content::RunAllPendingInMessageLoop(); | 630 content::RunAllPendingInMessageLoop(); |
| 631 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); | 631 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); |
| 632 } | 632 } |
| OLD | NEW |