| Index: google_apis/gaia/oauth2_api_call_flow_unittest.cc
|
| diff --git a/google_apis/gaia/oauth2_api_call_flow_unittest.cc b/google_apis/gaia/oauth2_api_call_flow_unittest.cc
|
| index d56a613eded68003a7b19bc8859aca7349254c3e..98c53d3e45e395bd1dcfe323328b3b42752ebe45 100644
|
| --- a/google_apis/gaia/oauth2_api_call_flow_unittest.cc
|
| +++ b/google_apis/gaia/oauth2_api_call_flow_unittest.cc
|
| @@ -13,7 +13,7 @@
|
| #include "google_apis/gaia/gaia_urls.h"
|
| #include "google_apis/gaia/google_service_auth_error.h"
|
| #include "google_apis/gaia/oauth2_access_token_consumer.h"
|
| -#include "google_apis/gaia/oauth2_access_token_fetcher.h"
|
| +#include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
|
| #include "google_apis/gaia/oauth2_api_call_flow.h"
|
| #include "net/http/http_request_headers.h"
|
| #include "net/http/http_status_code.h"
|
| @@ -70,18 +70,18 @@ class MockUrlFetcherFactory : public ScopedURLFetcherFactory,
|
| URLFetcherDelegate* d));
|
| };
|
|
|
| -class MockAccessTokenFetcher : public OAuth2AccessTokenFetcher {
|
| +class MockAccessTokenFetcher : public OAuth2AccessTokenFetcherImpl {
|
| public:
|
| - MockAccessTokenFetcher(OAuth2AccessTokenConsumer* consumer,
|
| - net::URLRequestContextGetter* getter)
|
| - : OAuth2AccessTokenFetcher(consumer, getter) {}
|
| + MockAccessTokenFetcher(net::URLRequestContextGetter* getter)
|
| + : OAuth2AccessTokenFetcherImpl(getter) {}
|
| ~MockAccessTokenFetcher() {}
|
|
|
| - MOCK_METHOD4(Start,
|
| - void (const std::string& client_id,
|
| - const std::string& client_secret,
|
| - const std::string& refresh_token,
|
| - const std::vector<std::string>& scopes));
|
| + MOCK_METHOD5(Start,
|
| + void(const std::string& client_id,
|
| + const std::string& client_secret,
|
| + const std::string& refresh_token,
|
| + const std::vector<std::string>& scopes,
|
| + OAuth2AccessTokenConsumer* consumer));
|
| };
|
|
|
| class MockApiCallFlow : public OAuth2ApiCallFlow {
|
| @@ -110,13 +110,15 @@ class MockApiCallFlow : public OAuth2ApiCallFlow {
|
|
|
| class OAuth2ApiCallFlowTest : public testing::Test {
|
| protected:
|
| - void SetupAccessTokenFetcher(
|
| - const std::string& rt, const std::vector<std::string>& scopes) {
|
| + void SetupAccessTokenFetcher(const std::string& rt,
|
| + const std::vector<std::string>& scopes,
|
| + OAuth2AccessTokenConsumer* consumer) {
|
| EXPECT_CALL(*access_token_fetcher_,
|
| - Start(GaiaUrls::GetInstance()->oauth2_chrome_client_id(),
|
| - GaiaUrls::GetInstance()->oauth2_chrome_client_secret(),
|
| - rt, scopes))
|
| - .Times(1);
|
| + Start(GaiaUrls::GetInstance()->oauth2_chrome_client_id(),
|
| + GaiaUrls::GetInstance()->oauth2_chrome_client_secret(),
|
| + rt,
|
| + scopes,
|
| + consumer)).Times(1);
|
| EXPECT_CALL(*flow_, CreateAccessTokenFetcher())
|
| .WillOnce(Return(access_token_fetcher_.release()));
|
| }
|
| @@ -147,7 +149,7 @@ class OAuth2ApiCallFlowTest : public testing::Test {
|
| flow_.reset(new MockApiCallFlow(
|
| request_context_getter, refresh_token, access_token, scopes));
|
| access_token_fetcher_.reset(
|
| - new MockAccessTokenFetcher(flow_.get(), request_context_getter));
|
| + new MockAccessTokenFetcher(request_context_getter));
|
| }
|
|
|
| TestURLFetcher* SetupApiCall(bool succeeds, net::HttpStatusCode status) {
|
| @@ -188,7 +190,7 @@ TEST_F(OAuth2ApiCallFlowTest, SecondApiCallSucceeds) {
|
| CreateFlow(rt, at, scopes);
|
| TestURLFetcher* url_fetcher1 = SetupApiCall(true, net::HTTP_UNAUTHORIZED);
|
| flow_->Start();
|
| - SetupAccessTokenFetcher(rt, scopes);
|
| + SetupAccessTokenFetcher(rt, scopes, flow_.get());
|
| flow_->OnURLFetchComplete(url_fetcher1);
|
| TestURLFetcher* url_fetcher2 = SetupApiCall(true, net::HTTP_OK);
|
| EXPECT_CALL(*flow_, ProcessApiCallSuccess(url_fetcher2));
|
| @@ -206,7 +208,7 @@ TEST_F(OAuth2ApiCallFlowTest, SecondApiCallFails) {
|
| CreateFlow(rt, at, scopes);
|
| TestURLFetcher* url_fetcher1 = SetupApiCall(true, net::HTTP_UNAUTHORIZED);
|
| flow_->Start();
|
| - SetupAccessTokenFetcher(rt, scopes);
|
| + SetupAccessTokenFetcher(rt, scopes, flow_.get());
|
| flow_->OnURLFetchComplete(url_fetcher1);
|
| TestURLFetcher* url_fetcher2 = SetupApiCall(false, net::HTTP_UNAUTHORIZED);
|
| EXPECT_CALL(*flow_, ProcessApiCallFailure(url_fetcher2));
|
| @@ -224,7 +226,7 @@ TEST_F(OAuth2ApiCallFlowTest, NewTokenGenerationFails) {
|
| CreateFlow(rt, at, scopes);
|
| TestURLFetcher* url_fetcher = SetupApiCall(true, net::HTTP_UNAUTHORIZED);
|
| flow_->Start();
|
| - SetupAccessTokenFetcher(rt, scopes);
|
| + SetupAccessTokenFetcher(rt, scopes, flow_.get());
|
| flow_->OnURLFetchComplete(url_fetcher);
|
| GoogleServiceAuthError error(
|
| GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
|
| @@ -238,7 +240,7 @@ TEST_F(OAuth2ApiCallFlowTest, EmptyAccessTokenFirstApiCallSucceeds) {
|
| std::vector<std::string> scopes(CreateTestScopes());
|
|
|
| CreateFlow(rt, std::string(), scopes);
|
| - SetupAccessTokenFetcher(rt, scopes);
|
| + SetupAccessTokenFetcher(rt, scopes, flow_.get());
|
| TestURLFetcher* url_fetcher = SetupApiCall(true, net::HTTP_OK);
|
| EXPECT_CALL(*flow_, ProcessApiCallSuccess(url_fetcher));
|
| flow_->Start();
|
| @@ -254,7 +256,7 @@ TEST_F(OAuth2ApiCallFlowTest, EmptyAccessTokenApiCallFails) {
|
| std::vector<std::string> scopes(CreateTestScopes());
|
|
|
| CreateFlow(rt, std::string(), scopes);
|
| - SetupAccessTokenFetcher(rt, scopes);
|
| + SetupAccessTokenFetcher(rt, scopes, flow_.get());
|
| TestURLFetcher* url_fetcher = SetupApiCall(false, net::HTTP_BAD_GATEWAY);
|
| EXPECT_CALL(*flow_, ProcessApiCallFailure(url_fetcher));
|
| flow_->Start();
|
| @@ -270,7 +272,7 @@ TEST_F(OAuth2ApiCallFlowTest, EmptyAccessTokenNewTokenGenerationFails) {
|
| std::vector<std::string> scopes(CreateTestScopes());
|
|
|
| CreateFlow(rt, std::string(), scopes);
|
| - SetupAccessTokenFetcher(rt, scopes);
|
| + SetupAccessTokenFetcher(rt, scopes, flow_.get());
|
| GoogleServiceAuthError error(
|
| GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
|
| EXPECT_CALL(*flow_, ProcessMintAccessTokenFailure(error));
|
|
|