| 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 457 |
| 458 } // namespace | 458 } // namespace |
| 459 | 459 |
| 460 // Inherit PlatformTest since we require the autorelease pool on Mac OS X. | 460 // Inherit PlatformTest since we require the autorelease pool on Mac OS X. |
| 461 class URLRequestTest : public PlatformTest { | 461 class URLRequestTest : public PlatformTest { |
| 462 public: | 462 public: |
| 463 URLRequestTest() : default_context_(true) { | 463 URLRequestTest() : default_context_(true) { |
| 464 default_context_.set_network_delegate(&default_network_delegate_); | 464 default_context_.set_network_delegate(&default_network_delegate_); |
| 465 default_context_.Init(); | 465 default_context_.Init(); |
| 466 } | 466 } |
| 467 virtual ~URLRequestTest() {} |
| 467 | 468 |
| 468 // Adds the TestJobInterceptor to the default context. | 469 // Adds the TestJobInterceptor to the default context. |
| 469 TestJobInterceptor* AddTestInterceptor() { | 470 TestJobInterceptor* AddTestInterceptor() { |
| 470 TestJobInterceptor* interceptor = new TestJobInterceptor(); | 471 TestJobInterceptor* protocol_handler_ = new TestJobInterceptor(); |
| 471 default_context_.set_job_factory(&job_factory_); | 472 job_factory_.reset(new URLRequestJobFactoryImpl); |
| 472 job_factory_.AddInterceptor(interceptor); | 473 job_factory_->SetProtocolHandler("http", protocol_handler_); |
| 473 return interceptor; | 474 default_context_.set_job_factory(job_factory_.get()); |
| 475 return protocol_handler_; |
| 474 } | 476 } |
| 475 | 477 |
| 476 protected: | 478 protected: |
| 477 TestNetworkDelegate default_network_delegate_; // Must outlive URLRequest. | 479 TestNetworkDelegate default_network_delegate_; // Must outlive URLRequest. |
| 478 URLRequestJobFactoryImpl job_factory_; | 480 scoped_ptr<URLRequestJobFactoryImpl> job_factory_; |
| 479 TestURLRequestContext default_context_; | 481 TestURLRequestContext default_context_; |
| 480 }; | 482 }; |
| 481 | 483 |
| 482 TEST_F(URLRequestTest, AboutBlankTest) { | 484 TEST_F(URLRequestTest, AboutBlankTest) { |
| 483 TestDelegate d; | 485 TestDelegate d; |
| 484 { | 486 { |
| 485 URLRequest r(GURL("about:blank"), &d, &default_context_); | 487 URLRequest r(GURL("about:blank"), &d, &default_context_); |
| 486 | 488 |
| 487 r.Start(); | 489 r.Start(); |
| 488 EXPECT_TRUE(r.is_pending()); | 490 EXPECT_TRUE(r.is_pending()); |
| (...skipping 4676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5165 | 5167 |
| 5166 EXPECT_FALSE(r.is_pending()); | 5168 EXPECT_FALSE(r.is_pending()); |
| 5167 EXPECT_EQ(1, d->response_started_count()); | 5169 EXPECT_EQ(1, d->response_started_count()); |
| 5168 EXPECT_FALSE(d->received_data_before_response()); | 5170 EXPECT_FALSE(d->received_data_before_response()); |
| 5169 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 5171 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 5170 } | 5172 } |
| 5171 } | 5173 } |
| 5172 #endif // !defined(DISABLE_FTP_SUPPORT) | 5174 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 5173 | 5175 |
| 5174 } // namespace net | 5176 } // namespace net |
| OLD | NEW |