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

Unified Diff: webkit/appcache/appcache_unittest.cc

Issue 10575044: AppCache - Don't ignore network namespace entries when '*' is in the list. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | « webkit/appcache/appcache.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/appcache/appcache_unittest.cc
===================================================================
--- webkit/appcache/appcache_unittest.cc (revision 143213)
+++ webkit/appcache/appcache_unittest.cc (working copy)
@@ -323,5 +323,73 @@
EXPECT_FALSE(network_namespace);
}
+TEST(AppCacheTest, ToFromDatabaseRecords) {
+ // Setup a cache with some entries.
+ const GURL kManifestUrl("http://foo.com/manifest");
+ const GURL kInterceptUrl("http://foo.com/intercept.html");
+ const GURL kFallbackUrl("http://foo.com/fallback.html");
tony 2012/06/21 16:48:09 Nit: FWIW, I think example.com is reserved so you
+ const std::string kData(
+ "CACHE MANIFEST\r"
+ "CHROMIUM-INTERCEPT:\r"
+ "/intercept return /intercept.html\r"
+ "FALLBACK:\r"
+ "/ /fallback.html\r"
+ "NETWORK:\r"
+ "/whitelist\r"
+ "*\r");
+ MockAppCacheService service;
+ scoped_refptr<AppCacheGroup> group =
+ new AppCacheGroup(&service, kManifestUrl, 4321);
+ scoped_refptr<AppCache> cache(new AppCache(&service, 1234));
+ Manifest manifest;
+ EXPECT_TRUE(
+ ParseManifest(kManifestUrl, kData.c_str(), kData.length(), manifest));
+ cache->InitializeWithManifest(&manifest);
+ cache->AddEntry(
+ kManifestUrl,
+ AppCacheEntry(AppCacheEntry::MANIFEST, 1, 1));
+ cache->AddEntry(
+ kInterceptUrl,
+ AppCacheEntry(AppCacheEntry::INTERCEPT, 3, 3));
+ cache->AddEntry(
+ kFallbackUrl,
+ AppCacheEntry(AppCacheEntry::FALLBACK, 2, 2));
+
+ // Get it to produce database records and verify them.
+ AppCacheDatabase::CacheRecord cache_record;
+ std::vector<AppCacheDatabase::EntryRecord> entries;
+ std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
+ std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
+ std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
+ cache->ToDatabaseRecords(
+ group, &cache_record, &entries,
+ &intercepts, &fallbacks, &whitelists);
+ EXPECT_EQ(1234, cache_record.cache_id);
+ EXPECT_EQ(4321, cache_record.group_id);
tony 2012/06/21 16:48:09 Nit: Can we put 1234 and 4321 in const variables?
+ EXPECT_TRUE(cache_record.online_wildcard);
+ EXPECT_EQ(1 + 2 + 3, cache_record.cache_size);
+ EXPECT_EQ(3u, entries.size());
+ EXPECT_EQ(1u, intercepts.size());
+ EXPECT_EQ(1u, fallbacks.size());
+ EXPECT_EQ(1u, whitelists.size());
+ cache = NULL;
+
+ // Create a new AppCache and populate it with those records and verify.
+ cache = new AppCache(&service, 1234);
+ cache->InitializeWithDatabaseRecords(
+ cache_record, entries, intercepts,
+ fallbacks, whitelists);
+ EXPECT_TRUE(cache->online_whitelist_all_);
+ EXPECT_EQ(3u, cache->entries().size());
+ EXPECT_TRUE(cache->GetEntry(kManifestUrl));
+ EXPECT_TRUE(cache->GetEntry(kInterceptUrl));
+ EXPECT_TRUE(cache->GetEntry(kFallbackUrl));
+ EXPECT_EQ(kInterceptUrl,
+ cache->GetInterceptEntryUrl(GURL("http://foo.com/intercept")));
+ EXPECT_EQ(kFallbackUrl,
+ cache->GetFallbackEntryUrl(GURL("http://foo.com/")));
+ EXPECT_EQ(1 + 2 + 3, cache->cache_size());
+}
+
} // namespace appacache
« no previous file with comments | « webkit/appcache/appcache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698