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

Side by Side Diff: webkit/appcache/appcache_storage_impl_unittest.cc

Issue 6727006: Select a more appropiate appcache based on the opener or the parent of the new document. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
OLDNEW
1 // Copyright (c) 2010 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/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/threading/thread.h" 8 #include "base/threading/thread.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "webkit/appcache/appcache.h" 12 #include "webkit/appcache/appcache.h"
13 #include "webkit/appcache/appcache_database.h" 13 #include "webkit/appcache/appcache_database.h"
14 #include "webkit/appcache/appcache_entry.h" 14 #include "webkit/appcache/appcache_entry.h"
15 #include "webkit/appcache/appcache_group.h" 15 #include "webkit/appcache/appcache_group.h"
16 #include "webkit/appcache/appcache_policy.h" 16 #include "webkit/appcache/appcache_policy.h"
17 #include "webkit/appcache/appcache_service.h" 17 #include "webkit/appcache/appcache_service.h"
18 #include "webkit/appcache/appcache_storage_impl.h" 18 #include "webkit/appcache/appcache_storage_impl.h"
19 #include "webkit/tools/test_shell/simple_appcache_system.h" 19 #include "webkit/tools/test_shell/simple_appcache_system.h"
20 20
21 namespace appcache { 21 namespace appcache {
22 22
23 namespace { 23 namespace {
24 24
25 const base::Time kZeroTime; 25 const base::Time kZeroTime;
26 const GURL kManifestUrl("http://blah/manifest"); 26 const GURL kManifestUrl("http://blah/manifest");
27 const GURL kManifestUrl2("http://blah/manifest2"); 27 const GURL kManifestUrl2("http://blah/manifest2");
28 const GURL kManifestUrl3("http://blah/manifest3");
28 const GURL kEntryUrl("http://blah/entry"); 29 const GURL kEntryUrl("http://blah/entry");
29 const GURL kEntryUrl2("http://blah/entry2"); 30 const GURL kEntryUrl2("http://blah/entry2");
30 const GURL kFallbackNamespace("http://blah/fallback_namespace/"); 31 const GURL kFallbackNamespace("http://blah/fallback_namespace/");
31 const GURL kFallbackNamespace2("http://blah/fallback_namespace/longer"); 32 const GURL kFallbackNamespace2("http://blah/fallback_namespace/longer");
32 const GURL kFallbackTestUrl("http://blah/fallback_namespace/longer/test"); 33 const GURL kFallbackTestUrl("http://blah/fallback_namespace/longer/test");
33 const GURL kOnlineNamespace("http://blah/online_namespace"); 34 const GURL kOnlineNamespace("http://blah/online_namespace");
34 const GURL kOnlineNamespaceWithinFallback( 35 const GURL kOnlineNamespaceWithinFallback(
35 "http://blah/fallback_namespace/online/"); 36 "http://blah/fallback_namespace/online/");
36 37
38 const int kManifestEntryIdOffset = 100;
39 const int kFallbackEntryIdOffset = 1000;
40
37 // For the duration of this test case, we hijack the AppCacheThread API 41 // For the duration of this test case, we hijack the AppCacheThread API
38 // calls and implement them in terms of the io and db threads created here. 42 // calls and implement them in terms of the io and db threads created here.
39 43
40 scoped_ptr<base::Thread> io_thread; 44 scoped_ptr<base::Thread> io_thread;
41 scoped_ptr<base::Thread> db_thread; 45 scoped_ptr<base::Thread> db_thread;
42 46
43 class TestThreadProvider : public SimpleAppCacheSystem::ThreadProvider { 47 class TestThreadProvider : public SimpleAppCacheSystem::ThreadProvider {
44 public: 48 public:
45 virtual bool PostTask( 49 virtual bool PostTask(
46 int id, 50 int id,
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 TestFinished(); 720 TestFinished();
717 } 721 }
718 722
719 // FindNoMainResponse ------------------------------- 723 // FindNoMainResponse -------------------------------
720 724
721 void FindNoMainResponse() { 725 void FindNoMainResponse() {
722 PushNextTask(NewRunnableMethod( 726 PushNextTask(NewRunnableMethod(
723 this, &AppCacheStorageImplTest::Verify_FindNoMainResponse)); 727 this, &AppCacheStorageImplTest::Verify_FindNoMainResponse));
724 728
725 // Conduct the test. 729 // Conduct the test.
726 storage()->FindResponseForMainRequest(kEntryUrl, delegate()); 730 storage()->FindResponseForMainRequest(kEntryUrl, GURL(), delegate());
727 EXPECT_NE(kEntryUrl, delegate()->found_url_); 731 EXPECT_NE(kEntryUrl, delegate()->found_url_);
728 } 732 }
729 733
730 void Verify_FindNoMainResponse() { 734 void Verify_FindNoMainResponse() {
731 EXPECT_EQ(kEntryUrl, delegate()->found_url_); 735 EXPECT_EQ(kEntryUrl, delegate()->found_url_);
732 // If the request was blocked by a policy, the manifest url is still valid. 736 // If the request was blocked by a policy, the manifest url is still valid.
733 EXPECT_TRUE(delegate()->found_manifest_url_.is_empty() || 737 EXPECT_TRUE(delegate()->found_manifest_url_.is_empty() ||
734 delegate()->found_blocked_by_policy_); 738 delegate()->found_blocked_by_policy_);
735 EXPECT_EQ(kNoCacheId, delegate()->found_cache_id_); 739 EXPECT_EQ(kNoCacheId, delegate()->found_cache_id_);
736 EXPECT_EQ(kNoResponseId, delegate()->found_entry_.response_id()); 740 EXPECT_EQ(kNoResponseId, delegate()->found_entry_.response_id());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 780
777 // Optionally drop the cache/group pair from the working set. 781 // Optionally drop the cache/group pair from the working set.
778 if (drop_from_working_set) { 782 if (drop_from_working_set) {
779 EXPECT_TRUE(cache_->HasOneRef()); 783 EXPECT_TRUE(cache_->HasOneRef());
780 cache_ = NULL; 784 cache_ = NULL;
781 EXPECT_TRUE(group_->HasOneRef()); 785 EXPECT_TRUE(group_->HasOneRef());
782 group_ = NULL; 786 group_ = NULL;
783 } 787 }
784 788
785 // Conduct the test. 789 // Conduct the test.
786 storage()->FindResponseForMainRequest(kEntryUrl, delegate()); 790 storage()->FindResponseForMainRequest(kEntryUrl, GURL(), delegate());
787 EXPECT_NE(kEntryUrl, delegate()->found_url_); 791 EXPECT_NE(kEntryUrl, delegate()->found_url_);
788 } 792 }
789 793
790 void Verify_BasicFindMainResponse() { 794 void Verify_BasicFindMainResponse() {
791 EXPECT_EQ(kManifestUrl, policy_.requested_manifest_url_); 795 EXPECT_EQ(kManifestUrl, policy_.requested_manifest_url_);
792 if (policy_.can_load_return_value_) { 796 if (policy_.can_load_return_value_) {
793 EXPECT_EQ(kEntryUrl, delegate()->found_url_); 797 EXPECT_EQ(kEntryUrl, delegate()->found_url_);
794 EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_); 798 EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_);
795 EXPECT_FALSE(delegate()->found_blocked_by_policy_); 799 EXPECT_FALSE(delegate()->found_blocked_by_policy_);
796 EXPECT_EQ(1, delegate()->found_cache_id_); 800 EXPECT_EQ(1, delegate()->found_cache_id_);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 EXPECT_TRUE(database()->InsertOnlineWhiteListRecords(whitelists)); 841 EXPECT_TRUE(database()->InsertOnlineWhiteListRecords(whitelists));
838 if (drop_from_working_set) { 842 if (drop_from_working_set) {
839 EXPECT_TRUE(cache_->HasOneRef()); 843 EXPECT_TRUE(cache_->HasOneRef());
840 cache_ = NULL; 844 cache_ = NULL;
841 EXPECT_TRUE(group_->HasOneRef()); 845 EXPECT_TRUE(group_->HasOneRef());
842 group_ = NULL; 846 group_ = NULL;
843 } 847 }
844 848
845 // Conduct the test. The test url is in both fallback namespace urls, 849 // Conduct the test. The test url is in both fallback namespace urls,
846 // but should match the longer of the two. 850 // but should match the longer of the two.
847 storage()->FindResponseForMainRequest(kFallbackTestUrl, delegate()); 851 storage()->FindResponseForMainRequest(kFallbackTestUrl, GURL(), delegate());
848 EXPECT_NE(kFallbackTestUrl, delegate()->found_url_); 852 EXPECT_NE(kFallbackTestUrl, delegate()->found_url_);
849 } 853 }
850 854
851 void Verify_BasicFindMainFallbackResponse() { 855 void Verify_BasicFindMainFallbackResponse() {
852 EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_); 856 EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_);
853 EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_); 857 EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_);
854 EXPECT_FALSE(delegate()->found_blocked_by_policy_); 858 EXPECT_FALSE(delegate()->found_blocked_by_policy_);
855 EXPECT_EQ(1, delegate()->found_cache_id_); 859 EXPECT_EQ(1, delegate()->found_cache_id_);
856 EXPECT_FALSE(delegate()->found_entry_.has_response_id()); 860 EXPECT_FALSE(delegate()->found_entry_.has_response_id());
857 EXPECT_EQ(2, delegate()->found_fallback_entry_.response_id()); 861 EXPECT_EQ(2, delegate()->found_fallback_entry_.response_id());
858 EXPECT_EQ(kEntryUrl2, delegate()->found_fallback_url_); 862 EXPECT_EQ(kEntryUrl2, delegate()->found_fallback_url_);
859 EXPECT_TRUE(delegate()->found_fallback_entry_.IsFallback()); 863 EXPECT_TRUE(delegate()->found_fallback_entry_.IsFallback());
860 TestFinished(); 864 TestFinished();
861 } 865 }
862 866
863 // FindMainResponseWithMultipleHits ------------------------------- 867 // FindMainResponseWithMultipleHits -------------------------------
864 868
865 void FindMainResponseWithMultipleHits() { 869 void FindMainResponseWithMultipleHits() {
866 PushNextTask(NewRunnableMethod(this, 870 PushNextTask(NewRunnableMethod(this,
867 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits)); 871 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits));
868 872
869 // Setup some preconditions. Create 2 complete caches with an entry 873 // Setup some preconditions, create a few caches with an identical set
870 // for the same url. 874 // of entries and fallback namespaces. Only the last one remains in
875 // the working set to similulate appearing as "in use".
jennb 2011/04/12 00:07:56 simulate
michaeln 2011/04/14 23:41:23 Done.
876 MakeMultipleHitCacheAndGroup(kManifestUrl, 1);
877 MakeMultipleHitCacheAndGroup(kManifestUrl2, 2);
878 MakeMultipleHitCacheAndGroup(kManifestUrl3, 3);
jennb 2011/04/12 00:07:56 What logic ensures that only this one remains in t
michaeln 2011/04/14 23:41:23 The helper methods stores a ref to the cache_ and
871 879
872 // The first cache, in the database but not in the working set. 880 // Conduct the test, we should find the response from the last cache
873 MakeCacheAndGroup(kManifestUrl, 1, 1, true);
874 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, 1));
875 AppCacheDatabase::EntryRecord entry_record;
876 entry_record.cache_id = 1;
877 entry_record.url = kEntryUrl;
878 entry_record.flags = AppCacheEntry::EXPLICIT;
879 entry_record.response_id = 1;
880 EXPECT_TRUE(database()->InsertEntry(&entry_record));
881 cache_ = NULL;
882 group_ = NULL;
883
884 // The second cache, in the database and working set.
885 MakeCacheAndGroup(kManifestUrl2, 2, 2, true);
886 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, 2));
887 entry_record.cache_id = 2;
888 entry_record.url = kEntryUrl;
889 entry_record.flags = AppCacheEntry::EXPLICIT;
890 entry_record.response_id = 2;
891 EXPECT_TRUE(database()->InsertEntry(&entry_record));
892
893 // Conduct the test, we should find the response from the second cache
894 // since it's "in use". 881 // since it's "in use".
895 storage()->FindResponseForMainRequest(kEntryUrl, delegate()); 882 storage()->FindResponseForMainRequest(kEntryUrl, GURL(), delegate());
896 EXPECT_NE(kEntryUrl, delegate()->found_url_); 883 EXPECT_NE(kEntryUrl, delegate()->found_url_);
897 } 884 }
898 885
886 void MakeMultipleHitCacheAndGroup(const GURL& manifest_url, int id) {
887 MakeCacheAndGroup(manifest_url, id, id, true);
888 AppCacheDatabase::EntryRecord entry_record;
889
890 // Add and entry for kEntryUrl
jennb 2011/04/12 00:07:56 Add an entry
michaeln 2011/04/14 23:41:23 Done.
891 entry_record.cache_id = id;
892 entry_record.url = kEntryUrl;
893 entry_record.flags = AppCacheEntry::EXPLICIT;
894 entry_record.response_id = id;
895 EXPECT_TRUE(database()->InsertEntry(&entry_record));
896 cache_->AddEntry(
897 entry_record.url,
898 AppCacheEntry(entry_record.flags, entry_record.response_id));
899
900 // Add and entry for the manifestUrl
jennb 2011/04/12 00:07:56 Add an entry
michaeln 2011/04/14 23:41:23 Done.
901 entry_record.cache_id = id;
902 entry_record.url = manifest_url;
903 entry_record.flags = AppCacheEntry::MANIFEST;
904 entry_record.response_id = id + kManifestEntryIdOffset;
905 EXPECT_TRUE(database()->InsertEntry(&entry_record));
906 cache_->AddEntry(
907 entry_record.url,
908 AppCacheEntry(entry_record.flags, entry_record.response_id));
909
910 // Add a fallback entry and namespace
911 entry_record.cache_id = id;
912 entry_record.url = kEntryUrl2;
913 entry_record.flags = AppCacheEntry::FALLBACK;
914 entry_record.response_id = id + kFallbackEntryIdOffset;
915 EXPECT_TRUE(database()->InsertEntry(&entry_record));
916 cache_->AddEntry(
917 entry_record.url,
918 AppCacheEntry(entry_record.flags, entry_record.response_id));
919 AppCacheDatabase::FallbackNameSpaceRecord fallback_namespace_record;
920 fallback_namespace_record.cache_id = id;
921 fallback_namespace_record.fallback_entry_url = entry_record.url;
922 fallback_namespace_record.namespace_url = kFallbackNamespace;
923 fallback_namespace_record.origin = manifest_url.GetOrigin();
924 EXPECT_TRUE(
925 database()->InsertFallbackNameSpace(&fallback_namespace_record));
926 cache_->fallback_namespaces_.push_back(
927 FallbackNamespace(kFallbackNamespace, kEntryUrl2));
928 }
929
899 void Verify_FindMainResponseWithMultipleHits() { 930 void Verify_FindMainResponseWithMultipleHits() {
900 EXPECT_EQ(kEntryUrl, delegate()->found_url_); 931 EXPECT_EQ(kEntryUrl, delegate()->found_url_);
932 EXPECT_EQ(kManifestUrl3, delegate()->found_manifest_url_);
933 EXPECT_FALSE(delegate()->found_blocked_by_policy_);
934 EXPECT_EQ(3, delegate()->found_cache_id_);
935 EXPECT_EQ(3, delegate()->found_entry_.response_id());
936 EXPECT_TRUE(delegate()->found_entry_.IsExplicit());
937 EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id());
938
939 // Conduct the another test perferring kManifestUrl
jennb 2011/04/12 00:07:56 Conduct another test
michaeln 2011/04/14 23:41:23 Done.
940 delegate_.reset(new MockStorageDelegate(this));
941 PushNextTask(NewRunnableMethod(this,
942 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits2));
943 storage()->FindResponseForMainRequest(kEntryUrl, kManifestUrl, delegate());
944 EXPECT_NE(kEntryUrl, delegate()->found_url_);
945 }
946
947 void Verify_FindMainResponseWithMultipleHits2() {
948 EXPECT_EQ(kEntryUrl, delegate()->found_url_);
949 EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_);
950 EXPECT_FALSE(delegate()->found_blocked_by_policy_);
951 EXPECT_EQ(1, delegate()->found_cache_id_);
952 EXPECT_EQ(1, delegate()->found_entry_.response_id());
953 EXPECT_TRUE(delegate()->found_entry_.IsExplicit());
954 EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id());
955
956 // Conduct the another test perferring kManifestUrl2
957 delegate_.reset(new MockStorageDelegate(this));
958 PushNextTask(NewRunnableMethod(this,
959 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits3));
960 storage()->FindResponseForMainRequest(kEntryUrl, kManifestUrl2, delegate());
961 EXPECT_NE(kEntryUrl, delegate()->found_url_);
962 }
963
964 void Verify_FindMainResponseWithMultipleHits3() {
965 EXPECT_EQ(kEntryUrl, delegate()->found_url_);
901 EXPECT_EQ(kManifestUrl2, delegate()->found_manifest_url_); 966 EXPECT_EQ(kManifestUrl2, delegate()->found_manifest_url_);
902 EXPECT_FALSE(delegate()->found_blocked_by_policy_); 967 EXPECT_FALSE(delegate()->found_blocked_by_policy_);
903 EXPECT_EQ(2, delegate()->found_cache_id_); 968 EXPECT_EQ(2, delegate()->found_cache_id_);
904 EXPECT_EQ(2, delegate()->found_entry_.response_id()); 969 EXPECT_EQ(2, delegate()->found_entry_.response_id());
905 EXPECT_TRUE(delegate()->found_entry_.IsExplicit()); 970 EXPECT_TRUE(delegate()->found_entry_.IsExplicit());
906 EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id()); 971 EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id());
972
973 // Conduct another test with no preferred manifest that hits the fallback.
974 delegate_.reset(new MockStorageDelegate(this));
975 PushNextTask(NewRunnableMethod(this,
976 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits4));
977 storage()->FindResponseForMainRequest(
978 kFallbackTestUrl, GURL(), delegate());
979 EXPECT_NE(kFallbackTestUrl, delegate()->found_url_);
980 }
981
982 void Verify_FindMainResponseWithMultipleHits4() {
983 EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_);
984 EXPECT_EQ(kManifestUrl3, delegate()->found_manifest_url_);
985 EXPECT_FALSE(delegate()->found_blocked_by_policy_);
986 EXPECT_EQ(3, delegate()->found_cache_id_);
987 EXPECT_FALSE(delegate()->found_entry_.has_response_id());
988 EXPECT_EQ(3 + kFallbackEntryIdOffset,
989 delegate()->found_fallback_entry_.response_id());
990 EXPECT_TRUE(delegate()->found_fallback_entry_.IsFallback());
991 EXPECT_EQ(kEntryUrl2, delegate()->found_fallback_url_);
992
993 // Conduct another test preferring kManifestUrl2 that hits the fallback.
994 delegate_.reset(new MockStorageDelegate(this));
995 PushNextTask(NewRunnableMethod(this,
996 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits5));
997 storage()->FindResponseForMainRequest(
998 kFallbackTestUrl, kManifestUrl2, delegate());
999 EXPECT_NE(kFallbackTestUrl, delegate()->found_url_);
1000 }
1001
1002 void Verify_FindMainResponseWithMultipleHits5() {
jennb 2011/04/12 00:07:56 Do we have test coverage for these cases: 1) mult
michaeln 2011/04/14 23:41:23 No, i've just got one entry per bucket. Do you thi
1003 EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_);
1004 EXPECT_EQ(kManifestUrl2, delegate()->found_manifest_url_);
1005 EXPECT_FALSE(delegate()->found_blocked_by_policy_);
1006 EXPECT_EQ(2, delegate()->found_cache_id_);
1007 EXPECT_FALSE(delegate()->found_entry_.has_response_id());
1008 EXPECT_EQ(2 + kFallbackEntryIdOffset,
1009 delegate()->found_fallback_entry_.response_id());
1010 EXPECT_TRUE(delegate()->found_fallback_entry_.IsFallback());
1011 EXPECT_EQ(kEntryUrl2, delegate()->found_fallback_url_);
1012
907 TestFinished(); 1013 TestFinished();
908 } 1014 }
909 1015
910 // FindMainResponseExclusions ------------------------------- 1016 // FindMainResponseExclusions -------------------------------
911 1017
912 void FindMainResponseExclusionsInDatabase() { 1018 void FindMainResponseExclusionsInDatabase() {
913 FindMainResponseExclusions(true); 1019 FindMainResponseExclusions(true);
914 } 1020 }
915 1021
916 void FindMainResponseExclusionsInWorkingSet() { 1022 void FindMainResponseExclusionsInWorkingSet() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 EXPECT_TRUE(database()->InsertOnlineWhiteList(&whitelist_record)); 1060 EXPECT_TRUE(database()->InsertOnlineWhiteList(&whitelist_record));
955 if (drop_from_working_set) { 1061 if (drop_from_working_set) {
956 cache_ = NULL; 1062 cache_ = NULL;
957 group_ = NULL; 1063 group_ = NULL;
958 } 1064 }
959 1065
960 // We should not find anything for the foreign entry. 1066 // We should not find anything for the foreign entry.
961 PushNextTask(NewRunnableMethod( 1067 PushNextTask(NewRunnableMethod(
962 this, &AppCacheStorageImplTest::Verify_ExclusionNotFound, 1068 this, &AppCacheStorageImplTest::Verify_ExclusionNotFound,
963 kEntryUrl, 1)); 1069 kEntryUrl, 1));
964 storage()->FindResponseForMainRequest(kEntryUrl, delegate()); 1070 storage()->FindResponseForMainRequest(kEntryUrl, GURL(), delegate());
965 } 1071 }
966 1072
967 void Verify_ExclusionNotFound(GURL expected_url, int phase) { 1073 void Verify_ExclusionNotFound(GURL expected_url, int phase) {
968 EXPECT_EQ(expected_url, delegate()->found_url_); 1074 EXPECT_EQ(expected_url, delegate()->found_url_);
969 EXPECT_TRUE(delegate()->found_manifest_url_.is_empty()); 1075 EXPECT_TRUE(delegate()->found_manifest_url_.is_empty());
970 EXPECT_FALSE(delegate()->found_blocked_by_policy_); 1076 EXPECT_FALSE(delegate()->found_blocked_by_policy_);
971 EXPECT_EQ(kNoCacheId, delegate()->found_cache_id_); 1077 EXPECT_EQ(kNoCacheId, delegate()->found_cache_id_);
972 EXPECT_EQ(kNoResponseId, delegate()->found_entry_.response_id()); 1078 EXPECT_EQ(kNoResponseId, delegate()->found_entry_.response_id());
973 EXPECT_EQ(kNoResponseId, delegate()->found_fallback_entry_.response_id()); 1079 EXPECT_EQ(kNoResponseId, delegate()->found_fallback_entry_.response_id());
974 EXPECT_TRUE(delegate()->found_fallback_url_.is_empty()); 1080 EXPECT_TRUE(delegate()->found_fallback_url_.is_empty());
975 EXPECT_EQ(0, delegate()->found_entry_.types()); 1081 EXPECT_EQ(0, delegate()->found_entry_.types());
976 EXPECT_EQ(0, delegate()->found_fallback_entry_.types()); 1082 EXPECT_EQ(0, delegate()->found_fallback_entry_.types());
977 1083
978 if (phase == 1) { 1084 if (phase == 1) {
979 // We should not find anything for the online namespace. 1085 // We should not find anything for the online namespace.
980 PushNextTask(NewRunnableMethod(this, 1086 PushNextTask(NewRunnableMethod(this,
981 &AppCacheStorageImplTest::Verify_ExclusionNotFound, 1087 &AppCacheStorageImplTest::Verify_ExclusionNotFound,
982 kOnlineNamespace, 2)); 1088 kOnlineNamespace, 2));
983 storage()->FindResponseForMainRequest(kOnlineNamespace, delegate()); 1089 storage()->FindResponseForMainRequest(
1090 kOnlineNamespace, GURL(), delegate());
984 return; 1091 return;
985 } 1092 }
986 if (phase == 2) { 1093 if (phase == 2) {
987 // We should not find anything for the online namespace nested within 1094 // We should not find anything for the online namespace nested within
988 // the fallback namespace. 1095 // the fallback namespace.
989 PushNextTask(NewRunnableMethod(this, 1096 PushNextTask(NewRunnableMethod(this,
990 &AppCacheStorageImplTest::Verify_ExclusionNotFound, 1097 &AppCacheStorageImplTest::Verify_ExclusionNotFound,
991 kOnlineNamespaceWithinFallback, 3)); 1098 kOnlineNamespaceWithinFallback, 3));
992 storage()->FindResponseForMainRequest( 1099 storage()->FindResponseForMainRequest(
993 kOnlineNamespaceWithinFallback, delegate()); 1100 kOnlineNamespaceWithinFallback, GURL(), delegate());
994 return; 1101 return;
995 } 1102 }
996 1103
997 TestFinished(); 1104 TestFinished();
998 } 1105 }
999 1106
1000 // Test case helpers -------------------------------------------------- 1107 // Test case helpers --------------------------------------------------
1001 1108
1002 AppCacheService* service() { 1109 AppCacheService* service() {
1003 return service_.get(); 1110 return service_.get();
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 &AppCacheStorageImplTest::FindMainResponseExclusionsInWorkingSet); 1251 &AppCacheStorageImplTest::FindMainResponseExclusionsInWorkingSet);
1145 } 1252 }
1146 1253
1147 // That's all folks! 1254 // That's all folks!
1148 1255
1149 } // namespace appcache 1256 } // namespace appcache
1150 1257
1151 // AppCacheStorageImplTest is expected to always live longer than the 1258 // AppCacheStorageImplTest is expected to always live longer than the
1152 // runnable methods. This lets us call NewRunnableMethod on its instances. 1259 // runnable methods. This lets us call NewRunnableMethod on its instances.
1153 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheStorageImplTest); 1260 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheStorageImplTest);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698