Chromium Code Reviews

Side by Side Diff: webkit/glue/multipart_response_delegate_unittest.cc

Issue 3863002: Refactoring BufferedDataSource to work with WebURLLoader instead of a MediaResourceLoaderBridge. (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: little indent Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « webkit/glue/multipart_response_delegate.cc ('k') | webkit/glue/plugins/webplugin_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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...)
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;
553 554
554 bool result = MultipartResponseDelegate::ReadContentRanges( 555 bool result = MultipartResponseDelegate::ReadContentRanges(
555 response1, &content_range_lower_bound, 556 response1, &content_range_lower_bound,
556 &content_range_upper_bound); 557 &content_range_upper_bound,
558 &content_range_instance_size);
557 559
558 EXPECT_EQ(result, true); 560 EXPECT_EQ(result, true);
559 EXPECT_EQ(content_range_lower_bound, 1000); 561 EXPECT_EQ(content_range_lower_bound, 1000);
560 EXPECT_EQ(content_range_upper_bound, 1050); 562 EXPECT_EQ(content_range_upper_bound, 1050);
561 563
562 WebURLResponse response2; 564 WebURLResponse response2;
563 response2.initialize(); 565 response2.initialize();
564 response2.setMIMEType("application/pdf"); 566 response2.setMIMEType("application/pdf");
565 response2.setHTTPHeaderField("Content-Length", "200"); 567 response2.setHTTPHeaderField("Content-Length", "200");
566 response2.setHTTPHeaderField("Content-Range", "bytes 1000/1050"); 568 response2.setHTTPHeaderField("Content-Range", "bytes 1000/1050");
567 569
568 content_range_lower_bound = 0; 570 content_range_lower_bound = 0;
569 content_range_upper_bound = 0; 571 content_range_upper_bound = 0;
572 content_range_instance_size = 0;
570 573
571 result = MultipartResponseDelegate::ReadContentRanges( 574 result = MultipartResponseDelegate::ReadContentRanges(
572 response2, &content_range_lower_bound, 575 response2, &content_range_lower_bound,
573 &content_range_upper_bound); 576 &content_range_upper_bound,
577 &content_range_instance_size);
574 578
575 EXPECT_EQ(result, false); 579 EXPECT_EQ(result, false);
576 580
577 WebURLResponse response3; 581 WebURLResponse response3;
578 response3.initialize(); 582 response3.initialize();
579 response3.setMIMEType("application/pdf"); 583 response3.setMIMEType("application/pdf");
580 response3.setHTTPHeaderField("Content-Length", "200"); 584 response3.setHTTPHeaderField("Content-Length", "200");
581 response3.setHTTPHeaderField("Range", "bytes 1000-1050/5000"); 585 response3.setHTTPHeaderField("Range", "bytes 1000-1050/5000");
582 586
583 content_range_lower_bound = 0; 587 content_range_lower_bound = 0;
584 content_range_upper_bound = 0; 588 content_range_upper_bound = 0;
589 content_range_instance_size = 0;
585 590
586 result = MultipartResponseDelegate::ReadContentRanges( 591 result = MultipartResponseDelegate::ReadContentRanges(
587 response3, &content_range_lower_bound, 592 response3, &content_range_lower_bound,
588 &content_range_upper_bound); 593 &content_range_upper_bound,
594 &content_range_instance_size);
589 595
590 EXPECT_EQ(result, true); 596 EXPECT_EQ(result, true);
591 EXPECT_EQ(content_range_lower_bound, 1000); 597 EXPECT_EQ(content_range_lower_bound, 1000);
592 EXPECT_EQ(content_range_upper_bound, 1050); 598 EXPECT_EQ(content_range_upper_bound, 1050);
593 599
594 WebURLResponse response4; 600 WebURLResponse response4;
595 response4.initialize(); 601 response4.initialize();
596 response4.setMIMEType("application/pdf"); 602 response4.setMIMEType("application/pdf");
597 response4.setHTTPHeaderField("Content-Length", "200"); 603 response4.setHTTPHeaderField("Content-Length", "200");
598 604
599 content_range_lower_bound = 0; 605 content_range_lower_bound = 0;
600 content_range_upper_bound = 0; 606 content_range_upper_bound = 0;
607 content_range_instance_size = 0;
601 608
602 result = MultipartResponseDelegate::ReadContentRanges( 609 result = MultipartResponseDelegate::ReadContentRanges(
603 response4, &content_range_lower_bound, 610 response4, &content_range_lower_bound,
604 &content_range_upper_bound); 611 &content_range_upper_bound,
612 &content_range_instance_size);
605 613
606 EXPECT_EQ(result, false); 614 EXPECT_EQ(result, false);
607 } 615 }
608 616
609 TEST(MultipartResponseTest, MultipartPayloadSet) { 617 TEST(MultipartResponseTest, MultipartPayloadSet) {
610 WebURLResponse response; 618 WebURLResponse response;
611 response.initialize(); 619 response.initialize();
612 response.setMIMEType("multipart/x-mixed-replace"); 620 response.setMIMEType("multipart/x-mixed-replace");
613 MockWebURLLoaderClient client; 621 MockWebURLLoaderClient client;
614 MultipartResponseDelegate delegate(&client, NULL, response, "bound"); 622 MultipartResponseDelegate delegate(&client, NULL, response, "bound");
(...skipping 16 matching lines...)
631 "--bound\n"); 639 "--bound\n");
632 delegate.OnReceivedData(data2.c_str(), static_cast<int>(data2.length())); 640 delegate.OnReceivedData(data2.c_str(), static_cast<int>(data2.length()));
633 EXPECT_EQ(2, 641 EXPECT_EQ(2,
634 client.received_response_); 642 client.received_response_);
635 EXPECT_EQ(string("response data2"), 643 EXPECT_EQ(string("response data2"),
636 client.data_); 644 client.data_);
637 EXPECT_TRUE(client.response_.isMultipartPayload()); 645 EXPECT_TRUE(client.response_.isMultipartPayload());
638 } 646 }
639 647
640 } // namespace 648 } // namespace
OLDNEW
« no previous file with comments | « webkit/glue/multipart_response_delegate.cc ('k') | webkit/glue/plugins/webplugin_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine