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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/policy/browser_policy_connector.h" | 8 #include "chrome/browser/policy/browser_policy_connector.h" |
9 #include "chrome/browser/policy/mock_device_management_service.h" | 9 #include "chrome/browser/policy/mock_device_management_service.h" |
10 #include "chrome/browser/policy/mock_user_cloud_policy_store.h" | 10 #include "chrome/browser/policy/mock_user_cloud_policy_store.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 virtual void SetUp() OVERRIDE { | 70 virtual void SetUp() OVERRIDE { |
71 device_management_service_ = new MockDeviceManagementService(); | 71 device_management_service_ = new MockDeviceManagementService(); |
72 g_browser_process->browser_policy_connector()-> | 72 g_browser_process->browser_policy_connector()-> |
73 SetDeviceManagementServiceForTesting( | 73 SetDeviceManagementServiceForTesting( |
74 scoped_ptr<DeviceManagementService>(device_management_service_)); | 74 scoped_ptr<DeviceManagementService>(device_management_service_)); |
75 | 75 |
76 g_browser_process->browser_policy_connector()->Init(); | 76 g_browser_process->browser_policy_connector()->Init(); |
77 | 77 |
78 local_state_.reset(new TestingPrefServiceSimple); | 78 local_state_.reset(new TestingPrefServiceSimple); |
79 chrome::RegisterLocalState(local_state_.get()); | 79 chrome::RegisterLocalState(local_state_.get()); |
80 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState( | 80 TestingBrowserProcess::GetGlobal()->SetLocalState( |
81 local_state_.get()); | 81 local_state_.get()); |
82 | 82 |
83 // Create a testing profile with cloud-policy-on-signin enabled, and bring | 83 // Create a testing profile with cloud-policy-on-signin enabled, and bring |
84 // up a UserCloudPolicyManager with a MockUserCloudPolicyStore. | 84 // up a UserCloudPolicyManager with a MockUserCloudPolicyStore. |
85 scoped_ptr<TestingPrefServiceSyncable> prefs( | 85 scoped_ptr<TestingPrefServiceSyncable> prefs( |
86 new TestingPrefServiceSyncable()); | 86 new TestingPrefServiceSyncable()); |
87 Profile::RegisterUserPrefs(prefs.get()); | 87 Profile::RegisterUserPrefs(prefs.get()); |
88 chrome::RegisterUserPrefs(prefs.get()); | 88 chrome::RegisterUserPrefs(prefs.get()); |
89 prefs->SetUserPref(prefs::kLoadCloudPolicyOnSignin, | 89 prefs->SetUserPref(prefs::kLoadCloudPolicyOnSignin, |
90 Value::CreateBooleanValue(true)); | 90 Value::CreateBooleanValue(true)); |
(...skipping 12 matching lines...) Expand all Loading... |
103 // Make sure the UserPolicySigninService is created. | 103 // Make sure the UserPolicySigninService is created. |
104 UserPolicySigninServiceFactory::GetForProfile(profile_.get()); | 104 UserPolicySigninServiceFactory::GetForProfile(profile_.get()); |
105 Mock::VerifyAndClearExpectations(mock_store_); | 105 Mock::VerifyAndClearExpectations(mock_store_); |
106 url_factory_.set_remove_fetcher_on_delete(true); | 106 url_factory_.set_remove_fetcher_on_delete(true); |
107 } | 107 } |
108 | 108 |
109 virtual void TearDown() OVERRIDE { | 109 virtual void TearDown() OVERRIDE { |
110 // Free the profile before we clear out the browser prefs. | 110 // Free the profile before we clear out the browser prefs. |
111 profile_.reset(); | 111 profile_.reset(); |
112 TestingBrowserProcess* testing_browser_process = | 112 TestingBrowserProcess* testing_browser_process = |
113 static_cast<TestingBrowserProcess*>(g_browser_process); | 113 TestingBrowserProcess::GetGlobal(); |
114 testing_browser_process->SetLocalState(NULL); | 114 testing_browser_process->SetLocalState(NULL); |
115 local_state_.reset(); | 115 local_state_.reset(); |
116 testing_browser_process->SetBrowserPolicyConnector(NULL); | 116 testing_browser_process->SetBrowserPolicyConnector(NULL); |
117 base::RunLoop run_loop; | 117 base::RunLoop run_loop; |
118 run_loop.RunUntilIdle(); | 118 run_loop.RunUntilIdle(); |
119 } | 119 } |
120 | 120 |
121 bool IsRequestActive() { | 121 bool IsRequestActive() { |
122 return url_factory_.GetFetcherByID(0); | 122 return url_factory_.GetFetcherByID(0); |
123 } | 123 } |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 SigninManagerFactory::GetForProfile(profile_.get())->SignOut(); | 610 SigninManagerFactory::GetForProfile(profile_.get())->SignOut(); |
611 ASSERT_FALSE(manager_->core()->service()); | 611 ASSERT_FALSE(manager_->core()->service()); |
612 | 612 |
613 // Now sign in again. | 613 // Now sign in again. |
614 TestSuccessfulSignin(); | 614 TestSuccessfulSignin(); |
615 } | 615 } |
616 | 616 |
617 } // namespace | 617 } // namespace |
618 | 618 |
619 } // namespace policy | 619 } // namespace policy |
OLD | NEW |