| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // A complete set of unit tests for OAuth2AccessTokenFetcherImpl. | 5 // A complete set of unit tests for OAuth2AccessTokenFetcherImpl. |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 MOCK_METHOD1(OnGetTokenFailure, void(const GoogleServiceAuthError& error)); | 79 MOCK_METHOD1(OnGetTokenFailure, void(const GoogleServiceAuthError& error)); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 } // namespace | 82 } // namespace |
| 83 | 83 |
| 84 class OAuth2AccessTokenFetcherImplTest : public testing::Test { | 84 class OAuth2AccessTokenFetcherImplTest : public testing::Test { |
| 85 public: | 85 public: |
| 86 OAuth2AccessTokenFetcherImplTest() | 86 OAuth2AccessTokenFetcherImplTest() |
| 87 : request_context_getter_(new net::TestURLRequestContextGetter( | 87 : request_context_getter_(new net::TestURLRequestContextGetter( |
| 88 base::MessageLoopProxy::current())), | 88 base::MessageLoopProxy::current())), |
| 89 fetcher_(&consumer_, request_context_getter_, "refresh_token") { | 89 fetcher_(&consumer_, request_context_getter_.get(), "refresh_token") { |
| 90 base::RunLoop().RunUntilIdle(); | 90 base::RunLoop().RunUntilIdle(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 virtual ~OAuth2AccessTokenFetcherImplTest() {} | 93 virtual ~OAuth2AccessTokenFetcherImplTest() {} |
| 94 | 94 |
| 95 virtual TestURLFetcher* SetupGetAccessToken(bool fetch_succeeds, | 95 virtual TestURLFetcher* SetupGetAccessToken(bool fetch_succeeds, |
| 96 int response_code, | 96 int response_code, |
| 97 const std::string& body) { | 97 const std::string& body) { |
| 98 GURL url(GaiaUrls::GetInstance()->oauth2_token_url()); | 98 GURL url(GaiaUrls::GetInstance()->oauth2_token_url()); |
| 99 TestURLFetcher* url_fetcher = new TestURLFetcher(0, url, &fetcher_); | 99 TestURLFetcher* url_fetcher = new TestURLFetcher(0, url, &fetcher_); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 TestURLFetcher url_fetcher(0, GURL("www.google.com"), NULL); | 256 TestURLFetcher url_fetcher(0, GURL("www.google.com"), NULL); |
| 257 url_fetcher.SetResponseString(kValidFailureTokenResponse); | 257 url_fetcher.SetResponseString(kValidFailureTokenResponse); |
| 258 | 258 |
| 259 std::string error; | 259 std::string error; |
| 260 EXPECT_TRUE( | 260 EXPECT_TRUE( |
| 261 OAuth2AccessTokenFetcherImpl::ParseGetAccessTokenFailureResponse( | 261 OAuth2AccessTokenFetcherImpl::ParseGetAccessTokenFailureResponse( |
| 262 &url_fetcher, &error)); | 262 &url_fetcher, &error)); |
| 263 EXPECT_EQ("invalid_grant", error); | 263 EXPECT_EQ("invalid_grant", error); |
| 264 } | 264 } |
| 265 } | 265 } |
| OLD | NEW |