| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 extra_headers.SetHeader(net::HttpRequestHeaders::kRange, | 488 extra_headers.SetHeader(net::HttpRequestHeaders::kRange, |
| 489 net::HttpByteRange::Bounded(5, 10).GetHeaderValue()); | 489 net::HttpByteRange::Bounded(5, 10).GetHeaderValue()); |
| 490 expected_status_code_ = 206; | 490 expected_status_code_ = 206; |
| 491 expected_response_ = result.substr(5, 10 - 5 + 1); | 491 expected_response_ = result.substr(5, 10 - 5 + 1); |
| 492 TestRequest("GET", extra_headers); | 492 TestRequest("GET", extra_headers); |
| 493 | 493 |
| 494 EXPECT_EQ(6, request_->response_headers()->GetContentLength()); | 494 EXPECT_EQ(6, request_->response_headers()->GetContentLength()); |
| 495 EXPECT_FALSE(url_request_delegate_.metadata()); | 495 EXPECT_FALSE(url_request_delegate_.metadata()); |
| 496 | 496 |
| 497 int64_t first = 0, last = 0, length = 0; | 497 int64_t first = 0, last = 0, length = 0; |
| 498 EXPECT_TRUE( | 498 EXPECT_TRUE(request_->response_headers()->GetContentRangeFor206(&first, &last, |
| 499 request_->response_headers()->GetContentRange(&first, &last, &length)); | 499 &length)); |
| 500 EXPECT_EQ(5, first); | 500 EXPECT_EQ(5, first); |
| 501 EXPECT_EQ(10, last); | 501 EXPECT_EQ(10, last); |
| 502 EXPECT_EQ(GetTotalBlobLength(), length); | 502 EXPECT_EQ(GetTotalBlobLength(), length); |
| 503 } | 503 } |
| 504 | 504 |
| 505 TEST_F(BlobURLRequestJobTest, TestGetRangeRequest2) { | 505 TEST_F(BlobURLRequestJobTest, TestGetRangeRequest2) { |
| 506 SetUpFileSystem(); | 506 SetUpFileSystem(); |
| 507 std::string result; | 507 std::string result; |
| 508 BuildComplicatedData(&result); | 508 BuildComplicatedData(&result); |
| 509 net::HttpRequestHeaders extra_headers; | 509 net::HttpRequestHeaders extra_headers; |
| 510 extra_headers.SetHeader(net::HttpRequestHeaders::kRange, | 510 extra_headers.SetHeader(net::HttpRequestHeaders::kRange, |
| 511 net::HttpByteRange::Suffix(10).GetHeaderValue()); | 511 net::HttpByteRange::Suffix(10).GetHeaderValue()); |
| 512 expected_status_code_ = 206; | 512 expected_status_code_ = 206; |
| 513 expected_response_ = result.substr(result.length() - 10); | 513 expected_response_ = result.substr(result.length() - 10); |
| 514 TestRequest("GET", extra_headers); | 514 TestRequest("GET", extra_headers); |
| 515 | 515 |
| 516 EXPECT_EQ(10, request_->response_headers()->GetContentLength()); | 516 EXPECT_EQ(10, request_->response_headers()->GetContentLength()); |
| 517 EXPECT_FALSE(url_request_delegate_.metadata()); | 517 EXPECT_FALSE(url_request_delegate_.metadata()); |
| 518 | 518 |
| 519 int64_t total = GetTotalBlobLength(); | 519 int64_t total = GetTotalBlobLength(); |
| 520 int64_t first = 0, last = 0, length = 0; | 520 int64_t first = 0, last = 0, length = 0; |
| 521 EXPECT_TRUE( | 521 EXPECT_TRUE(request_->response_headers()->GetContentRangeFor206(&first, &last, |
| 522 request_->response_headers()->GetContentRange(&first, &last, &length)); | 522 &length)); |
| 523 EXPECT_EQ(total - 10, first); | 523 EXPECT_EQ(total - 10, first); |
| 524 EXPECT_EQ(total - 1, last); | 524 EXPECT_EQ(total - 1, last); |
| 525 EXPECT_EQ(total, length); | 525 EXPECT_EQ(total, length); |
| 526 } | 526 } |
| 527 | 527 |
| 528 TEST_F(BlobURLRequestJobTest, TestGetRangeRequest3) { | 528 TEST_F(BlobURLRequestJobTest, TestGetRangeRequest3) { |
| 529 SetUpFileSystem(); | 529 SetUpFileSystem(); |
| 530 std::string result; | 530 std::string result; |
| 531 BuildComplicatedData(&result); | 531 BuildComplicatedData(&result); |
| 532 net::HttpRequestHeaders extra_headers; | 532 net::HttpRequestHeaders extra_headers; |
| 533 extra_headers.SetHeader(net::HttpRequestHeaders::kRange, | 533 extra_headers.SetHeader(net::HttpRequestHeaders::kRange, |
| 534 net::HttpByteRange::Bounded(0, 2).GetHeaderValue()); | 534 net::HttpByteRange::Bounded(0, 2).GetHeaderValue()); |
| 535 expected_status_code_ = 206; | 535 expected_status_code_ = 206; |
| 536 expected_response_ = result.substr(0, 3); | 536 expected_response_ = result.substr(0, 3); |
| 537 TestRequest("GET", extra_headers); | 537 TestRequest("GET", extra_headers); |
| 538 | 538 |
| 539 EXPECT_EQ(3, request_->response_headers()->GetContentLength()); | 539 EXPECT_EQ(3, request_->response_headers()->GetContentLength()); |
| 540 EXPECT_FALSE(url_request_delegate_.metadata()); | 540 EXPECT_FALSE(url_request_delegate_.metadata()); |
| 541 | 541 |
| 542 int64_t first = 0, last = 0, length = 0; | 542 int64_t first = 0, last = 0, length = 0; |
| 543 EXPECT_TRUE( | 543 EXPECT_TRUE(request_->response_headers()->GetContentRangeFor206(&first, &last, |
| 544 request_->response_headers()->GetContentRange(&first, &last, &length)); | 544 &length)); |
| 545 EXPECT_EQ(0, first); | 545 EXPECT_EQ(0, first); |
| 546 EXPECT_EQ(2, last); | 546 EXPECT_EQ(2, last); |
| 547 EXPECT_EQ(GetTotalBlobLength(), length); | 547 EXPECT_EQ(GetTotalBlobLength(), length); |
| 548 } | 548 } |
| 549 | 549 |
| 550 TEST_F(BlobURLRequestJobTest, TestExtraHeaders) { | 550 TEST_F(BlobURLRequestJobTest, TestExtraHeaders) { |
| 551 blob_data_->set_content_type(kTestContentType); | 551 blob_data_->set_content_type(kTestContentType); |
| 552 blob_data_->set_content_disposition(kTestContentDisposition); | 552 blob_data_->set_content_disposition(kTestContentDisposition); |
| 553 blob_data_->AppendData(kTestData1); | 553 blob_data_->AppendData(kTestData1); |
| 554 expected_status_code_ = 200; | 554 expected_status_code_ = 200; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 expected_status_code_ = 200; | 597 expected_status_code_ = 200; |
| 598 expected_response_ = kTestDiskCacheData2; | 598 expected_response_ = kTestDiskCacheData2; |
| 599 TestRequest("GET", net::HttpRequestHeaders()); | 599 TestRequest("GET", net::HttpRequestHeaders()); |
| 600 EXPECT_EQ(static_cast<int>(arraysize(kTestDiskCacheData2) - 1), | 600 EXPECT_EQ(static_cast<int>(arraysize(kTestDiskCacheData2) - 1), |
| 601 request_->response_headers()->GetContentLength()); | 601 request_->response_headers()->GetContentLength()); |
| 602 | 602 |
| 603 EXPECT_FALSE(url_request_delegate_.metadata()); | 603 EXPECT_FALSE(url_request_delegate_.metadata()); |
| 604 } | 604 } |
| 605 | 605 |
| 606 } // namespace content | 606 } // namespace content |
| OLD | NEW |