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

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

Issue 8396013: AppCache INTERCEPT namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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) 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 scoped_refptr<AppCache> cache(new AppCache(&service, 1234)); 82 scoped_refptr<AppCache> cache(new AppCache(&service, 1234));
83 EXPECT_TRUE(cache->fallback_namespaces_.empty()); 83 EXPECT_TRUE(cache->fallback_namespaces_.empty());
84 EXPECT_TRUE(cache->online_whitelist_namespaces_.empty()); 84 EXPECT_TRUE(cache->online_whitelist_namespaces_.empty());
85 EXPECT_FALSE(cache->online_whitelist_all_); 85 EXPECT_FALSE(cache->online_whitelist_all_);
86 86
87 Manifest manifest; 87 Manifest manifest;
88 manifest.explicit_urls.insert("http://one.com"); 88 manifest.explicit_urls.insert("http://one.com");
89 manifest.explicit_urls.insert("http://two.com"); 89 manifest.explicit_urls.insert("http://two.com");
90 manifest.fallback_namespaces.push_back( 90 manifest.fallback_namespaces.push_back(
91 FallbackNamespace(GURL("http://fb1.com"), GURL("http://fbone.com"))); 91 Namespace(FALLBACK_NAMESPACE, GURL("http://fb1.com"), GURL("http://fbone.c om")));
92 manifest.online_whitelist_namespaces.push_back(GURL("http://w1.com")); 92 manifest.online_whitelist_namespaces.push_back(GURL("http://w1.com"));
93 manifest.online_whitelist_namespaces.push_back(GURL("http://w2.com")); 93 manifest.online_whitelist_namespaces.push_back(GURL("http://w2.com"));
94 manifest.online_whitelist_all = true; 94 manifest.online_whitelist_all = true;
95 95
96 cache->InitializeWithManifest(&manifest); 96 cache->InitializeWithManifest(&manifest);
97 const std::vector<FallbackNamespace>& fallbacks = 97 const std::vector<Namespace>& fallbacks =
98 cache->fallback_namespaces_; 98 cache->fallback_namespaces_;
99 size_t expected = 1; 99 size_t expected = 1;
100 EXPECT_EQ(expected, fallbacks.size()); 100 EXPECT_EQ(expected, fallbacks.size());
101 EXPECT_EQ(GURL("http://fb1.com"), fallbacks[0].first); 101 EXPECT_EQ(GURL("http://fb1.com"), fallbacks[0].namespace_url);
102 EXPECT_EQ(GURL("http://fbone.com"), fallbacks[0].second); 102 EXPECT_EQ(GURL("http://fbone.com"), fallbacks[0].target_url);
103 const std::vector<GURL>& whitelist = cache->online_whitelist_namespaces_; 103 const std::vector<GURL>& whitelist = cache->online_whitelist_namespaces_;
104 expected = 2; 104 expected = 2;
105 EXPECT_EQ(expected, whitelist.size()); 105 EXPECT_EQ(expected, whitelist.size());
106 EXPECT_EQ(GURL("http://w1.com"), whitelist[0]); 106 EXPECT_EQ(GURL("http://w1.com"), whitelist[0]);
107 EXPECT_EQ(GURL("http://w2.com"), whitelist[1]); 107 EXPECT_EQ(GURL("http://w2.com"), whitelist[1]);
108 EXPECT_TRUE(cache->online_whitelist_all_); 108 EXPECT_TRUE(cache->online_whitelist_all_);
109 109
110 // Ensure collections in manifest were taken over by the cache rather than 110 // Ensure collections in manifest were taken over by the cache rather than
111 // copied. 111 // copied.
112 EXPECT_TRUE(manifest.fallback_namespaces.empty()); 112 EXPECT_TRUE(manifest.fallback_namespaces.empty());
(...skipping 23 matching lines...) Expand all
136 const int64 kFallbackResponseId2 = 2; 136 const int64 kFallbackResponseId2 = 2;
137 const int64 kManifestResponseId = 3; 137 const int64 kManifestResponseId = 3;
138 const int64 kForeignExplicitResponseId = 4; 138 const int64 kForeignExplicitResponseId = 4;
139 const int64 kExplicitInOnlineNamespaceResponseId = 5; 139 const int64 kExplicitInOnlineNamespaceResponseId = 5;
140 140
141 Manifest manifest; 141 Manifest manifest;
142 manifest.online_whitelist_namespaces.push_back(kOnlineNamespaceUrl); 142 manifest.online_whitelist_namespaces.push_back(kOnlineNamespaceUrl);
143 manifest.online_whitelist_namespaces.push_back( 143 manifest.online_whitelist_namespaces.push_back(
144 kOnlineNamespaceWithinFallback); 144 kOnlineNamespaceWithinFallback);
145 manifest.fallback_namespaces.push_back( 145 manifest.fallback_namespaces.push_back(
146 FallbackNamespace(kFallbackNamespaceUrl1, kFallbackEntryUrl1)); 146 Namespace(FALLBACK_NAMESPACE, kFallbackNamespaceUrl1, kFallbackEntryUrl1)) ;
147 manifest.fallback_namespaces.push_back( 147 manifest.fallback_namespaces.push_back(
148 FallbackNamespace(kFallbackNamespaceUrl2, kFallbackEntryUrl2)); 148 Namespace(FALLBACK_NAMESPACE, kFallbackNamespaceUrl2, kFallbackEntryUrl2)) ;
149 149
150 // Create a cache with some namespaces and entries. 150 // Create a cache with some namespaces and entries.
151 scoped_refptr<AppCache> cache(new AppCache(&service, 1234)); 151 scoped_refptr<AppCache> cache(new AppCache(&service, 1234));
152 cache->InitializeWithManifest(&manifest); 152 cache->InitializeWithManifest(&manifest);
153 cache->AddEntry( 153 cache->AddEntry(
154 kFallbackEntryUrl1, 154 kFallbackEntryUrl1,
155 AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId1)); 155 AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId1));
156 cache->AddEntry( 156 cache->AddEntry(
157 kFallbackEntryUrl2, 157 kFallbackEntryUrl2,
158 AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId2)); 158 AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId2));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 kOnlineNamespaceWithinFallback.Resolve("online_resource"), 252 kOnlineNamespaceWithinFallback.Resolve("online_resource"),
253 &entry, &fallback_entry, &fallback_namespace, &network_namespace); 253 &entry, &fallback_entry, &fallback_namespace, &network_namespace);
254 EXPECT_TRUE(found); 254 EXPECT_TRUE(found);
255 EXPECT_FALSE(entry.has_response_id()); 255 EXPECT_FALSE(entry.has_response_id());
256 EXPECT_FALSE(fallback_entry.has_response_id()); 256 EXPECT_FALSE(fallback_entry.has_response_id());
257 EXPECT_TRUE(network_namespace); 257 EXPECT_TRUE(network_namespace);
258 } 258 }
259 259
260 } // namespace appacache 260 } // namespace appacache
261 261
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698