| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" | 8 #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 14 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
| 15 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" | 15 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
| 16 #include "chrome/common/net/gaia/gaia_urls.h" | 16 #include "chrome/common/net/gaia/gaia_urls.h" |
| 17 #include "chrome/common/net/gaia/google_service_auth_error.h" | 17 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 18 #include "chrome/common/net/http_return.h" | 18 #include "chrome/common/net/http_return.h" |
| 19 #include "chrome/test/base/testing_browser_process_test.h" | |
| 20 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 21 #include "content/common/url_fetcher.h" | 20 #include "content/common/url_fetcher.h" |
| 22 #include "content/test/test_url_fetcher_factory.h" | 21 #include "content/test/test_url_fetcher_factory.h" |
| 23 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
| 24 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
| 25 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 26 #include "net/url_request/url_request_status.h" | 25 #include "net/url_request/url_request_status.h" |
| 27 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 28 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 55 net::URLRequestStatus status(code, 0); | 54 net::URLRequestStatus status(code, 0); |
| 56 delegate()->OnURLFetchComplete(NULL, | 55 delegate()->OnURLFetchComplete(NULL, |
| 57 url_, | 56 url_, |
| 58 status, | 57 status, |
| 59 http_code, | 58 http_code, |
| 60 net::ResponseCookies(), | 59 net::ResponseCookies(), |
| 61 results_); | 60 results_); |
| 62 } | 61 } |
| 63 | 62 |
| 64 | 63 |
| 65 class GaiaAuthFetcherTest : public TestingBrowserProcessTest { | 64 class GaiaAuthFetcherTest : public testing::Test { |
| 66 public: | 65 public: |
| 67 GaiaAuthFetcherTest() | 66 GaiaAuthFetcherTest() |
| 68 : client_login_source_(GaiaUrls::GetInstance()->client_login_url()), | 67 : client_login_source_(GaiaUrls::GetInstance()->client_login_url()), |
| 69 issue_auth_token_source_( | 68 issue_auth_token_source_( |
| 70 GaiaUrls::GetInstance()->issue_auth_token_url()), | 69 GaiaUrls::GetInstance()->issue_auth_token_url()), |
| 71 token_auth_source_(GaiaUrls::GetInstance()->token_auth_url()), | 70 token_auth_source_(GaiaUrls::GetInstance()->token_auth_url()), |
| 72 merge_session_source_(GaiaUrls::GetInstance()->merge_session_url()) {} | 71 merge_session_source_(GaiaUrls::GetInstance()->merge_session_url()) {} |
| 73 | 72 |
| 74 void RunParsingTest(const std::string& data, | 73 void RunParsingTest(const std::string& data, |
| 75 const std::string& sid, | 74 const std::string& sid, |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 | 645 |
| 647 auth.OnURLFetchComplete( | 646 auth.OnURLFetchComplete( |
| 648 test_fetcher, | 647 test_fetcher, |
| 649 test_fetcher->url(), | 648 test_fetcher->url(), |
| 650 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), | 649 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0), |
| 651 RC_REQUEST_OK, | 650 RC_REQUEST_OK, |
| 652 cookies_, | 651 cookies_, |
| 653 "<html></html>"); | 652 "<html></html>"); |
| 654 EXPECT_FALSE(auth.HasPendingFetch()); | 653 EXPECT_FALSE(auth.HasPendingFetch()); |
| 655 } | 654 } |
| OLD | NEW |