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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/appcache/appcache.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "webkit/appcache/appcache.h" 6 #include "webkit/appcache/appcache.h"
7 #include "webkit/appcache/appcache_frontend_impl.h" 7 #include "webkit/appcache/appcache_frontend_impl.h"
8 #include "webkit/appcache/appcache_host.h" 8 #include "webkit/appcache/appcache_host.h"
9 #include "webkit/appcache/mock_appcache_service.h" 9 #include "webkit/appcache/mock_appcache_service.h"
10 10
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 &network_namespace); 316 &network_namespace);
317 EXPECT_TRUE(found); 317 EXPECT_TRUE(found);
318 EXPECT_EQ(kInterceptResponseId, entry.response_id()); 318 EXPECT_EQ(kInterceptResponseId, entry.response_id());
319 EXPECT_EQ(kInterceptNamespaceEntry, 319 EXPECT_EQ(kInterceptNamespaceEntry,
320 cache->GetInterceptEntryUrl(intercept_namespace)); 320 cache->GetInterceptEntryUrl(intercept_namespace));
321 EXPECT_FALSE(fallback_entry.has_response_id()); 321 EXPECT_FALSE(fallback_entry.has_response_id());
322 EXPECT_TRUE(fallback_namespace.is_empty()); 322 EXPECT_TRUE(fallback_namespace.is_empty());
323 EXPECT_FALSE(network_namespace); 323 EXPECT_FALSE(network_namespace);
324 } 324 }
325 325
326 TEST(AppCacheTest, ToFromDatabaseRecords) {
327 // Setup a cache with some entries.
328 const GURL kManifestUrl("http://foo.com/manifest");
329 const GURL kInterceptUrl("http://foo.com/intercept.html");
330 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
331 const std::string kData(
332 "CACHE MANIFEST\r"
333 "CHROMIUM-INTERCEPT:\r"
334 "/intercept return /intercept.html\r"
335 "FALLBACK:\r"
336 "/ /fallback.html\r"
337 "NETWORK:\r"
338 "/whitelist\r"
339 "*\r");
340 MockAppCacheService service;
341 scoped_refptr<AppCacheGroup> group =
342 new AppCacheGroup(&service, kManifestUrl, 4321);
343 scoped_refptr<AppCache> cache(new AppCache(&service, 1234));
344 Manifest manifest;
345 EXPECT_TRUE(
346 ParseManifest(kManifestUrl, kData.c_str(), kData.length(), manifest));
347 cache->InitializeWithManifest(&manifest);
348 cache->AddEntry(
349 kManifestUrl,
350 AppCacheEntry(AppCacheEntry::MANIFEST, 1, 1));
351 cache->AddEntry(
352 kInterceptUrl,
353 AppCacheEntry(AppCacheEntry::INTERCEPT, 3, 3));
354 cache->AddEntry(
355 kFallbackUrl,
356 AppCacheEntry(AppCacheEntry::FALLBACK, 2, 2));
357
358 // Get it to produce database records and verify them.
359 AppCacheDatabase::CacheRecord cache_record;
360 std::vector<AppCacheDatabase::EntryRecord> entries;
361 std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
362 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
363 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
364 cache->ToDatabaseRecords(
365 group, &cache_record, &entries,
366 &intercepts, &fallbacks, &whitelists);
367 EXPECT_EQ(1234, cache_record.cache_id);
368 EXPECT_EQ(4321, cache_record.group_id);
tony 2012/06/21 16:48:09 Nit: Can we put 1234 and 4321 in const variables?
369 EXPECT_TRUE(cache_record.online_wildcard);
370 EXPECT_EQ(1 + 2 + 3, cache_record.cache_size);
371 EXPECT_EQ(3u, entries.size());
372 EXPECT_EQ(1u, intercepts.size());
373 EXPECT_EQ(1u, fallbacks.size());
374 EXPECT_EQ(1u, whitelists.size());
375 cache = NULL;
376
377 // Create a new AppCache and populate it with those records and verify.
378 cache = new AppCache(&service, 1234);
379 cache->InitializeWithDatabaseRecords(
380 cache_record, entries, intercepts,
381 fallbacks, whitelists);
382 EXPECT_TRUE(cache->online_whitelist_all_);
383 EXPECT_EQ(3u, cache->entries().size());
384 EXPECT_TRUE(cache->GetEntry(kManifestUrl));
385 EXPECT_TRUE(cache->GetEntry(kInterceptUrl));
386 EXPECT_TRUE(cache->GetEntry(kFallbackUrl));
387 EXPECT_EQ(kInterceptUrl,
388 cache->GetInterceptEntryUrl(GURL("http://foo.com/intercept")));
389 EXPECT_EQ(kFallbackUrl,
390 cache->GetFallbackEntryUrl(GURL("http://foo.com/")));
391 EXPECT_EQ(1 + 2 + 3, cache->cache_size());
392 }
393
326 } // namespace appacache 394 } // namespace appacache
327 395
OLDNEW
« 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