summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_unittest.cc
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 01:26:10 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 01:26:10 +0000
commit4f32303e4491c3b2358825e0b26f8c5db3b28b33 (patch)
treeeeb15549ae8540ddc6e1be0a5400247d5f771844 /webkit/appcache/appcache_unittest.cc
parente07dfdab975039ea0719e8dc7e7f5faaf0887a91 (diff)
downloadchromium_src-4f32303e4491c3b2358825e0b26f8c5db3b28b33.zip
chromium_src-4f32303e4491c3b2358825e0b26f8c5db3b28b33.tar.gz
chromium_src-4f32303e4491c3b2358825e0b26f8c5db3b28b33.tar.bz2
Undo in memory changes made by an update job if the commit to disk fails. Provide a more clear error message when the commit fails due to exceeding the quota.
TEST=MasterEntryFailStoreNewestCacheTest BUG=50985 Review URL: http://codereview.chromium.org/2836075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_unittest.cc')
-rw-r--r--webkit/appcache/appcache_unittest.cc48
1 files changed, 35 insertions, 13 deletions
diff --git a/webkit/appcache/appcache_unittest.cc b/webkit/appcache/appcache_unittest.cc
index 6177d13..8fcde53 100644
--- a/webkit/appcache/appcache_unittest.cc
+++ b/webkit/appcache/appcache_unittest.cc
@@ -32,26 +32,48 @@ TEST(AppCacheTest, CleanupUnusedCache) {
host2.AssociateCache(NULL);
}
-TEST(AppCacheTest, AddModifyEntry) {
+TEST(AppCacheTest, AddModifyRemoveEntry) {
MockAppCacheService service;
scoped_refptr<AppCache> cache = new AppCache(&service, 111);
- const GURL kUrl1("http://foo.com");
- AppCacheEntry entry1(AppCacheEntry::MASTER);
- cache->AddEntry(kUrl1, entry1);
- EXPECT_EQ(entry1.types(), cache->GetEntry(kUrl1)->types());
-
- const GURL kUrl2("http://bar.com");
- AppCacheEntry entry2(AppCacheEntry::FALLBACK);
- EXPECT_TRUE(cache->AddOrModifyEntry(kUrl2, entry2));
- EXPECT_EQ(entry2.types(), cache->GetEntry(kUrl2)->types());
+ EXPECT_TRUE(cache->entries().empty());
+ EXPECT_EQ(0L, cache->cache_size());
+
+ const GURL kFooUrl("http://foo.com");
+ const int64 kFooResponseId = 1;
+ const int64 kFooSize = 100;
+ AppCacheEntry entry1(AppCacheEntry::MASTER, kFooResponseId, kFooSize);
+ cache->AddEntry(kFooUrl, entry1);
+ EXPECT_EQ(entry1.types(), cache->GetEntry(kFooUrl)->types());
+ EXPECT_EQ(1UL, cache->entries().size());
+ EXPECT_EQ(kFooSize, cache->cache_size());
+
+ const GURL kBarUrl("http://bar.com");
+ const int64 kBarResponseId = 2;
+ const int64 kBarSize = 200;
+ AppCacheEntry entry2(AppCacheEntry::FALLBACK, kBarResponseId, kBarSize);
+ EXPECT_TRUE(cache->AddOrModifyEntry(kBarUrl, entry2));
+ EXPECT_EQ(entry2.types(), cache->GetEntry(kBarUrl)->types());
+ EXPECT_EQ(2UL, cache->entries().size());
+ EXPECT_EQ(kFooSize + kBarSize, cache->cache_size());
// Expected to return false when an existing entry is modified.
AppCacheEntry entry3(AppCacheEntry::EXPLICIT);
- EXPECT_FALSE(cache->AddOrModifyEntry(kUrl1, entry3));
+ EXPECT_FALSE(cache->AddOrModifyEntry(kFooUrl, entry3));
EXPECT_EQ((AppCacheEntry::MASTER | AppCacheEntry::EXPLICIT),
- cache->GetEntry(kUrl1)->types());
- EXPECT_EQ(entry2.types(), cache->GetEntry(kUrl2)->types()); // unchanged
+ cache->GetEntry(kFooUrl)->types());
+ // Only the type should be modified.
+ EXPECT_EQ(kFooResponseId, cache->GetEntry(kFooUrl)->response_id());
+ EXPECT_EQ(kFooSize, cache->GetEntry(kFooUrl)->response_size());
+ EXPECT_EQ(kFooSize + kBarSize, cache->cache_size());
+
+ EXPECT_EQ(entry2.types(), cache->GetEntry(kBarUrl)->types()); // unchanged
+
+ cache->RemoveEntry(kBarUrl);
+ EXPECT_EQ(kFooSize, cache->cache_size());
+ cache->RemoveEntry(kFooUrl);
+ EXPECT_EQ(0L, cache->cache_size());
+ EXPECT_TRUE(cache->entries().empty());
}
TEST(AppCacheTest, InitializeWithManifest) {