| 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.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/test/multiprocess_test.h" | 14 #include "base/test/multiprocess_test.h" |
| 15 #include "base/test/test_timeouts.h" | 15 #include "base/test/test_timeouts.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 17 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 18 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 18 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
| 19 #include "chrome/browser/profiles/profile_keyed_service.h" | 19 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 20 #include "chrome/browser/service/service_process_control.h" | 20 #include "chrome/browser/service/service_process_control.h" |
| 21 #include "chrome/browser/ui/browser_init.h" | 21 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/common/service_messages.h" | 24 #include "chrome/common/service_messages.h" |
| 25 #include "chrome/common/service_process_util.h" | 25 #include "chrome/common/service_process_util.h" |
| 26 #include "chrome/service/service_ipc_server.h" | 26 #include "chrome/service/service_ipc_server.h" |
| 27 #include "chrome/service/service_process.h" | 27 #include "chrome/service/service_process.h" |
| 28 #include "chrome/test/base/test_launcher_utils.h" | 28 #include "chrome/test/base/test_launcher_utils.h" |
| 29 #include "chrome/test/base/testing_browser_process.h" | 29 #include "chrome/test/base/testing_browser_process.h" |
| 30 #include "chrome/test/base/testing_pref_service.h" | 30 #include "chrome/test/base/testing_pref_service.h" |
| 31 #include "chrome/test/base/testing_profile.h" | 31 #include "chrome/test/base/testing_profile.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // IPC::Channel::Listener implementation | 296 // IPC::Channel::Listener implementation |
| 297 virtual bool OnMessageReceived(const IPC::Message& message) { return false; } | 297 virtual bool OnMessageReceived(const IPC::Message& message) { return false; } |
| 298 virtual void OnChannelConnected(int32 peer_pid); | 298 virtual void OnChannelConnected(int32 peer_pid); |
| 299 | 299 |
| 300 // MultiProcessTest implementation. | 300 // MultiProcessTest implementation. |
| 301 virtual CommandLine MakeCmdLine(const std::string& procname, | 301 virtual CommandLine MakeCmdLine(const std::string& procname, |
| 302 bool debug_on_start) OVERRIDE; | 302 bool debug_on_start) OVERRIDE; |
| 303 | 303 |
| 304 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) { | 304 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) { |
| 305 int return_code = 0; | 305 int return_code = 0; |
| 306 BrowserInit browser_init; | 306 StartupBrowserCreator browser_creator; |
| 307 return BrowserInit::ProcessCmdLineImpl(command_line, FilePath(), false, | 307 return StartupBrowserCreator::ProcessCmdLineImpl( |
| 308 profile, BrowserInit::Profiles(), | 308 command_line, FilePath(), false, profile, |
| 309 &return_code, &browser_init); | 309 StartupBrowserCreator::Profiles(), &return_code, &browser_creator); |
| 310 } | 310 } |
| 311 | 311 |
| 312 protected: | 312 protected: |
| 313 MessageLoopForUI message_loop_; | 313 MessageLoopForUI message_loop_; |
| 314 content::TestBrowserThread ui_thread_; | 314 content::TestBrowserThread ui_thread_; |
| 315 base::Thread io_thread_; | 315 base::Thread io_thread_; |
| 316 | 316 |
| 317 std::string startup_channel_id_; | 317 std::string startup_channel_id_; |
| 318 scoped_ptr<IPC::ChannelProxy> startup_channel_; | 318 scoped_ptr<IPC::ChannelProxy> startup_channel_; |
| 319 | 319 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 // No expectations on run_loop being true here; that would be a race | 532 // No expectations on run_loop being true here; that would be a race |
| 533 // condition. | 533 // condition. |
| 534 if (run_loop) | 534 if (run_loop) |
| 535 MessageLoop::current()->Run(); | 535 MessageLoop::current()->Run(); |
| 536 | 536 |
| 537 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); | 537 EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail)); |
| 538 | 538 |
| 539 ShutdownAndWaitForExitWithTimeout(handle); | 539 ShutdownAndWaitForExitWithTimeout(handle); |
| 540 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); | 540 profile_manager.DeleteTestingProfile("StartBrowserWithPolicy"); |
| 541 } | 541 } |
| OLD | NEW |