Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / signin / ios / browser / fake_profile_oauth2_token_service_ios_provider.h
bloba622b8b8b9896d794ba83606117b9798d1ad400e
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_
8 #include <string>
9 #include <utility>
10 #include <vector>
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 {
18 public:
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);
36 void ClearAccounts();
38 // Issues access token responses.
39 void IssueAccessTokenForAllRequests();
40 void IssueAccessTokenErrorForAllRequests();
42 private:
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_