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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/message_loop/message_loop.h" | |
7 #include "base/message_loop/message_loop_proxy.h" | |
8 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
9 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/thread_task_runner_handle.h" |
10 #include "base/time/time.h" | 9 #include "base/time/time.h" |
11 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 12 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
14 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" | 13 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" |
15 #include "chrome/browser/prefs/browser_prefs.h" | 14 #include "chrome/browser/prefs/browser_prefs.h" |
16 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/signin/account_tracker_service_factory.h" | 16 #include "chrome/browser/signin/account_tracker_service_factory.h" |
18 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 17 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
19 #include "chrome/browser/signin/fake_account_tracker_service.h" | 18 #include "chrome/browser/signin/fake_account_tracker_service.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 102 |
104 UserCloudPolicyManager* BuildCloudPolicyManager( | 103 UserCloudPolicyManager* BuildCloudPolicyManager( |
105 content::BrowserContext* context) { | 104 content::BrowserContext* context) { |
106 MockUserCloudPolicyStore* store = new MockUserCloudPolicyStore(); | 105 MockUserCloudPolicyStore* store = new MockUserCloudPolicyStore(); |
107 EXPECT_CALL(*store, Load()).Times(AnyNumber()); | 106 EXPECT_CALL(*store, Load()).Times(AnyNumber()); |
108 | 107 |
109 return new UserCloudPolicyManager( | 108 return new UserCloudPolicyManager( |
110 scoped_ptr<UserCloudPolicyStore>(store), | 109 scoped_ptr<UserCloudPolicyStore>(store), |
111 base::FilePath(), | 110 base::FilePath(), |
112 scoped_ptr<CloudExternalDataManager>(), | 111 scoped_ptr<CloudExternalDataManager>(), |
113 base::MessageLoopProxy::current(), | 112 base::ThreadTaskRunnerHandle::Get(), |
114 base::MessageLoopProxy::current(), | 113 base::ThreadTaskRunnerHandle::Get(), |
115 base::MessageLoopProxy::current()); | 114 base::ThreadTaskRunnerHandle::Get()); |
116 } | 115 } |
117 | 116 |
118 class UserPolicySigninServiceTest : public testing::Test { | 117 class UserPolicySigninServiceTest : public testing::Test { |
119 public: | 118 public: |
120 UserPolicySigninServiceTest() | 119 UserPolicySigninServiceTest() |
121 : mock_store_(NULL), | 120 : mock_store_(NULL), |
122 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 121 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
123 register_completed_(false) {} | 122 register_completed_(false) {} |
124 | 123 |
125 MOCK_METHOD1(OnPolicyRefresh, void(bool)); | 124 MOCK_METHOD1(OnPolicyRefresh, void(bool)); |
(...skipping 25 matching lines...) Expand all Loading... |
151 ASSERT_TRUE(IsRequestActive()); | 150 ASSERT_TRUE(IsRequestActive()); |
152 } | 151 } |
153 | 152 |
154 void SetUp() override { | 153 void SetUp() override { |
155 UserPolicySigninServiceFactory::SetDeviceManagementServiceForTesting( | 154 UserPolicySigninServiceFactory::SetDeviceManagementServiceForTesting( |
156 &device_management_service_); | 155 &device_management_service_); |
157 | 156 |
158 local_state_.reset(new TestingPrefServiceSimple); | 157 local_state_.reset(new TestingPrefServiceSimple); |
159 chrome::RegisterLocalState(local_state_->registry()); | 158 chrome::RegisterLocalState(local_state_->registry()); |
160 system_request_context_getter_ = new net::TestURLRequestContextGetter( | 159 system_request_context_getter_ = new net::TestURLRequestContextGetter( |
161 base::MessageLoopProxy::current()); | 160 base::ThreadTaskRunnerHandle::Get()); |
162 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( | 161 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( |
163 system_request_context_getter_.get()); | 162 system_request_context_getter_.get()); |
164 TestingBrowserProcess::GetGlobal()->SetLocalState(local_state_.get()); | 163 TestingBrowserProcess::GetGlobal()->SetLocalState(local_state_.get()); |
165 | 164 |
166 g_browser_process->browser_policy_connector()->Init( | 165 g_browser_process->browser_policy_connector()->Init( |
167 local_state_.get(), system_request_context_getter_); | 166 local_state_.get(), system_request_context_getter_); |
168 | 167 |
169 // Create a testing profile with cloud-policy-on-signin enabled, and bring | 168 // Create a testing profile with cloud-policy-on-signin enabled, and bring |
170 // up a UserCloudPolicyManager with a MockUserCloudPolicyStore. | 169 // up a UserCloudPolicyManager with a MockUserCloudPolicyStore. |
171 scoped_ptr<TestingPrefServiceSyncable> prefs( | 170 scoped_ptr<TestingPrefServiceSyncable> prefs( |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 base::RunLoop().RunUntilIdle(); | 830 base::RunLoop().RunUntilIdle(); |
832 EXPECT_FALSE(manager_->IsClientRegistered()); | 831 EXPECT_FALSE(manager_->IsClientRegistered()); |
833 #if !defined(OS_ANDROID) | 832 #if !defined(OS_ANDROID) |
834 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); | 833 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); |
835 #endif | 834 #endif |
836 } | 835 } |
837 | 836 |
838 } // namespace | 837 } // namespace |
839 | 838 |
840 } // namespace policy | 839 } // namespace policy |
OLD | NEW |