OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef IOS_TEST_MOCK_PROFILE_OAUTH2_TOKEN_SERVICE_PROVIDER_IOS_H_ |
| 6 #define IOS_TEST_MOCK_PROFILE_OAUTH2_TOKEN_SERVICE_PROVIDER_IOS_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <utility> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ios/public/provider/components/signin/browser/profile_oauth2_token_ser
vice_ios_provider.h" |
| 14 |
| 15 namespace ios { |
| 16 |
| 17 // Mock class of ProfileOAuth2TokenServiceIOSProvider for testing. |
| 18 class FakeProfileOAuth2TokenServiceIOSProvider |
| 19 : public ProfileOAuth2TokenServiceIOSProvider { |
| 20 public: |
| 21 FakeProfileOAuth2TokenServiceIOSProvider(); |
| 22 virtual ~FakeProfileOAuth2TokenServiceIOSProvider(); |
| 23 |
| 24 // ProfileOAuth2TokenServiceIOSProvider |
| 25 virtual bool IsUsingSharedAuthentication() const OVERRIDE; |
| 26 virtual void InitializeSharedAuthentication() OVERRIDE; |
| 27 |
| 28 virtual void GetAccessToken(const std::string& account_id, |
| 29 const std::string& client_id, |
| 30 const std::string& client_secret, |
| 31 const std::set<std::string>& scopes, |
| 32 const AccessTokenCallback& callback) OVERRIDE; |
| 33 |
| 34 virtual std::vector<std::string> GetAllAccountIds() OVERRIDE; |
| 35 |
| 36 virtual AuthenticationErrorCategory GetAuthenticationErrorCategory( |
| 37 NSError* error) const OVERRIDE; |
| 38 |
| 39 // Methods to configure this fake provider. |
| 40 void AddAccount(const std::string& account_id); |
| 41 void SetAccounts(const std::vector<std::string>& accounts); |
| 42 void ClearAccounts(); |
| 43 void set_using_shared_authentication(bool is_using_shared_authentication) { |
| 44 is_using_shared_authentication_ = is_using_shared_authentication; |
| 45 } |
| 46 |
| 47 // Issues access token responses. |
| 48 void IssueAccessTokenForAllRequests(); |
| 49 void IssueAccessTokenErrorForAllRequests(); |
| 50 |
| 51 private: |
| 52 typedef std::pair<std::string, AccessTokenCallback> AccessTokenRequest; |
| 53 |
| 54 std::vector<std::string> accounts_; |
| 55 bool is_using_shared_authentication_; |
| 56 std::vector<AccessTokenRequest> requests_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenServiceIOSProvider); |
| 59 }; |
| 60 |
| 61 } // namespace ios |
| 62 |
| 63 #endif // IOS_TEST_PROVIDER_CHROME_BROWSER_SIGNIN_MOCK_PROFILE_OAUTH2_TOKEN_SER
VICE_PROVIDER_IOS_H_ |
OLD | NEW |