OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stack> | 5 #include <stack> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 const GURL kManifestUrl2("http://blah/manifest2"); | 29 const GURL kManifestUrl2("http://blah/manifest2"); |
30 const GURL kManifestUrl3("http://blah/manifest3"); | 30 const GURL kManifestUrl3("http://blah/manifest3"); |
31 const GURL kEntryUrl("http://blah/entry"); | 31 const GURL kEntryUrl("http://blah/entry"); |
32 const GURL kEntryUrl2("http://blah/entry2"); | 32 const GURL kEntryUrl2("http://blah/entry2"); |
33 const GURL kFallbackNamespace("http://blah/fallback_namespace/"); | 33 const GURL kFallbackNamespace("http://blah/fallback_namespace/"); |
34 const GURL kFallbackNamespace2("http://blah/fallback_namespace/longer"); | 34 const GURL kFallbackNamespace2("http://blah/fallback_namespace/longer"); |
35 const GURL kFallbackTestUrl("http://blah/fallback_namespace/longer/test"); | 35 const GURL kFallbackTestUrl("http://blah/fallback_namespace/longer/test"); |
36 const GURL kOnlineNamespace("http://blah/online_namespace"); | 36 const GURL kOnlineNamespace("http://blah/online_namespace"); |
37 const GURL kOnlineNamespaceWithinFallback( | 37 const GURL kOnlineNamespaceWithinFallback( |
38 "http://blah/fallback_namespace/online/"); | 38 "http://blah/fallback_namespace/online/"); |
39 const GURL kInterceptNamespace("http://blah/intercept_namespace/"); | |
40 const GURL kInterceptNamespace2("http://blah/intercept_namespace/longer/"); | |
41 const GURL kInterceptTestUrl("http://blah/intercept_namespace/longer/test"); | |
39 const GURL kOrigin(kManifestUrl.GetOrigin()); | 42 const GURL kOrigin(kManifestUrl.GetOrigin()); |
40 | 43 |
41 const int kManifestEntryIdOffset = 100; | 44 const int kManifestEntryIdOffset = 100; |
42 const int kFallbackEntryIdOffset = 1000; | 45 const int kFallbackEntryIdOffset = 1000; |
43 | 46 |
44 const GURL kDefaultEntryUrl("http://blah/makecacheandgroup_default_entry"); | 47 const GURL kDefaultEntryUrl("http://blah/makecacheandgroup_default_entry"); |
45 const int kDefaultEntrySize = 10; | 48 const int kDefaultEntrySize = 10; |
46 const int kDefaultEntryIdOffset = 12345; | 49 const int kDefaultEntryIdOffset = 12345; |
47 | 50 |
48 const int kMockQuota = 5000; | 51 const int kMockQuota = 5000; |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 EXPECT_EQ(kDefaultEntrySize, storage()->usage_map_[kOrigin]); | 664 EXPECT_EQ(kDefaultEntrySize, storage()->usage_map_[kOrigin]); |
662 | 665 |
663 // Also insert some related records. | 666 // Also insert some related records. |
664 AppCacheDatabase::EntryRecord entry_record; | 667 AppCacheDatabase::EntryRecord entry_record; |
665 entry_record.cache_id = 1; | 668 entry_record.cache_id = 1; |
666 entry_record.flags = AppCacheEntry::FALLBACK; | 669 entry_record.flags = AppCacheEntry::FALLBACK; |
667 entry_record.response_id = 1; | 670 entry_record.response_id = 1; |
668 entry_record.url = kEntryUrl; | 671 entry_record.url = kEntryUrl; |
669 EXPECT_TRUE(database()->InsertEntry(&entry_record)); | 672 EXPECT_TRUE(database()->InsertEntry(&entry_record)); |
670 | 673 |
671 AppCacheDatabase::FallbackNameSpaceRecord fallback_namespace_record; | 674 AppCacheDatabase::NamespaceRecord fallback_namespace_record; |
672 fallback_namespace_record.cache_id = 1; | 675 fallback_namespace_record.cache_id = 1; |
673 fallback_namespace_record.fallback_entry_url = kEntryUrl; | 676 fallback_namespace_record.target_url = kEntryUrl; |
674 fallback_namespace_record.namespace_url = kFallbackNamespace; | 677 fallback_namespace_record.namespace_url = kFallbackNamespace; |
675 fallback_namespace_record.origin = kManifestUrl.GetOrigin(); | 678 fallback_namespace_record.origin = kManifestUrl.GetOrigin(); |
676 EXPECT_TRUE( | 679 EXPECT_TRUE(database()->InsertNamespace(&fallback_namespace_record)); |
677 database()->InsertFallbackNameSpace(&fallback_namespace_record)); | |
678 | 680 |
679 AppCacheDatabase::OnlineWhiteListRecord online_whitelist_record; | 681 AppCacheDatabase::OnlineWhiteListRecord online_whitelist_record; |
680 online_whitelist_record.cache_id = 1; | 682 online_whitelist_record.cache_id = 1; |
681 online_whitelist_record.namespace_url = kOnlineNamespace; | 683 online_whitelist_record.namespace_url = kOnlineNamespace; |
682 EXPECT_TRUE(database()->InsertOnlineWhiteList(&online_whitelist_record)); | 684 EXPECT_TRUE(database()->InsertOnlineWhiteList(&online_whitelist_record)); |
683 | 685 |
684 // Conduct the test. | 686 // Conduct the test. |
685 storage()->MakeGroupObsolete(group_, delegate()); | 687 storage()->MakeGroupObsolete(group_, delegate()); |
686 EXPECT_FALSE(group_->is_obsolete()); | 688 EXPECT_FALSE(group_->is_obsolete()); |
687 } | 689 } |
688 | 690 |
689 void Verify_MakeGroupObsolete() { | 691 void Verify_MakeGroupObsolete() { |
690 EXPECT_TRUE(delegate()->obsoleted_success_); | 692 EXPECT_TRUE(delegate()->obsoleted_success_); |
691 EXPECT_EQ(group_.get(), delegate()->obsoleted_group_.get()); | 693 EXPECT_EQ(group_.get(), delegate()->obsoleted_group_.get()); |
692 EXPECT_TRUE(group_->is_obsolete()); | 694 EXPECT_TRUE(group_->is_obsolete()); |
693 EXPECT_TRUE(storage()->usage_map_.empty()); | 695 EXPECT_TRUE(storage()->usage_map_.empty()); |
694 | 696 |
695 // The cache and group have been deleted from the database. | 697 // The cache and group have been deleted from the database. |
696 AppCacheDatabase::GroupRecord group_record; | 698 AppCacheDatabase::GroupRecord group_record; |
697 AppCacheDatabase::CacheRecord cache_record; | 699 AppCacheDatabase::CacheRecord cache_record; |
698 EXPECT_FALSE(database()->FindGroup(1, &group_record)); | 700 EXPECT_FALSE(database()->FindGroup(1, &group_record)); |
699 EXPECT_FALSE(database()->FindCache(1, &cache_record)); | 701 EXPECT_FALSE(database()->FindCache(1, &cache_record)); |
700 | 702 |
701 // The related records should have been deleted too. | 703 // The related records should have been deleted too. |
702 std::vector<AppCacheDatabase::EntryRecord> entry_records; | 704 std::vector<AppCacheDatabase::EntryRecord> entry_records; |
703 database()->FindEntriesForCache(1, &entry_records); | 705 database()->FindEntriesForCache(1, &entry_records); |
704 EXPECT_TRUE(entry_records.empty()); | 706 EXPECT_TRUE(entry_records.empty()); |
705 std::vector<AppCacheDatabase::FallbackNameSpaceRecord> fallback_records; | 707 std::vector<AppCacheDatabase::NamespaceRecord> intercept_records; |
706 database()->FindFallbackNameSpacesForCache(1, &fallback_records); | 708 std::vector<AppCacheDatabase::NamespaceRecord> fallback_records; |
709 database()->FindNamespacesForCache( | |
710 1, &intercept_records, &fallback_records); | |
707 EXPECT_TRUE(fallback_records.empty()); | 711 EXPECT_TRUE(fallback_records.empty()); |
708 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelist_records; | 712 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelist_records; |
709 database()->FindOnlineWhiteListForCache(1, &whitelist_records); | 713 database()->FindOnlineWhiteListForCache(1, &whitelist_records); |
710 EXPECT_TRUE(whitelist_records.empty()); | 714 EXPECT_TRUE(whitelist_records.empty()); |
711 | 715 |
712 // Verify quota bookkeeping | 716 // Verify quota bookkeeping |
713 EXPECT_TRUE(storage()->usage_map_.empty()); | 717 EXPECT_TRUE(storage()->usage_map_.empty()); |
714 EXPECT_EQ(1, mock_quota_manager_proxy_->notify_storage_modified_count_); | 718 EXPECT_EQ(1, mock_quota_manager_proxy_->notify_storage_modified_count_); |
715 EXPECT_EQ(kOrigin, mock_quota_manager_proxy_->last_origin_); | 719 EXPECT_EQ(kOrigin, mock_quota_manager_proxy_->last_origin_); |
716 EXPECT_EQ(-kDefaultEntrySize, mock_quota_manager_proxy_->last_delta_); | 720 EXPECT_EQ(-kDefaultEntrySize, mock_quota_manager_proxy_->last_delta_); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 PushNextTask(base::Bind( | 886 PushNextTask(base::Bind( |
883 &AppCacheStorageImplTest::Verify_BasicFindMainFallbackResponse, | 887 &AppCacheStorageImplTest::Verify_BasicFindMainFallbackResponse, |
884 base::Unretained(this))); | 888 base::Unretained(this))); |
885 | 889 |
886 // Setup some preconditions. Create a complete cache with a | 890 // Setup some preconditions. Create a complete cache with a |
887 // fallback namespace and entry. | 891 // fallback namespace and entry. |
888 MakeCacheAndGroup(kManifestUrl, 2, 1, true); | 892 MakeCacheAndGroup(kManifestUrl, 2, 1, true); |
889 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::FALLBACK, 1)); | 893 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::FALLBACK, 1)); |
890 cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, 2)); | 894 cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, 2)); |
891 cache_->fallback_namespaces_.push_back( | 895 cache_->fallback_namespaces_.push_back( |
892 FallbackNamespace(kFallbackNamespace2, kEntryUrl2)); | 896 Namespace(FALLBACK_NAMESPACE, kFallbackNamespace2, kEntryUrl2)); |
893 cache_->fallback_namespaces_.push_back( | 897 cache_->fallback_namespaces_.push_back( |
894 FallbackNamespace(kFallbackNamespace, kEntryUrl)); | 898 Namespace(FALLBACK_NAMESPACE, kFallbackNamespace, kEntryUrl)); |
895 AppCacheDatabase::CacheRecord cache_record; | 899 AppCacheDatabase::CacheRecord cache_record; |
896 std::vector<AppCacheDatabase::EntryRecord> entries; | 900 std::vector<AppCacheDatabase::EntryRecord> entries; |
897 std::vector<AppCacheDatabase::FallbackNameSpaceRecord> fallbacks; | 901 std::vector<AppCacheDatabase::NamespaceRecord> intercepts; |
902 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks; | |
898 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists; | 903 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists; |
899 cache_->ToDatabaseRecords(group_, | 904 cache_->ToDatabaseRecords(group_, |
900 &cache_record, &entries, &fallbacks, &whitelists); | 905 &cache_record, &entries, &intercepts, &fallbacks, &whitelists); |
901 | 906 |
902 std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter = | 907 std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter = |
903 entries.begin(); | 908 entries.begin(); |
904 while (iter != entries.end()) { | 909 while (iter != entries.end()) { |
905 // MakeCacheAndGroup has inserted the default entry record already | 910 // MakeCacheAndGroup has inserted the default entry record already |
906 if (iter->url != kDefaultEntryUrl) | 911 if (iter->url != kDefaultEntryUrl) |
907 EXPECT_TRUE(database()->InsertEntry(&(*iter))); | 912 EXPECT_TRUE(database()->InsertEntry(&(*iter))); |
908 ++iter; | 913 ++iter; |
909 } | 914 } |
910 | 915 |
911 EXPECT_TRUE(database()->InsertFallbackNameSpaceRecords(fallbacks)); | 916 EXPECT_TRUE(database()->InsertNamespaceRecords(fallbacks)); |
912 EXPECT_TRUE(database()->InsertOnlineWhiteListRecords(whitelists)); | 917 EXPECT_TRUE(database()->InsertOnlineWhiteListRecords(whitelists)); |
913 if (drop_from_working_set) { | 918 if (drop_from_working_set) { |
914 EXPECT_TRUE(cache_->HasOneRef()); | 919 EXPECT_TRUE(cache_->HasOneRef()); |
915 cache_ = NULL; | 920 cache_ = NULL; |
916 EXPECT_TRUE(group_->HasOneRef()); | 921 EXPECT_TRUE(group_->HasOneRef()); |
917 group_ = NULL; | 922 group_ = NULL; |
918 } | 923 } |
919 | 924 |
920 // Conduct the test. The test url is in both fallback namespace urls, | 925 // Conduct the test. The test url is in both fallback namespace urls, |
921 // but should match the longer of the two. | 926 // but should match the longer of the two. |
922 storage()->FindResponseForMainRequest(kFallbackTestUrl, GURL(), delegate()); | 927 storage()->FindResponseForMainRequest(kFallbackTestUrl, GURL(), delegate()); |
923 EXPECT_NE(kFallbackTestUrl, delegate()->found_url_); | 928 EXPECT_NE(kFallbackTestUrl, delegate()->found_url_); |
924 } | 929 } |
925 | 930 |
926 void Verify_BasicFindMainFallbackResponse() { | 931 void Verify_BasicFindMainFallbackResponse() { |
927 EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_); | 932 EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_); |
928 EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_); | 933 EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_); |
929 EXPECT_EQ(1, delegate()->found_cache_id_); | 934 EXPECT_EQ(1, delegate()->found_cache_id_); |
930 EXPECT_EQ(2, delegate()->found_group_id_); | 935 EXPECT_EQ(2, delegate()->found_group_id_); |
931 EXPECT_FALSE(delegate()->found_entry_.has_response_id()); | 936 EXPECT_FALSE(delegate()->found_entry_.has_response_id()); |
932 EXPECT_EQ(2, delegate()->found_fallback_entry_.response_id()); | 937 EXPECT_EQ(2, delegate()->found_fallback_entry_.response_id()); |
933 EXPECT_EQ(kEntryUrl2, delegate()->found_fallback_url_); | 938 EXPECT_EQ(kEntryUrl2, delegate()->found_fallback_url_); |
934 EXPECT_TRUE(delegate()->found_fallback_entry_.IsFallback()); | 939 EXPECT_TRUE(delegate()->found_fallback_entry_.IsFallback()); |
935 TestFinished(); | 940 TestFinished(); |
936 } | 941 } |
937 | 942 |
943 // BasicFindMainInterceptResponse ------------------------------- | |
944 | |
945 void BasicFindMainInterceptResponseInDatabase() { | |
946 BasicFindMainInterceptResponse(true); | |
947 } | |
948 | |
949 void BasicFindMainInterceptResponseInWorkingSet() { | |
950 BasicFindMainInterceptResponse(false); | |
951 } | |
952 | |
953 void BasicFindMainInterceptResponse(bool drop_from_working_set) { | |
954 PushNextTask(base::Bind( | |
955 &AppCacheStorageImplTest::Verify_BasicFindMainInterceptResponse, | |
956 base::Unretained(this))); | |
957 | |
958 // Setup some preconditions. Create a complete cache with an | |
959 // intercept namespace and entry. | |
960 MakeCacheAndGroup(kManifestUrl, 2, 1, true); | |
961 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::INTERCEPT, 1)); | |
962 cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::INTERCEPT, 2)); | |
963 cache_->intercept_namespaces_.push_back( | |
964 Namespace(INTERCEPT_NAMESPACE, kInterceptNamespace2, kEntryUrl2)); | |
965 cache_->intercept_namespaces_.push_back( | |
966 Namespace(INTERCEPT_NAMESPACE, kInterceptNamespace, kEntryUrl)); | |
967 AppCacheDatabase::CacheRecord cache_record; | |
968 std::vector<AppCacheDatabase::EntryRecord> entries; | |
969 std::vector<AppCacheDatabase::NamespaceRecord> intercepts; | |
970 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks; | |
971 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists; | |
972 cache_->ToDatabaseRecords(group_, | |
973 &cache_record, &entries, &intercepts, &fallbacks, &whitelists); | |
974 | |
975 std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter = | |
976 entries.begin(); | |
977 while (iter != entries.end()) { | |
978 // MakeCacheAndGroup has inserted the default entry record already | |
jennb
2011/12/13 00:33:09
extra space in sentence
| |
979 if (iter->url != kDefaultEntryUrl) | |
980 EXPECT_TRUE(database()->InsertEntry(&(*iter))); | |
981 ++iter; | |
982 } | |
983 | |
984 EXPECT_TRUE(database()->InsertNamespaceRecords(intercepts)); | |
985 EXPECT_TRUE(database()->InsertOnlineWhiteListRecords(whitelists)); | |
986 if (drop_from_working_set) { | |
987 EXPECT_TRUE(cache_->HasOneRef()); | |
988 cache_ = NULL; | |
989 EXPECT_TRUE(group_->HasOneRef()); | |
990 group_ = NULL; | |
991 } | |
992 | |
993 // Conduct the test. The test url is in both intercept namespaces, | |
994 // but should match the longer of the two. | |
995 storage()->FindResponseForMainRequest( | |
996 kInterceptTestUrl, GURL(), delegate()); | |
997 EXPECT_NE(kInterceptTestUrl, delegate()->found_url_); | |
998 } | |
999 | |
1000 void Verify_BasicFindMainInterceptResponse() { | |
1001 EXPECT_EQ(kInterceptTestUrl, delegate()->found_url_); | |
1002 EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_); | |
1003 EXPECT_EQ(1, delegate()->found_cache_id_); | |
1004 EXPECT_EQ(2, delegate()->found_group_id_); | |
1005 EXPECT_EQ(2, delegate()->found_entry_.response_id()); | |
1006 EXPECT_TRUE(delegate()->found_entry_.IsIntercept()); | |
1007 EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id()); | |
1008 TestFinished(); | |
1009 } | |
938 // FindMainResponseWithMultipleHits ------------------------------- | 1010 // FindMainResponseWithMultipleHits ------------------------------- |
939 | 1011 |
940 void FindMainResponseWithMultipleHits() { | 1012 void FindMainResponseWithMultipleHits() { |
941 PushNextTask(base::Bind( | 1013 PushNextTask(base::Bind( |
942 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits, | 1014 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits, |
943 base::Unretained(this))); | 1015 base::Unretained(this))); |
944 | 1016 |
945 // Setup some preconditions, create a few caches with an identical set | 1017 // Setup some preconditions, create a few caches with an identical set |
946 // of entries and fallback namespaces. Only the last one remains in | 1018 // of entries and fallback namespaces. Only the last one remains in |
947 // the working set to simulate appearing as "in use". | 1019 // the working set to simulate appearing as "in use". |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
981 | 1053 |
982 // Add a fallback entry and namespace | 1054 // Add a fallback entry and namespace |
983 entry_record.cache_id = id; | 1055 entry_record.cache_id = id; |
984 entry_record.url = kEntryUrl2; | 1056 entry_record.url = kEntryUrl2; |
985 entry_record.flags = AppCacheEntry::FALLBACK; | 1057 entry_record.flags = AppCacheEntry::FALLBACK; |
986 entry_record.response_id = id + kFallbackEntryIdOffset; | 1058 entry_record.response_id = id + kFallbackEntryIdOffset; |
987 EXPECT_TRUE(database()->InsertEntry(&entry_record)); | 1059 EXPECT_TRUE(database()->InsertEntry(&entry_record)); |
988 cache_->AddEntry( | 1060 cache_->AddEntry( |
989 entry_record.url, | 1061 entry_record.url, |
990 AppCacheEntry(entry_record.flags, entry_record.response_id)); | 1062 AppCacheEntry(entry_record.flags, entry_record.response_id)); |
991 AppCacheDatabase::FallbackNameSpaceRecord fallback_namespace_record; | 1063 AppCacheDatabase::NamespaceRecord fallback_namespace_record; |
992 fallback_namespace_record.cache_id = id; | 1064 fallback_namespace_record.cache_id = id; |
993 fallback_namespace_record.fallback_entry_url = entry_record.url; | 1065 fallback_namespace_record.target_url = entry_record.url; |
994 fallback_namespace_record.namespace_url = kFallbackNamespace; | 1066 fallback_namespace_record.namespace_url = kFallbackNamespace; |
995 fallback_namespace_record.origin = manifest_url.GetOrigin(); | 1067 fallback_namespace_record.origin = manifest_url.GetOrigin(); |
996 EXPECT_TRUE( | 1068 EXPECT_TRUE(database()->InsertNamespace(&fallback_namespace_record)); |
997 database()->InsertFallbackNameSpace(&fallback_namespace_record)); | |
998 cache_->fallback_namespaces_.push_back( | 1069 cache_->fallback_namespaces_.push_back( |
999 FallbackNamespace(kFallbackNamespace, kEntryUrl2)); | 1070 Namespace(FALLBACK_NAMESPACE, kFallbackNamespace, kEntryUrl2)); |
1000 } | 1071 } |
1001 | 1072 |
1002 void Verify_FindMainResponseWithMultipleHits() { | 1073 void Verify_FindMainResponseWithMultipleHits() { |
1003 EXPECT_EQ(kEntryUrl, delegate()->found_url_); | 1074 EXPECT_EQ(kEntryUrl, delegate()->found_url_); |
1004 EXPECT_EQ(kManifestUrl3, delegate()->found_manifest_url_); | 1075 EXPECT_EQ(kManifestUrl3, delegate()->found_manifest_url_); |
1005 EXPECT_EQ(3, delegate()->found_cache_id_); | 1076 EXPECT_EQ(3, delegate()->found_cache_id_); |
1006 EXPECT_EQ(3, delegate()->found_group_id_); | 1077 EXPECT_EQ(3, delegate()->found_group_id_); |
1007 EXPECT_EQ(3, delegate()->found_entry_.response_id()); | 1078 EXPECT_EQ(3, delegate()->found_entry_.response_id()); |
1008 EXPECT_TRUE(delegate()->found_entry_.IsExplicit()); | 1079 EXPECT_TRUE(delegate()->found_entry_.IsExplicit()); |
1009 EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id()); | 1080 EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id()); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1102 void FindMainResponseExclusions(bool drop_from_working_set) { | 1173 void FindMainResponseExclusions(bool drop_from_working_set) { |
1103 // Setup some preconditions. Create a complete cache with a | 1174 // Setup some preconditions. Create a complete cache with a |
1104 // foreign entry, an online namespace, and a second online | 1175 // foreign entry, an online namespace, and a second online |
1105 // namespace nested within a fallback namespace. | 1176 // namespace nested within a fallback namespace. |
1106 MakeCacheAndGroup(kManifestUrl, 1, 1, true); | 1177 MakeCacheAndGroup(kManifestUrl, 1, 1, true); |
1107 cache_->AddEntry(kEntryUrl, | 1178 cache_->AddEntry(kEntryUrl, |
1108 AppCacheEntry(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, 1)); | 1179 AppCacheEntry(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, 1)); |
1109 cache_->online_whitelist_namespaces_.push_back(kOnlineNamespace); | 1180 cache_->online_whitelist_namespaces_.push_back(kOnlineNamespace); |
1110 cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, 2)); | 1181 cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, 2)); |
1111 cache_->fallback_namespaces_.push_back( | 1182 cache_->fallback_namespaces_.push_back( |
1112 FallbackNamespace(kFallbackNamespace, kEntryUrl2)); | 1183 Namespace(FALLBACK_NAMESPACE, kFallbackNamespace, kEntryUrl2)); |
1113 cache_->online_whitelist_namespaces_.push_back(kOnlineNamespace); | 1184 cache_->online_whitelist_namespaces_.push_back(kOnlineNamespace); |
1114 cache_->online_whitelist_namespaces_.push_back( | 1185 cache_->online_whitelist_namespaces_.push_back( |
1115 kOnlineNamespaceWithinFallback); | 1186 kOnlineNamespaceWithinFallback); |
1116 | 1187 |
1117 AppCacheDatabase::EntryRecord entry_record; | 1188 AppCacheDatabase::EntryRecord entry_record; |
1118 entry_record.cache_id = 1; | 1189 entry_record.cache_id = 1; |
1119 entry_record.url = kEntryUrl; | 1190 entry_record.url = kEntryUrl; |
1120 entry_record.flags = AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN; | 1191 entry_record.flags = AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN; |
1121 entry_record.response_id = 1; | 1192 entry_record.response_id = 1; |
1122 EXPECT_TRUE(database()->InsertEntry(&entry_record)); | 1193 EXPECT_TRUE(database()->InsertEntry(&entry_record)); |
1123 AppCacheDatabase::OnlineWhiteListRecord whitelist_record; | 1194 AppCacheDatabase::OnlineWhiteListRecord whitelist_record; |
1124 whitelist_record.cache_id = 1; | 1195 whitelist_record.cache_id = 1; |
1125 whitelist_record.namespace_url = kOnlineNamespace; | 1196 whitelist_record.namespace_url = kOnlineNamespace; |
1126 EXPECT_TRUE(database()->InsertOnlineWhiteList(&whitelist_record)); | 1197 EXPECT_TRUE(database()->InsertOnlineWhiteList(&whitelist_record)); |
1127 AppCacheDatabase::FallbackNameSpaceRecord fallback_namespace_record; | 1198 AppCacheDatabase::NamespaceRecord fallback_namespace_record; |
1128 fallback_namespace_record.cache_id = 1; | 1199 fallback_namespace_record.cache_id = 1; |
1129 fallback_namespace_record.fallback_entry_url = kEntryUrl2; | 1200 fallback_namespace_record.target_url = kEntryUrl2; |
1130 fallback_namespace_record.namespace_url = kFallbackNamespace; | 1201 fallback_namespace_record.namespace_url = kFallbackNamespace; |
1131 fallback_namespace_record.origin = kManifestUrl.GetOrigin(); | 1202 fallback_namespace_record.origin = kManifestUrl.GetOrigin(); |
1132 EXPECT_TRUE( | 1203 EXPECT_TRUE(database()->InsertNamespace(&fallback_namespace_record)); |
1133 database()->InsertFallbackNameSpace(&fallback_namespace_record)); | |
1134 whitelist_record.cache_id = 1; | 1204 whitelist_record.cache_id = 1; |
1135 whitelist_record.namespace_url = kOnlineNamespaceWithinFallback; | 1205 whitelist_record.namespace_url = kOnlineNamespaceWithinFallback; |
1136 EXPECT_TRUE(database()->InsertOnlineWhiteList(&whitelist_record)); | 1206 EXPECT_TRUE(database()->InsertOnlineWhiteList(&whitelist_record)); |
1137 if (drop_from_working_set) { | 1207 if (drop_from_working_set) { |
1138 cache_ = NULL; | 1208 cache_ = NULL; |
1139 group_ = NULL; | 1209 group_ = NULL; |
1140 } | 1210 } |
1141 | 1211 |
1142 // We should not find anything for the foreign entry. | 1212 // We should not find anything for the foreign entry. |
1143 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_ExclusionNotFound, | 1213 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_ExclusionNotFound, |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1313 TEST_F(AppCacheStorageImplTest, BasicFindMainFallbackResponseInDatabase) { | 1383 TEST_F(AppCacheStorageImplTest, BasicFindMainFallbackResponseInDatabase) { |
1314 RunTestOnIOThread( | 1384 RunTestOnIOThread( |
1315 &AppCacheStorageImplTest::BasicFindMainFallbackResponseInDatabase); | 1385 &AppCacheStorageImplTest::BasicFindMainFallbackResponseInDatabase); |
1316 } | 1386 } |
1317 | 1387 |
1318 TEST_F(AppCacheStorageImplTest, BasicFindMainFallbackResponseInWorkingSet) { | 1388 TEST_F(AppCacheStorageImplTest, BasicFindMainFallbackResponseInWorkingSet) { |
1319 RunTestOnIOThread( | 1389 RunTestOnIOThread( |
1320 &AppCacheStorageImplTest::BasicFindMainFallbackResponseInWorkingSet); | 1390 &AppCacheStorageImplTest::BasicFindMainFallbackResponseInWorkingSet); |
1321 } | 1391 } |
1322 | 1392 |
1393 TEST_F(AppCacheStorageImplTest, BasicFindMainInterceptResponseInDatabase) { | |
1394 RunTestOnIOThread( | |
1395 &AppCacheStorageImplTest::BasicFindMainInterceptResponseInDatabase); | |
1396 } | |
1397 | |
1398 TEST_F(AppCacheStorageImplTest, BasicFindMainInterceptResponseInWorkingSet) { | |
1399 RunTestOnIOThread( | |
1400 &AppCacheStorageImplTest::BasicFindMainInterceptResponseInWorkingSet); | |
1401 } | |
1402 | |
1323 TEST_F(AppCacheStorageImplTest, FindMainResponseWithMultipleHits) { | 1403 TEST_F(AppCacheStorageImplTest, FindMainResponseWithMultipleHits) { |
1324 RunTestOnIOThread( | 1404 RunTestOnIOThread( |
1325 &AppCacheStorageImplTest::FindMainResponseWithMultipleHits); | 1405 &AppCacheStorageImplTest::FindMainResponseWithMultipleHits); |
1326 } | 1406 } |
1327 | 1407 |
1328 TEST_F(AppCacheStorageImplTest, FindMainResponseExclusionsInDatabase) { | 1408 TEST_F(AppCacheStorageImplTest, FindMainResponseExclusionsInDatabase) { |
1329 RunTestOnIOThread( | 1409 RunTestOnIOThread( |
1330 &AppCacheStorageImplTest::FindMainResponseExclusionsInDatabase); | 1410 &AppCacheStorageImplTest::FindMainResponseExclusionsInDatabase); |
1331 } | 1411 } |
1332 | 1412 |
1333 TEST_F(AppCacheStorageImplTest, FindMainResponseExclusionsInWorkingSet) { | 1413 TEST_F(AppCacheStorageImplTest, FindMainResponseExclusionsInWorkingSet) { |
1334 RunTestOnIOThread( | 1414 RunTestOnIOThread( |
1335 &AppCacheStorageImplTest::FindMainResponseExclusionsInWorkingSet); | 1415 &AppCacheStorageImplTest::FindMainResponseExclusionsInWorkingSet); |
1336 } | 1416 } |
1337 | 1417 |
1338 // That's all folks! | 1418 // That's all folks! |
1339 | 1419 |
1340 } // namespace appcache | 1420 } // namespace appcache |
OLD | NEW |