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.
5 #include "google_apis/gaia/oauth2_token_service_test_util.h"
7 #include "base/strings/stringprintf.h"
10 const char kValidTokenResponse[] =
12 " \"access_token\": \"%s\","
13 " \"expires_in\": %d,"
14 " \"token_type\": \"Bearer\""
18 std::string GetValidTokenResponse(std::string token, int expiration) {
19 return base::StringPrintf(kValidTokenResponse, token.c_str(), expiration);
22 TestingOAuth2TokenServiceConsumer::TestingOAuth2TokenServiceConsumer()
23 : number_of_successful_tokens_(0),
24 last_error_(GoogleServiceAuthError::AuthErrorNone()),
25 number_of_errors_(0) {
28 TestingOAuth2TokenServiceConsumer::~TestingOAuth2TokenServiceConsumer() {
31 void TestingOAuth2TokenServiceConsumer::OnGetTokenSuccess(
32 const OAuth2TokenService::Request* request,
33 const std::string& token,
34 const base::Time& expiration_date) {
36 ++number_of_successful_tokens_;
39 void TestingOAuth2TokenServiceConsumer::OnGetTokenFailure(
40 const OAuth2TokenService::Request* request,
41 const GoogleServiceAuthError& error) {