OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.
h" | 5 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.
h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include "base/mac/scoped_block.h" | 9 #include "base/mac/scoped_block.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "google_apis/gaia/gaia_auth_util.h" | 11 #include "google_apis/gaia/gaia_auth_util.h" |
12 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 12 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
13 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" | 13 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" |
14 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_interact
ion_manager.h" | 14 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_interact
ion_manager.h" |
15 #include "ios/public/provider/chrome/browser/signin/signin_resources_provider.h" | 15 #include "ios/public/provider/chrome/browser/signin/signin_resources_provider.h" |
16 | 16 |
17 using ::testing::_; | 17 using ::testing::_; |
18 using ::testing::Invoke; | 18 using ::testing::Invoke; |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 void FakeGetAccessToken(ChromeIdentity*, | 22 void FakeGetAccessToken(ChromeIdentity*, |
23 const std::string&, | 23 const std::string&, |
24 const std::string&, | 24 const std::string&, |
25 const std::set<std::string>&, | 25 const std::set<std::string>&, |
26 const ios::AccessTokenCallback& callback) { | 26 ios::AccessTokenCallback callback) { |
27 base::mac::ScopedBlock<ios::AccessTokenCallback> safe_callback( | 27 base::mac::ScopedBlock<ios::AccessTokenCallback> safe_callback( |
28 [callback copy]); | 28 [callback copy]); |
29 | 29 |
30 // |GetAccessToken| is normally an asynchronous operation (that requires some | 30 // |GetAccessToken| is normally an asynchronous operation (that requires some |
31 // network calls), this is replicated here by dispatching it. | 31 // network calls), this is replicated here by dispatching it. |
32 dispatch_async(dispatch_get_main_queue(), ^{ | 32 dispatch_async(dispatch_get_main_queue(), ^{ |
33 // Token and expiration date. It should be larger than typical test | 33 // Token and expiration date. It should be larger than typical test |
34 // execution because tests usually setup mock to expect one token request | 34 // execution because tests usually setup mock to expect one token request |
35 // and then rely on access token being served from cache. | 35 // and then rely on access token being served from cache. |
36 NSTimeInterval expiration = 60.0; | 36 NSTimeInterval expiration = 60.0; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 callback(nil); | 208 callback(nil); |
209 }); | 209 }); |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 void FakeChromeIdentityService::GetAccessToken( | 213 void FakeChromeIdentityService::GetAccessToken( |
214 ChromeIdentity* identity, | 214 ChromeIdentity* identity, |
215 const std::string& client_id, | 215 const std::string& client_id, |
216 const std::string& client_secret, | 216 const std::string& client_secret, |
217 const std::set<std::string>& scopes, | 217 const std::set<std::string>& scopes, |
218 const ios::AccessTokenCallback& callback) { | 218 ios::AccessTokenCallback callback) { |
219 FakeGetAccessToken(identity, client_id, client_secret, scopes, callback); | 219 FakeGetAccessToken(identity, client_id, client_secret, scopes, callback); |
220 } | 220 } |
221 | 221 |
222 UIImage* FakeChromeIdentityService::GetCachedAvatarForIdentity( | 222 UIImage* FakeChromeIdentityService::GetCachedAvatarForIdentity( |
223 ChromeIdentity* identity) { | 223 ChromeIdentity* identity) { |
224 return FakeGetCachedAvatarForIdentity(identity); | 224 return FakeGetCachedAvatarForIdentity(identity); |
225 } | 225 } |
226 | 226 |
227 void FakeChromeIdentityService::GetAvatarForIdentity( | 227 void FakeChromeIdentityService::GetAvatarForIdentity( |
228 ChromeIdentity* identity, | 228 ChromeIdentity* identity, |
(...skipping 25 matching lines...) Expand all Loading... |
254 } | 254 } |
255 | 255 |
256 void FakeChromeIdentityService::RemoveIdentity(ChromeIdentity* identity) { | 256 void FakeChromeIdentityService::RemoveIdentity(ChromeIdentity* identity) { |
257 if ([identities_ indexOfObject:identity] != NSNotFound) { | 257 if ([identities_ indexOfObject:identity] != NSNotFound) { |
258 [identities_ removeObject:identity]; | 258 [identities_ removeObject:identity]; |
259 FireIdentityListChanged(); | 259 FireIdentityListChanged(); |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
263 } // namespace ios | 263 } // namespace ios |
OLD | NEW |