1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_TEST_MOCK_PROFILE_OAUTH2_TOKEN_SERVICE_PROVIDER_IOS_H_
6 #define IOS_TEST_MOCK_PROFILE_OAUTH2_TOKEN_SERVICE_PROVIDER_IOS_H_
12 #include "base/memory/scoped_ptr.h"
13 #include "components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h"
15 // Mock class of ProfileOAuth2TokenServiceIOSProvider for testing.
16 class FakeProfileOAuth2TokenServiceIOSProvider
17 : public ProfileOAuth2TokenServiceIOSProvider
{
19 FakeProfileOAuth2TokenServiceIOSProvider();
20 ~FakeProfileOAuth2TokenServiceIOSProvider() override
;
22 // ProfileOAuth2TokenServiceIOSProvider
23 void GetAccessToken(const std::string
& account_id
,
24 const std::string
& client_id
,
25 const std::string
& client_secret
,
26 const std::set
<std::string
>& scopes
,
27 const AccessTokenCallback
& callback
) override
;
28 std::vector
<AccountInfo
> GetAllAccounts() const override
;
29 AccountInfo
GetAccountInfoForEmail(const std::string
& email
) const override
;
30 AccountInfo
GetAccountInfoForGaia(const std::string
& gaia
) const override
;
31 AuthenticationErrorCategory
GetAuthenticationErrorCategory(
32 NSError
* error
) const override
;
34 // Methods to configure this fake provider.
35 AccountInfo
AddAccount(const std::string
& gaia
, const std::string
& email
);
38 // Issues access token responses.
39 void IssueAccessTokenForAllRequests();
40 void IssueAccessTokenErrorForAllRequests();
43 typedef std::pair
<std::string
, AccessTokenCallback
> AccessTokenRequest
;
45 std::vector
<AccountInfo
> accounts_
;
46 std::vector
<AccessTokenRequest
> requests_
;
48 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenServiceIOSProvider
);
51 #endif // IOS_TEST_PROVIDER_CHROME_BROWSER_SIGNIN_MOCK_PROFILE_OAUTH2_TOKEN_SERVICE_PROVIDER_IOS_H_