diff options
author | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-18 22:22:37 +0000 |
---|---|---|
committer | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-18 22:22:37 +0000 |
commit | 91fce0c025e0ff1516d1a8ea762bc4eab326b8de (patch) | |
tree | 3a8f22ff91e21328dcb5d9db7ad3b4f4cc7c609f /webkit/appcache/mock_appcache_storage_unittest.cc | |
parent | 7f1654c7b6a85ec08b0080b68124bb39471b1a16 (diff) | |
download | chromium_src-91fce0c025e0ff1516d1a8ea762bc4eab326b8de.zip chromium_src-91fce0c025e0ff1516d1a8ea762bc4eab326b8de.tar.gz chromium_src-91fce0c025e0ff1516d1a8ea762bc4eab326b8de.tar.bz2 |
Mock appcache storage bug fix for storing group and changes to its existing newest cache.
TEST=test added to catch bug
BUG=none
Review URL: http://codereview.chromium.org/399078
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32417 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/mock_appcache_storage_unittest.cc')
-rw-r--r-- | webkit/appcache/mock_appcache_storage_unittest.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/webkit/appcache/mock_appcache_storage_unittest.cc b/webkit/appcache/mock_appcache_storage_unittest.cc index 39fc445..0a0bae5 100644 --- a/webkit/appcache/mock_appcache_storage_unittest.cc +++ b/webkit/appcache/mock_appcache_storage_unittest.cc @@ -271,6 +271,48 @@ TEST_F(MockAppCacheStorageTest, StoreExistingGroup) { EXPECT_EQ(new_cache.get(), group->newest_complete_cache()); } +TEST_F(MockAppCacheStorageTest, StoreExistingGroupExistingCache) { + // Store a group with updates to its existing newest complete cache. + MockAppCacheService service; + MockAppCacheStorage* storage = + reinterpret_cast<MockAppCacheStorage*>(service.storage()); + + // Setup some preconditions. Create a group and a complete cache that + // appear to be "stored". + GURL manifest_url("http://blah"); + scoped_refptr<AppCacheGroup> group = + new AppCacheGroup(&service, manifest_url); + int64 cache_id = storage->NewCacheId(); + scoped_refptr<AppCache> cache = new AppCache(&service, cache_id); + cache->set_complete(true); + group->AddCache(cache); + storage->AddStoredGroup(group); + storage->AddStoredCache(cache); + // Hold our refs to simulate the UpdateJob holding these refs. + + // Change the group's newest cache. + EXPECT_EQ(cache, group->newest_complete_cache()); + GURL entry_url("http://blah/blah"); + cache->AddEntry(entry_url, AppCacheEntry(AppCacheEntry::MASTER)); + + // Conduct the test. + MockStorageDelegate delegate; + EXPECT_EQ(size_t(1), storage->stored_caches_.size()); + EXPECT_EQ(size_t(1), storage->stored_groups_.size()); + EXPECT_TRUE(storage->IsCacheStored(cache)); + storage->StoreGroupAndNewestCache(group, cache, &delegate); + EXPECT_FALSE(delegate.stored_group_success_); + EXPECT_EQ(size_t(1), storage->stored_caches_.size()); + EXPECT_EQ(size_t(1), storage->stored_groups_.size()); + MessageLoop::current()->RunAllPending(); // Do async task execution. + EXPECT_TRUE(delegate.stored_group_success_); + EXPECT_EQ(size_t(1), storage->stored_caches_.size()); + EXPECT_EQ(size_t(1), storage->stored_groups_.size()); + EXPECT_TRUE(storage->IsCacheStored(cache)); + EXPECT_EQ(cache, group->newest_complete_cache()); + EXPECT_TRUE(cache->GetEntry(entry_url)); +} + TEST_F(MockAppCacheStorageTest, MakeGroupObsolete) { // Make a group obsolete, should complete asyncly. MockAppCacheService service; |