Chromium Code Reviews| 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 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #endif | 10 #endif |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 #include "net/http/http_cache.h" | 47 #include "net/http/http_cache.h" |
| 48 #include "net/http/http_network_layer.h" | 48 #include "net/http/http_network_layer.h" |
| 49 #include "net/http/http_network_session.h" | 49 #include "net/http/http_network_session.h" |
| 50 #include "net/http/http_request_headers.h" | 50 #include "net/http/http_request_headers.h" |
| 51 #include "net/http/http_response_headers.h" | 51 #include "net/http/http_response_headers.h" |
| 52 #include "net/ocsp/nss_ocsp.h" | 52 #include "net/ocsp/nss_ocsp.h" |
| 53 #include "net/proxy/proxy_service.h" | 53 #include "net/proxy/proxy_service.h" |
| 54 #include "net/socket/ssl_client_socket.h" | 54 #include "net/socket/ssl_client_socket.h" |
| 55 #include "net/test/test_server.h" | 55 #include "net/test/test_server.h" |
| 56 #include "net/url_request/ftp_protocol_handler.h" | 56 #include "net/url_request/ftp_protocol_handler.h" |
| 57 #include "net/url_request/protocol_intercept_job_factory.h" | |
| 57 #include "net/url_request/static_http_user_agent_settings.h" | 58 #include "net/url_request/static_http_user_agent_settings.h" |
| 58 #include "net/url_request/url_request.h" | 59 #include "net/url_request/url_request.h" |
| 59 #include "net/url_request/url_request_file_dir_job.h" | 60 #include "net/url_request/url_request_file_dir_job.h" |
| 60 #include "net/url_request/url_request_http_job.h" | 61 #include "net/url_request/url_request_http_job.h" |
| 61 #include "net/url_request/url_request_job_factory_impl.h" | 62 #include "net/url_request/url_request_job_factory_impl.h" |
| 62 #include "net/url_request/url_request_redirect_job.h" | 63 #include "net/url_request/url_request_redirect_job.h" |
| 63 #include "net/url_request/url_request_test_job.h" | 64 #include "net/url_request/url_request_test_job.h" |
| 64 #include "net/url_request/url_request_test_util.h" | 65 #include "net/url_request/url_request_test_util.h" |
| 65 #include "testing/gtest/include/gtest/gtest.h" | 66 #include "testing/gtest/include/gtest/gtest.h" |
| 66 #include "testing/platform_test.h" | 67 #include "testing/platform_test.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 | 458 |
| 458 } // namespace | 459 } // namespace |
| 459 | 460 |
| 460 // Inherit PlatformTest since we require the autorelease pool on Mac OS X.f | 461 // Inherit PlatformTest since we require the autorelease pool on Mac OS X.f |
| 461 class URLRequestTest : public PlatformTest { | 462 class URLRequestTest : public PlatformTest { |
| 462 public: | 463 public: |
| 463 URLRequestTest() : default_context_(true) { | 464 URLRequestTest() : default_context_(true) { |
| 464 default_context_.set_network_delegate(&default_network_delegate_); | 465 default_context_.set_network_delegate(&default_network_delegate_); |
| 465 default_context_.Init(); | 466 default_context_.Init(); |
| 466 } | 467 } |
| 468 virtual ~URLRequestTest() {} | |
| 467 | 469 |
| 468 // Adds the TestJobInterceptor to the default context. | 470 // Adds the TestJobInterceptor to the default context. |
| 469 TestJobInterceptor* AddTestInterceptor() { | 471 TestJobInterceptor* AddTestInterceptor() { |
| 470 TestJobInterceptor* interceptor = new TestJobInterceptor(); | 472 TestJobInterceptor* protocol_handler_ = new TestJobInterceptor(); |
| 471 default_context_.set_job_factory(&job_factory_); | 473 job_factory_.reset(new URLRequestJobFactoryImpl); |
|
erikwright (departed)
2012/12/06 15:26:28
Is there a reason why this should be a ProtocolInt
pauljensen
2012/12/07 18:47:42
TestJobInterceptor only intercepts the first HTTP
erikwright (departed)
2012/12/07 20:12:05
OK, I see.
pauljensen
2012/12/09 23:14:12
For now they must pass things like SetProtocolHand
| |
| 472 job_factory_.AddInterceptor(interceptor); | 474 job_factory_.reset(new ProtocolInterceptJobFactory(job_factory_.Pass(), |
| 473 return interceptor; | 475 "http", |
| 476 protocol_handler_)); | |
| 477 default_context_.set_job_factory(job_factory_.get()); | |
| 478 return protocol_handler_; | |
| 474 } | 479 } |
| 475 | 480 |
| 476 protected: | 481 protected: |
| 477 TestNetworkDelegate default_network_delegate_; // Must outlive URLRequest. | 482 TestNetworkDelegate default_network_delegate_; // Must outlive URLRequest. |
| 478 URLRequestJobFactoryImpl job_factory_; | 483 scoped_ptr<URLRequestJobFactory> job_factory_; |
| 479 TestURLRequestContext default_context_; | 484 TestURLRequestContext default_context_; |
| 480 }; | 485 }; |
| 481 | 486 |
| 482 TEST_F(URLRequestTest, AboutBlankTest) { | 487 TEST_F(URLRequestTest, AboutBlankTest) { |
| 483 TestDelegate d; | 488 TestDelegate d; |
| 484 { | 489 { |
| 485 URLRequest r(GURL("about:blank"), &d, &default_context_); | 490 URLRequest r(GURL("about:blank"), &d, &default_context_); |
| 486 | 491 |
| 487 r.Start(); | 492 r.Start(); |
| 488 EXPECT_TRUE(r.is_pending()); | 493 EXPECT_TRUE(r.is_pending()); |
| (...skipping 4676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5165 | 5170 |
| 5166 EXPECT_FALSE(r.is_pending()); | 5171 EXPECT_FALSE(r.is_pending()); |
| 5167 EXPECT_EQ(1, d->response_started_count()); | 5172 EXPECT_EQ(1, d->response_started_count()); |
| 5168 EXPECT_FALSE(d->received_data_before_response()); | 5173 EXPECT_FALSE(d->received_data_before_response()); |
| 5169 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 5174 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 5170 } | 5175 } |
| 5171 } | 5176 } |
| 5172 #endif // !defined(DISABLE_FTP_SUPPORT) | 5177 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 5173 | 5178 |
| 5174 } // namespace net | 5179 } // namespace net |
| OLD | NEW |