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

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
jennb 2011/12/05 23:23:07 Extra blank line?
michaeln 2011/12/06 19:41:24 Done.
195 inline bool operator==(const Namespace& lhs, const Namespace& rhs) {
196 return lhs.type == rhs.type &&
197 lhs.namespace_url == rhs.namespace_url &&
198 lhs.target_url == rhs.target_url;
199 }
200
194 } // namespace 201 } // namespace
195 202
196 class MockFrontend : public AppCacheFrontend { 203 class MockFrontend : public AppCacheFrontend {
197 public: 204 public:
198 MockFrontend() 205 MockFrontend()
199 : ignore_progress_events_(false), verify_progress_events_(false), 206 : ignore_progress_events_(false), verify_progress_events_(false),
200 last_progress_total_(-1), last_progress_complete_(-1), 207 last_progress_total_(-1), last_progress_complete_(-1),
201 start_update_trigger_(CHECKING_EVENT), update_(NULL) { 208 start_update_trigger_(CHECKING_EVENT), update_(NULL) {
202 } 209 }
203 210
(...skipping 2832 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 EXPECT_EQ(AppCacheEntry::FALLBACK, entry->types()); 3043 EXPECT_EQ(AppCacheEntry::FALLBACK, entry->types());
3037 3044
3038 for (AppCache::EntryMap::iterator i = expect_extra_entries_.begin(); 3045 for (AppCache::EntryMap::iterator i = expect_extra_entries_.begin();
3039 i != expect_extra_entries_.end(); ++i) { 3046 i != expect_extra_entries_.end(); ++i) {
3040 entry = cache->GetEntry(i->first); 3047 entry = cache->GetEntry(i->first);
3041 ASSERT_TRUE(entry); 3048 ASSERT_TRUE(entry);
3042 EXPECT_EQ(i->second.types(), entry->types()); 3049 EXPECT_EQ(i->second.types(), entry->types());
3043 } 3050 }
3044 3051
3045 expected = 1; 3052 expected = 1;
3046 EXPECT_EQ(expected, cache->fallback_namespaces_.size()); 3053 ASSERT_EQ(expected, cache->fallback_namespaces_.size());
3047 EXPECT_TRUE(cache->fallback_namespaces_.end() != 3054 EXPECT_TRUE(cache->fallback_namespaces_[0] ==
jennb 2011/12/05 23:23:07 Change to EXPECT_EQ?
michaeln 2011/12/06 19:41:24 for some reason EXPECT_EQ doesn't figure out the =
3048 std::find(cache->fallback_namespaces_.begin(), 3055 Namespace(
3049 cache->fallback_namespaces_.end(), 3056 FALLBACK_NAMESPACE,
3050 FallbackNamespace( 3057 MockHttpServer::GetMockUrl("files/fallback1"),
3051 MockHttpServer::GetMockUrl("files/fallback1"), 3058 MockHttpServer::GetMockUrl("files/fallback1a")));
3052 MockHttpServer::GetMockUrl("files/fallback1a"))));
3053 3059
3054 EXPECT_TRUE(cache->online_whitelist_namespaces_.empty()); 3060 EXPECT_TRUE(cache->online_whitelist_namespaces_.empty());
3055 EXPECT_TRUE(cache->online_whitelist_all_); 3061 EXPECT_TRUE(cache->online_whitelist_all_);
3056 3062
3057 EXPECT_TRUE(cache->update_time_ > base::Time()); 3063 EXPECT_TRUE(cache->update_time_ > base::Time());
3058 } 3064 }
3059 3065
3060 void VerifyManifestMergedTypes(AppCache* cache) { 3066 void VerifyManifestMergedTypes(AppCache* cache) {
3061 size_t expected = 2; 3067 size_t expected = 2;
3062 EXPECT_EQ(expected, cache->entries().size()); 3068 EXPECT_EQ(expected, cache->entries().size());
3063 AppCacheEntry* entry = cache->GetEntry( 3069 AppCacheEntry* entry = cache->GetEntry(
3064 MockHttpServer::GetMockUrl("files/manifest-merged-types")); 3070 MockHttpServer::GetMockUrl("files/manifest-merged-types"));
3065 ASSERT_TRUE(entry); 3071 ASSERT_TRUE(entry);
3066 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::MANIFEST, 3072 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::MANIFEST,
3067 entry->types()); 3073 entry->types());
3068 entry = cache->GetEntry(MockHttpServer::GetMockUrl("files/explicit1")); 3074 entry = cache->GetEntry(MockHttpServer::GetMockUrl("files/explicit1"));
3069 ASSERT_TRUE(entry); 3075 ASSERT_TRUE(entry);
3070 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FALLBACK | 3076 EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FALLBACK |
3071 AppCacheEntry::MASTER, entry->types()); 3077 AppCacheEntry::MASTER, entry->types());
3072 3078
3073 expected = 1; 3079 expected = 1;
3074 EXPECT_EQ(expected, cache->fallback_namespaces_.size()); 3080 ASSERT_EQ(expected, cache->fallback_namespaces_.size());
3075 EXPECT_TRUE(cache->fallback_namespaces_.end() != 3081 EXPECT_TRUE(cache->fallback_namespaces_[0] ==
jennb 2011/12/05 23:23:07 Ditto.
3076 std::find(cache->fallback_namespaces_.begin(), 3082 Namespace(
3077 cache->fallback_namespaces_.end(), 3083 FALLBACK_NAMESPACE,
3078 FallbackNamespace( 3084 MockHttpServer::GetMockUrl("files/fallback1"),
3079 MockHttpServer::GetMockUrl("files/fallback1"), 3085 MockHttpServer::GetMockUrl("files/explicit1")));
3080 MockHttpServer::GetMockUrl("files/explicit1"))));
3081 3086
3082 EXPECT_EQ(expected, cache->online_whitelist_namespaces_.size()); 3087 EXPECT_EQ(expected, cache->online_whitelist_namespaces_.size());
3083 EXPECT_TRUE(cache->online_whitelist_namespaces_.end() != 3088 EXPECT_TRUE(cache->online_whitelist_namespaces_.end() !=
3084 std::find(cache->online_whitelist_namespaces_.begin(), 3089 std::find(cache->online_whitelist_namespaces_.begin(),
3085 cache->online_whitelist_namespaces_.end(), 3090 cache->online_whitelist_namespaces_.end(),
3086 MockHttpServer::GetMockUrl("files/online1"))); 3091 MockHttpServer::GetMockUrl("files/online1")));
3087 EXPECT_FALSE(cache->online_whitelist_all_); 3092 EXPECT_FALSE(cache->online_whitelist_all_);
3088 3093
3089 EXPECT_TRUE(cache->update_time_ > base::Time()); 3094 EXPECT_TRUE(cache->update_time_ > base::Time());
3090 } 3095 }
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
3459 3464
3460 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) { 3465 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) {
3461 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest); 3466 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest);
3462 } 3467 }
3463 3468
3464 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { 3469 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) {
3465 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); 3470 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest);
3466 } 3471 }
3467 3472
3468 } // namespace appcache 3473 } // namespace appcache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698