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