OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderClient.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderClient.h" |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 result = MultipartResponseDelegate::ReadMultipartBoundary( | 559 result = MultipartResponseDelegate::ReadMultipartBoundary( |
560 response5, &multipart_boundary); | 560 response5, &multipart_boundary); |
561 EXPECT_EQ(result, true); | 561 EXPECT_EQ(result, true); |
562 EXPECT_EQ(string("--bound--"), multipart_boundary); | 562 EXPECT_EQ(string("--bound--"), multipart_boundary); |
563 } | 563 } |
564 | 564 |
565 TEST(MultipartResponseTest, MultipartContentRangesTest) { | 565 TEST(MultipartResponseTest, MultipartContentRangesTest) { |
566 WebURLResponse response1; | 566 WebURLResponse response1; |
567 response1.initialize(); | 567 response1.initialize(); |
568 response1.setMIMEType("application/pdf"); | 568 response1.setMIMEType("application/pdf"); |
569 response1.setHTTPHeaderField("Content-Length", "200"); | 569 response1.setHTTPHeaderField("Content-Length", "200"); // Ignored! |
570 response1.setHTTPHeaderField("Content-Range", "bytes 1000-1050/5000"); | 570 // Use intentionally >32bit values to check they are handled correctly. |
| 571 response1.setHTTPHeaderField("Content-Range", |
| 572 "bytes 5000000000-5000000050/6000000000"); |
571 | 573 |
572 int content_range_lower_bound = 0; | 574 int64 content_range_lower_bound = 0; |
573 int content_range_upper_bound = 0; | 575 int64 content_range_upper_bound = 0; |
574 int content_range_instance_size = 0; | 576 int64 content_range_instance_size = 0; |
575 | 577 |
576 bool result = MultipartResponseDelegate::ReadContentRanges( | 578 bool result = MultipartResponseDelegate::ReadContentRanges( |
577 response1, &content_range_lower_bound, | 579 response1, &content_range_lower_bound, |
578 &content_range_upper_bound, | 580 &content_range_upper_bound, |
579 &content_range_instance_size); | 581 &content_range_instance_size); |
580 | 582 |
581 EXPECT_EQ(result, true); | 583 EXPECT_EQ(result, true); |
582 EXPECT_EQ(content_range_lower_bound, 1000); | 584 EXPECT_EQ(content_range_lower_bound, 5e9); |
583 EXPECT_EQ(content_range_upper_bound, 1050); | 585 EXPECT_EQ(content_range_upper_bound, 5e9+50); |
| 586 EXPECT_EQ(content_range_instance_size, 6e9); |
584 | 587 |
585 WebURLResponse response2; | 588 WebURLResponse response2; |
586 response2.initialize(); | 589 response2.initialize(); |
587 response2.setMIMEType("application/pdf"); | 590 response2.setMIMEType("application/pdf"); |
588 response2.setHTTPHeaderField("Content-Length", "200"); | 591 response2.setHTTPHeaderField("Content-Length", "200"); |
589 response2.setHTTPHeaderField("Content-Range", "bytes 1000/1050"); | 592 response2.setHTTPHeaderField("Content-Range", "bytes 1000/1050"); |
590 | 593 |
591 content_range_lower_bound = 0; | 594 content_range_lower_bound = 0; |
592 content_range_upper_bound = 0; | 595 content_range_upper_bound = 0; |
593 content_range_instance_size = 0; | 596 content_range_instance_size = 0; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 static_cast<int>(data2.length()), | 666 static_cast<int>(data2.length()), |
664 static_cast<int>(data2.length())); | 667 static_cast<int>(data2.length())); |
665 EXPECT_EQ(2, client.received_response_); | 668 EXPECT_EQ(2, client.received_response_); |
666 EXPECT_EQ(string("response data2"), client.data_); | 669 EXPECT_EQ(string("response data2"), client.data_); |
667 EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()), | 670 EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()), |
668 client.total_encoded_data_length_); | 671 client.total_encoded_data_length_); |
669 EXPECT_TRUE(client.response_.isMultipartPayload()); | 672 EXPECT_TRUE(client.response_.isMultipartPayload()); |
670 } | 673 } |
671 | 674 |
672 } // namespace | 675 } // namespace |
OLD | NEW |