Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: google_apis/gaia/oauth2_access_token_fetcher_impl_unittest.cc

Issue 1135793002: Using ThreadTaskRunnerHandle in lieu of MessageLoopProxy in google_apis module (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/thread_task_runner_handle.h"
11 #include "google_apis/gaia/gaia_urls.h" 12 #include "google_apis/gaia/gaia_urls.h"
12 #include "google_apis/gaia/google_service_auth_error.h" 13 #include "google_apis/gaia/google_service_auth_error.h"
13 #include "google_apis/gaia/oauth2_access_token_consumer.h" 14 #include "google_apis/gaia/oauth2_access_token_consumer.h"
14 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h" 15 #include "google_apis/gaia/oauth2_access_token_fetcher_impl.h"
15 #include "net/http/http_status_code.h" 16 #include "net/http/http_status_code.h"
16 #include "net/url_request/test_url_fetcher_factory.h" 17 #include "net/url_request/test_url_fetcher_factory.h"
17 #include "net/url_request/url_fetcher.h" 18 #include "net/url_request/url_fetcher.h"
18 #include "net/url_request/url_fetcher_delegate.h" 19 #include "net/url_request/url_fetcher_delegate.h"
19 #include "net/url_request/url_fetcher_factory.h" 20 #include "net/url_request/url_fetcher_factory.h"
20 #include "net/url_request/url_request.h" 21 #include "net/url_request/url_request.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 const base::Time& expiration_time)); 87 const base::Time& expiration_time));
87 MOCK_METHOD1(OnGetTokenFailure, void(const GoogleServiceAuthError& error)); 88 MOCK_METHOD1(OnGetTokenFailure, void(const GoogleServiceAuthError& error));
88 }; 89 };
89 90
90 } // namespace 91 } // namespace
91 92
92 class OAuth2AccessTokenFetcherImplTest : public testing::Test { 93 class OAuth2AccessTokenFetcherImplTest : public testing::Test {
93 public: 94 public:
94 OAuth2AccessTokenFetcherImplTest() 95 OAuth2AccessTokenFetcherImplTest()
95 : request_context_getter_(new net::TestURLRequestContextGetter( 96 : request_context_getter_(new net::TestURLRequestContextGetter(
96 base::MessageLoopProxy::current())), 97 base::ThreadTaskRunnerHandle::Get())),
97 fetcher_(&consumer_, request_context_getter_.get(), "refresh_token") { 98 fetcher_(&consumer_, request_context_getter_.get(), "refresh_token") {
98 base::RunLoop().RunUntilIdle(); 99 base::RunLoop().RunUntilIdle();
99 } 100 }
100 101
101 ~OAuth2AccessTokenFetcherImplTest() override {} 102 ~OAuth2AccessTokenFetcherImplTest() override {}
102 103
103 virtual TestURLFetcher* SetupGetAccessToken(bool fetch_succeeds, 104 virtual TestURLFetcher* SetupGetAccessToken(bool fetch_succeeds,
104 int response_code, 105 int response_code,
105 const std::string& body) { 106 const std::string& body) {
106 GURL url(GaiaUrls::GetInstance()->oauth2_token_url()); 107 GURL url(GaiaUrls::GetInstance()->oauth2_token_url());
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 TestURLFetcher url_fetcher(0, GURL("http://www.google.com"), NULL); 265 TestURLFetcher url_fetcher(0, GURL("http://www.google.com"), NULL);
265 url_fetcher.SetResponseString(kValidFailureTokenResponse); 266 url_fetcher.SetResponseString(kValidFailureTokenResponse);
266 267
267 std::string error; 268 std::string error;
268 EXPECT_TRUE( 269 EXPECT_TRUE(
269 OAuth2AccessTokenFetcherImpl::ParseGetAccessTokenFailureResponse( 270 OAuth2AccessTokenFetcherImpl::ParseGetAccessTokenFailureResponse(
270 &url_fetcher, &error)); 271 &url_fetcher, &error));
271 EXPECT_EQ("invalid_grant", error); 272 EXPECT_EQ("invalid_grant", error);
272 } 273 }
273 } 274 }
OLDNEW
« no previous file with comments | « google_apis/drive/task_util.h ('k') | google_apis/gaia/oauth2_token_service_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698