| 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 #include "chrome/browser/chromeos/login/mock_auth_response_handler.h" | 5 #include "chrome/browser/chromeos/login/mock_auth_response_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "content/common/net/url_fetcher.h" | |
| 12 #include "content/public/common/url_fetcher_delegate.h" | 11 #include "content/public/common/url_fetcher_delegate.h" |
| 13 #include "content/test/test_url_fetcher_factory.h" | 12 #include "content/test/test_url_fetcher_factory.h" |
| 14 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 15 #include "net/url_request/url_request_status.h" | 14 #include "net/url_request/url_request_status.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 17 | 16 |
| 18 namespace chromeos { | 17 namespace chromeos { |
| 19 | 18 |
| 20 using ::testing::_; | 19 using ::testing::_; |
| 21 using ::testing::Invoke; | 20 using ::testing::Invoke; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 } | 36 } |
| 38 | 37 |
| 39 MockAuthResponseHandler::~MockAuthResponseHandler() {} | 38 MockAuthResponseHandler::~MockAuthResponseHandler() {} |
| 40 | 39 |
| 41 void MockAuthResponseHandler::CompleteFetch( | 40 void MockAuthResponseHandler::CompleteFetch( |
| 42 content::URLFetcherDelegate* delegate, | 41 content::URLFetcherDelegate* delegate, |
| 43 const GURL remote, | 42 const GURL remote, |
| 44 const net::URLRequestStatus status, | 43 const net::URLRequestStatus status, |
| 45 const int http_response_code, | 44 const int http_response_code, |
| 46 const std::string data) { | 45 const std::string data) { |
| 47 TestURLFetcher fetcher(0, GURL(), URLFetcher::GET, delegate); | 46 TestURLFetcher fetcher(0, GURL(), content::URLFetcher::GET, delegate); |
| 48 fetcher.set_url(remote); | 47 fetcher.set_url(remote); |
| 49 fetcher.set_status(status); | 48 fetcher.set_status(status); |
| 50 fetcher.set_response_code(http_response_code); | 49 fetcher.set_response_code(http_response_code); |
| 51 fetcher.SetResponseString(data); | 50 fetcher.SetResponseString(data); |
| 52 delegate->OnURLFetchComplete(&fetcher); | 51 delegate->OnURLFetchComplete(&fetcher); |
| 53 } | 52 } |
| 54 | 53 |
| 55 URLFetcher* MockAuthResponseHandler::MockNetwork( | 54 content::URLFetcher* MockAuthResponseHandler::MockNetwork( |
| 56 std::string data, | 55 std::string data, |
| 57 content::URLFetcherDelegate* delegate) { | 56 content::URLFetcherDelegate* delegate) { |
| 58 MessageLoop::current()->PostTask( | 57 MessageLoop::current()->PostTask( |
| 59 FROM_HERE, | 58 FROM_HERE, |
| 60 base::Bind(MockAuthResponseHandler::CompleteFetch, delegate, remote_, | 59 base::Bind(MockAuthResponseHandler::CompleteFetch, delegate, remote_, |
| 61 status_, http_response_code_, data_)); | 60 status_, http_response_code_, data_)); |
| 62 return new URLFetcher(GURL(), URLFetcher::GET, delegate); | 61 return content::URLFetcher::Create( |
| 62 GURL(), content::URLFetcher::GET, delegate); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace chromeos | 65 } // namespace chromeos |
| OLD | NEW |