| 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" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 if (callback) { | 203 if (callback) { |
| 204 // Forgetting an identity is normally an asynchronous operation (that | 204 // Forgetting an identity is normally an asynchronous operation (that |
| 205 // require some network calls), this is replicated here by dispatching | 205 // require some network calls), this is replicated here by dispatching |
| 206 // it. | 206 // it. |
| 207 dispatch_async(dispatch_get_main_queue(), ^{ | 207 dispatch_async(dispatch_get_main_queue(), ^{ |
| 208 callback(nil); | 208 callback(nil); |
| 209 }); | 209 }); |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 | 212 |
| 213 void FakeChromeIdentityService::SetUpForIntegrationTests() { | 213 void FakeChromeIdentityService::GetAccessToken( |
| 214 ON_CALL(*this, GetAccessToken(_, _, _, _, _)) | 214 ChromeIdentity* identity, |
| 215 .WillByDefault(Invoke(FakeGetAccessToken)); | 215 const std::string& client_id, |
| 216 const std::string& client_secret, |
| 217 const std::set<std::string>& scopes, |
| 218 const ios::AccessTokenCallback& callback) { |
| 219 FakeGetAccessToken(identity, client_id, client_secret, scopes, callback); |
| 220 } |
| 216 | 221 |
| 217 ON_CALL(*this, GetAvatarForIdentity(_, _)) | 222 UIImage* FakeChromeIdentityService::GetCachedAvatarForIdentity( |
| 218 .WillByDefault(Invoke(FakeGetAvatarForIdentity)); | 223 ChromeIdentity* identity) { |
| 224 return FakeGetCachedAvatarForIdentity(identity); |
| 225 } |
| 219 | 226 |
| 220 ON_CALL(*this, GetCachedAvatarForIdentity(_)) | 227 void FakeChromeIdentityService::GetAvatarForIdentity( |
| 221 .WillByDefault(Invoke(FakeGetCachedAvatarForIdentity)); | 228 ChromeIdentity* identity, |
| 229 GetAvatarCallback callback) { |
| 230 FakeGetAvatarForIdentity(identity, callback); |
| 231 } |
| 222 | 232 |
| 223 ON_CALL(*this, GetHostedDomainForIdentity(_, _)) | 233 void FakeChromeIdentityService::GetHostedDomainForIdentity( |
| 224 .WillByDefault(Invoke(FakeGetHostedDomainForIdentity)); | 234 ChromeIdentity* identity, |
| 235 GetHostedDomainCallback callback) { |
| 236 FakeGetHostedDomainForIdentity(identity, callback); |
| 225 } | 237 } |
| 226 | 238 |
| 239 void FakeChromeIdentityService::SetUpForIntegrationTests() {} |
| 240 |
| 227 void FakeChromeIdentityService::AddIdentities(NSArray* identitiesNames) { | 241 void FakeChromeIdentityService::AddIdentities(NSArray* identitiesNames) { |
| 228 for (NSString* name in identitiesNames) { | 242 for (NSString* name in identitiesNames) { |
| 229 NSString* email = [NSString stringWithFormat:kIdentityEmailFormat, name]; | 243 NSString* email = [NSString stringWithFormat:kIdentityEmailFormat, name]; |
| 230 NSString* gaiaID = [NSString stringWithFormat:kIdentityGaiaIDFormat, name]; | 244 NSString* gaiaID = [NSString stringWithFormat:kIdentityGaiaIDFormat, name]; |
| 231 [identities_ addObject:[FakeChromeIdentity identityWithEmail:email | 245 [identities_ addObject:[FakeChromeIdentity identityWithEmail:email |
| 232 gaiaID:gaiaID | 246 gaiaID:gaiaID |
| 233 name:name]]; | 247 name:name]]; |
| 234 } | 248 } |
| 235 } | 249 } |
| 236 | 250 |
| 237 void FakeChromeIdentityService::AddIdentity(ChromeIdentity* identity) { | 251 void FakeChromeIdentityService::AddIdentity(ChromeIdentity* identity) { |
| 238 [identities_ addObject:identity]; | 252 [identities_ addObject:identity]; |
| 239 FireIdentityListChanged(); | 253 FireIdentityListChanged(); |
| 240 } | 254 } |
| 241 | 255 |
| 242 } // namespace ios | 256 } // namespace ios |
| OLD | NEW |