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

Side by Side Diff: webkit/appcache/appcache_update_job_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) 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
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/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 }; 184 };
185 185
186 class MockHttpServerJobFactory 186 class MockHttpServerJobFactory
187 : public net::URLRequestJobFactory::ProtocolHandler { 187 : public net::URLRequestJobFactory::ProtocolHandler {
188 public: 188 public:
189 virtual net::URLRequestJob* MaybeCreateJob(net::URLRequest* request) const { 189 virtual net::URLRequestJob* MaybeCreateJob(net::URLRequest* request) const {
190 return MockHttpServer::JobFactory(request); 190 return MockHttpServer::JobFactory(request);
191 } 191 }
192 }; 192 };
193 193
194 inline bool operator==(const Namespace& lhs, const Namespace& rhs) {
195 return lhs.type == rhs.type &&
196 lhs.namespace_url == rhs.namespace_url &&
197 lhs.target_url == rhs.target_url;
198 }
199
194 } // namespace 200 } // namespace
195 201
196 class MockFrontend : public AppCacheFrontend { 202 class MockFrontend : public AppCacheFrontend {
197 public: 203 public:
198 MockFrontend() 204 MockFrontend()
199 : ignore_progress_events_(false), verify_progress_events_(false), 205 : ignore_progress_events_(false), verify_progress_events_(false),
200 last_progress_total_(-1), last_progress_complete_(-1), 206 last_progress_total_(-1), last_progress_complete_(-1),
201 start_update_trigger_(CHECKING_EVENT), update_(NULL) { 207 start_update_trigger_(CHECKING_EVENT), update_(NULL) {
202 } 208 }
203 209
(...skipping 2832 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 EXPECT_EQ(AppCacheEntry::FALLBACK, entry->types()); 3042 EXPECT_EQ(AppCacheEntry::FALLBACK, entry->types());
3037 3043
3038 for (AppCache::EntryMap::iterator i = expect_extra_entries_.begin(); 3044 for (AppCache::EntryMap::iterator i = expect_extra_entries_.begin();
3039 i != expect_extra_entries_.end(); ++i) { 3045 i != expect_extra_entries_.end(); ++i) {
3040 entry = cache->GetEntry(i->first); 3046 entry = cache->GetEntry(i->first);
3041 ASSERT_TRUE(entry); 3047 ASSERT_TRUE(entry);
3042 EXPECT_EQ(i->second.types(), entry->types()); 3048 EXPECT_EQ(i->second.types(), entry->types());
3043 } 3049 }
3044 3050
3045 expected = 1; 3051 expected = 1;
3046 EXPECT_EQ(expected, cache->fallback_namespaces_.size()); 3052 ASSERT_EQ(expected, cache->fallback_namespaces_.size());
3047 EXPECT_TRUE(cache->fallback_namespaces_.end() != 3053 EXPECT_TRUE(cache->fallback_namespaces_[0] ==
3048 std::find(cache->fallback_namespaces_.begin(), 3054 Namespace(
3049 cache->fallback_namespaces_.end(), 3055 FALLBACK_NAMESPACE,
3050 FallbackNamespace( 3056 MockHttpServer::GetMockUrl("files/fallback1"),
3051 MockHttpServer::GetMockUrl("files/fallback1"), 3057 MockHttpServer::GetMockUrl("files/fallback1a")));
3052 MockHttpServer::GetMockUrl("files/fallback1a"))));
3053 3058
3054 EXPECT_TRUE(cache->online_whitelist_namespaces_.empty()); 3059 EXPECT_TRUE(cache->online_whitelist_namespaces_.empty());
3055 EXPECT_TRUE(cache->online_whitelist_all_); 3060 EXPECT_TRUE(cache->online_whitelist_all_);
3056 3061
3057 EXPECT_TRUE(cache->update_time_ > base::Time()); 3062 EXPECT_TRUE(cache->update_time_ > base::Time());
3058 } 3063 }
3059 3064
3060 void VerifyManifestMergedTypes(AppCache* cache) { 3065 void VerifyManifestMergedTypes(AppCache* cache) {
3061 size_t expected = 2; 3066 size_t expected = 2;
3062 EXPECT_EQ(expected, cache->entries().size()); 3067 EXPECT_EQ(expected, cache->entries().size());
3063 AppCacheEntry* entry = cache->GetEntry( 3068 AppCacheEntry* entry = cache->GetEntry(
3064 MockHttpServer::GetMockUrl("files/manifest-merged-types")); 3069 MockHttpServer::GetMockUrl("files/manifest-merged-types"));
3065 ASSERT_TRUE(entry); 3070 ASSERT_TRUE(entry);
3066 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::MANIFEST, 3071 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::MANIFEST,
3067 entry->types()); 3072 entry->types());
3068 entry = cache->GetEntry(MockHttpServer::GetMockUrl("files/explicit1")); 3073 entry = cache->GetEntry(MockHttpServer::GetMockUrl("files/explicit1"));
3069 ASSERT_TRUE(entry); 3074 ASSERT_TRUE(entry);
3070 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FALLBACK | 3075 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FALLBACK |
3071 AppCacheEntry::MASTER, entry->types()); 3076 AppCacheEntry::MASTER, entry->types());
3072 3077
3073 expected = 1; 3078 expected = 1;
3074 EXPECT_EQ(expected, cache->fallback_namespaces_.size()); 3079 ASSERT_EQ(expected, cache->fallback_namespaces_.size());
3075 EXPECT_TRUE(cache->fallback_namespaces_.end() != 3080 EXPECT_TRUE(cache->fallback_namespaces_[0] ==
3076 std::find(cache->fallback_namespaces_.begin(), 3081 Namespace(
3077 cache->fallback_namespaces_.end(), 3082 FALLBACK_NAMESPACE,
3078 FallbackNamespace( 3083 MockHttpServer::GetMockUrl("files/fallback1"),
3079 MockHttpServer::GetMockUrl("files/fallback1"), 3084 MockHttpServer::GetMockUrl("files/explicit1")));
3080 MockHttpServer::GetMockUrl("files/explicit1"))));
3081 3085
3082 EXPECT_EQ(expected, cache->online_whitelist_namespaces_.size()); 3086 EXPECT_EQ(expected, cache->online_whitelist_namespaces_.size());
3083 EXPECT_TRUE(cache->online_whitelist_namespaces_.end() != 3087 EXPECT_TRUE(cache->online_whitelist_namespaces_.end() !=
3084 std::find(cache->online_whitelist_namespaces_.begin(), 3088 std::find(cache->online_whitelist_namespaces_.begin(),
3085 cache->online_whitelist_namespaces_.end(), 3089 cache->online_whitelist_namespaces_.end(),
3086 MockHttpServer::GetMockUrl("files/online1"))); 3090 MockHttpServer::GetMockUrl("files/online1")));
3087 EXPECT_FALSE(cache->online_whitelist_all_); 3091 EXPECT_FALSE(cache->online_whitelist_all_);
3088 3092
3089 EXPECT_TRUE(cache->update_time_ > base::Time()); 3093 EXPECT_TRUE(cache->update_time_ > base::Time());
3090 } 3094 }
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
3459 3463
3460 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { 3464 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) {
3461 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); 3465 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest);
3462 } 3466 }
3463 3467
3464 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { 3468 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) {
3465 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); 3469 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest);
3466 } 3470 }
3467 3471
3468 } // namespace appcache 3472 } // namespace appcache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698