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

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

Issue 51953002: [Net] Add a priority parameter to URLRequest's constructor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error from rebase Created 7 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 "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_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "net/base/request_priority.h"
10 #include "net/ftp/ftp_auth_cache.h" 11 #include "net/ftp/ftp_auth_cache.h"
11 #include "net/http/http_transaction_unittest.h" 12 #include "net/http/http_transaction_unittest.h"
12 #include "net/proxy/mock_proxy_resolver.h" 13 #include "net/proxy/mock_proxy_resolver.h"
13 #include "net/proxy/proxy_config_service.h" 14 #include "net/proxy/proxy_config_service.h"
14 #include "net/proxy/proxy_config_service_fixed.h" 15 #include "net/proxy/proxy_config_service_fixed.h"
15 #include "net/socket/socket_test_util.h" 16 #include "net/socket/socket_test_util.h"
16 #include "net/url_request/ftp_protocol_handler.h" 17 #include "net/url_request/ftp_protocol_handler.h"
17 #include "net/url_request/url_request.h" 18 #include "net/url_request/url_request.h"
18 #include "net/url_request/url_request_context.h" 19 #include "net/url_request/url_request_context.h"
19 #include "net/url_request/url_request_job_factory_impl.h" 20 #include "net/url_request/url_request_job_factory_impl.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 115
115 virtual void Suspend(bool suspend) OVERRIDE {} 116 virtual void Suspend(bool suspend) OVERRIDE {}
116 }; 117 };
117 118
118 // Fixture for priority-related tests. Priority matters when there is 119 // Fixture for priority-related tests. Priority matters when there is
119 // an HTTP proxy. 120 // an HTTP proxy.
120 class URLRequestFtpJobPriorityTest : public testing::Test { 121 class URLRequestFtpJobPriorityTest : public testing::Test {
121 protected: 122 protected:
122 URLRequestFtpJobPriorityTest() 123 URLRequestFtpJobPriorityTest()
123 : proxy_service_(new SimpleProxyConfigService, NULL, NULL), 124 : proxy_service_(new SimpleProxyConfigService, NULL, NULL),
124 req_(GURL("ftp://ftp.example.com"), &delegate_, &context_, NULL) { 125 req_(GURL("ftp://ftp.example.com"),
126 DEFAULT_PRIORITY,
127 &delegate_,
128 &context_,
129 NULL) {
125 context_.set_proxy_service(&proxy_service_); 130 context_.set_proxy_service(&proxy_service_);
126 context_.set_http_transaction_factory(&network_layer_); 131 context_.set_http_transaction_factory(&network_layer_);
127 } 132 }
128 133
129 ProxyService proxy_service_; 134 ProxyService proxy_service_;
130 MockNetworkLayer network_layer_; 135 MockNetworkLayer network_layer_;
131 MockFtpTransactionFactory ftp_factory_; 136 MockFtpTransactionFactory ftp_factory_;
132 FtpAuthCache ftp_auth_cache_; 137 FtpAuthCache ftp_auth_cache_;
133 TestURLRequestContext context_; 138 TestURLRequestContext context_;
134 TestDelegate delegate_; 139 TestDelegate delegate_;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 MockRead reads[] = { 260 MockRead reads[] = {
256 MockRead(ASYNC, 1, "HTTP/1.1 200 OK\r\n"), 261 MockRead(ASYNC, 1, "HTTP/1.1 200 OK\r\n"),
257 MockRead(ASYNC, 2, "Content-Length: 9\r\n\r\n"), 262 MockRead(ASYNC, 2, "Content-Length: 9\r\n\r\n"),
258 MockRead(ASYNC, 3, "test.html"), 263 MockRead(ASYNC, 3, "test.html"),
259 }; 264 };
260 265
261 AddSocket(reads, arraysize(reads), writes, arraysize(writes)); 266 AddSocket(reads, arraysize(reads), writes, arraysize(writes));
262 267
263 TestDelegate request_delegate; 268 TestDelegate request_delegate;
264 URLRequest url_request(GURL("ftp://ftp.example.com/"), 269 URLRequest url_request(GURL("ftp://ftp.example.com/"),
270 DEFAULT_PRIORITY,
265 &request_delegate, 271 &request_delegate,
266 request_context(), 272 request_context(),
267 network_delegate()); 273 network_delegate());
268 url_request.Start(); 274 url_request.Start();
269 ASSERT_TRUE(url_request.is_pending()); 275 ASSERT_TRUE(url_request.is_pending());
270 socket_data(0)->RunFor(4); 276 socket_data(0)->RunFor(4);
271 277
272 EXPECT_TRUE(url_request.status().is_success()); 278 EXPECT_TRUE(url_request.status().is_success());
273 EXPECT_EQ(1, network_delegate()->completed_requests()); 279 EXPECT_EQ(1, network_delegate()->completed_requests());
274 EXPECT_EQ(0, network_delegate()->error_count()); 280 EXPECT_EQ(0, network_delegate()->error_count());
275 EXPECT_FALSE(request_delegate.auth_required_called()); 281 EXPECT_FALSE(request_delegate.auth_required_called());
276 EXPECT_EQ("test.html", request_delegate.data_received()); 282 EXPECT_EQ("test.html", request_delegate.data_received());
277 } 283 }
278 284
279 // Regression test for http://crbug.com/237526 . 285 // Regression test for http://crbug.com/237526 .
280 TEST_F(URLRequestFtpJobTest, FtpProxyRequestOrphanJob) { 286 TEST_F(URLRequestFtpJobTest, FtpProxyRequestOrphanJob) {
281 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL. 287 // Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL.
282 request_context()->set_proxy_service( 288 request_context()->set_proxy_service(
283 new ProxyService( 289 new ProxyService(
284 new ProxyConfigServiceFixed( 290 new ProxyConfigServiceFixed(
285 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo"))), 291 ProxyConfig::CreateFromCustomPacURL(GURL("http://foo"))),
286 new MockAsyncProxyResolver, NULL)); 292 new MockAsyncProxyResolver, NULL));
287 293
288 TestDelegate request_delegate; 294 TestDelegate request_delegate;
289 URLRequest url_request(GURL("ftp://ftp.example.com/"), 295 URLRequest url_request(GURL("ftp://ftp.example.com/"),
296 DEFAULT_PRIORITY,
290 &request_delegate, 297 &request_delegate,
291 request_context(), 298 request_context(),
292 network_delegate()); 299 network_delegate());
293 url_request.Start(); 300 url_request.Start();
294 301
295 // Now |url_request| will be deleted before its completion, 302 // Now |url_request| will be deleted before its completion,
296 // resulting in it being orphaned. It should not crash. 303 // resulting in it being orphaned. It should not crash.
297 } 304 }
298 305
299 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAuthNoCredentials) { 306 TEST_F(URLRequestFtpJobTest, FtpProxyRequestNeedProxyAuthNoCredentials) {
300 MockWrite writes[] = { 307 MockWrite writes[] = {
301 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n" 308 MockWrite(ASYNC, 0, "GET ftp://ftp.example.com/ HTTP/1.1\r\n"
302 "Host: ftp.example.com\r\n" 309 "Host: ftp.example.com\r\n"
303 "Proxy-Connection: keep-alive\r\n\r\n"), 310 "Proxy-Connection: keep-alive\r\n\r\n"),
304 }; 311 };
305 MockRead reads[] = { 312 MockRead reads[] = {
306 // No credentials. 313 // No credentials.
307 MockRead(ASYNC, 1, "HTTP/1.1 407 Proxy Authentication Required\r\n"), 314 MockRead(ASYNC, 1, "HTTP/1.1 407 Proxy Authentication Required\r\n"),
308 MockRead(ASYNC, 2, "Proxy-Authenticate: Basic " 315 MockRead(ASYNC, 2, "Proxy-Authenticate: Basic "
309 "realm=\"MyRealm1\"\r\n"), 316 "realm=\"MyRealm1\"\r\n"),
310 MockRead(ASYNC, 3, "Content-Length: 9\r\n\r\n"), 317 MockRead(ASYNC, 3, "Content-Length: 9\r\n\r\n"),
311 MockRead(ASYNC, 4, "test.html"), 318 MockRead(ASYNC, 4, "test.html"),
312 }; 319 };
313 320
314 AddSocket(reads, arraysize(reads), writes, arraysize(writes)); 321 AddSocket(reads, arraysize(reads), writes, arraysize(writes));
315 322
316 TestDelegate request_delegate; 323 TestDelegate request_delegate;
317 URLRequest url_request(GURL("ftp://ftp.example.com/"), 324 URLRequest url_request(GURL("ftp://ftp.example.com/"),
325 DEFAULT_PRIORITY,
318 &request_delegate, 326 &request_delegate,
319 request_context(), 327 request_context(),
320 network_delegate()); 328 network_delegate());
321 url_request.Start(); 329 url_request.Start();
322 ASSERT_TRUE(url_request.is_pending()); 330 ASSERT_TRUE(url_request.is_pending());
323 socket_data(0)->RunFor(5); 331 socket_data(0)->RunFor(5);
324 332
325 EXPECT_TRUE(url_request.status().is_success()); 333 EXPECT_TRUE(url_request.status().is_success());
326 EXPECT_EQ(1, network_delegate()->completed_requests()); 334 EXPECT_EQ(1, network_delegate()->completed_requests());
327 EXPECT_EQ(0, network_delegate()->error_count()); 335 EXPECT_EQ(0, network_delegate()->error_count());
(...skipping 24 matching lines...) Expand all
352 MockRead(ASYNC, 7, "Content-Length: 10\r\n\r\n"), 360 MockRead(ASYNC, 7, "Content-Length: 10\r\n\r\n"),
353 MockRead(ASYNC, 8, "test2.html"), 361 MockRead(ASYNC, 8, "test2.html"),
354 }; 362 };
355 363
356 AddSocket(reads, arraysize(reads), writes, arraysize(writes)); 364 AddSocket(reads, arraysize(reads), writes, arraysize(writes));
357 365
358 TestDelegate request_delegate; 366 TestDelegate request_delegate;
359 request_delegate.set_credentials( 367 request_delegate.set_credentials(
360 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass"))); 368 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass")));
361 URLRequest url_request(GURL("ftp://ftp.example.com/"), 369 URLRequest url_request(GURL("ftp://ftp.example.com/"),
370 DEFAULT_PRIORITY,
362 &request_delegate, 371 &request_delegate,
363 request_context(), 372 request_context(),
364 network_delegate()); 373 network_delegate());
365 url_request.Start(); 374 url_request.Start();
366 ASSERT_TRUE(url_request.is_pending()); 375 ASSERT_TRUE(url_request.is_pending());
367 socket_data(0)->RunFor(9); 376 socket_data(0)->RunFor(9);
368 377
369 EXPECT_TRUE(url_request.status().is_success()); 378 EXPECT_TRUE(url_request.status().is_success());
370 EXPECT_EQ(1, network_delegate()->completed_requests()); 379 EXPECT_EQ(1, network_delegate()->completed_requests());
371 EXPECT_EQ(0, network_delegate()->error_count()); 380 EXPECT_EQ(0, network_delegate()->error_count());
(...skipping 13 matching lines...) Expand all
385 MockRead(ASYNC, 2, "WWW-Authenticate: Basic " 394 MockRead(ASYNC, 2, "WWW-Authenticate: Basic "
386 "realm=\"MyRealm1\"\r\n"), 395 "realm=\"MyRealm1\"\r\n"),
387 MockRead(ASYNC, 3, "Content-Length: 9\r\n\r\n"), 396 MockRead(ASYNC, 3, "Content-Length: 9\r\n\r\n"),
388 MockRead(ASYNC, 4, "test.html"), 397 MockRead(ASYNC, 4, "test.html"),
389 }; 398 };
390 399
391 AddSocket(reads, arraysize(reads), writes, arraysize(writes)); 400 AddSocket(reads, arraysize(reads), writes, arraysize(writes));
392 401
393 TestDelegate request_delegate; 402 TestDelegate request_delegate;
394 URLRequest url_request(GURL("ftp://ftp.example.com/"), 403 URLRequest url_request(GURL("ftp://ftp.example.com/"),
404 DEFAULT_PRIORITY,
395 &request_delegate, 405 &request_delegate,
396 request_context(), 406 request_context(),
397 network_delegate()); 407 network_delegate());
398 url_request.Start(); 408 url_request.Start();
399 ASSERT_TRUE(url_request.is_pending()); 409 ASSERT_TRUE(url_request.is_pending());
400 socket_data(0)->RunFor(5); 410 socket_data(0)->RunFor(5);
401 411
402 EXPECT_TRUE(url_request.status().is_success()); 412 EXPECT_TRUE(url_request.status().is_success());
403 EXPECT_EQ(1, network_delegate()->completed_requests()); 413 EXPECT_EQ(1, network_delegate()->completed_requests());
404 EXPECT_EQ(0, network_delegate()->error_count()); 414 EXPECT_EQ(0, network_delegate()->error_count());
(...skipping 24 matching lines...) Expand all
429 MockRead(ASYNC, 7, "Content-Length: 10\r\n\r\n"), 439 MockRead(ASYNC, 7, "Content-Length: 10\r\n\r\n"),
430 MockRead(ASYNC, 8, "test2.html"), 440 MockRead(ASYNC, 8, "test2.html"),
431 }; 441 };
432 442
433 AddSocket(reads, arraysize(reads), writes, arraysize(writes)); 443 AddSocket(reads, arraysize(reads), writes, arraysize(writes));
434 444
435 TestDelegate request_delegate; 445 TestDelegate request_delegate;
436 request_delegate.set_credentials( 446 request_delegate.set_credentials(
437 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass"))); 447 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass")));
438 URLRequest url_request(GURL("ftp://ftp.example.com/"), 448 URLRequest url_request(GURL("ftp://ftp.example.com/"),
449 DEFAULT_PRIORITY,
439 &request_delegate, 450 &request_delegate,
440 request_context(), 451 request_context(),
441 network_delegate()); 452 network_delegate());
442 url_request.Start(); 453 url_request.Start();
443 ASSERT_TRUE(url_request.is_pending()); 454 ASSERT_TRUE(url_request.is_pending());
444 socket_data(0)->RunFor(9); 455 socket_data(0)->RunFor(9);
445 456
446 EXPECT_TRUE(url_request.status().is_success()); 457 EXPECT_TRUE(url_request.status().is_success());
447 EXPECT_EQ(1, network_delegate()->completed_requests()); 458 EXPECT_EQ(1, network_delegate()->completed_requests());
448 EXPECT_EQ(0, network_delegate()->error_count()); 459 EXPECT_EQ(0, network_delegate()->error_count());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // Make sure cached FTP credentials are not used for proxy authentication. 506 // Make sure cached FTP credentials are not used for proxy authentication.
496 request_context()->GetFtpAuthCache()->Add( 507 request_context()->GetFtpAuthCache()->Add(
497 url.GetOrigin(), 508 url.GetOrigin(),
498 AuthCredentials(ASCIIToUTF16("userdonotuse"), 509 AuthCredentials(ASCIIToUTF16("userdonotuse"),
499 ASCIIToUTF16("passworddonotuse"))); 510 ASCIIToUTF16("passworddonotuse")));
500 511
501 TestDelegate request_delegate; 512 TestDelegate request_delegate;
502 request_delegate.set_credentials( 513 request_delegate.set_credentials(
503 AuthCredentials(ASCIIToUTF16("proxyuser"), ASCIIToUTF16("proxypass"))); 514 AuthCredentials(ASCIIToUTF16("proxyuser"), ASCIIToUTF16("proxypass")));
504 URLRequest url_request(url, 515 URLRequest url_request(url,
516 DEFAULT_PRIORITY,
505 &request_delegate, 517 &request_delegate,
506 request_context(), 518 request_context(),
507 network_delegate()); 519 network_delegate());
508 url_request.Start(); 520 url_request.Start();
509 ASSERT_TRUE(url_request.is_pending()); 521 ASSERT_TRUE(url_request.is_pending());
510 socket_data(0)->RunFor(5); 522 socket_data(0)->RunFor(5);
511 523
512 request_delegate.set_credentials( 524 request_delegate.set_credentials(
513 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass"))); 525 AuthCredentials(ASCIIToUTF16("myuser"), ASCIIToUTF16("mypass")));
514 socket_data(0)->RunFor(9); 526 socket_data(0)->RunFor(9);
(...skipping 15 matching lines...) Expand all
530 MockRead(ASYNC, 1, "HTTP/1.1 200 OK\r\n"), 542 MockRead(ASYNC, 1, "HTTP/1.1 200 OK\r\n"),
531 MockRead(ASYNC, 2, "Content-Length: 9\r\n"), 543 MockRead(ASYNC, 2, "Content-Length: 9\r\n"),
532 MockRead(ASYNC, 3, "Set-Cookie: name=value\r\n\r\n"), 544 MockRead(ASYNC, 3, "Set-Cookie: name=value\r\n\r\n"),
533 MockRead(ASYNC, 4, "test.html"), 545 MockRead(ASYNC, 4, "test.html"),
534 }; 546 };
535 547
536 AddSocket(reads, arraysize(reads), writes, arraysize(writes)); 548 AddSocket(reads, arraysize(reads), writes, arraysize(writes));
537 549
538 TestDelegate request_delegate; 550 TestDelegate request_delegate;
539 URLRequest url_request(GURL("ftp://ftp.example.com/"), 551 URLRequest url_request(GURL("ftp://ftp.example.com/"),
552 DEFAULT_PRIORITY,
540 &request_delegate, 553 &request_delegate,
541 request_context(), 554 request_context(),
542 network_delegate()); 555 network_delegate());
543 url_request.Start(); 556 url_request.Start();
544 ASSERT_TRUE(url_request.is_pending()); 557 ASSERT_TRUE(url_request.is_pending());
545 558
546 socket_data(0)->RunFor(5); 559 socket_data(0)->RunFor(5);
547 560
548 EXPECT_TRUE(url_request.status().is_success()); 561 EXPECT_TRUE(url_request.status().is_success());
549 EXPECT_EQ(1, network_delegate()->completed_requests()); 562 EXPECT_EQ(1, network_delegate()->completed_requests());
(...skipping 14 matching lines...) Expand all
564 }; 577 };
565 MockRead reads[] = { 578 MockRead reads[] = {
566 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 302 Found\r\n"), 579 MockRead(SYNCHRONOUS, 1, "HTTP/1.1 302 Found\r\n"),
567 MockRead(ASYNC, 2, "Location: http://other.example.com/\r\n\r\n"), 580 MockRead(ASYNC, 2, "Location: http://other.example.com/\r\n\r\n"),
568 }; 581 };
569 582
570 AddSocket(reads, arraysize(reads), writes, arraysize(writes)); 583 AddSocket(reads, arraysize(reads), writes, arraysize(writes));
571 584
572 TestDelegate request_delegate; 585 TestDelegate request_delegate;
573 URLRequest url_request(GURL("ftp://ftp.example.com/"), 586 URLRequest url_request(GURL("ftp://ftp.example.com/"),
587 DEFAULT_PRIORITY,
574 &request_delegate, 588 &request_delegate,
575 request_context(), 589 request_context(),
576 network_delegate()); 590 network_delegate());
577 url_request.Start(); 591 url_request.Start();
578 EXPECT_TRUE(url_request.is_pending()); 592 EXPECT_TRUE(url_request.is_pending());
579 593
580 base::MessageLoop::current()->RunUntilIdle(); 594 base::MessageLoop::current()->RunUntilIdle();
581 595
582 EXPECT_TRUE(url_request.is_pending()); 596 EXPECT_TRUE(url_request.is_pending());
583 EXPECT_EQ(0, request_delegate.response_started_count()); 597 EXPECT_EQ(0, request_delegate.response_started_count());
(...skipping 24 matching lines...) Expand all
608 MockRead(ASYNC, 3, "test1.html"), 622 MockRead(ASYNC, 3, "test1.html"),
609 MockRead(ASYNC, 5, "HTTP/1.1 200 OK\r\n"), 623 MockRead(ASYNC, 5, "HTTP/1.1 200 OK\r\n"),
610 MockRead(ASYNC, 6, "Content-Length: 10\r\n\r\n"), 624 MockRead(ASYNC, 6, "Content-Length: 10\r\n\r\n"),
611 MockRead(ASYNC, 7, "test2.html"), 625 MockRead(ASYNC, 7, "test2.html"),
612 }; 626 };
613 627
614 AddSocket(reads, arraysize(reads), writes, arraysize(writes)); 628 AddSocket(reads, arraysize(reads), writes, arraysize(writes));
615 629
616 TestDelegate request_delegate1; 630 TestDelegate request_delegate1;
617 URLRequest url_request1(GURL("ftp://ftp.example.com/first"), 631 URLRequest url_request1(GURL("ftp://ftp.example.com/first"),
632 DEFAULT_PRIORITY,
618 &request_delegate1, 633 &request_delegate1,
619 request_context(), 634 request_context(),
620 network_delegate()); 635 network_delegate());
621 url_request1.Start(); 636 url_request1.Start();
622 ASSERT_TRUE(url_request1.is_pending()); 637 ASSERT_TRUE(url_request1.is_pending());
623 socket_data(0)->RunFor(4); 638 socket_data(0)->RunFor(4);
624 639
625 EXPECT_TRUE(url_request1.status().is_success()); 640 EXPECT_TRUE(url_request1.status().is_success());
626 EXPECT_EQ(1, network_delegate()->completed_requests()); 641 EXPECT_EQ(1, network_delegate()->completed_requests());
627 EXPECT_EQ(0, network_delegate()->error_count()); 642 EXPECT_EQ(0, network_delegate()->error_count());
628 EXPECT_FALSE(request_delegate1.auth_required_called()); 643 EXPECT_FALSE(request_delegate1.auth_required_called());
629 EXPECT_EQ("test1.html", request_delegate1.data_received()); 644 EXPECT_EQ("test1.html", request_delegate1.data_received());
630 645
631 TestDelegate request_delegate2; 646 TestDelegate request_delegate2;
632 URLRequest url_request2(GURL("ftp://ftp.example.com/second"), 647 URLRequest url_request2(GURL("ftp://ftp.example.com/second"),
648 DEFAULT_PRIORITY,
633 &request_delegate2, 649 &request_delegate2,
634 request_context(), 650 request_context(),
635 network_delegate()); 651 network_delegate());
636 url_request2.Start(); 652 url_request2.Start();
637 ASSERT_TRUE(url_request2.is_pending()); 653 ASSERT_TRUE(url_request2.is_pending());
638 socket_data(0)->RunFor(4); 654 socket_data(0)->RunFor(4);
639 655
640 EXPECT_TRUE(url_request2.status().is_success()); 656 EXPECT_TRUE(url_request2.status().is_success());
641 EXPECT_EQ(2, network_delegate()->completed_requests()); 657 EXPECT_EQ(2, network_delegate()->completed_requests());
642 EXPECT_EQ(0, network_delegate()->error_count()); 658 EXPECT_EQ(0, network_delegate()->error_count());
(...skipping 26 matching lines...) Expand all
669 MockRead(ASYNC, 1, "HTTP/1.1 200 OK\r\n"), 685 MockRead(ASYNC, 1, "HTTP/1.1 200 OK\r\n"),
670 MockRead(ASYNC, 2, "Content-Length: 10\r\n\r\n"), 686 MockRead(ASYNC, 2, "Content-Length: 10\r\n\r\n"),
671 MockRead(ASYNC, 3, "test2.html"), 687 MockRead(ASYNC, 3, "test2.html"),
672 }; 688 };
673 689
674 AddSocket(reads1, arraysize(reads1), writes1, arraysize(writes1)); 690 AddSocket(reads1, arraysize(reads1), writes1, arraysize(writes1));
675 AddSocket(reads2, arraysize(reads2), writes2, arraysize(writes2)); 691 AddSocket(reads2, arraysize(reads2), writes2, arraysize(writes2));
676 692
677 TestDelegate request_delegate1; 693 TestDelegate request_delegate1;
678 URLRequest url_request1(GURL("ftp://ftp.example.com/first"), 694 URLRequest url_request1(GURL("ftp://ftp.example.com/first"),
695 DEFAULT_PRIORITY,
679 &request_delegate1, 696 &request_delegate1,
680 request_context(), 697 request_context(),
681 network_delegate()); 698 network_delegate());
682 url_request1.Start(); 699 url_request1.Start();
683 ASSERT_TRUE(url_request1.is_pending()); 700 ASSERT_TRUE(url_request1.is_pending());
684 socket_data(0)->RunFor(4); 701 socket_data(0)->RunFor(4);
685 702
686 EXPECT_TRUE(url_request1.status().is_success()); 703 EXPECT_TRUE(url_request1.status().is_success());
687 EXPECT_EQ(1, network_delegate()->completed_requests()); 704 EXPECT_EQ(1, network_delegate()->completed_requests());
688 EXPECT_EQ(0, network_delegate()->error_count()); 705 EXPECT_EQ(0, network_delegate()->error_count());
689 EXPECT_FALSE(request_delegate1.auth_required_called()); 706 EXPECT_FALSE(request_delegate1.auth_required_called());
690 EXPECT_EQ("test1.html", request_delegate1.data_received()); 707 EXPECT_EQ("test1.html", request_delegate1.data_received());
691 708
692 TestDelegate request_delegate2; 709 TestDelegate request_delegate2;
693 URLRequest url_request2(GURL("http://ftp.example.com/second"), 710 URLRequest url_request2(GURL("http://ftp.example.com/second"),
711 DEFAULT_PRIORITY,
694 &request_delegate2, 712 &request_delegate2,
695 request_context(), 713 request_context(),
696 network_delegate()); 714 network_delegate());
697 url_request2.Start(); 715 url_request2.Start();
698 ASSERT_TRUE(url_request2.is_pending()); 716 ASSERT_TRUE(url_request2.is_pending());
699 socket_data(1)->RunFor(4); 717 socket_data(1)->RunFor(4);
700 718
701 EXPECT_TRUE(url_request2.status().is_success()); 719 EXPECT_TRUE(url_request2.status().is_success());
702 EXPECT_EQ(2, network_delegate()->completed_requests()); 720 EXPECT_EQ(2, network_delegate()->completed_requests());
703 EXPECT_EQ(0, network_delegate()->error_count()); 721 EXPECT_EQ(0, network_delegate()->error_count());
704 EXPECT_FALSE(request_delegate2.auth_required_called()); 722 EXPECT_FALSE(request_delegate2.auth_required_called());
705 EXPECT_EQ("test2.html", request_delegate2.data_received()); 723 EXPECT_EQ("test2.html", request_delegate2.data_received());
706 } 724 }
707 725
708 } // namespace 726 } // namespace
709 727
710 } // namespace net 728 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698