OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/platform/WebString.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
Client.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
Client.h" |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 &content_range_upper_bound, | 635 &content_range_upper_bound, |
636 &content_range_instance_size); | 636 &content_range_instance_size); |
637 | 637 |
638 EXPECT_EQ(result, false); | 638 EXPECT_EQ(result, false); |
639 } | 639 } |
640 | 640 |
641 TEST(MultipartResponseTest, MultipartPayloadSet) { | 641 TEST(MultipartResponseTest, MultipartPayloadSet) { |
642 WebURLResponse response; | 642 WebURLResponse response; |
643 response.initialize(); | 643 response.initialize(); |
644 response.setMIMEType("multipart/x-mixed-replace"); | 644 response.setMIMEType("multipart/x-mixed-replace"); |
| 645 response.setExtraData(new WebURLResponseExtraDataImpl("")); |
645 MockWebURLLoaderClient client; | 646 MockWebURLLoaderClient client; |
646 MultipartResponseDelegate delegate(&client, NULL, response, "bound"); | 647 MultipartResponseDelegate delegate(&client, NULL, response, "bound"); |
647 | 648 |
648 string data( | 649 string data( |
649 "--bound\n" | 650 "--bound\n" |
650 "Content-type: text/plain\n\n" | 651 "Content-type: text/plain\n\n" |
651 "response data\n" | 652 "response data\n" |
652 "--bound\n"); | 653 "--bound\n"); |
653 delegate.OnReceivedData(data.c_str(), | 654 delegate.OnReceivedData(data.c_str(), |
654 static_cast<int>(data.length()), | 655 static_cast<int>(data.length()), |
655 static_cast<int>(data.length())); | 656 static_cast<int>(data.length())); |
656 EXPECT_EQ(1, client.received_response_); | 657 EXPECT_EQ(1, client.received_response_); |
657 EXPECT_EQ(string("response data"), client.data_); | 658 EXPECT_EQ(string("response data"), client.data_); |
658 EXPECT_EQ(static_cast<int>(data.length()), client.total_encoded_data_length_); | 659 EXPECT_EQ(static_cast<int>(data.length()), client.total_encoded_data_length_); |
659 EXPECT_FALSE(client.response_.isMultipartPayload()); | 660 WebURLResponseExtraDataImpl* extra_data = |
| 661 static_cast<WebURLResponseExtraDataImpl*>(client.response_.extraData()); |
| 662 EXPECT_FALSE(extra_data->is_multipart_payload()); |
660 | 663 |
661 string data2( | 664 string data2( |
662 "Content-type: text/plain\n\n" | 665 "Content-type: text/plain\n\n" |
663 "response data2\n" | 666 "response data2\n" |
664 "--bound\n"); | 667 "--bound\n"); |
665 delegate.OnReceivedData(data2.c_str(), | 668 delegate.OnReceivedData(data2.c_str(), |
666 static_cast<int>(data2.length()), | 669 static_cast<int>(data2.length()), |
667 static_cast<int>(data2.length())); | 670 static_cast<int>(data2.length())); |
668 EXPECT_EQ(2, client.received_response_); | 671 EXPECT_EQ(2, client.received_response_); |
669 EXPECT_EQ(string("response data2"), client.data_); | 672 EXPECT_EQ(string("response data2"), client.data_); |
670 EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()), | 673 EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()), |
671 client.total_encoded_data_length_); | 674 client.total_encoded_data_length_); |
672 EXPECT_TRUE(client.response_.isMultipartPayload()); | 675 extra_data = static_cast<WebURLResponseExtraDataImpl*>( |
| 676 client.response_.extraData()); |
| 677 EXPECT_TRUE(extra_data->is_multipart_payload()); |
673 } | 678 } |
674 | 679 |
675 } // namespace | 680 } // namespace |
OLD | NEW |