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> |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 cookies_(cookies), | 64 cookies_(cookies), |
65 results_(results) { | 65 results_(results) { |
66 } | 66 } |
67 | 67 |
68 MockFetcher::~MockFetcher() {} | 68 MockFetcher::~MockFetcher() {} |
69 | 69 |
70 void MockFetcher::Start() { | 70 void MockFetcher::Start() { |
71 delegate()->OnURLFetchComplete(this); | 71 delegate()->OnURLFetchComplete(this); |
72 } | 72 } |
73 | 73 |
74 const GURL& MockFetcher::url() const { | 74 const GURL& MockFetcher::GetUrl() const { |
75 return url_; | 75 return url_; |
76 } | 76 } |
77 | 77 |
78 const net::URLRequestStatus& MockFetcher::status() const { | 78 const net::URLRequestStatus& MockFetcher::GetStatus() const { |
79 return status_; | 79 return status_; |
80 } | 80 } |
81 | 81 |
82 int MockFetcher::response_code() const { | 82 int MockFetcher::GetResponseCode() const { |
83 return response_code_; | 83 return response_code_; |
84 } | 84 } |
85 | 85 |
86 const net::ResponseCookies& MockFetcher::cookies() const { | 86 const net::ResponseCookies& MockFetcher::GetCookies() const { |
87 return cookies_; | 87 return cookies_; |
88 } | 88 } |
89 | 89 |
90 bool MockFetcher::GetResponseAsString(std::string* out_response_string) const { | 90 bool MockFetcher::GetResponseAsString(std::string* out_response_string) const { |
91 *out_response_string = results_; | 91 *out_response_string = results_; |
92 return true; | 92 return true; |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 class GaiaAuthFetcherTest : public testing::Test { | 96 class GaiaAuthFetcherTest : public testing::Test { |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 TestURLFetcherFactory factory; | 639 TestURLFetcherFactory factory; |
640 | 640 |
641 GaiaAuthFetcher auth(&consumer, std::string(), | 641 GaiaAuthFetcher auth(&consumer, std::string(), |
642 profile_.GetRequestContext()); | 642 profile_.GetRequestContext()); |
643 auth.StartMergeSession("myubertoken"); | 643 auth.StartMergeSession("myubertoken"); |
644 | 644 |
645 // Make sure the fetcher created has the expected flags. Set its url() | 645 // Make sure the fetcher created has the expected flags. Set its url() |
646 // properties to reflect a redirect. | 646 // properties to reflect a redirect. |
647 TestURLFetcher* test_fetcher = factory.GetFetcherByID(0); | 647 TestURLFetcher* test_fetcher = factory.GetFetcherByID(0); |
648 EXPECT_TRUE(test_fetcher != NULL); | 648 EXPECT_TRUE(test_fetcher != NULL); |
649 EXPECT_TRUE(test_fetcher->load_flags() == net::LOAD_NORMAL); | 649 EXPECT_TRUE(test_fetcher->GetLoadFlags() == net::LOAD_NORMAL); |
650 EXPECT_TRUE(auth.HasPendingFetch()); | 650 EXPECT_TRUE(auth.HasPendingFetch()); |
651 | 651 |
652 GURL final_url("http://www.google.com/CheckCookie"); | 652 GURL final_url("http://www.google.com/CheckCookie"); |
653 test_fetcher->set_url(final_url); | 653 test_fetcher->set_url(final_url); |
654 test_fetcher->set_status( | 654 test_fetcher->set_status( |
655 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0)); | 655 net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0)); |
656 test_fetcher->set_response_code(RC_REQUEST_OK); | 656 test_fetcher->set_response_code(RC_REQUEST_OK); |
657 test_fetcher->set_cookies(cookies_); | 657 test_fetcher->set_cookies(cookies_); |
658 test_fetcher->SetResponseString("<html></html>"); | 658 test_fetcher->SetResponseString("<html></html>"); |
659 | 659 |
660 auth.OnURLFetchComplete(test_fetcher); | 660 auth.OnURLFetchComplete(test_fetcher); |
661 EXPECT_FALSE(auth.HasPendingFetch()); | 661 EXPECT_FALSE(auth.HasPendingFetch()); |
662 } | 662 } |
OLD | NEW |