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

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

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

Powered by Google App Engine
This is Rietveld 408576698