OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 request.placeholderImageRequestType()); | 564 request.placeholderImageRequestType()); |
565 EXPECT_EQ("bytes=0-2047", | 565 EXPECT_EQ("bytes=0-2047", |
566 imageResource->resourceRequest().httpHeaderField("range")); | 566 imageResource->resourceRequest().httpHeaderField("range")); |
567 std::unique_ptr<MockImageResourceObserver> observer = | 567 std::unique_ptr<MockImageResourceObserver> observer = |
568 MockImageResourceObserver::create(imageResource->getContent()); | 568 MockImageResourceObserver::create(imageResource->getContent()); |
569 | 569 |
570 ResourceResponse response(testURL, "image/jpeg", | 570 ResourceResponse response(testURL, "image/jpeg", |
571 kJpegImageSubrangeWithDimensionsLength, nullAtom); | 571 kJpegImageSubrangeWithDimensionsLength, nullAtom); |
572 response.setHTTPStatusCode(206); | 572 response.setHTTPStatusCode(206); |
573 response.setHTTPHeaderField( | 573 response.setHTTPHeaderField( |
574 "content-range", buildContentRange(kJpegImageSubrangeWithDimensionsLength, | 574 "content-range", |
575 sizeof(kJpegImage))); | 575 buildContentRange(kJpegImageSubrangeWithDimensionsLength, |
| 576 sizeof(kJpegImage))); |
576 imageResource->loader()->didReceiveResponse( | 577 imageResource->loader()->didReceiveResponse( |
577 WrappedResourceResponse(response)); | 578 WrappedResourceResponse(response)); |
578 imageResource->loader()->didReceiveData( | 579 imageResource->loader()->didReceiveData( |
579 reinterpret_cast<const char*>(kJpegImage), | 580 reinterpret_cast<const char*>(kJpegImage), |
580 kJpegImageSubrangeWithDimensionsLength); | 581 kJpegImageSubrangeWithDimensionsLength); |
581 imageResource->loader()->didFinishLoading( | 582 imageResource->loader()->didFinishLoading( |
582 0.0, kJpegImageSubrangeWithDimensionsLength, | 583 0.0, kJpegImageSubrangeWithDimensionsLength, |
583 kJpegImageSubrangeWithDimensionsLength); | 584 kJpegImageSubrangeWithDimensionsLength); |
584 | 585 |
585 EXPECT_EQ(ResourceStatus::Cached, imageResource->getStatus()); | 586 EXPECT_EQ(ResourceStatus::Cached, imageResource->getStatus()); |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 EXPECT_EQ("bytes=0-2047", | 1056 EXPECT_EQ("bytes=0-2047", |
1056 imageResource->resourceRequest().httpHeaderField("range")); | 1057 imageResource->resourceRequest().httpHeaderField("range")); |
1057 EXPECT_TRUE(imageResource->isPlaceholder()); | 1058 EXPECT_TRUE(imageResource->isPlaceholder()); |
1058 std::unique_ptr<MockImageResourceObserver> observer = | 1059 std::unique_ptr<MockImageResourceObserver> observer = |
1059 MockImageResourceObserver::create(imageResource->getContent()); | 1060 MockImageResourceObserver::create(imageResource->getContent()); |
1060 | 1061 |
1061 ResourceResponse response(testURL, "image/jpeg", | 1062 ResourceResponse response(testURL, "image/jpeg", |
1062 kJpegImageSubrangeWithDimensionsLength, nullAtom); | 1063 kJpegImageSubrangeWithDimensionsLength, nullAtom); |
1063 response.setHTTPStatusCode(206); | 1064 response.setHTTPStatusCode(206); |
1064 response.setHTTPHeaderField( | 1065 response.setHTTPHeaderField( |
1065 "content-range", buildContentRange(kJpegImageSubrangeWithDimensionsLength, | 1066 "content-range", |
1066 sizeof(kJpegImage))); | 1067 buildContentRange(kJpegImageSubrangeWithDimensionsLength, |
| 1068 sizeof(kJpegImage))); |
1067 imageResource->loader()->didReceiveResponse( | 1069 imageResource->loader()->didReceiveResponse( |
1068 WrappedResourceResponse(response)); | 1070 WrappedResourceResponse(response)); |
1069 imageResource->loader()->didReceiveData( | 1071 imageResource->loader()->didReceiveData( |
1070 reinterpret_cast<const char*>(kJpegImage), | 1072 reinterpret_cast<const char*>(kJpegImage), |
1071 kJpegImageSubrangeWithDimensionsLength); | 1073 kJpegImageSubrangeWithDimensionsLength); |
1072 imageResource->loader()->didFinishLoading( | 1074 imageResource->loader()->didFinishLoading( |
1073 0.0, kJpegImageSubrangeWithDimensionsLength, | 1075 0.0, kJpegImageSubrangeWithDimensionsLength, |
1074 kJpegImageSubrangeWithDimensionsLength); | 1076 kJpegImageSubrangeWithDimensionsLength); |
1075 | 1077 |
1076 EXPECT_EQ(ResourceStatus::Cached, imageResource->getStatus()); | 1078 EXPECT_EQ(ResourceStatus::Cached, imageResource->getStatus()); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 placeholderRequest.setAllowImagePlaceholder(); | 1263 placeholderRequest.setAllowImagePlaceholder(); |
1262 ImageResource* imageResource = | 1264 ImageResource* imageResource = |
1263 ImageResource::fetch(placeholderRequest, fetcher); | 1265 ImageResource::fetch(placeholderRequest, fetcher); |
1264 std::unique_ptr<MockImageResourceObserver> observer = | 1266 std::unique_ptr<MockImageResourceObserver> observer = |
1265 MockImageResourceObserver::create(imageResource->getContent()); | 1267 MockImageResourceObserver::create(imageResource->getContent()); |
1266 | 1268 |
1267 ResourceResponse response(testURL, "image/jpeg", | 1269 ResourceResponse response(testURL, "image/jpeg", |
1268 kJpegImageSubrangeWithDimensionsLength, nullAtom); | 1270 kJpegImageSubrangeWithDimensionsLength, nullAtom); |
1269 response.setHTTPStatusCode(206); | 1271 response.setHTTPStatusCode(206); |
1270 response.setHTTPHeaderField( | 1272 response.setHTTPHeaderField( |
1271 "content-range", buildContentRange(kJpegImageSubrangeWithDimensionsLength, | 1273 "content-range", |
1272 sizeof(kJpegImage))); | 1274 buildContentRange(kJpegImageSubrangeWithDimensionsLength, |
| 1275 sizeof(kJpegImage))); |
1273 imageResource->loader()->didReceiveResponse( | 1276 imageResource->loader()->didReceiveResponse( |
1274 WrappedResourceResponse(response)); | 1277 WrappedResourceResponse(response)); |
1275 imageResource->loader()->didReceiveData( | 1278 imageResource->loader()->didReceiveData( |
1276 reinterpret_cast<const char*>(kJpegImage), | 1279 reinterpret_cast<const char*>(kJpegImage), |
1277 kJpegImageSubrangeWithDimensionsLength); | 1280 kJpegImageSubrangeWithDimensionsLength); |
1278 imageResource->loader()->didFinishLoading( | 1281 imageResource->loader()->didFinishLoading( |
1279 0.0, kJpegImageSubrangeWithDimensionsLength, | 1282 0.0, kJpegImageSubrangeWithDimensionsLength, |
1280 kJpegImageSubrangeWithDimensionsLength); | 1283 kJpegImageSubrangeWithDimensionsLength); |
1281 | 1284 |
1282 EXPECT_EQ(ResourceStatus::Cached, imageResource->getStatus()); | 1285 EXPECT_EQ(ResourceStatus::Cached, imageResource->getStatus()); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 EXPECT_TRUE(observer->imageNotifyFinishedCalled()); | 1542 EXPECT_TRUE(observer->imageNotifyFinishedCalled()); |
1540 EXPECT_TRUE(imageResource->getContent()->getImage()->isBitmapImage()); | 1543 EXPECT_TRUE(imageResource->getContent()->getImage()->isBitmapImage()); |
1541 EXPECT_EQ(50, imageResource->getContent()->getImage()->width()); | 1544 EXPECT_EQ(50, imageResource->getContent()->getImage()->width()); |
1542 EXPECT_EQ(50, imageResource->getContent()->getImage()->height()); | 1545 EXPECT_EQ(50, imageResource->getContent()->getImage()->height()); |
1543 | 1546 |
1544 WTF::setTimeFunctionsForTesting(nullptr); | 1547 WTF::setTimeFunctionsForTesting(nullptr); |
1545 } | 1548 } |
1546 | 1549 |
1547 } // namespace | 1550 } // namespace |
1548 } // namespace blink | 1551 } // namespace blink |
OLD | NEW |