OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 |
11 namespace appcache { | 11 namespace appcache { |
12 | 12 |
13 class AppCacheTest : public testing::Test { | 13 class AppCacheTest : public testing::Test { |
14 }; | 14 }; |
15 | 15 |
16 TEST(AppCacheTest, CleanupUnusedCache) { | 16 TEST(AppCacheTest, CleanupUnusedCache) { |
17 MockAppCacheService service; | 17 MockAppCacheService service; |
18 AppCacheFrontendImpl frontend; | 18 AppCacheFrontendImpl frontend; |
19 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 111)); | 19 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 111)); |
20 cache->set_complete(true); | 20 cache->set_complete(true); |
21 scoped_refptr<AppCacheGroup> group( | 21 scoped_refptr<AppCacheGroup> group( |
22 new AppCacheGroup(service.storage(), GURL("http://blah/manifest"), 111)); | 22 new AppCacheGroup(service.storage(), GURL("http://blah/manifest"), 111)); |
23 group->AddCache(cache); | 23 group->AddCache(cache.get()); |
24 | 24 |
25 AppCacheHost host1(1, &frontend, &service); | 25 AppCacheHost host1(1, &frontend, &service); |
26 AppCacheHost host2(2, &frontend, &service); | 26 AppCacheHost host2(2, &frontend, &service); |
27 | 27 |
28 host1.AssociateCompleteCache(cache.get()); | 28 host1.AssociateCompleteCache(cache.get()); |
29 host2.AssociateCompleteCache(cache.get()); | 29 host2.AssociateCompleteCache(cache.get()); |
30 | 30 |
31 host1.AssociateNoCache(GURL()); | 31 host1.AssociateNoCache(GURL()); |
32 host2.AssociateNoCache(GURL()); | 32 host2.AssociateNoCache(GURL()); |
33 } | 33 } |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 cache->AddEntry( | 552 cache->AddEntry( |
553 kFallbackUrl, | 553 kFallbackUrl, |
554 AppCacheEntry(AppCacheEntry::FALLBACK, 2, 2)); | 554 AppCacheEntry(AppCacheEntry::FALLBACK, 2, 2)); |
555 | 555 |
556 // Get it to produce database records and verify them. | 556 // Get it to produce database records and verify them. |
557 AppCacheDatabase::CacheRecord cache_record; | 557 AppCacheDatabase::CacheRecord cache_record; |
558 std::vector<AppCacheDatabase::EntryRecord> entries; | 558 std::vector<AppCacheDatabase::EntryRecord> entries; |
559 std::vector<AppCacheDatabase::NamespaceRecord> intercepts; | 559 std::vector<AppCacheDatabase::NamespaceRecord> intercepts; |
560 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks; | 560 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks; |
561 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists; | 561 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists; |
562 cache->ToDatabaseRecords( | 562 cache->ToDatabaseRecords(group.get(), |
563 group, &cache_record, &entries, | 563 &cache_record, |
564 &intercepts, &fallbacks, &whitelists); | 564 &entries, |
| 565 &intercepts, |
| 566 &fallbacks, |
| 567 &whitelists); |
565 EXPECT_EQ(kCacheId, cache_record.cache_id); | 568 EXPECT_EQ(kCacheId, cache_record.cache_id); |
566 EXPECT_EQ(kGroupId, cache_record.group_id); | 569 EXPECT_EQ(kGroupId, cache_record.group_id); |
567 EXPECT_TRUE(cache_record.online_wildcard); | 570 EXPECT_TRUE(cache_record.online_wildcard); |
568 EXPECT_EQ(1 + 2 + 3, cache_record.cache_size); | 571 EXPECT_EQ(1 + 2 + 3, cache_record.cache_size); |
569 EXPECT_EQ(3u, entries.size()); | 572 EXPECT_EQ(3u, entries.size()); |
570 EXPECT_EQ(1u, intercepts.size()); | 573 EXPECT_EQ(1u, intercepts.size()); |
571 EXPECT_EQ(1u, fallbacks.size()); | 574 EXPECT_EQ(1u, fallbacks.size()); |
572 EXPECT_EQ(1u, whitelists.size()); | 575 EXPECT_EQ(1u, whitelists.size()); |
573 cache = NULL; | 576 cache = NULL; |
574 | 577 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 GURL("http://foo.com/a/b/01234567890abcdef/b"))); | 664 GURL("http://foo.com/a/b/01234567890abcdef/b"))); |
662 EXPECT_TRUE(star_greediness.IsMatch( | 665 EXPECT_TRUE(star_greediness.IsMatch( |
663 GURL("http://foo.com/a/b/01234567890abcdef/b01234567890abcdef/b"))); | 666 GURL("http://foo.com/a/b/01234567890abcdef/b01234567890abcdef/b"))); |
664 EXPECT_TRUE(star_greediness.IsMatch( | 667 EXPECT_TRUE(star_greediness.IsMatch( |
665 GURL("http://foo.com/a/b/01234567890abcdef_eat_some_more_characters_" | 668 GURL("http://foo.com/a/b/01234567890abcdef_eat_some_more_characters_" |
666 "/and_even_more_for_the_heck_of_it/01234567890abcdef/b"))); | 669 "/and_even_more_for_the_heck_of_it/01234567890abcdef/b"))); |
667 } | 670 } |
668 | 671 |
669 } // namespace appacache | 672 } // namespace appacache |
670 | 673 |
OLD | NEW |