Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp

Issue 2175163002: Merge "Ensure |m_image| is (re-)created in ImageResource::didAddClient()" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Fix merge error Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp b/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
index f71f4c81b0c53fe8dec0ce6c728af5213130297b..30055a45ad08903b5e8b65197e3ca79e8ad450c8 100644
--- a/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
+++ b/third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp
@@ -305,4 +305,48 @@ TEST(ImageResourceTest, ReloadIfLoFi)
ASSERT_TRUE(cachedImage->getImage()->isBitmapImage());
}
+// Tests for pruning.
+
+TEST(ImageResourceTest, AddClientAfterPrune)
+{
+ KURL url(ParsedURLString, "http://127.0.0.1:8000/foo");
+ ImageResource* imageResource = ImageResource::create(ResourceRequest(url));
+
+ // Adds a ResourceClient but not ImageResourceObserver.
+ MockResourceClient client1(imageResource);
+
+ Vector<unsigned char> jpeg = jpegImage();
+ ResourceResponse response;
+ response.setURL(url);
+ response.setHTTPStatusCode(200);
+ response.setMimeType("image/jpeg");
+ imageResource->responseReceived(response, nullptr);
+ imageResource->appendData(reinterpret_cast<const char*>(jpeg.data()), jpeg.size());
+ imageResource->finish();
+
+ EXPECT_FALSE(imageResource->errorOccurred());
+ ASSERT_TRUE(imageResource->hasImage());
+ EXPECT_FALSE(imageResource->getImage()->isNull());
+ EXPECT_EQ(1, imageResource->getImage()->width());
+ EXPECT_EQ(1, imageResource->getImage()->height());
+ EXPECT_TRUE(client1.notifyFinishedCalled());
+
+ client1.removeAsClient();
+
+ EXPECT_FALSE(imageResource->hasClientsOrObservers());
+
+ imageResource->prune();
+
+ EXPECT_FALSE(imageResource->hasImage());
+
+ // Re-adds a ResourceClient but not ImageResourceObserver.
+ MockResourceClient client2(imageResource);
+
+ ASSERT_TRUE(imageResource->hasImage());
+ EXPECT_FALSE(imageResource->getImage()->isNull());
+ EXPECT_EQ(1, imageResource->getImage()->width());
+ EXPECT_EQ(1, imageResource->getImage()->height());
+ EXPECT_TRUE(client2.notifyFinishedCalled());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698