| 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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 781 |
| 782 TEST_F(GaiaAuthFetcherTest, ListAccounts) { | 782 TEST_F(GaiaAuthFetcherTest, ListAccounts) { |
| 783 std::string data("[\"gaia.l.a.r\", [" | 783 std::string data("[\"gaia.l.a.r\", [" |
| 784 "[\"gaia.l.a\", 1, \"First Last\", \"user@gmail.com\", " | 784 "[\"gaia.l.a\", 1, \"First Last\", \"user@gmail.com\", " |
| 785 "\"//googleusercontent.com/A/B/C/D/photo.jpg\", 1, 1, 0]]]"); | 785 "\"//googleusercontent.com/A/B/C/D/photo.jpg\", 1, 1, 0]]]"); |
| 786 MockGaiaConsumer consumer; | 786 MockGaiaConsumer consumer; |
| 787 EXPECT_CALL(consumer, OnListAccountsSuccess(data)).Times(1); | 787 EXPECT_CALL(consumer, OnListAccountsSuccess(data)).Times(1); |
| 788 | 788 |
| 789 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); | 789 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); |
| 790 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 790 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
| 791 MockFetcher mock_fetcher(GaiaUrls::GetInstance()->list_accounts_url(), | 791 MockFetcher mock_fetcher( |
| 792 GaiaUrls::GetInstance()->ListAccountsURLWithSource(std::string()), |
| 792 status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth); | 793 status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth); |
| 793 auth.OnURLFetchComplete(&mock_fetcher); | 794 auth.OnURLFetchComplete(&mock_fetcher); |
| 794 } | 795 } |
| 795 | 796 |
| 796 TEST_F(GaiaAuthFetcherTest, GetCheckConnectionInfo) { | 797 TEST_F(GaiaAuthFetcherTest, GetCheckConnectionInfo) { |
| 797 std::string data( | 798 std::string data( |
| 798 "[{\"carryBackToken\": \"token1\", \"url\": \"http://www.google.com\"}]"); | 799 "[{\"carryBackToken\": \"token1\", \"url\": \"http://www.google.com\"}]"); |
| 799 MockGaiaConsumer consumer; | 800 MockGaiaConsumer consumer; |
| 800 EXPECT_CALL(consumer, OnGetCheckConnectionInfoSuccess(data)).Times(1); | 801 EXPECT_CALL(consumer, OnGetCheckConnectionInfoSuccess(data)).Times(1); |
| 801 | 802 |
| 802 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); | 803 GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext()); |
| 803 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 804 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
| 804 MockFetcher mock_fetcher( | 805 MockFetcher mock_fetcher( |
| 805 GaiaUrls::GetInstance()->get_check_connection_info_url(), | 806 GaiaUrls::GetInstance()->GetCheckConnectionInfoURLWithSource( |
| 807 std::string()), |
| 806 status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth); | 808 status, net::HTTP_OK, cookies_, data, net::URLFetcher::GET, &auth); |
| 807 auth.OnURLFetchComplete(&mock_fetcher); | 809 auth.OnURLFetchComplete(&mock_fetcher); |
| 808 } | 810 } |
| OLD | NEW |