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

Unified Diff: Source/core/fetch/ResourceFetcherTest.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/fetch/RawResourceTest.cpp ('k') | Source/core/frame/ImageBitmapTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/ResourceFetcherTest.cpp
diff --git a/Source/core/fetch/ResourceFetcherTest.cpp b/Source/core/fetch/ResourceFetcherTest.cpp
index fdd49f2023f182c512de702ee8f393a23f98937e..d41fcba891f1c8daf3dd71c216cf320cf16f40e5 100644
--- a/Source/core/fetch/ResourceFetcherTest.cpp
+++ b/Source/core/fetch/ResourceFetcherTest.cpp
@@ -34,6 +34,7 @@
#include "core/fetch/FetchInitiatorInfo.h"
#include "core/fetch/FetchRequest.h"
#include "core/fetch/MemoryCache.h"
+#include "core/fetch/ResourceLoader.h"
#include "core/fetch/ResourcePtr.h"
#include "platform/exported/WrappedResourceResponse.h"
#include "platform/heap/Handle.h"
@@ -117,11 +118,8 @@ TEST_F(ResourceFetcherTest, UseExistingResource)
memoryCache()->remove(resource.get());
}
-
TEST_F(ResourceFetcherTest, Vary)
{
- ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFetchContext::create());
-
KURL url(ParsedURLString, "http://127.0.0.1:8000/foo.html");
ResourcePtr<Resource> resource = new Resource(url, Resource::Raw);
memoryCache()->add(resource.get());
@@ -134,13 +132,16 @@ TEST_F(ResourceFetcherTest, Vary)
resource->finish();
ASSERT_TRUE(resource->hasVaryHeader());
+ ResourceFetcher* fetcher = ResourceFetcher::create(ResourceFetcherTestMockFetchContext::create());
FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo());
Platform::current()->unitTestSupport()->registerMockedURL(url, WebURLResponse(), "");
ResourcePtr<Resource> newResource = fetcher->requestResource(fetchRequest, TestResourceFactory());
EXPECT_NE(resource, newResource);
-
+ newResource->loader()->cancel();
memoryCache()->remove(newResource.get());
Platform::current()->unitTestSupport()->unregisterMockedURL(url);
+
+ memoryCache()->remove(resource.get());
}
TEST_F(ResourceFetcherTest, VaryOnBack)
@@ -218,6 +219,10 @@ TEST_F(ResourceFetcherTest, RevalidateWhileLoading)
FetchRequest fetchRequest2(url, FetchInitiatorInfo());
ResourcePtr<Resource> resource2 = fetcher2->requestResource(fetchRequest2, TestResourceFactory(Resource::Image));
EXPECT_EQ(resource1, resource2);
+
+ // Tidily(?) shut down the ResourceLoader.
+ resource1->loader()->cancel();
+ Platform::current()->unitTestSupport()->unregisterMockedURL(url);
}
} // namespace blink
« no previous file with comments | « Source/core/fetch/RawResourceTest.cpp ('k') | Source/core/frame/ImageBitmapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698