OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_TEST_UTIL_H_ | 5 #ifndef GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_TEST_UTIL_H_ |
6 #define GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_TEST_UTIL_H_ | 6 #define GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_TEST_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "google_apis/gaia/google_service_auth_error.h" | 10 #include "google_apis/gaia/google_service_auth_error.h" |
11 #include "google_apis/gaia/oauth2_token_service.h" | 11 #include "google_apis/gaia/oauth2_token_service.h" |
12 | 12 |
13 std::string GetValidTokenResponse(std::string token, int expiration); | 13 std::string GetValidTokenResponse(std::string token, int expiration); |
14 | 14 |
15 // A simple testing consumer. | 15 // A simple testing consumer. |
16 class TestingOAuth2TokenServiceConsumer : public OAuth2TokenService::Consumer { | 16 class TestingOAuth2TokenServiceConsumer : public OAuth2TokenService::Consumer { |
17 public: | 17 public: |
18 TestingOAuth2TokenServiceConsumer(); | 18 TestingOAuth2TokenServiceConsumer(); |
19 virtual ~TestingOAuth2TokenServiceConsumer(); | 19 virtual ~TestingOAuth2TokenServiceConsumer(); |
20 | 20 |
21 // OAuth2TokenService::Consumer overrides. | 21 // OAuth2TokenService::Consumer overrides. |
22 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 22 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
23 const std::string& token, | 23 const std::string& token, |
24 const base::Time& expiration_date) OVERRIDE; | 24 const base::Time& expiration_date) override; |
25 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 25 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
26 const GoogleServiceAuthError& error) OVERRIDE; | 26 const GoogleServiceAuthError& error) override; |
27 | 27 |
28 std::string last_token_; | 28 std::string last_token_; |
29 int number_of_successful_tokens_; | 29 int number_of_successful_tokens_; |
30 GoogleServiceAuthError last_error_; | 30 GoogleServiceAuthError last_error_; |
31 int number_of_errors_; | 31 int number_of_errors_; |
32 }; | 32 }; |
33 | 33 |
34 #endif // GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_TEST_UTIL_H_ | 34 #endif // GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_TEST_UTIL_H_ |
OLD | NEW |