OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_TEST_UTIL_H_ |
| 7 |
| 8 #include "chrome/browser/signin/oauth2_token_service.h" |
| 9 |
| 10 #include <string> |
| 11 |
| 12 #include "base/stringprintf.h" |
| 13 #include "google_apis/gaia/google_service_auth_error.h" |
| 14 |
| 15 static const char kValidTokenResponse[] = |
| 16 "{" |
| 17 " \"access_token\": \"%s\"," |
| 18 " \"expires_in\": %d," |
| 19 " \"token_type\": \"Bearer\"" |
| 20 "}"; |
| 21 |
| 22 std::string GetValidTokenResponse(std::string token, int expiration); |
| 23 |
| 24 // A simple testing consumer. |
| 25 class TestingOAuth2TokenServiceConsumer : public OAuth2TokenService::Consumer { |
| 26 public: |
| 27 TestingOAuth2TokenServiceConsumer(); |
| 28 virtual ~TestingOAuth2TokenServiceConsumer(); |
| 29 |
| 30 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 31 const std::string& token, |
| 32 const base::Time& expiration_date) OVERRIDE; |
| 33 |
| 34 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 35 const GoogleServiceAuthError& error) OVERRIDE; |
| 36 |
| 37 std::string last_token_; |
| 38 int number_of_correct_tokens_; |
| 39 GoogleServiceAuthError last_error_; |
| 40 int number_of_errors_; |
| 41 }; |
| 42 |
| 43 #endif // CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_TEST_UTIL_H_ |
OLD | NEW |