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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 bool g_good_shutdown = false; | 74 bool g_good_shutdown = false; |
75 | 75 |
76 void ShutdownTask() { | 76 void ShutdownTask() { |
77 g_good_shutdown = true; | 77 g_good_shutdown = true; |
78 g_service_process->Shutdown(); | 78 g_service_process->Shutdown(); |
79 } | 79 } |
80 | 80 |
81 class TestStartupClientChannelListener : public IPC::Listener { | 81 class TestStartupClientChannelListener : public IPC::Listener { |
82 public: | 82 public: |
83 virtual bool OnMessageReceived(const IPC::Message& message) { return false; } | 83 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
| 84 return false; |
| 85 } |
84 }; | 86 }; |
85 | 87 |
86 } // namespace | 88 } // namespace |
87 | 89 |
88 class TestServiceProcess : public ServiceProcess { | 90 class TestServiceProcess : public ServiceProcess { |
89 public: | 91 public: |
90 TestServiceProcess() { } | 92 TestServiceProcess() { } |
91 virtual ~TestServiceProcess() { } | 93 virtual ~TestServiceProcess() { } |
92 | 94 |
93 bool Initialize(MessageLoopForUI* message_loop, ServiceProcessState* state); | 95 bool Initialize(MessageLoopForUI* message_loop, ServiceProcessState* state); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 278 |
277 MULTIPROCESS_IPC_TEST_MAIN(CloudPrintMockService_StartEnabledExpectDisabled) { | 279 MULTIPROCESS_IPC_TEST_MAIN(CloudPrintMockService_StartEnabledExpectDisabled) { |
278 return CloudPrintMockService_Main( | 280 return CloudPrintMockService_Main( |
279 base::Bind(&SetServiceWillBeDisabledExpectations)); | 281 base::Bind(&SetServiceWillBeDisabledExpectations)); |
280 } | 282 } |
281 | 283 |
282 class CloudPrintProxyPolicyStartupTest : public base::MultiProcessTest, | 284 class CloudPrintProxyPolicyStartupTest : public base::MultiProcessTest, |
283 public IPC::Listener { | 285 public IPC::Listener { |
284 public: | 286 public: |
285 CloudPrintProxyPolicyStartupTest(); | 287 CloudPrintProxyPolicyStartupTest(); |
286 ~CloudPrintProxyPolicyStartupTest(); | 288 virtual ~CloudPrintProxyPolicyStartupTest(); |
287 | 289 |
288 virtual void SetUp(); | 290 virtual void SetUp(); |
289 base::MessageLoopProxy* IOMessageLoopProxy() { | 291 base::MessageLoopProxy* IOMessageLoopProxy() { |
290 return io_thread_.message_loop_proxy(); | 292 return io_thread_.message_loop_proxy(); |
291 } | 293 } |
292 base::ProcessHandle Launch(const std::string& name); | 294 base::ProcessHandle Launch(const std::string& name); |
293 void WaitForConnect(); | 295 void WaitForConnect(); |
294 bool Send(IPC::Message* message); | 296 bool Send(IPC::Message* message); |
295 void ShutdownAndWaitForExitWithTimeout(base::ProcessHandle handle); | 297 void ShutdownAndWaitForExitWithTimeout(base::ProcessHandle handle); |
296 | 298 |
297 // IPC::Listener implementation | 299 // IPC::Listener implementation |
298 virtual bool OnMessageReceived(const IPC::Message& message) { return false; } | 300 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
299 virtual void OnChannelConnected(int32 peer_pid); | 301 return false; |
| 302 } |
| 303 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
300 | 304 |
301 // MultiProcessTest implementation. | 305 // MultiProcessTest implementation. |
302 virtual CommandLine MakeCmdLine(const std::string& procname, | 306 virtual CommandLine MakeCmdLine(const std::string& procname, |
303 bool debug_on_start) OVERRIDE; | 307 bool debug_on_start) OVERRIDE; |
304 | 308 |
305 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) { | 309 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) { |
306 int return_code = 0; | 310 int return_code = 0; |
307 StartupBrowserCreator browser_creator; | 311 StartupBrowserCreator browser_creator; |
308 return StartupBrowserCreator::ProcessCmdLineImpl( | 312 return StartupBrowserCreator::ProcessCmdLineImpl( |
309 command_line, FilePath(), false, profile, | 313 command_line, FilePath(), false, profile, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 // No expectations on run_loop being true here; that would be a race | 537 // No expectations on run_loop being true here; that would be a race |
534 // condition. | 538 // condition. |
535 if (run_loop) | 539 if (run_loop) |
536 MessageLoop::current()->Run(); | 540 MessageLoop::current()->Run(); |
537 | 541 |
538 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); | 542 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); |
539 | 543 |
540 ShutdownAndWaitForExitWithTimeout(handle); | 544 ShutdownAndWaitForExitWithTimeout(handle); |
541 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); | 545 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); |
542 } | 546 } |
OLD | NEW |