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

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

Issue 2129093002: Remove ApplicationCache runtime flag (status=stable) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some unit tests for MemoryCache. 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 | « content/test/test_blink_web_unit_test_support.cc ('k') | third_party/WebKit/Source/core/frame/Window.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/fetch/MemoryCacheTest.cpp
diff --git a/third_party/WebKit/Source/core/fetch/MemoryCacheTest.cpp b/third_party/WebKit/Source/core/fetch/MemoryCacheTest.cpp
index a4a649f042a9e99f5acf953cb08952bab5433567..87cfdbfcedc6fd4b842b9087de70346c750511b6 100644
--- a/third_party/WebKit/Source/core/fetch/MemoryCacheTest.cpp
+++ b/third_party/WebKit/Source/core/fetch/MemoryCacheTest.cpp
@@ -425,4 +425,55 @@ TEST_F(MemoryCacheTest, ResourceMapIsolation)
EXPECT_FALSE(memoryCache()->contains(resource3));
}
+TEST_F(MemoryCacheTest, FragmentIdentifier)
+{
+ FakeResource* resource = FakeResource::create(ResourceRequest("http://test/resource#foo"), Resource::Raw);
+ memoryCache()->add(resource);
+ ASSERT_TRUE(memoryCache()->contains(resource));
+
+ const KURL url1 = KURL(ParsedURLString, "http://test/resource");
+ EXPECT_EQ(resource, memoryCache()->resourceForURL(url1));
+
+ const KURL url2 = KURL(ParsedURLString, "http://test/resource#foo");
+ EXPECT_EQ(resource, memoryCache()->resourceForURL(url2));
+}
+
+TEST_F(MemoryCacheTest, MakeLiveAndDead)
+{
+ FakeResource* resource = FakeResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
+ const char data[6] = "abcde";
+ resource->appendData(data, 5u);
+ memoryCache()->add(resource);
+
+ const size_t deadSize = memoryCache()->deadSize();
+ const size_t liveSize = memoryCache()->liveSize();
+
+ memoryCache()->makeLive(resource);
+ ASSERT_EQ(deadSize, memoryCache()->deadSize() + resource->size());
+ ASSERT_EQ(liveSize, memoryCache()->liveSize() - resource->size());
+
+ memoryCache()->makeDead(resource);
+ ASSERT_EQ(deadSize, memoryCache()->deadSize());
+ ASSERT_EQ(liveSize, memoryCache()->liveSize());
+}
+
+TEST_F(MemoryCacheTest, RemoveURLFromCache)
+{
+ FakeResource* resource1 = FakeResource::create(ResourceRequest("http://test/resource1"), Resource::Raw);
+ memoryCache()->add(resource1);
+ ASSERT_TRUE(memoryCache()->contains(resource1));
+
+ const KURL url1 = KURL(ParsedURLString, "http://test/resource1");
+ memoryCache()->removeURLFromCache(url1);
+ EXPECT_FALSE(memoryCache()->contains(resource1));
+
+ FakeResource* resource2 = FakeResource::create(ResourceRequest("http://test/resource2#foo"), Resource::Raw);
+ memoryCache()->add(resource2);
+ ASSERT_TRUE(memoryCache()->contains(resource2));
+
+ const KURL url2 = KURL(ParsedURLString, "http://test/resource2#foo");
+ memoryCache()->removeURLFromCache(url2);
+ EXPECT_FALSE(memoryCache()->contains(resource2));
+}
+
} // namespace blink
« no previous file with comments | « content/test/test_blink_web_unit_test_support.cc ('k') | third_party/WebKit/Source/core/frame/Window.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698