| 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 10 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 11 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" | 11 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
| 12 #include "chrome/browser/service/service_process_control.h" | 12 #include "chrome/browser/service/service_process_control.h" |
| 13 #include "chrome/browser/ui/browser_init.h" | 13 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/cloud_print/cloud_print_proxy_info.h" | 15 #include "chrome/common/cloud_print/cloud_print_proxy_info.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/service_messages.h" | 17 #include "chrome/common/service_messages.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" | 18 #include "chrome/test/base/testing_browser_process.h" |
| 19 #include "chrome/test/base/testing_pref_service.h" | 19 #include "chrome/test/base/testing_pref_service.h" |
| 20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 21 #include "chrome/test/base/testing_profile_manager.h" | 21 #include "chrome/test/base/testing_profile_manager.h" |
| 22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/test/test_browser_thread.h" | 23 #include "content/test/test_browser_thread.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 }; | 181 }; |
| 182 | 182 |
| 183 class CloudPrintProxyPolicyTest : public ::testing::Test { | 183 class CloudPrintProxyPolicyTest : public ::testing::Test { |
| 184 public: | 184 public: |
| 185 CloudPrintProxyPolicyTest() | 185 CloudPrintProxyPolicyTest() |
| 186 : ui_thread_(content::BrowserThread::UI, &message_loop_) { | 186 : ui_thread_(content::BrowserThread::UI, &message_loop_) { |
| 187 } | 187 } |
| 188 | 188 |
| 189 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) { | 189 bool LaunchBrowser(const CommandLine& command_line, Profile* profile) { |
| 190 int return_code = 0; | 190 int return_code = 0; |
| 191 BrowserInit browser_init; | 191 StartupBrowserCreator browser_creator; |
| 192 return BrowserInit::ProcessCmdLineImpl(command_line, FilePath(), false, | 192 return StartupBrowserCreator::ProcessCmdLineImpl( |
| 193 profile, BrowserInit::Profiles(), | 193 command_line, FilePath(), false, profile, |
| 194 &return_code, &browser_init); | 194 StartupBrowserCreator::Profiles(), &return_code, &browser_creator); |
| 195 } | 195 } |
| 196 | 196 |
| 197 protected: | 197 protected: |
| 198 MessageLoopForUI message_loop_; | 198 MessageLoopForUI message_loop_; |
| 199 content::TestBrowserThread ui_thread_; | 199 content::TestBrowserThread ui_thread_; |
| 200 TestingProfile profile_; | 200 TestingProfile profile_; |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 TEST_F(CloudPrintProxyPolicyTest, VerifyExpectations) { | 203 TEST_F(CloudPrintProxyPolicyTest, VerifyExpectations) { |
| 204 MockServiceProcessControl mock_control; | 204 MockServiceProcessControl mock_control; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 426 |
| 427 service->GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( | 427 service->GetMockServiceProcessControl()->SetConnectSuccessMockExpectations( |
| 428 MockServiceProcessControl::kServiceStateEnabled, true); | 428 MockServiceProcessControl::kServiceStateEnabled, true); |
| 429 service->GetMockServiceProcessControl()->SetWillBeDisabledExpectations(); | 429 service->GetMockServiceProcessControl()->SetWillBeDisabledExpectations(); |
| 430 | 430 |
| 431 service->Initialize(); | 431 service->Initialize(); |
| 432 MessageLoop::current()->RunAllPending(); | 432 MessageLoop::current()->RunAllPending(); |
| 433 return service; | 433 return service; |
| 434 } | 434 } |
| 435 | 435 |
| 436 TEST_F(CloudPrintProxyPolicyTest, StartBrowserInitWithCommandLine) { | 436 TEST_F(CloudPrintProxyPolicyTest, StartupBrowserCreatorWithCommandLine) { |
| 437 TestingPrefService* prefs = profile_.GetTestingPrefService(); | 437 TestingPrefService* prefs = profile_.GetTestingPrefService(); |
| 438 prefs->SetUserPref(prefs::kCloudPrintEmail, | 438 prefs->SetUserPref(prefs::kCloudPrintEmail, |
| 439 Value::CreateStringValue(std::string())); | 439 Value::CreateStringValue(std::string())); |
| 440 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, | 440 prefs->SetManagedPref(prefs::kCloudPrintProxyEnabled, |
| 441 Value::CreateBooleanValue(false)); | 441 Value::CreateBooleanValue(false)); |
| 442 | 442 |
| 443 CloudPrintProxyServiceFactory::GetInstance()-> | 443 CloudPrintProxyServiceFactory::GetInstance()-> |
| 444 SetTestingFactory(&profile_, TestCloudPrintProxyServiceFactory); | 444 SetTestingFactory(&profile_, TestCloudPrintProxyServiceFactory); |
| 445 | 445 |
| 446 CommandLine command_line(CommandLine::NO_PROGRAM); | 446 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 447 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); | 447 command_line.AppendSwitch(switches::kCheckCloudPrintConnectorPolicy); |
| 448 | 448 |
| 449 EXPECT_FALSE(LaunchBrowser(command_line, &profile_)); | 449 EXPECT_FALSE(LaunchBrowser(command_line, &profile_)); |
| 450 MessageLoop::current()->RunAllPending(); | 450 MessageLoop::current()->RunAllPending(); |
| 451 } | 451 } |
| OLD | NEW |