| 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 #ifndef CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ | 5 #ifndef CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ |
| 6 #define CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ | 6 #define CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // Overriden to cache the chunks uploaded. Caller can read back the uploaded | 66 // Overriden to cache the chunks uploaded. Caller can read back the uploaded |
| 67 // chunks with the upload_data() accessor. | 67 // chunks with the upload_data() accessor. |
| 68 virtual void AppendChunkToUpload(const std::string& data, bool is_last_chunk); | 68 virtual void AppendChunkToUpload(const std::string& data, bool is_last_chunk); |
| 69 | 69 |
| 70 // Unique ID in our factory. | 70 // Unique ID in our factory. |
| 71 int id() const { return id_; } | 71 int id() const { return id_; } |
| 72 | 72 |
| 73 // URL we were created with. Because of how we're using URLFetcher url() | 73 // URL we were created with. Because of how we're using URLFetcher url() |
| 74 // always returns an empty URL. Chances are you'll want to use original_url() | 74 // always returns an empty URL. Chances are you'll want to use original_url() |
| 75 // in your tests. | 75 // in your tests. |
| 76 const GURL& original_url() const { return original_url_; } | 76 virtual const GURL& original_url() const OVERRIDE { return original_url_; } |
| 77 | 77 |
| 78 // Returns the data uploaded on this URLFetcher. | 78 // Returns the data uploaded on this URLFetcher. |
| 79 const std::string& upload_data() const { return URLFetcher::upload_data(); } | 79 const std::string& upload_data() const { return URLFetcher::upload_data(); } |
| 80 | 80 |
| 81 // Returns the chunks of data uploaded on this URLFetcher. | 81 // Returns the chunks of data uploaded on this URLFetcher. |
| 82 const std::list<std::string>& upload_chunks() const { return chunks_; } | 82 const std::list<std::string>& upload_chunks() const { return chunks_; } |
| 83 | 83 |
| 84 // Returns the delegate installed on the URLFetcher. | 84 // Returns the delegate installed on the URLFetcher. |
| 85 Delegate* delegate() const { return URLFetcher::delegate(); } | 85 Delegate* delegate() const { return URLFetcher::delegate(); } |
| 86 | 86 |
| 87 void set_url(const GURL& url) { fake_url_ = url; } | 87 void set_url(const GURL& url) { fake_url_ = url; } |
| 88 virtual const GURL& url() const; | 88 virtual const GURL& url() const OVERRIDE; |
| 89 | 89 |
| 90 void set_status(const net::URLRequestStatus& status); | 90 void set_status(const net::URLRequestStatus& status); |
| 91 virtual const net::URLRequestStatus& status() const; | 91 virtual const net::URLRequestStatus& status() const OVERRIDE; |
| 92 | 92 |
| 93 void set_response_code(int response_code) { | 93 void set_response_code(int response_code) { |
| 94 fake_response_code_ = response_code; | 94 fake_response_code_ = response_code; |
| 95 } | 95 } |
| 96 virtual int response_code() const; | 96 virtual int response_code() const OVERRIDE; |
| 97 | 97 |
| 98 // Set string data. | 98 // Set string data. |
| 99 void SetResponseString(const std::string& response); | 99 void SetResponseString(const std::string& response); |
| 100 | 100 |
| 101 // Set File data. | 101 // Set File data. |
| 102 void SetResponseFilePath(const FilePath& path); | 102 void SetResponseFilePath(const FilePath& path); |
| 103 | 103 |
| 104 // Override response access functions to return fake data. | 104 // Override response access functions to return fake data. |
| 105 virtual bool GetResponseAsString(std::string* out_response_string) const; | 105 virtual bool GetResponseAsString(std::string* out_response_string) const |
| 106 OVERRIDE; |
| 106 virtual bool GetResponseAsFilePath(bool take_ownership, | 107 virtual bool GetResponseAsFilePath(bool take_ownership, |
| 107 FilePath* out_response_path) const; | 108 FilePath* out_response_path) const |
| 109 OVERRIDE; |
| 108 | 110 |
| 109 private: | 111 private: |
| 110 const int id_; | 112 const int id_; |
| 111 const GURL original_url_; | 113 const GURL original_url_; |
| 112 std::list<std::string> chunks_; | 114 std::list<std::string> chunks_; |
| 113 bool did_receive_last_chunk_; | 115 bool did_receive_last_chunk_; |
| 114 | 116 |
| 115 // User can use set_* methods to provide values returned by getters. | 117 // User can use set_* methods to provide values returned by getters. |
| 116 // Setting the real values is not possible, because the real class | 118 // Setting the real values is not possible, because the real class |
| 117 // has no setters. The data is a private member of a class defined | 119 // has no setters. The data is a private member of a class defined |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 230 |
| 229 // This method will create a real URLFetcher. | 231 // This method will create a real URLFetcher. |
| 230 virtual URLFetcher* CreateURLFetcher(int id, | 232 virtual URLFetcher* CreateURLFetcher(int id, |
| 231 const GURL& url, | 233 const GURL& url, |
| 232 URLFetcher::RequestType request_type, | 234 URLFetcher::RequestType request_type, |
| 233 URLFetcher::Delegate* d); | 235 URLFetcher::Delegate* d); |
| 234 | 236 |
| 235 }; | 237 }; |
| 236 | 238 |
| 237 #endif // CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ | 239 #endif // CONTENT_TEST_TEST_URL_FETCHER_FACTORY_H_ |
| OLD | NEW |