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

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

Issue 1327653004: Have uses of MockImageResourceClient leak less. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clean up MockImageResourceClient somewhat Created 5 years, 3 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 | « Source/core/core.gypi ('k') | Source/core/fetch/MemoryCacheTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/ImageResourceTest.cpp
diff --git a/Source/core/fetch/ImageResourceTest.cpp b/Source/core/fetch/ImageResourceTest.cpp
index 75dac51683505ed7841e030f439d42627c1c5cbf..15e7fbc6ae2d319981fd20299b71ff1652724b2a 100644
--- a/Source/core/fetch/ImageResourceTest.cpp
+++ b/Source/core/fetch/ImageResourceTest.cpp
@@ -48,6 +48,8 @@
#include "public/platform/WebURLResponse.h"
#include "public/platform/WebUnitTestSupport.h"
+#include <gtest/gtest.h>
+
namespace blink {
static Vector<unsigned char> jpegImage()
@@ -94,8 +96,7 @@ TEST(ImageResourceTest, MultipartImage)
cachedImage->load(fetcher, ResourceLoaderOptions());
Platform::current()->unitTestSupport()->unregisterMockedURL(testURL);
- MockImageResourceClient client;
- cachedImage->addClient(&client);
+ MockImageResourceClient client(cachedImage);
EXPECT_EQ(Resource::Pending, cachedImage->status());
// Send the multipart response. No image or data buffer is created.
@@ -152,12 +153,11 @@ TEST(ImageResourceTest, CancelOnDetach)
cachedImage->load(fetcher, ResourceLoaderOptions());
memoryCache()->add(cachedImage.get());
- MockImageResourceClient client;
- cachedImage->addClient(&client);
+ MockImageResourceClient client(cachedImage);
EXPECT_EQ(Resource::Pending, cachedImage->status());
// The load should still be alive, but a timer should be started to cancel the load inside removeClient().
- cachedImage->removeClient(&client);
+ client.removeAsClient();
EXPECT_EQ(Resource::Pending, cachedImage->status());
EXPECT_NE(reinterpret_cast<Resource*>(0), memoryCache()->resourceForURL(testURL));
@@ -174,8 +174,7 @@ TEST(ImageResourceTest, DecodedDataRemainsWhileHasClients)
ResourcePtr<ImageResource> cachedImage = new ImageResource(ResourceRequest(), nullptr);
cachedImage->setLoading(true);
- MockImageResourceClient client;
- cachedImage->addClient(&client);
+ MockImageResourceClient client(cachedImage);
// Send the image response.
cachedImage->responseReceived(ResourceResponse(KURL(), "multipart/x-mixed-replace", 0, nullAtom, String()), nullptr);
@@ -196,7 +195,7 @@ TEST(ImageResourceTest, DecodedDataRemainsWhileHasClients)
ASSERT_FALSE(cachedImage->image()->isNull());
// The ImageResource no longer has clients. The image should be deleted by prune.
- cachedImage->removeClient(&client);
+ client.removeAsClient();
cachedImage->prune();
ASSERT_FALSE(cachedImage->hasClients());
ASSERT_FALSE(cachedImage->hasImage());
@@ -208,8 +207,7 @@ TEST(ImageResourceTest, UpdateBitmapImages)
ResourcePtr<ImageResource> cachedImage = new ImageResource(ResourceRequest(), nullptr);
cachedImage->setLoading(true);
- MockImageResourceClient client;
- cachedImage->addClient(&client);
+ MockImageResourceClient client(cachedImage);
// Send the image response.
Vector<unsigned char> jpeg = jpegImage();
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/fetch/MemoryCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698