| 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 UIImage* FakeChromeIdentityService::GetCachedAvatarForIdentity( |
| 214 ChromeIdentity* identity) { |
| 215 return FakeGetCachedAvatarForIdentity(identity); |
| 216 } |
| 217 |
| 213 void FakeChromeIdentityService::SetUpForIntegrationTests() { | 218 void FakeChromeIdentityService::SetUpForIntegrationTests() { |
| 214 ON_CALL(*this, GetAccessToken(_, _, _, _, _)) | 219 ON_CALL(*this, GetAccessToken(_, _, _, _, _)) |
| 215 .WillByDefault(Invoke(FakeGetAccessToken)); | 220 .WillByDefault(Invoke(FakeGetAccessToken)); |
| 216 | 221 |
| 217 ON_CALL(*this, GetAvatarForIdentity(_, _)) | 222 ON_CALL(*this, GetAvatarForIdentity(_, _)) |
| 218 .WillByDefault(Invoke(FakeGetAvatarForIdentity)); | 223 .WillByDefault(Invoke(FakeGetAvatarForIdentity)); |
| 219 | 224 |
| 220 ON_CALL(*this, GetCachedAvatarForIdentity(_)) | |
| 221 .WillByDefault(Invoke(FakeGetCachedAvatarForIdentity)); | |
| 222 | |
| 223 ON_CALL(*this, GetHostedDomainForIdentity(_, _)) | 225 ON_CALL(*this, GetHostedDomainForIdentity(_, _)) |
| 224 .WillByDefault(Invoke(FakeGetHostedDomainForIdentity)); | 226 .WillByDefault(Invoke(FakeGetHostedDomainForIdentity)); |
| 225 } | 227 } |
| 226 | 228 |
| 227 void FakeChromeIdentityService::AddIdentities(NSArray* identitiesNames) { | 229 void FakeChromeIdentityService::AddIdentities(NSArray* identitiesNames) { |
| 228 for (NSString* name in identitiesNames) { | 230 for (NSString* name in identitiesNames) { |
| 229 NSString* email = [NSString stringWithFormat:kIdentityEmailFormat, name]; | 231 NSString* email = [NSString stringWithFormat:kIdentityEmailFormat, name]; |
| 230 NSString* gaiaID = [NSString stringWithFormat:kIdentityGaiaIDFormat, name]; | 232 NSString* gaiaID = [NSString stringWithFormat:kIdentityGaiaIDFormat, name]; |
| 231 [identities_ addObject:[FakeChromeIdentity identityWithEmail:email | 233 [identities_ addObject:[FakeChromeIdentity identityWithEmail:email |
| 232 gaiaID:gaiaID | 234 gaiaID:gaiaID |
| 233 name:name]]; | 235 name:name]]; |
| 234 } | 236 } |
| 235 } | 237 } |
| 236 | 238 |
| 237 void FakeChromeIdentityService::AddIdentity(ChromeIdentity* identity) { | 239 void FakeChromeIdentityService::AddIdentity(ChromeIdentity* identity) { |
| 238 [identities_ addObject:identity]; | 240 [identities_ addObject:identity]; |
| 239 FireIdentityListChanged(); | 241 FireIdentityListChanged(); |
| 240 } | 242 } |
| 241 | 243 |
| 242 } // namespace ios | 244 } // namespace ios |
| OLD | NEW |