| Index: third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp b/third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp
|
| index 2213c24b4bb9c9373a849374bbae5a3e31666bd7..5a08fdf48f5845d59d084a771f29da657cdb4746 100644
|
| --- a/third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp
|
| +++ b/third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp
|
| @@ -248,10 +248,10 @@ TEST(ImageResourceTest, MultipartImage) {
|
| EXPECT_FALSE(client->notifyFinishedCalled());
|
| EXPECT_EQ("multipart/x-mixed-replace", cachedImage->response().mimeType());
|
|
|
| - const char firstPart[] =
|
| + const char firstPartHeader[] =
|
| "--boundary\n"
|
| "Content-Type: image/svg+xml\n\n";
|
| - cachedImage->appendData(firstPart, strlen(firstPart));
|
| + cachedImage->appendData(firstPartHeader, strlen(firstPartHeader));
|
| // Send the response for the first real part. No image or data buffer is
|
| // created.
|
| EXPECT_FALSE(cachedImage->resourceBuffer());
|
| @@ -260,12 +260,12 @@ TEST(ImageResourceTest, MultipartImage) {
|
| EXPECT_FALSE(client->notifyFinishedCalled());
|
| EXPECT_EQ("image/svg+xml", cachedImage->response().mimeType());
|
|
|
| - const char secondPart[] =
|
| + const char firstPartBody[] =
|
| "<svg xmlns='http://www.w3.org/2000/svg' width='1' height='1'><rect "
|
| "width='1' height='1' fill='green'/></svg>\n";
|
| // The first bytes arrive. The data buffer is created, but no image is
|
| // created.
|
| - cachedImage->appendData(secondPart, strlen(secondPart));
|
| + cachedImage->appendData(firstPartBody, strlen(firstPartBody));
|
| EXPECT_TRUE(cachedImage->resourceBuffer());
|
| EXPECT_FALSE(cachedImage->getContent()->hasImage());
|
| EXPECT_EQ(0, client->imageChangedCount());
|
| @@ -278,14 +278,14 @@ TEST(ImageResourceTest, MultipartImage) {
|
| EXPECT_EQ(0, client2->imageChangedCount());
|
| EXPECT_FALSE(client2->notifyFinishedCalled());
|
|
|
| - const char thirdPart[] = "--boundary";
|
| - cachedImage->appendData(thirdPart, strlen(thirdPart));
|
| + const char secondPartHeader[] =
|
| + "--boundary\n"
|
| + "Content-Type: image/jpeg\n\n";
|
| + cachedImage->appendData(secondPartHeader, strlen(secondPartHeader));
|
| ASSERT_TRUE(cachedImage->resourceBuffer());
|
| - EXPECT_EQ(strlen(secondPart) - 1, cachedImage->resourceBuffer()->size());
|
| -
|
| - // This part finishes. The image is created, callbacks are sent, and the data
|
| - // buffer is cleared.
|
| - cachedImage->loader()->didFinishLoading(0.0, 0, 0);
|
| + EXPECT_EQ(strlen(firstPartBody) - 1, cachedImage->resourceBuffer()->size());
|
| + // The first part finishes.
|
| + // The image is created, callbacks are sent, and the data buffer is cleared.
|
| EXPECT_TRUE(cachedImage->resourceBuffer());
|
| EXPECT_FALSE(cachedImage->errorOccurred());
|
| ASSERT_TRUE(cachedImage->getContent()->hasImage());
|
| @@ -296,6 +296,29 @@ TEST(ImageResourceTest, MultipartImage) {
|
| EXPECT_TRUE(client->notifyFinishedCalled());
|
| EXPECT_EQ(1, client2->imageChangedCount());
|
| EXPECT_TRUE(client2->notifyFinishedCalled());
|
| +
|
| + // The body of the second part arrives.
|
| + cachedImage->appendData(reinterpret_cast<const char*>(kJpegImage2),
|
| + sizeof(kJpegImage2));
|
| + ASSERT_TRUE(cachedImage->resourceBuffer());
|
| +
|
| + // The last boundary arrives.
|
| + // The second part is processed.
|
| + const char lastBoundary[] = "\n--boundary";
|
| + cachedImage->appendData(lastBoundary, strlen(lastBoundary));
|
| + ASSERT_TRUE(cachedImage->resourceBuffer());
|
| + EXPECT_EQ(sizeof(kJpegImage2), cachedImage->resourceBuffer()->size());
|
| +
|
| + // Load finishes.
|
| + cachedImage->loader()->didFinishLoading(0.0, 0, 0);
|
| +
|
| + EXPECT_FALSE(cachedImage->errorOccurred());
|
| + ASSERT_TRUE(cachedImage->getContent()->hasImage());
|
| + EXPECT_FALSE(cachedImage->getContent()->getImage()->isNull());
|
| + EXPECT_EQ(50, cachedImage->getContent()->getImage()->width());
|
| + EXPECT_EQ(50, cachedImage->getContent()->getImage()->height());
|
| + EXPECT_EQ(2, client->imageChangedCount());
|
| + EXPECT_EQ(2, client2->imageChangedCount());
|
| }
|
|
|
| TEST(ImageResourceTest, CancelOnDetach) {
|
|
|