This source file includes following definitions.
- GetValidTokenResponse
- number_of_errors_
- OnGetTokenSuccess
- OnGetTokenFailure
#include "google_apis/gaia/oauth2_token_service_test_util.h"
#include "base/strings/stringprintf.h"
namespace {
const char kValidTokenResponse[] =
"{"
" \"access_token\": \"%s\","
" \"expires_in\": %d,"
" \"token_type\": \"Bearer\""
"}";
}
std::string GetValidTokenResponse(std::string token, int expiration) {
return base::StringPrintf(kValidTokenResponse, token.c_str(), expiration);
}
TestingOAuth2TokenServiceConsumer::TestingOAuth2TokenServiceConsumer()
: OAuth2TokenService::Consumer("test"),
number_of_successful_tokens_(0),
last_error_(GoogleServiceAuthError::AuthErrorNone()),
number_of_errors_(0) {
}
TestingOAuth2TokenServiceConsumer::~TestingOAuth2TokenServiceConsumer() {
}
void TestingOAuth2TokenServiceConsumer::OnGetTokenSuccess(
const OAuth2TokenService::Request* request,
const std::string& token,
const base::Time& expiration_date) {
last_token_ = token;
++number_of_successful_tokens_;
}
void TestingOAuth2TokenServiceConsumer::OnGetTokenFailure(
const OAuth2TokenService::Request* request,
const GoogleServiceAuthError& error) {
last_error_ = error;
++number_of_errors_;
}