OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 GaiaAuthFetcher. | 5 // A complete set of unit tests for GaiaAuthFetcher. |
6 // Originally ported from GoogleAuthenticator tests. | 6 // Originally ported from GoogleAuthenticator tests. |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 GURL issue_auth_token_source_; | 147 GURL issue_auth_token_source_; |
148 GURL client_login_to_oauth2_source_; | 148 GURL client_login_to_oauth2_source_; |
149 GURL oauth2_token_source_; | 149 GURL oauth2_token_source_; |
150 GURL token_auth_source_; | 150 GURL token_auth_source_; |
151 GURL merge_session_source_; | 151 GURL merge_session_source_; |
152 GURL uberauth_token_source_; | 152 GURL uberauth_token_source_; |
153 GURL oauth_login_gurl_; | 153 GURL oauth_login_gurl_; |
154 | 154 |
155 protected: | 155 protected: |
156 net::TestURLRequestContextGetter* GetRequestContext() { | 156 net::TestURLRequestContextGetter* GetRequestContext() { |
157 if (!request_context_getter_) { | 157 if (!request_context_getter_.get()) { |
158 request_context_getter_ = new net::TestURLRequestContextGetter( | 158 request_context_getter_ = new net::TestURLRequestContextGetter( |
159 message_loop_.message_loop_proxy()); | 159 message_loop_.message_loop_proxy()); |
160 } | 160 } |
161 return request_context_getter_; | 161 return request_context_getter_.get(); |
162 } | 162 } |
163 | 163 |
164 base::MessageLoop message_loop_; | 164 base::MessageLoop message_loop_; |
165 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; | 165 scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; |
166 }; | 166 }; |
167 | 167 |
168 class MockGaiaConsumer : public GaiaAuthConsumer { | 168 class MockGaiaConsumer : public GaiaAuthConsumer { |
169 public: | 169 public: |
170 MockGaiaConsumer() {} | 170 MockGaiaConsumer() {} |
171 ~MockGaiaConsumer() {} | 171 ~MockGaiaConsumer() {} |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 MockGaiaConsumer consumer; | 799 MockGaiaConsumer consumer; |
800 EXPECT_CALL(consumer, OnGetCheckConnectionInfoSuccess(data)).Times(1); | 800 EXPECT_CALL(consumer, OnGetCheckConnectionInfoSuccess(data)).Times(1); |
801 | 801 |
802 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); | 802 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); |
803 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 803 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
804 MockFetcher mock_fetcher( | 804 MockFetcher mock_fetcher( |
805 GaiaUrls::GetInstance()->get_check_connection_info_url(), | 805 GaiaUrls::GetInstance()->get_check_connection_info_url(), |
806 status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth); | 806 status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth); |
807 auth.OnURLFetchComplete(&mock_fetcher); | 807 auth.OnURLFetchComplete(&mock_fetcher); |
808 } | 808 } |
OLD | NEW |