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 <memory> | 5 #include <memory> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 const std::string& client_id) { | 113 const std::string& client_id) { |
114 register_completed_ = true; | 114 register_completed_ = true; |
115 dm_token_ = dm_token; | 115 dm_token_ = dm_token; |
116 client_id_ = client_id; | 116 client_id_ = client_id; |
117 } | 117 } |
118 | 118 |
119 void RegisterPolicyClientWithCallback(UserPolicySigninService* service) { | 119 void RegisterPolicyClientWithCallback(UserPolicySigninService* service) { |
120 // Policy client registration on Android depends on Token Service having | 120 // Policy client registration on Android depends on Token Service having |
121 // a valid login token, while on other platforms, the login refresh token | 121 // a valid login token, while on other platforms, the login refresh token |
122 // is specified directly. | 122 // is specified directly. |
| 123 UserPolicySigninServiceBase::PolicyRegistrationCallback callback = |
| 124 base::Bind(&UserPolicySigninServiceTest::OnRegisterCompleted, |
| 125 base::Unretained(this)); |
123 #if defined(OS_ANDROID) | 126 #if defined(OS_ANDROID) |
124 GetTokenService()->UpdateCredentials( | 127 GetTokenService()->UpdateCredentials( |
125 AccountTrackerService::PickAccountIdForAccount( | 128 AccountTrackerService::PickAccountIdForAccount( |
126 profile_.get()->GetPrefs(), kTestGaiaId, kTestUser), | 129 profile_.get()->GetPrefs(), kTestGaiaId, kTestUser), |
127 "oauth2_login_refresh_token"); | 130 "oauth2_login_refresh_token"); |
| 131 service->RegisterForPolicyWithAccountId(kTestUser, kTestGaiaId, callback); |
| 132 #else |
| 133 service->RegisterForPolicyWithLoginToken(kTestUser, "mock_oauth_token", |
| 134 callback); |
128 #endif | 135 #endif |
129 service->RegisterForPolicy( | |
130 kTestUser, | |
131 #if defined(OS_ANDROID) | |
132 kTestGaiaId, | |
133 #else | |
134 "mock_oauth_token", | |
135 #endif | |
136 base::Bind(&UserPolicySigninServiceTest::OnRegisterCompleted, | |
137 base::Unretained(this))); | |
138 ASSERT_TRUE(IsRequestActive()); | 136 ASSERT_TRUE(IsRequestActive()); |
139 } | 137 } |
140 | 138 |
141 void SetUp() override { | 139 void SetUp() override { |
142 UserPolicySigninServiceFactory::SetDeviceManagementServiceForTesting( | 140 UserPolicySigninServiceFactory::SetDeviceManagementServiceForTesting( |
143 &device_management_service_); | 141 &device_management_service_); |
144 | 142 |
145 local_state_.reset(new TestingPrefServiceSimple); | 143 local_state_.reset(new TestingPrefServiceSimple); |
146 chrome::RegisterLocalState(local_state_->registry()); | 144 chrome::RegisterLocalState(local_state_->registry()); |
147 system_request_context_getter_ = new net::TestURLRequestContextGetter( | 145 system_request_context_getter_ = new net::TestURLRequestContextGetter( |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 base::RunLoop().RunUntilIdle(); | 819 base::RunLoop().RunUntilIdle(); |
822 EXPECT_FALSE(manager_->IsClientRegistered()); | 820 EXPECT_FALSE(manager_->IsClientRegistered()); |
823 #if !defined(OS_ANDROID) | 821 #if !defined(OS_ANDROID) |
824 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); | 822 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); |
825 #endif | 823 #endif |
826 } | 824 } |
827 | 825 |
828 } // namespace | 826 } // namespace |
829 | 827 |
830 } // namespace policy | 828 } // namespace policy |
OLD | NEW |