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