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

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: Created 8 years, 1 month 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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/11/27 05:54:05 I assume this wrapped factory exists because someo
pauljensen 2012/11/30 21:02:34 Nobody adds protocol handlers later and job_factor
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 4624 matching lines...) Expand 10 before | Expand all | Expand 10 after
5113 5118
5114 EXPECT_FALSE(r.is_pending()); 5119 EXPECT_FALSE(r.is_pending());
5115 EXPECT_EQ(1, d->response_started_count()); 5120 EXPECT_EQ(1, d->response_started_count());
5116 EXPECT_FALSE(d->received_data_before_response()); 5121 EXPECT_FALSE(d->received_data_before_response());
5117 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 5122 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
5118 } 5123 }
5119 } 5124 }
5120 #endif // !defined(DISABLE_FTP_SUPPORT) 5125 #endif // !defined(DISABLE_FTP_SUPPORT)
5121 5126
5122 } // namespace net 5127 } // namespace net
OLDNEW
« net/url_request/url_request_filter.h ('K') | « net/url_request/url_request_test_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698