Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 11293252: Change Interceptors into URLRequestJobFactory::ProtocolHandlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync (including tedv's change) Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 4675 matching lines...) Expand 10 before | Expand all | Expand 10 after
5166 5168
5167 EXPECT_FALSE(r.is_pending()); 5169 EXPECT_FALSE(r.is_pending());
5168 EXPECT_EQ(1, d->response_started_count()); 5170 EXPECT_EQ(1, d->response_started_count());
5169 EXPECT_FALSE(d->received_data_before_response()); 5171 EXPECT_FALSE(d->received_data_before_response());
5170 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 5172 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
5171 } 5173 }
5172 } 5174 }
5173 #endif // !defined(DISABLE_FTP_SUPPORT) 5175 #endif // !defined(DISABLE_FTP_SUPPORT)
5174 5176
5175 } // namespace net 5177 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698