| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "net/url_request/url_request_unittest.h" | 5 #include "net/url_request/url_request_unittest.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 new net::HttpCache( | 59 new net::HttpCache( |
| 60 net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_, | 60 net::HttpNetworkLayer::CreateFactory(host_resolver_, proxy_service_, |
| 61 ssl_config_service_), | 61 ssl_config_service_), |
| 62 disk_cache::CreateInMemoryCacheBackend(0)); | 62 disk_cache::CreateInMemoryCacheBackend(0)); |
| 63 // In-memory cookie store. | 63 // In-memory cookie store. |
| 64 cookie_store_ = new net::CookieMonster(); | 64 cookie_store_ = new net::CookieMonster(); |
| 65 accept_language_ = "en-us,fr"; | 65 accept_language_ = "en-us,fr"; |
| 66 accept_charset_ = "iso-8859-1,*,utf-8"; | 66 accept_charset_ = "iso-8859-1,*,utf-8"; |
| 67 } | 67 } |
| 68 | 68 |
| 69 private: |
| 69 virtual ~URLRequestTestContext() { | 70 virtual ~URLRequestTestContext() { |
| 70 delete ftp_transaction_factory_; | 71 delete ftp_transaction_factory_; |
| 71 delete http_transaction_factory_; | 72 delete http_transaction_factory_; |
| 72 } | 73 } |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 class TestURLRequest : public URLRequest { | 76 class TestURLRequest : public URLRequest { |
| 76 public: | 77 public: |
| 77 TestURLRequest(const GURL& url, Delegate* delegate) | 78 TestURLRequest(const GURL& url, Delegate* delegate) |
| 78 : URLRequest(url, delegate) { | 79 : URLRequest(url, delegate) { |
| (...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 | 1427 |
| 1427 // Custom URLRequestJobs for use with interceptor tests | 1428 // Custom URLRequestJobs for use with interceptor tests |
| 1428 class RestartTestJob : public URLRequestTestJob { | 1429 class RestartTestJob : public URLRequestTestJob { |
| 1429 public: | 1430 public: |
| 1430 explicit RestartTestJob(URLRequest* request) | 1431 explicit RestartTestJob(URLRequest* request) |
| 1431 : URLRequestTestJob(request, true) {} | 1432 : URLRequestTestJob(request, true) {} |
| 1432 protected: | 1433 protected: |
| 1433 virtual void StartAsync() { | 1434 virtual void StartAsync() { |
| 1434 this->NotifyRestartRequired(); | 1435 this->NotifyRestartRequired(); |
| 1435 } | 1436 } |
| 1437 private: |
| 1438 ~RestartTestJob() {} |
| 1436 }; | 1439 }; |
| 1437 | 1440 |
| 1438 class CancelTestJob : public URLRequestTestJob { | 1441 class CancelTestJob : public URLRequestTestJob { |
| 1439 public: | 1442 public: |
| 1440 explicit CancelTestJob(URLRequest* request) | 1443 explicit CancelTestJob(URLRequest* request) |
| 1441 : URLRequestTestJob(request, true) {} | 1444 : URLRequestTestJob(request, true) {} |
| 1442 protected: | 1445 protected: |
| 1443 virtual void StartAsync() { | 1446 virtual void StartAsync() { |
| 1444 request_->Cancel(); | 1447 request_->Cancel(); |
| 1445 } | 1448 } |
| 1449 private: |
| 1450 ~CancelTestJob() {} |
| 1446 }; | 1451 }; |
| 1447 | 1452 |
| 1448 class CancelThenRestartTestJob : public URLRequestTestJob { | 1453 class CancelThenRestartTestJob : public URLRequestTestJob { |
| 1449 public: | 1454 public: |
| 1450 explicit CancelThenRestartTestJob(URLRequest* request) | 1455 explicit CancelThenRestartTestJob(URLRequest* request) |
| 1451 : URLRequestTestJob(request, true) { | 1456 : URLRequestTestJob(request, true) { |
| 1452 } | 1457 } |
| 1453 protected: | 1458 protected: |
| 1454 virtual void StartAsync() { | 1459 virtual void StartAsync() { |
| 1455 request_->Cancel(); | 1460 request_->Cancel(); |
| 1456 this->NotifyRestartRequired(); | 1461 this->NotifyRestartRequired(); |
| 1457 } | 1462 } |
| 1463 private: |
| 1464 ~CancelThenRestartTestJob() {} |
| 1458 }; | 1465 }; |
| 1459 | 1466 |
| 1460 // An Interceptor for use with interceptor tests | 1467 // An Interceptor for use with interceptor tests |
| 1461 class TestInterceptor : URLRequest::Interceptor { | 1468 class TestInterceptor : URLRequest::Interceptor { |
| 1462 public: | 1469 public: |
| 1463 TestInterceptor() | 1470 TestInterceptor() |
| 1464 : intercept_main_request_(false), restart_main_request_(false), | 1471 : intercept_main_request_(false), restart_main_request_(false), |
| 1465 cancel_main_request_(false), cancel_then_restart_main_request_(false), | 1472 cancel_main_request_(false), cancel_then_restart_main_request_(false), |
| 1466 simulate_main_network_error_(false), | 1473 simulate_main_network_error_(false), |
| 1467 intercept_redirect_(false), cancel_redirect_request_(false), | 1474 intercept_redirect_(false), cancel_redirect_request_(false), |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2203 ASSERT_TRUE(NULL != server_.get()); | 2210 ASSERT_TRUE(NULL != server_.get()); |
| 2204 TestDelegate d; | 2211 TestDelegate d; |
| 2205 TestURLRequest | 2212 TestURLRequest |
| 2206 req(server_->TestServerPage("echoheaderoverride?Accept-Charset"), &d); | 2213 req(server_->TestServerPage("echoheaderoverride?Accept-Charset"), &d); |
| 2207 req.set_context(new URLRequestTestContext()); | 2214 req.set_context(new URLRequestTestContext()); |
| 2208 req.SetExtraRequestHeaders("Accept-Charset: koi-8r"); | 2215 req.SetExtraRequestHeaders("Accept-Charset: koi-8r"); |
| 2209 req.Start(); | 2216 req.Start(); |
| 2210 MessageLoop::current()->Run(); | 2217 MessageLoop::current()->Run(); |
| 2211 EXPECT_EQ(std::string("koi-8r"), d.data_received()); | 2218 EXPECT_EQ(std::string("koi-8r"), d.data_received()); |
| 2212 } | 2219 } |
| OLD | NEW |