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

Side by Side Diff: content/browser/appcache/mock_appcache_storage_unittest.cc

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h>
6 #include <stdint.h>
7
5 #include "base/run_loop.h" 8 #include "base/run_loop.h"
6 #include "content/browser/appcache/appcache.h" 9 #include "content/browser/appcache/appcache.h"
7 #include "content/browser/appcache/appcache_group.h" 10 #include "content/browser/appcache/appcache_group.h"
8 #include "content/browser/appcache/appcache_response.h" 11 #include "content/browser/appcache/appcache_response.h"
9 #include "content/browser/appcache/appcache_storage.h" 12 #include "content/browser/appcache/appcache_storage.h"
10 #include "content/browser/appcache/mock_appcache_service.h" 13 #include "content/browser/appcache/mock_appcache_service.h"
11 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
12 15
13 namespace content { 16 namespace content {
14 17
15 class MockAppCacheStorageTest : public testing::Test { 18 class MockAppCacheStorageTest : public testing::Test {
16 public: 19 public:
17 class MockStorageDelegate : public AppCacheStorage::Delegate { 20 class MockStorageDelegate : public AppCacheStorage::Delegate {
18 public: 21 public:
19 explicit MockStorageDelegate() 22 explicit MockStorageDelegate()
20 : loaded_cache_id_(0), stored_group_success_(false), 23 : loaded_cache_id_(0), stored_group_success_(false),
21 obsoleted_success_(false), found_cache_id_(kAppCacheNoCacheId) { 24 obsoleted_success_(false), found_cache_id_(kAppCacheNoCacheId) {
22 } 25 }
23 26
24 void OnCacheLoaded(AppCache* cache, int64 cache_id) override { 27 void OnCacheLoaded(AppCache* cache, int64_t cache_id) override {
25 loaded_cache_ = cache; 28 loaded_cache_ = cache;
26 loaded_cache_id_ = cache_id; 29 loaded_cache_id_ = cache_id;
27 } 30 }
28 31
29 void OnGroupLoaded(AppCacheGroup* group, 32 void OnGroupLoaded(AppCacheGroup* group,
30 const GURL& manifest_url) override { 33 const GURL& manifest_url) override {
31 loaded_group_ = group; 34 loaded_group_ = group;
32 loaded_manifest_url_ = manifest_url; 35 loaded_manifest_url_ = manifest_url;
33 } 36 }
34 37
35 void OnGroupAndNewestCacheStored(AppCacheGroup* group, 38 void OnGroupAndNewestCacheStored(AppCacheGroup* group,
36 AppCache* newest_cache, 39 AppCache* newest_cache,
37 bool success, 40 bool success,
38 bool would_exceed_quota) override { 41 bool would_exceed_quota) override {
39 stored_group_ = group; 42 stored_group_ = group;
40 stored_group_success_ = success; 43 stored_group_success_ = success;
41 } 44 }
42 45
43 void OnGroupMadeObsolete(AppCacheGroup* group, 46 void OnGroupMadeObsolete(AppCacheGroup* group,
44 bool success, 47 bool success,
45 int response_code) override { 48 int response_code) override {
46 obsoleted_group_ = group; 49 obsoleted_group_ = group;
47 obsoleted_success_ = success; 50 obsoleted_success_ = success;
48 } 51 }
49 52
50 void OnMainResponseFound(const GURL& url, 53 void OnMainResponseFound(const GURL& url,
51 const AppCacheEntry& entry, 54 const AppCacheEntry& entry,
52 const GURL& fallback_url, 55 const GURL& fallback_url,
53 const AppCacheEntry& fallback_entry, 56 const AppCacheEntry& fallback_entry,
54 int64 cache_id, 57 int64_t cache_id,
55 int64 group_id, 58 int64_t group_id,
56 const GURL& manifest_url) override { 59 const GURL& manifest_url) override {
57 found_url_ = url; 60 found_url_ = url;
58 found_entry_ = entry; 61 found_entry_ = entry;
59 found_fallback_url_ = fallback_url; 62 found_fallback_url_ = fallback_url;
60 found_fallback_entry_ = fallback_entry; 63 found_fallback_entry_ = fallback_entry;
61 found_cache_id_ = cache_id; 64 found_cache_id_ = cache_id;
62 found_manifest_url_ = manifest_url; 65 found_manifest_url_ = manifest_url;
63 } 66 }
64 67
65 scoped_refptr<AppCache> loaded_cache_; 68 scoped_refptr<AppCache> loaded_cache_;
66 int64 loaded_cache_id_; 69 int64_t loaded_cache_id_;
67 scoped_refptr<AppCacheGroup> loaded_group_; 70 scoped_refptr<AppCacheGroup> loaded_group_;
68 GURL loaded_manifest_url_; 71 GURL loaded_manifest_url_;
69 scoped_refptr<AppCacheGroup> stored_group_; 72 scoped_refptr<AppCacheGroup> stored_group_;
70 bool stored_group_success_; 73 bool stored_group_success_;
71 scoped_refptr<AppCacheGroup> obsoleted_group_; 74 scoped_refptr<AppCacheGroup> obsoleted_group_;
72 bool obsoleted_success_; 75 bool obsoleted_success_;
73 GURL found_url_; 76 GURL found_url_;
74 AppCacheEntry found_entry_; 77 AppCacheEntry found_entry_;
75 GURL found_fallback_url_; 78 GURL found_fallback_url_;
76 AppCacheEntry found_fallback_entry_; 79 AppCacheEntry found_fallback_entry_;
77 int64 found_cache_id_; 80 int64_t found_cache_id_;
78 GURL found_manifest_url_; 81 GURL found_manifest_url_;
79 }; 82 };
80 83
81 private: 84 private:
82 base::MessageLoop message_loop_; 85 base::MessageLoop message_loop_;
83 }; 86 };
84 87
85 TEST_F(MockAppCacheStorageTest, LoadCache_Miss) { 88 TEST_F(MockAppCacheStorageTest, LoadCache_Miss) {
86 // Attempt to load a cache that doesn't exist. Should 89 // Attempt to load a cache that doesn't exist. Should
87 // complete asyncly. 90 // complete asyncly.
88 MockAppCacheService service; 91 MockAppCacheService service;
89 MockStorageDelegate delegate; 92 MockStorageDelegate delegate;
90 service.storage()->LoadCache(111, &delegate); 93 service.storage()->LoadCache(111, &delegate);
91 EXPECT_NE(111, delegate.loaded_cache_id_); 94 EXPECT_NE(111, delegate.loaded_cache_id_);
92 base::RunLoop().RunUntilIdle(); // Do async task execution. 95 base::RunLoop().RunUntilIdle(); // Do async task execution.
93 EXPECT_EQ(111, delegate.loaded_cache_id_); 96 EXPECT_EQ(111, delegate.loaded_cache_id_);
94 EXPECT_FALSE(delegate.loaded_cache_.get()); 97 EXPECT_FALSE(delegate.loaded_cache_.get());
95 } 98 }
96 99
97 TEST_F(MockAppCacheStorageTest, LoadCache_NearHit) { 100 TEST_F(MockAppCacheStorageTest, LoadCache_NearHit) {
98 // Attempt to load a cache that is currently in use 101 // Attempt to load a cache that is currently in use
99 // and does not require loading from disk. This 102 // and does not require loading from disk. This
100 // load should complete syncly. 103 // load should complete syncly.
101 MockAppCacheService service; 104 MockAppCacheService service;
102 105
103 // Setup some preconditions. Make an 'unstored' cache for 106 // Setup some preconditions. Make an 'unstored' cache for
104 // us to load. The ctor should put it in the working set. 107 // us to load. The ctor should put it in the working set.
105 int64 cache_id = service.storage()->NewCacheId(); 108 int64_t cache_id = service.storage()->NewCacheId();
106 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id)); 109 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
107 110
108 // Conduct the test. 111 // Conduct the test.
109 MockStorageDelegate delegate; 112 MockStorageDelegate delegate;
110 service.storage()->LoadCache(cache_id, &delegate); 113 service.storage()->LoadCache(cache_id, &delegate);
111 EXPECT_EQ(cache_id, delegate.loaded_cache_id_); 114 EXPECT_EQ(cache_id, delegate.loaded_cache_id_);
112 EXPECT_EQ(cache.get(), delegate.loaded_cache_.get()); 115 EXPECT_EQ(cache.get(), delegate.loaded_cache_.get());
113 } 116 }
114 117
115 TEST_F(MockAppCacheStorageTest, CreateGroup) { 118 TEST_F(MockAppCacheStorageTest, CreateGroup) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // load should complete asyncly. 166 // load should complete asyncly.
164 MockAppCacheService service; 167 MockAppCacheService service;
165 MockAppCacheStorage* storage = 168 MockAppCacheStorage* storage =
166 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 169 reinterpret_cast<MockAppCacheStorage*>(service.storage());
167 170
168 // Setup some preconditions. Create a group and newest cache that 171 // Setup some preconditions. Create a group and newest cache that
169 // appears to be "stored" and "not currently in use". 172 // appears to be "stored" and "not currently in use".
170 GURL manifest_url("http://blah/"); 173 GURL manifest_url("http://blah/");
171 scoped_refptr<AppCacheGroup> group( 174 scoped_refptr<AppCacheGroup> group(
172 new AppCacheGroup(service.storage(), manifest_url, 111)); 175 new AppCacheGroup(service.storage(), manifest_url, 111));
173 int64 cache_id = storage->NewCacheId(); 176 int64_t cache_id = storage->NewCacheId();
174 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id)); 177 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
175 cache->set_complete(true); 178 cache->set_complete(true);
176 group->AddCache(cache.get()); 179 group->AddCache(cache.get());
177 storage->AddStoredGroup(group.get()); 180 storage->AddStoredGroup(group.get());
178 storage->AddStoredCache(cache.get()); 181 storage->AddStoredCache(cache.get());
179 182
180 // Drop the references from above so the only refs to these 183 // Drop the references from above so the only refs to these
181 // objects are from within the storage class. This is to make 184 // objects are from within the storage class. This is to make
182 // these objects appear as "not currently in use". 185 // these objects appear as "not currently in use".
183 AppCache* cache_ptr = cache.get(); 186 AppCache* cache_ptr = cache.get();
(...skipping 30 matching lines...) Expand all
214 // Store a group and its newest cache. Should complete asyncly. 217 // Store a group and its newest cache. Should complete asyncly.
215 MockAppCacheService service; 218 MockAppCacheService service;
216 MockAppCacheStorage* storage = 219 MockAppCacheStorage* storage =
217 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 220 reinterpret_cast<MockAppCacheStorage*>(service.storage());
218 221
219 // Setup some preconditions. Create a group and newest cache that 222 // Setup some preconditions. Create a group and newest cache that
220 // appears to be "unstored". 223 // appears to be "unstored".
221 GURL manifest_url("http://blah/"); 224 GURL manifest_url("http://blah/");
222 scoped_refptr<AppCacheGroup> group( 225 scoped_refptr<AppCacheGroup> group(
223 new AppCacheGroup(service.storage(), manifest_url, 111)); 226 new AppCacheGroup(service.storage(), manifest_url, 111));
224 int64 cache_id = storage->NewCacheId(); 227 int64_t cache_id = storage->NewCacheId();
225 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id)); 228 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
226 // Hold a ref to the cache simulate the UpdateJob holding that ref, 229 // Hold a ref to the cache simulate the UpdateJob holding that ref,
227 // and hold a ref to the group to simulate the CacheHost holding that ref. 230 // and hold a ref to the group to simulate the CacheHost holding that ref.
228 231
229 // Conduct the store test. 232 // Conduct the store test.
230 MockStorageDelegate delegate; 233 MockStorageDelegate delegate;
231 EXPECT_TRUE(storage->stored_caches_.empty()); 234 EXPECT_TRUE(storage->stored_caches_.empty());
232 EXPECT_TRUE(storage->stored_groups_.empty()); 235 EXPECT_TRUE(storage->stored_groups_.empty());
233 storage->StoreGroupAndNewestCache(group.get(), cache.get(), &delegate); 236 storage->StoreGroupAndNewestCache(group.get(), cache.get(), &delegate);
234 EXPECT_FALSE(delegate.stored_group_success_); 237 EXPECT_FALSE(delegate.stored_group_success_);
(...skipping 11 matching lines...) Expand all
246 // Store a group and its newest cache. Should complete asyncly. 249 // Store a group and its newest cache. Should complete asyncly.
247 MockAppCacheService service; 250 MockAppCacheService service;
248 MockAppCacheStorage* storage = 251 MockAppCacheStorage* storage =
249 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 252 reinterpret_cast<MockAppCacheStorage*>(service.storage());
250 253
251 // Setup some preconditions. Create a group and old complete cache 254 // Setup some preconditions. Create a group and old complete cache
252 // that appear to be "stored", and a newest unstored complete cache. 255 // that appear to be "stored", and a newest unstored complete cache.
253 GURL manifest_url("http://blah/"); 256 GURL manifest_url("http://blah/");
254 scoped_refptr<AppCacheGroup> group( 257 scoped_refptr<AppCacheGroup> group(
255 new AppCacheGroup(service.storage(), manifest_url, 111)); 258 new AppCacheGroup(service.storage(), manifest_url, 111));
256 int64 old_cache_id = storage->NewCacheId(); 259 int64_t old_cache_id = storage->NewCacheId();
257 scoped_refptr<AppCache> old_cache( 260 scoped_refptr<AppCache> old_cache(
258 new AppCache(service.storage(), old_cache_id)); 261 new AppCache(service.storage(), old_cache_id));
259 old_cache->set_complete(true); 262 old_cache->set_complete(true);
260 group->AddCache(old_cache.get()); 263 group->AddCache(old_cache.get());
261 storage->AddStoredGroup(group.get()); 264 storage->AddStoredGroup(group.get());
262 storage->AddStoredCache(old_cache.get()); 265 storage->AddStoredCache(old_cache.get());
263 int64 new_cache_id = storage->NewCacheId(); 266 int64_t new_cache_id = storage->NewCacheId();
264 scoped_refptr<AppCache> new_cache( 267 scoped_refptr<AppCache> new_cache(
265 new AppCache(service.storage(), new_cache_id)); 268 new AppCache(service.storage(), new_cache_id));
266 // Hold our refs to simulate the UpdateJob holding these refs. 269 // Hold our refs to simulate the UpdateJob holding these refs.
267 270
268 // Conduct the test. 271 // Conduct the test.
269 MockStorageDelegate delegate; 272 MockStorageDelegate delegate;
270 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); 273 EXPECT_EQ(size_t(1), storage->stored_caches_.size());
271 EXPECT_EQ(size_t(1), storage->stored_groups_.size()); 274 EXPECT_EQ(size_t(1), storage->stored_groups_.size());
272 EXPECT_TRUE(storage->IsCacheStored(old_cache.get())); 275 EXPECT_TRUE(storage->IsCacheStored(old_cache.get()));
273 EXPECT_FALSE(storage->IsCacheStored(new_cache.get())); 276 EXPECT_FALSE(storage->IsCacheStored(new_cache.get()));
(...skipping 17 matching lines...) Expand all
291 // Store a group with updates to its existing newest complete cache. 294 // Store a group with updates to its existing newest complete cache.
292 MockAppCacheService service; 295 MockAppCacheService service;
293 MockAppCacheStorage* storage = 296 MockAppCacheStorage* storage =
294 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 297 reinterpret_cast<MockAppCacheStorage*>(service.storage());
295 298
296 // Setup some preconditions. Create a group and a complete cache that 299 // Setup some preconditions. Create a group and a complete cache that
297 // appear to be "stored". 300 // appear to be "stored".
298 GURL manifest_url("http://blah"); 301 GURL manifest_url("http://blah");
299 scoped_refptr<AppCacheGroup> group( 302 scoped_refptr<AppCacheGroup> group(
300 new AppCacheGroup(service.storage(), manifest_url, 111)); 303 new AppCacheGroup(service.storage(), manifest_url, 111));
301 int64 cache_id = storage->NewCacheId(); 304 int64_t cache_id = storage->NewCacheId();
302 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id)); 305 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
303 cache->set_complete(true); 306 cache->set_complete(true);
304 group->AddCache(cache.get()); 307 group->AddCache(cache.get());
305 storage->AddStoredGroup(group.get()); 308 storage->AddStoredGroup(group.get());
306 storage->AddStoredCache(cache.get()); 309 storage->AddStoredCache(cache.get());
307 // Hold our refs to simulate the UpdateJob holding these refs. 310 // Hold our refs to simulate the UpdateJob holding these refs.
308 311
309 // Change the group's newest cache. 312 // Change the group's newest cache.
310 EXPECT_EQ(cache.get(), group->newest_complete_cache()); 313 EXPECT_EQ(cache.get(), group->newest_complete_cache());
311 GURL entry_url("http://blah/blah"); 314 GURL entry_url("http://blah/blah");
(...skipping 21 matching lines...) Expand all
333 // Make a group obsolete, should complete asyncly. 336 // Make a group obsolete, should complete asyncly.
334 MockAppCacheService service; 337 MockAppCacheService service;
335 MockAppCacheStorage* storage = 338 MockAppCacheStorage* storage =
336 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 339 reinterpret_cast<MockAppCacheStorage*>(service.storage());
337 340
338 // Setup some preconditions. Create a group and newest cache that 341 // Setup some preconditions. Create a group and newest cache that
339 // appears to be "stored" and "currently in use". 342 // appears to be "stored" and "currently in use".
340 GURL manifest_url("http://blah/"); 343 GURL manifest_url("http://blah/");
341 scoped_refptr<AppCacheGroup> group( 344 scoped_refptr<AppCacheGroup> group(
342 new AppCacheGroup(service.storage(), manifest_url, 111)); 345 new AppCacheGroup(service.storage(), manifest_url, 111));
343 int64 cache_id = storage->NewCacheId(); 346 int64_t cache_id = storage->NewCacheId();
344 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id)); 347 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
345 cache->set_complete(true); 348 cache->set_complete(true);
346 group->AddCache(cache.get()); 349 group->AddCache(cache.get());
347 storage->AddStoredGroup(group.get()); 350 storage->AddStoredGroup(group.get());
348 storage->AddStoredCache(cache.get()); 351 storage->AddStoredCache(cache.get());
349 // Hold our refs to simulate the UpdateJob holding these refs. 352 // Hold our refs to simulate the UpdateJob holding these refs.
350 353
351 // Conduct the test. 354 // Conduct the test.
352 MockStorageDelegate delegate; 355 MockStorageDelegate delegate;
353 EXPECT_FALSE(group->is_obsolete()); 356 EXPECT_FALSE(group->is_obsolete());
(...skipping 21 matching lines...) Expand all
375 } 378 }
376 379
377 TEST_F(MockAppCacheStorageTest, MarkEntryAsForeign) { 380 TEST_F(MockAppCacheStorageTest, MarkEntryAsForeign) {
378 // Should complete syncly. 381 // Should complete syncly.
379 MockAppCacheService service; 382 MockAppCacheService service;
380 MockAppCacheStorage* storage = 383 MockAppCacheStorage* storage =
381 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 384 reinterpret_cast<MockAppCacheStorage*>(service.storage());
382 385
383 // Setup some preconditions. Create a cache with an entry. 386 // Setup some preconditions. Create a cache with an entry.
384 GURL entry_url("http://blah/entry"); 387 GURL entry_url("http://blah/entry");
385 int64 cache_id = storage->NewCacheId(); 388 int64_t cache_id = storage->NewCacheId();
386 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id)); 389 scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
387 cache->AddEntry(entry_url, AppCacheEntry(AppCacheEntry::EXPLICIT)); 390 cache->AddEntry(entry_url, AppCacheEntry(AppCacheEntry::EXPLICIT));
388 391
389 // Conduct the test. 392 // Conduct the test.
390 MockStorageDelegate delegate; 393 MockStorageDelegate delegate;
391 EXPECT_FALSE(cache->GetEntry(entry_url)->IsForeign()); 394 EXPECT_FALSE(cache->GetEntry(entry_url)->IsForeign());
392 storage->MarkEntryAsForeign(entry_url, cache_id); 395 storage->MarkEntryAsForeign(entry_url, cache_id);
393 EXPECT_TRUE(cache->GetEntry(entry_url)->IsForeign()); 396 EXPECT_TRUE(cache->GetEntry(entry_url)->IsForeign());
394 EXPECT_TRUE(cache->GetEntry(entry_url)->IsExplicit()); 397 EXPECT_TRUE(cache->GetEntry(entry_url)->IsExplicit());
395 } 398 }
(...skipping 22 matching lines...) Expand all
418 EXPECT_EQ(0, delegate.found_fallback_entry_.types()); 421 EXPECT_EQ(0, delegate.found_fallback_entry_.types());
419 } 422 }
420 423
421 TEST_F(MockAppCacheStorageTest, BasicFindMainResponse) { 424 TEST_F(MockAppCacheStorageTest, BasicFindMainResponse) {
422 // Should complete asyncly. 425 // Should complete asyncly.
423 MockAppCacheService service; 426 MockAppCacheService service;
424 MockAppCacheStorage* storage = 427 MockAppCacheStorage* storage =
425 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 428 reinterpret_cast<MockAppCacheStorage*>(service.storage());
426 429
427 // Setup some preconditions. Create a complete cache with an entry. 430 // Setup some preconditions. Create a complete cache with an entry.
428 const int64 kCacheId = storage->NewCacheId(); 431 const int64_t kCacheId = storage->NewCacheId();
429 const GURL kEntryUrl("http://blah/entry"); 432 const GURL kEntryUrl("http://blah/entry");
430 const GURL kManifestUrl("http://blah/manifest"); 433 const GURL kManifestUrl("http://blah/manifest");
431 const int64 kResponseId = 1; 434 const int64_t kResponseId = 1;
432 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId)); 435 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId));
433 cache->AddEntry( 436 cache->AddEntry(
434 kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kResponseId)); 437 kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kResponseId));
435 cache->set_complete(true); 438 cache->set_complete(true);
436 scoped_refptr<AppCacheGroup> group( 439 scoped_refptr<AppCacheGroup> group(
437 new AppCacheGroup(service.storage(), kManifestUrl, 111)); 440 new AppCacheGroup(service.storage(), kManifestUrl, 111));
438 group->AddCache(cache.get()); 441 group->AddCache(cache.get());
439 storage->AddStoredGroup(group.get()); 442 storage->AddStoredGroup(group.get());
440 storage->AddStoredCache(cache.get()); 443 storage->AddStoredCache(cache.get());
441 444
(...skipping 12 matching lines...) Expand all
454 } 457 }
455 458
456 TEST_F(MockAppCacheStorageTest, BasicFindMainFallbackResponse) { 459 TEST_F(MockAppCacheStorageTest, BasicFindMainFallbackResponse) {
457 // Should complete asyncly. 460 // Should complete asyncly.
458 MockAppCacheService service; 461 MockAppCacheService service;
459 MockAppCacheStorage* storage = 462 MockAppCacheStorage* storage =
460 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 463 reinterpret_cast<MockAppCacheStorage*>(service.storage());
461 464
462 // Setup some preconditions. Create a complete cache with a 465 // Setup some preconditions. Create a complete cache with a
463 // fallback namespace and entry. 466 // fallback namespace and entry.
464 const int64 kCacheId = storage->NewCacheId(); 467 const int64_t kCacheId = storage->NewCacheId();
465 const GURL kFallbackEntryUrl1("http://blah/fallback_entry1"); 468 const GURL kFallbackEntryUrl1("http://blah/fallback_entry1");
466 const GURL kFallbackNamespaceUrl1("http://blah/fallback_namespace/"); 469 const GURL kFallbackNamespaceUrl1("http://blah/fallback_namespace/");
467 const GURL kFallbackEntryUrl2("http://blah/fallback_entry2"); 470 const GURL kFallbackEntryUrl2("http://blah/fallback_entry2");
468 const GURL kFallbackNamespaceUrl2("http://blah/fallback_namespace/longer"); 471 const GURL kFallbackNamespaceUrl2("http://blah/fallback_namespace/longer");
469 const GURL kManifestUrl("http://blah/manifest"); 472 const GURL kManifestUrl("http://blah/manifest");
470 const int64 kResponseId1 = 1; 473 const int64_t kResponseId1 = 1;
471 const int64 kResponseId2 = 2; 474 const int64_t kResponseId2 = 2;
472 475
473 AppCacheManifest manifest; 476 AppCacheManifest manifest;
474 manifest.fallback_namespaces.push_back( 477 manifest.fallback_namespaces.push_back(
475 AppCacheNamespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl1, 478 AppCacheNamespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl1,
476 kFallbackEntryUrl1, false)); 479 kFallbackEntryUrl1, false));
477 manifest.fallback_namespaces.push_back( 480 manifest.fallback_namespaces.push_back(
478 AppCacheNamespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl2, 481 AppCacheNamespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl2,
479 kFallbackEntryUrl2, false)); 482 kFallbackEntryUrl2, false));
480 483
481 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId)); 484 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 TEST_F(MockAppCacheStorageTest, FindMainResponseWithMultipleCandidates) { 517 TEST_F(MockAppCacheStorageTest, FindMainResponseWithMultipleCandidates) {
515 // Should complete asyncly. 518 // Should complete asyncly.
516 MockAppCacheService service; 519 MockAppCacheService service;
517 MockAppCacheStorage* storage = 520 MockAppCacheStorage* storage =
518 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 521 reinterpret_cast<MockAppCacheStorage*>(service.storage());
519 522
520 // Setup some preconditions. Create 2 complete caches with an entry 523 // Setup some preconditions. Create 2 complete caches with an entry
521 // for the same url. 524 // for the same url.
522 525
523 const GURL kEntryUrl("http://blah/entry"); 526 const GURL kEntryUrl("http://blah/entry");
524 const int64 kCacheId1 = storage->NewCacheId(); 527 const int64_t kCacheId1 = storage->NewCacheId();
525 const int64 kCacheId2 = storage->NewCacheId(); 528 const int64_t kCacheId2 = storage->NewCacheId();
526 const GURL kManifestUrl1("http://blah/manifest1"); 529 const GURL kManifestUrl1("http://blah/manifest1");
527 const GURL kManifestUrl2("http://blah/manifest2"); 530 const GURL kManifestUrl2("http://blah/manifest2");
528 const int64 kResponseId1 = 1; 531 const int64_t kResponseId1 = 1;
529 const int64 kResponseId2 = 2; 532 const int64_t kResponseId2 = 2;
530 533
531 // The first cache. 534 // The first cache.
532 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId1)); 535 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId1));
533 cache->AddEntry( 536 cache->AddEntry(
534 kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kResponseId1)); 537 kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kResponseId1));
535 cache->set_complete(true); 538 cache->set_complete(true);
536 scoped_refptr<AppCacheGroup> group( 539 scoped_refptr<AppCacheGroup> group(
537 new AppCacheGroup(service.storage(), kManifestUrl1, 111)); 540 new AppCacheGroup(service.storage(), kManifestUrl1, 111));
538 group->AddCache(cache.get()); 541 group->AddCache(cache.get());
539 storage->AddStoredGroup(group.get()); 542 storage->AddStoredGroup(group.get());
(...skipping 29 matching lines...) Expand all
569 572
570 TEST_F(MockAppCacheStorageTest, FindMainResponseExclusions) { 573 TEST_F(MockAppCacheStorageTest, FindMainResponseExclusions) {
571 // Should complete asyncly. 574 // Should complete asyncly.
572 MockAppCacheService service; 575 MockAppCacheService service;
573 MockAppCacheStorage* storage = 576 MockAppCacheStorage* storage =
574 reinterpret_cast<MockAppCacheStorage*>(service.storage()); 577 reinterpret_cast<MockAppCacheStorage*>(service.storage());
575 578
576 // Setup some preconditions. Create a complete cache with a 579 // Setup some preconditions. Create a complete cache with a
577 // foreign entry and an online namespace. 580 // foreign entry and an online namespace.
578 581
579 const int64 kCacheId = storage->NewCacheId(); 582 const int64_t kCacheId = storage->NewCacheId();
580 const GURL kEntryUrl("http://blah/entry"); 583 const GURL kEntryUrl("http://blah/entry");
581 const GURL kManifestUrl("http://blah/manifest"); 584 const GURL kManifestUrl("http://blah/manifest");
582 const GURL kOnlineNamespaceUrl("http://blah/online_namespace"); 585 const GURL kOnlineNamespaceUrl("http://blah/online_namespace");
583 const int64 kResponseId = 1; 586 const int64_t kResponseId = 1;
584 587
585 AppCacheManifest manifest; 588 AppCacheManifest manifest;
586 manifest.online_whitelist_namespaces.push_back( 589 manifest.online_whitelist_namespaces.push_back(
587 AppCacheNamespace(APPCACHE_NETWORK_NAMESPACE, kOnlineNamespaceUrl, 590 AppCacheNamespace(APPCACHE_NETWORK_NAMESPACE, kOnlineNamespaceUrl,
588 GURL(), false)); 591 GURL(), false));
589 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId)); 592 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId));
590 cache->InitializeWithManifest(&manifest); 593 cache->InitializeWithManifest(&manifest);
591 cache->AddEntry( 594 cache->AddEntry(
592 kEntryUrl, 595 kEntryUrl,
593 AppCacheEntry(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, 596 AppCacheEntry(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 EXPECT_EQ(kAppCacheNoCacheId, delegate.found_cache_id_); 629 EXPECT_EQ(kAppCacheNoCacheId, delegate.found_cache_id_);
627 EXPECT_EQ(kAppCacheNoResponseId, delegate.found_entry_.response_id()); 630 EXPECT_EQ(kAppCacheNoResponseId, delegate.found_entry_.response_id());
628 EXPECT_EQ(kAppCacheNoResponseId, 631 EXPECT_EQ(kAppCacheNoResponseId,
629 delegate.found_fallback_entry_.response_id()); 632 delegate.found_fallback_entry_.response_id());
630 EXPECT_TRUE(delegate.found_fallback_url_.is_empty()); 633 EXPECT_TRUE(delegate.found_fallback_url_.is_empty());
631 EXPECT_EQ(0, delegate.found_entry_.types()); 634 EXPECT_EQ(0, delegate.found_entry_.types());
632 EXPECT_EQ(0, delegate.found_fallback_entry_.types()); 635 EXPECT_EQ(0, delegate.found_fallback_entry_.types());
633 } 636 }
634 637
635 } // namespace content 638 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/mock_appcache_storage.cc ('k') | content/browser/background_sync/background_sync_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698