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" |
11 #include "base/message_loop/message_loop.h" | |
12 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
13 #include "base/values.h" | 12 #include "base/values.h" |
14 #include "google_apis/gaia/gaia_auth_consumer.h" | 13 #include "google_apis/gaia/gaia_auth_consumer.h" |
15 #include "google_apis/gaia/gaia_auth_fetcher.h" | 14 #include "google_apis/gaia/gaia_auth_fetcher.h" |
16 #include "google_apis/gaia/gaia_urls.h" | 15 #include "google_apis/gaia/gaia_urls.h" |
17 #include "google_apis/gaia/google_service_auth_error.h" | 16 #include "google_apis/gaia/google_service_auth_error.h" |
18 #include "google_apis/gaia/mock_url_fetcher_factory.h" | 17 #include "google_apis/gaia/mock_url_fetcher_factory.h" |
19 #include "google_apis/google_api_keys.h" | 18 #include "google_apis/google_api_keys.h" |
20 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
21 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 SetResponseString(results); | 94 SetResponseString(results); |
96 } | 95 } |
97 | 96 |
98 MockFetcher::~MockFetcher() {} | 97 MockFetcher::~MockFetcher() {} |
99 | 98 |
100 void MockFetcher::Start() { | 99 void MockFetcher::Start() { |
101 delegate()->OnURLFetchComplete(this); | 100 delegate()->OnURLFetchComplete(this); |
102 } | 101 } |
103 | 102 |
104 class GaiaAuthFetcherTest : public testing::Test { | 103 class GaiaAuthFetcherTest : public testing::Test { |
105 public: | 104 protected: |
106 GaiaAuthFetcherTest() | 105 GaiaAuthFetcherTest() |
107 : client_login_source_(GaiaUrls::GetInstance()->client_login_url()), | 106 : client_login_source_(GaiaUrls::GetInstance()->client_login_url()), |
108 issue_auth_token_source_( | 107 issue_auth_token_source_( |
109 GaiaUrls::GetInstance()->issue_auth_token_url()), | 108 GaiaUrls::GetInstance()->issue_auth_token_url()), |
110 client_login_to_oauth2_source_( | 109 client_login_to_oauth2_source_( |
111 GaiaUrls::GetInstance()->client_login_to_oauth2_url()), | 110 GaiaUrls::GetInstance()->client_login_to_oauth2_url()), |
112 oauth2_token_source_(GaiaUrls::GetInstance()->oauth2_token_url()), | 111 oauth2_token_source_(GaiaUrls::GetInstance()->oauth2_token_url()), |
113 token_auth_source_(GaiaUrls::GetInstance()->token_auth_url()), | 112 token_auth_source_(GaiaUrls::GetInstance()->token_auth_url()), |
114 merge_session_source_(GaiaUrls::GetInstance()->merge_session_url()), | 113 merge_session_source_(GaiaUrls::GetInstance()->merge_session_url()), |
115 uberauth_token_source_(base::StringPrintf( | 114 uberauth_token_source_(base::StringPrintf( |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 EXPECT_CALL(consumer, OnClientLoginSuccess(result)) | 794 EXPECT_CALL(consumer, OnClientLoginSuccess(result)) |
796 .Times(1); | 795 .Times(1); |
797 | 796 |
798 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); | 797 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); |
799 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 798 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
800 MockFetcher mock_fetcher( | 799 MockFetcher mock_fetcher( |
801 oauth_login_gurl_, status, net::HTTP_OK, cookies_, data, | 800 oauth_login_gurl_, status, net::HTTP_OK, cookies_, data, |
802 net::URLFetcher::GET, &auth); | 801 net::URLFetcher::GET, &auth); |
803 auth.OnURLFetchComplete(&mock_fetcher); | 802 auth.OnURLFetchComplete(&mock_fetcher); |
804 } | 803 } |
OLD | NEW |