| 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 collection of classes that are useful when testing things that use a | 5 // A collection of classes that are useful when testing things that use a |
| 6 // GaiaAuthFetcher. | 6 // GaiaAuthFetcher. |
| 7 | 7 |
| 8 #ifndef GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ | 8 #ifndef GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ |
| 9 #define GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ | 9 #define GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "google_apis/gaia/gaia_auth_fetcher.h" | 14 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 15 #include "net/url_request/test_url_fetcher_factory.h" | 15 #include "net/url_request/test_url_fetcher_factory.h" |
| 16 #include "net/url_request/url_request_status.h" | 16 #include "net/url_request/url_request_status.h" |
| 17 | 17 |
| 18 // Responds as though ClientLogin returned from the server. | 18 // Responds as though ClientLogin returned from the server. |
| 19 class MockFetcher : public net::TestURLFetcher { | 19 class MockFetcher : public net::TestURLFetcher { |
| 20 public: | 20 public: |
| 21 MockFetcher(bool success, | 21 MockFetcher(bool success, |
| 22 const GURL& url, | 22 const GURL& url, |
| 23 const std::string& results, | 23 const std::string& results, |
| 24 net::URLFetcher::RequestType request_type, | 24 net::URLFetcher::RequestType request_type, |
| 25 net::URLFetcherDelegate* d); | 25 net::URLFetcherDelegate* d); |
| 26 | 26 |
| 27 MockFetcher(const GURL& url, | 27 MockFetcher(const GURL& url, |
| 28 const net::URLRequestStatus& status, | 28 const net::URLRequestStatus& status, |
| 29 int response_code, | 29 int response_code, |
| 30 const net::ResponseCookies& cookies, | |
| 31 const std::string& results, | 30 const std::string& results, |
| 32 net::URLFetcher::RequestType request_type, | 31 net::URLFetcher::RequestType request_type, |
| 33 net::URLFetcherDelegate* d); | 32 net::URLFetcherDelegate* d); |
| 34 | 33 |
| 35 ~MockFetcher() override; | 34 ~MockFetcher() override; |
| 36 | 35 |
| 37 void Start() override; | 36 void Start() override; |
| 38 | 37 |
| 39 private: | 38 private: |
| 40 DISALLOW_COPY_AND_ASSIGN(MockFetcher); | 39 DISALLOW_COPY_AND_ASSIGN(MockFetcher); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 63 void set_results(const std::string& results) { | 62 void set_results(const std::string& results) { |
| 64 results_ = results; | 63 results_ = results; |
| 65 } | 64 } |
| 66 private: | 65 private: |
| 67 bool success_; | 66 bool success_; |
| 68 std::string results_; | 67 std::string results_; |
| 69 DISALLOW_COPY_AND_ASSIGN(MockURLFetcherFactory); | 68 DISALLOW_COPY_AND_ASSIGN(MockURLFetcherFactory); |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 #endif // GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ | 71 #endif // GOOGLE_APIS_GAIA_MOCK_URL_FETCHER_FACTORY_H_ |
| OLD | NEW |