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

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

Issue 1301333002: make ProxyService::CreateSystemProxyConfigService return scoped_ptrs NOT FOR REVIEW (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: non linux builds Created 5 years, 4 months 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
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 "net/url_request/url_request_ftp_job.h" 5 #include "net/url_request/url_request_ftp_job.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 FtpTransaction* CreateTransaction() override { return NULL; } 129 FtpTransaction* CreateTransaction() override { return NULL; }
130 130
131 void Suspend(bool suspend) override {} 131 void Suspend(bool suspend) override {}
132 }; 132 };
133 133
134 // Fixture for priority-related tests. Priority matters when there is 134 // Fixture for priority-related tests. Priority matters when there is
135 // an HTTP proxy. 135 // an HTTP proxy.
136 class URLRequestFtpJobPriorityTest : public testing::Test { 136 class URLRequestFtpJobPriorityTest : public testing::Test {
137 protected: 137 protected:
138 URLRequestFtpJobPriorityTest() 138 URLRequestFtpJobPriorityTest()
139 : proxy_service_(new SimpleProxyConfigService, NULL, NULL), 139 : proxy_service_(make_scoped_ptr(new SimpleProxyConfigService).Pass(),
140 NULL,
141 NULL),
140 req_(context_.CreateRequest(GURL("ftp://ftp.example.com"), 142 req_(context_.CreateRequest(GURL("ftp://ftp.example.com"),
141 DEFAULT_PRIORITY, 143 DEFAULT_PRIORITY,
142 &delegate_)) { 144 &delegate_)) {
143 context_.set_proxy_service(&proxy_service_); 145 context_.set_proxy_service(&proxy_service_);
144 context_.set_http_transaction_factory(&network_layer_); 146 context_.set_http_transaction_factory(&network_layer_);
145 } 147 }
146 148
147 ProxyService proxy_service_; 149 ProxyService proxy_service_;
148 MockNetworkLayer network_layer_; 150 MockNetworkLayer network_layer_;
149 MockFtpTransactionFactory ftp_factory_; 151 MockFtpTransactionFactory ftp_factory_;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 220
219 // Creates a second transaction. 221 // Creates a second transaction.
220 job->Start(); 222 job->Start();
221 ASSERT_TRUE(network_layer_.last_transaction()); 223 ASSERT_TRUE(network_layer_.last_transaction());
222 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); 224 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority());
223 } 225 }
224 226
225 class URLRequestFtpJobTest : public testing::Test { 227 class URLRequestFtpJobTest : public testing::Test {
226 public: 228 public:
227 URLRequestFtpJobTest() 229 URLRequestFtpJobTest()
228 : request_context_(&socket_factory_, 230 : request_context_(
229 new ProxyService( 231 &socket_factory_,
230 new SimpleProxyConfigService, NULL, NULL), 232 new ProxyService(make_scoped_ptr(new SimpleProxyConfigService),
231 &network_delegate_, 233 NULL,
232 &ftp_transaction_factory_) { 234 NULL),
233 } 235 &network_delegate_,
236 &ftp_transaction_factory_) {}
234 237
235 ~URLRequestFtpJobTest() override { 238 ~URLRequestFtpJobTest() override {
236 // Clean up any remaining tasks that mess up unrelated tests. 239 // Clean up any remaining tasks that mess up unrelated tests.
237 base::RunLoop().RunUntilIdle(); 240 base::RunLoop().RunUntilIdle();
238 } 241 }
239 242
240 void AddSocket(MockRead* reads, size_t reads_size, 243 void AddSocket(MockRead* reads, size_t reads_size,
241 MockWrite* writes, size_t writes_size) { 244 MockWrite* writes, size_t writes_size) {
242 SequencedSocketData* socket_data = 245 SequencedSocketData* socket_data =
243 new SequencedSocketData(reads, reads_size, writes, writes_size); 246 new SequencedSocketData(reads, reads_size, writes, writes_size);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 EXPECT_EQ(1, network_delegate()->completed_requests()); 291 EXPECT_EQ(1, network_delegate()->completed_requests());
289 EXPECT_EQ(0, network_delegate()->error_count()); 292 EXPECT_EQ(0, network_delegate()->error_count());
290 EXPECT_FALSE(request_delegate.auth_required_called()); 293 EXPECT_FALSE(request_delegate.auth_required_called());
291 EXPECT_EQ("test.html", request_delegate.data_received()); 294 EXPECT_EQ("test.html", request_delegate.data_received());
292 } 295 }
293 296
294 // Regression test for http://crbug.com/237526 . 297 // Regression test for http://crbug.com/237526 .
295 TEST_F(URLRequestFtpJobTest, FtpProxyRequestOrphanJob) { 298 TEST_F(URLRequestFtpJobTest, FtpProxyRequestOrphanJob) {
296 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL. 299 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL.
297 request_context()->set_proxy_service(new ProxyService( 300 request_context()->set_proxy_service(new ProxyService(
298 new ProxyConfigServiceFixed( 301 make_scoped_ptr(new ProxyConfigServiceFixed(
299 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo"))), 302 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))),
300 make_scoped_ptr(new MockProxyResolverFactory), NULL)); 303 make_scoped_ptr(new MockProxyResolverFactory), NULL));
301 304
302 TestDelegate request_delegate; 305 TestDelegate request_delegate;
303 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest( 306 scoped_ptr<URLRequest> url_request(request_context()->CreateRequest(
304 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate)); 307 GURL("ftp://ftp.example.com/"), DEFAULT_PRIORITY, &request_delegate));
305 url_request->Start(); 308 url_request->Start();
306 309
307 // Now |url_request| will be deleted before its completion, 310 // Now |url_request| will be deleted before its completion,
308 // resulting in it being orphaned. It should not crash. 311 // resulting in it being orphaned. It should not crash.
309 } 312 }
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 EXPECT_TRUE(url_request2->status().is_success()); 729 EXPECT_TRUE(url_request2->status().is_success());
727 EXPECT_EQ(2, network_delegate()->completed_requests()); 730 EXPECT_EQ(2, network_delegate()->completed_requests());
728 EXPECT_EQ(0, network_delegate()->error_count()); 731 EXPECT_EQ(0, network_delegate()->error_count());
729 EXPECT_FALSE(request_delegate2.auth_required_called()); 732 EXPECT_FALSE(request_delegate2.auth_required_called());
730 EXPECT_EQ("test2.html", request_delegate2.data_received()); 733 EXPECT_EQ("test2.html", request_delegate2.data_received());
731 } 734 }
732 735
733 } // namespace 736 } // namespace
734 737
735 } // namespace net 738 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698