| 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/WebKit/chromium/public/WebString.h" | 8 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
| 9 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" | 9 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
| 10 #include "third_party/WebKit/WebKit/chromium/public/WebURLLoaderClient.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebURLLoaderClient.h" |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 543 |
| 544 TEST(MultipartResponseTest, MultipartContentRangesTest) { | 544 TEST(MultipartResponseTest, MultipartContentRangesTest) { |
| 545 WebURLResponse response1; | 545 WebURLResponse response1; |
| 546 response1.initialize(); | 546 response1.initialize(); |
| 547 response1.setMIMEType("application/pdf"); | 547 response1.setMIMEType("application/pdf"); |
| 548 response1.setHTTPHeaderField("Content-Length", "200"); | 548 response1.setHTTPHeaderField("Content-Length", "200"); |
| 549 response1.setHTTPHeaderField("Content-Range", "bytes 1000-1050/5000"); | 549 response1.setHTTPHeaderField("Content-Range", "bytes 1000-1050/5000"); |
| 550 | 550 |
| 551 int content_range_lower_bound = 0; | 551 int content_range_lower_bound = 0; |
| 552 int content_range_upper_bound = 0; | 552 int content_range_upper_bound = 0; |
| 553 int content_range_instance_size = 0; | |
| 554 | 553 |
| 555 bool result = MultipartResponseDelegate::ReadContentRanges( | 554 bool result = MultipartResponseDelegate::ReadContentRanges( |
| 556 response1, &content_range_lower_bound, | 555 response1, &content_range_lower_bound, |
| 557 &content_range_upper_bound, | 556 &content_range_upper_bound); |
| 558 &content_range_instance_size); | |
| 559 | 557 |
| 560 EXPECT_EQ(result, true); | 558 EXPECT_EQ(result, true); |
| 561 EXPECT_EQ(content_range_lower_bound, 1000); | 559 EXPECT_EQ(content_range_lower_bound, 1000); |
| 562 EXPECT_EQ(content_range_upper_bound, 1050); | 560 EXPECT_EQ(content_range_upper_bound, 1050); |
| 563 | 561 |
| 564 WebURLResponse response2; | 562 WebURLResponse response2; |
| 565 response2.initialize(); | 563 response2.initialize(); |
| 566 response2.setMIMEType("application/pdf"); | 564 response2.setMIMEType("application/pdf"); |
| 567 response2.setHTTPHeaderField("Content-Length", "200"); | 565 response2.setHTTPHeaderField("Content-Length", "200"); |
| 568 response2.setHTTPHeaderField("Content-Range", "bytes 1000/1050"); | 566 response2.setHTTPHeaderField("Content-Range", "bytes 1000/1050"); |
| 569 | 567 |
| 570 content_range_lower_bound = 0; | 568 content_range_lower_bound = 0; |
| 571 content_range_upper_bound = 0; | 569 content_range_upper_bound = 0; |
| 572 content_range_instance_size = 0; | |
| 573 | 570 |
| 574 result = MultipartResponseDelegate::ReadContentRanges( | 571 result = MultipartResponseDelegate::ReadContentRanges( |
| 575 response2, &content_range_lower_bound, | 572 response2, &content_range_lower_bound, |
| 576 &content_range_upper_bound, | 573 &content_range_upper_bound); |
| 577 &content_range_instance_size); | |
| 578 | 574 |
| 579 EXPECT_EQ(result, false); | 575 EXPECT_EQ(result, false); |
| 580 | 576 |
| 581 WebURLResponse response3; | 577 WebURLResponse response3; |
| 582 response3.initialize(); | 578 response3.initialize(); |
| 583 response3.setMIMEType("application/pdf"); | 579 response3.setMIMEType("application/pdf"); |
| 584 response3.setHTTPHeaderField("Content-Length", "200"); | 580 response3.setHTTPHeaderField("Content-Length", "200"); |
| 585 response3.setHTTPHeaderField("Range", "bytes 1000-1050/5000"); | 581 response3.setHTTPHeaderField("Range", "bytes 1000-1050/5000"); |
| 586 | 582 |
| 587 content_range_lower_bound = 0; | 583 content_range_lower_bound = 0; |
| 588 content_range_upper_bound = 0; | 584 content_range_upper_bound = 0; |
| 589 content_range_instance_size = 0; | |
| 590 | 585 |
| 591 result = MultipartResponseDelegate::ReadContentRanges( | 586 result = MultipartResponseDelegate::ReadContentRanges( |
| 592 response3, &content_range_lower_bound, | 587 response3, &content_range_lower_bound, |
| 593 &content_range_upper_bound, | 588 &content_range_upper_bound); |
| 594 &content_range_instance_size); | |
| 595 | 589 |
| 596 EXPECT_EQ(result, true); | 590 EXPECT_EQ(result, true); |
| 597 EXPECT_EQ(content_range_lower_bound, 1000); | 591 EXPECT_EQ(content_range_lower_bound, 1000); |
| 598 EXPECT_EQ(content_range_upper_bound, 1050); | 592 EXPECT_EQ(content_range_upper_bound, 1050); |
| 599 | 593 |
| 600 WebURLResponse response4; | 594 WebURLResponse response4; |
| 601 response4.initialize(); | 595 response4.initialize(); |
| 602 response4.setMIMEType("application/pdf"); | 596 response4.setMIMEType("application/pdf"); |
| 603 response4.setHTTPHeaderField("Content-Length", "200"); | 597 response4.setHTTPHeaderField("Content-Length", "200"); |
| 604 | 598 |
| 605 content_range_lower_bound = 0; | 599 content_range_lower_bound = 0; |
| 606 content_range_upper_bound = 0; | 600 content_range_upper_bound = 0; |
| 607 content_range_instance_size = 0; | |
| 608 | 601 |
| 609 result = MultipartResponseDelegate::ReadContentRanges( | 602 result = MultipartResponseDelegate::ReadContentRanges( |
| 610 response4, &content_range_lower_bound, | 603 response4, &content_range_lower_bound, |
| 611 &content_range_upper_bound, | 604 &content_range_upper_bound); |
| 612 &content_range_instance_size); | |
| 613 | 605 |
| 614 EXPECT_EQ(result, false); | 606 EXPECT_EQ(result, false); |
| 615 } | 607 } |
| 616 | 608 |
| 617 TEST(MultipartResponseTest, MultipartPayloadSet) { | 609 TEST(MultipartResponseTest, MultipartPayloadSet) { |
| 618 WebURLResponse response; | 610 WebURLResponse response; |
| 619 response.initialize(); | 611 response.initialize(); |
| 620 response.setMIMEType("multipart/x-mixed-replace"); | 612 response.setMIMEType("multipart/x-mixed-replace"); |
| 621 MockWebURLLoaderClient client; | 613 MockWebURLLoaderClient client; |
| 622 MultipartResponseDelegate delegate(&client, NULL, response, "bound"); | 614 MultipartResponseDelegate delegate(&client, NULL, response, "bound"); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 639 "--bound\n"); | 631 "--bound\n"); |
| 640 delegate.OnReceivedData(data2.c_str(), static_cast<int>(data2.length())); | 632 delegate.OnReceivedData(data2.c_str(), static_cast<int>(data2.length())); |
| 641 EXPECT_EQ(2, | 633 EXPECT_EQ(2, |
| 642 client.received_response_); | 634 client.received_response_); |
| 643 EXPECT_EQ(string("response data2"), | 635 EXPECT_EQ(string("response data2"), |
| 644 client.data_); | 636 client.data_); |
| 645 EXPECT_TRUE(client.response_.isMultipartPayload()); | 637 EXPECT_TRUE(client.response_.isMultipartPayload()); |
| 646 } | 638 } |
| 647 | 639 |
| 648 } // namespace | 640 } // namespace |
| OLD | NEW |