OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "webkit/appcache/appcache.h" | 7 #include "webkit/appcache/appcache.h" |
8 #include "webkit/appcache/appcache_group.h" | 8 #include "webkit/appcache/appcache_group.h" |
9 #include "webkit/appcache/appcache_response.h" | 9 #include "webkit/appcache/appcache_response.h" |
10 #include "webkit/appcache/appcache_storage.h" | 10 #include "webkit/appcache/appcache_storage.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 TEST_F(MockAppCacheStorageTest, LoadCache_NearHit) { | 86 TEST_F(MockAppCacheStorageTest, LoadCache_NearHit) { |
87 // Attempt to load a cache that is currently in use | 87 // Attempt to load a cache that is currently in use |
88 // and does not require loading from disk. This | 88 // and does not require loading from disk. This |
89 // load should complete syncly. | 89 // load should complete syncly. |
90 MockAppCacheService service; | 90 MockAppCacheService service; |
91 | 91 |
92 // Setup some preconditions. Make an 'unstored' cache for | 92 // Setup some preconditions. Make an 'unstored' cache for |
93 // us to load. The ctor should put it in the working set. | 93 // us to load. The ctor should put it in the working set. |
94 int64 cache_id = service.storage()->NewCacheId(); | 94 int64 cache_id = service.storage()->NewCacheId(); |
95 scoped_refptr<AppCache> cache = new AppCache(&service, cache_id); | 95 scoped_refptr<AppCache> cache(new AppCache(&service, cache_id)); |
96 | 96 |
97 // Conduct the test. | 97 // Conduct the test. |
98 MockStorageDelegate delegate; | 98 MockStorageDelegate delegate; |
99 service.storage()->LoadCache(cache_id, &delegate); | 99 service.storage()->LoadCache(cache_id, &delegate); |
100 EXPECT_EQ(cache_id, delegate.loaded_cache_id_); | 100 EXPECT_EQ(cache_id, delegate.loaded_cache_id_); |
101 EXPECT_EQ(cache.get(), delegate.loaded_cache_.get()); | 101 EXPECT_EQ(cache.get(), delegate.loaded_cache_.get()); |
102 } | 102 } |
103 | 103 |
104 TEST_F(MockAppCacheStorageTest, CreateGroup) { | 104 TEST_F(MockAppCacheStorageTest, CreateGroup) { |
105 // Attempt to load/create a group that doesn't exist. | 105 // Attempt to load/create a group that doesn't exist. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // Attempt to load a cache that is not currently in use | 150 // Attempt to load a cache that is not currently in use |
151 // and does require loading from disk. This | 151 // and does require loading from disk. This |
152 // load should complete asyncly. | 152 // load should complete asyncly. |
153 MockAppCacheService service; | 153 MockAppCacheService service; |
154 MockAppCacheStorage* storage = | 154 MockAppCacheStorage* storage = |
155 reinterpret_cast<MockAppCacheStorage*>(service.storage()); | 155 reinterpret_cast<MockAppCacheStorage*>(service.storage()); |
156 | 156 |
157 // Setup some preconditions. Create a group and newest cache that | 157 // Setup some preconditions. Create a group and newest cache that |
158 // appears to be "stored" and "not currently in use". | 158 // appears to be "stored" and "not currently in use". |
159 GURL manifest_url("http://blah/"); | 159 GURL manifest_url("http://blah/"); |
160 scoped_refptr<AppCacheGroup> group = | 160 scoped_refptr<AppCacheGroup> group( |
161 new AppCacheGroup(&service, manifest_url, 111); | 161 new AppCacheGroup(&service, manifest_url, 111)); |
162 int64 cache_id = storage->NewCacheId(); | 162 int64 cache_id = storage->NewCacheId(); |
163 scoped_refptr<AppCache> cache = new AppCache(&service, cache_id); | 163 scoped_refptr<AppCache> cache(new AppCache(&service, cache_id)); |
164 cache->set_complete(true); | 164 cache->set_complete(true); |
165 group->AddCache(cache); | 165 group->AddCache(cache); |
166 storage->AddStoredGroup(group); | 166 storage->AddStoredGroup(group); |
167 storage->AddStoredCache(cache); | 167 storage->AddStoredCache(cache); |
168 | 168 |
169 // Drop the references from above so the only refs to these | 169 // Drop the references from above so the only refs to these |
170 // objects are from within the storage class. This is to make | 170 // objects are from within the storage class. This is to make |
171 // these objects appear as "not currently in use". | 171 // these objects appear as "not currently in use". |
172 AppCache* cache_ptr = cache.get(); | 172 AppCache* cache_ptr = cache.get(); |
173 AppCacheGroup* group_ptr = group.get(); | 173 AppCacheGroup* group_ptr = group.get(); |
(...skipping 27 matching lines...) Expand all Loading... |
201 | 201 |
202 TEST_F(MockAppCacheStorageTest, StoreNewGroup) { | 202 TEST_F(MockAppCacheStorageTest, StoreNewGroup) { |
203 // Store a group and its newest cache. Should complete asyncly. | 203 // Store a group and its newest cache. Should complete asyncly. |
204 MockAppCacheService service; | 204 MockAppCacheService service; |
205 MockAppCacheStorage* storage = | 205 MockAppCacheStorage* storage = |
206 reinterpret_cast<MockAppCacheStorage*>(service.storage()); | 206 reinterpret_cast<MockAppCacheStorage*>(service.storage()); |
207 | 207 |
208 // Setup some preconditions. Create a group and newest cache that | 208 // Setup some preconditions. Create a group and newest cache that |
209 // appears to be "unstored". | 209 // appears to be "unstored". |
210 GURL manifest_url("http://blah/"); | 210 GURL manifest_url("http://blah/"); |
211 scoped_refptr<AppCacheGroup> group = | 211 scoped_refptr<AppCacheGroup> group( |
212 new AppCacheGroup(&service, manifest_url, 111); | 212 new AppCacheGroup(&service, manifest_url, 111)); |
213 int64 cache_id = storage->NewCacheId(); | 213 int64 cache_id = storage->NewCacheId(); |
214 scoped_refptr<AppCache> cache = new AppCache(&service, cache_id); | 214 scoped_refptr<AppCache> cache(new AppCache(&service, cache_id)); |
215 // Hold a ref to the cache simulate the UpdateJob holding that ref, | 215 // Hold a ref to the cache simulate the UpdateJob holding that ref, |
216 // and hold a ref to the group to simulate the CacheHost holding that ref. | 216 // and hold a ref to the group to simulate the CacheHost holding that ref. |
217 | 217 |
218 // Conduct the store test. | 218 // Conduct the store test. |
219 MockStorageDelegate delegate; | 219 MockStorageDelegate delegate; |
220 EXPECT_TRUE(storage->stored_caches_.empty()); | 220 EXPECT_TRUE(storage->stored_caches_.empty()); |
221 EXPECT_TRUE(storage->stored_groups_.empty()); | 221 EXPECT_TRUE(storage->stored_groups_.empty()); |
222 storage->StoreGroupAndNewestCache(group, cache, &delegate); | 222 storage->StoreGroupAndNewestCache(group, cache, &delegate); |
223 EXPECT_FALSE(delegate.stored_group_success_); | 223 EXPECT_FALSE(delegate.stored_group_success_); |
224 EXPECT_TRUE(storage->stored_caches_.empty()); | 224 EXPECT_TRUE(storage->stored_caches_.empty()); |
225 EXPECT_TRUE(storage->stored_groups_.empty()); | 225 EXPECT_TRUE(storage->stored_groups_.empty()); |
226 MessageLoop::current()->RunAllPending(); // Do async task execution. | 226 MessageLoop::current()->RunAllPending(); // Do async task execution. |
227 EXPECT_TRUE(delegate.stored_group_success_); | 227 EXPECT_TRUE(delegate.stored_group_success_); |
228 EXPECT_FALSE(storage->stored_caches_.empty()); | 228 EXPECT_FALSE(storage->stored_caches_.empty()); |
229 EXPECT_FALSE(storage->stored_groups_.empty()); | 229 EXPECT_FALSE(storage->stored_groups_.empty()); |
230 EXPECT_EQ(cache, group->newest_complete_cache()); | 230 EXPECT_EQ(cache, group->newest_complete_cache()); |
231 EXPECT_TRUE(cache->is_complete()); | 231 EXPECT_TRUE(cache->is_complete()); |
232 } | 232 } |
233 | 233 |
234 TEST_F(MockAppCacheStorageTest, StoreExistingGroup) { | 234 TEST_F(MockAppCacheStorageTest, StoreExistingGroup) { |
235 // Store a group and its newest cache. Should complete asyncly. | 235 // Store a group and its newest cache. Should complete asyncly. |
236 MockAppCacheService service; | 236 MockAppCacheService service; |
237 MockAppCacheStorage* storage = | 237 MockAppCacheStorage* storage = |
238 reinterpret_cast<MockAppCacheStorage*>(service.storage()); | 238 reinterpret_cast<MockAppCacheStorage*>(service.storage()); |
239 | 239 |
240 // Setup some preconditions. Create a group and old complete cache | 240 // Setup some preconditions. Create a group and old complete cache |
241 // that appear to be "stored", and a newest unstored complete cache. | 241 // that appear to be "stored", and a newest unstored complete cache. |
242 GURL manifest_url("http://blah/"); | 242 GURL manifest_url("http://blah/"); |
243 scoped_refptr<AppCacheGroup> group = | 243 scoped_refptr<AppCacheGroup> group( |
244 new AppCacheGroup(&service, manifest_url, 111); | 244 new AppCacheGroup(&service, manifest_url, 111)); |
245 int64 old_cache_id = storage->NewCacheId(); | 245 int64 old_cache_id = storage->NewCacheId(); |
246 scoped_refptr<AppCache> old_cache = new AppCache(&service, old_cache_id); | 246 scoped_refptr<AppCache> old_cache(new AppCache(&service, old_cache_id)); |
247 old_cache->set_complete(true); | 247 old_cache->set_complete(true); |
248 group->AddCache(old_cache); | 248 group->AddCache(old_cache); |
249 storage->AddStoredGroup(group); | 249 storage->AddStoredGroup(group); |
250 storage->AddStoredCache(old_cache); | 250 storage->AddStoredCache(old_cache); |
251 int64 new_cache_id = storage->NewCacheId(); | 251 int64 new_cache_id = storage->NewCacheId(); |
252 scoped_refptr<AppCache> new_cache = new AppCache(&service, new_cache_id); | 252 scoped_refptr<AppCache> new_cache(new AppCache(&service, new_cache_id)); |
253 // Hold our refs to simulate the UpdateJob holding these refs. | 253 // Hold our refs to simulate the UpdateJob holding these refs. |
254 | 254 |
255 // Conduct the test. | 255 // Conduct the test. |
256 MockStorageDelegate delegate; | 256 MockStorageDelegate delegate; |
257 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); | 257 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); |
258 EXPECT_EQ(size_t(1), storage->stored_groups_.size()); | 258 EXPECT_EQ(size_t(1), storage->stored_groups_.size()); |
259 EXPECT_TRUE(storage->IsCacheStored(old_cache)); | 259 EXPECT_TRUE(storage->IsCacheStored(old_cache)); |
260 EXPECT_FALSE(storage->IsCacheStored(new_cache)); | 260 EXPECT_FALSE(storage->IsCacheStored(new_cache)); |
261 storage->StoreGroupAndNewestCache(group, new_cache, &delegate); | 261 storage->StoreGroupAndNewestCache(group, new_cache, &delegate); |
262 EXPECT_FALSE(delegate.stored_group_success_); | 262 EXPECT_FALSE(delegate.stored_group_success_); |
(...skipping 13 matching lines...) Expand all Loading... |
276 | 276 |
277 TEST_F(MockAppCacheStorageTest, StoreExistingGroupExistingCache) { | 277 TEST_F(MockAppCacheStorageTest, StoreExistingGroupExistingCache) { |
278 // Store a group with updates to its existing newest complete cache. | 278 // Store a group with updates to its existing newest complete cache. |
279 MockAppCacheService service; | 279 MockAppCacheService service; |
280 MockAppCacheStorage* storage = | 280 MockAppCacheStorage* storage = |
281 reinterpret_cast<MockAppCacheStorage*>(service.storage()); | 281 reinterpret_cast<MockAppCacheStorage*>(service.storage()); |
282 | 282 |
283 // Setup some preconditions. Create a group and a complete cache that | 283 // Setup some preconditions. Create a group and a complete cache that |
284 // appear to be "stored". | 284 // appear to be "stored". |
285 GURL manifest_url("http://blah"); | 285 GURL manifest_url("http://blah"); |
286 scoped_refptr<AppCacheGroup> group = | 286 scoped_refptr<AppCacheGroup> group( |
287 new AppCacheGroup(&service, manifest_url, 111); | 287 new AppCacheGroup(&service, manifest_url, 111)); |
288 int64 cache_id = storage->NewCacheId(); | 288 int64 cache_id = storage->NewCacheId(); |
289 scoped_refptr<AppCache> cache = new AppCache(&service, cache_id); | 289 scoped_refptr<AppCache> cache(new AppCache(&service, cache_id)); |
290 cache->set_complete(true); | 290 cache->set_complete(true); |
291 group->AddCache(cache); | 291 group->AddCache(cache); |
292 storage->AddStoredGroup(group); | 292 storage->AddStoredGroup(group); |
293 storage->AddStoredCache(cache); | 293 storage->AddStoredCache(cache); |
294 // Hold our refs to simulate the UpdateJob holding these refs. | 294 // Hold our refs to simulate the UpdateJob holding these refs. |
295 | 295 |
296 // Change the group's newest cache. | 296 // Change the group's newest cache. |
297 EXPECT_EQ(cache, group->newest_complete_cache()); | 297 EXPECT_EQ(cache, group->newest_complete_cache()); |
298 GURL entry_url("http://blah/blah"); | 298 GURL entry_url("http://blah/blah"); |
299 cache->AddEntry(entry_url, AppCacheEntry(AppCacheEntry::MASTER)); | 299 cache->AddEntry(entry_url, AppCacheEntry(AppCacheEntry::MASTER)); |
(...skipping 18 matching lines...) Expand all Loading... |
318 | 318 |
319 TEST_F(MockAppCacheStorageTest, MakeGroupObsolete) { | 319 TEST_F(MockAppCacheStorageTest, MakeGroupObsolete) { |
320 // Make a group obsolete, should complete asyncly. | 320 // Make a group obsolete, should complete asyncly. |
321 MockAppCacheService service; | 321 MockAppCacheService service; |
322 MockAppCacheStorage* storage = | 322 MockAppCacheStorage* storage = |
323 reinterpret_cast<MockAppCacheStorage*>(service.storage()); | 323 reinterpret_cast<MockAppCacheStorage*>(service.storage()); |
324 | 324 |
325 // Setup some preconditions. Create a group and newest cache that | 325 // Setup some preconditions. Create a group and newest cache that |
326 // appears to be "stored" and "currently in use". | 326 // appears to be "stored" and "currently in use". |
327 GURL manifest_url("http://blah/"); | 327 GURL manifest_url("http://blah/"); |
328 scoped_refptr<AppCacheGroup> group = | 328 scoped_refptr<AppCacheGroup> group( |
329 new AppCacheGroup(&service, manifest_url, 111); | 329 new AppCacheGroup(&service, manifest_url, 111)); |
330 int64 cache_id = storage->NewCacheId(); | 330 int64 cache_id = storage->NewCacheId(); |
331 scoped_refptr<AppCache> cache = new AppCache(&service, cache_id); | 331 scoped_refptr<AppCache> cache(new AppCache(&service, cache_id)); |
332 cache->set_complete(true); | 332 cache->set_complete(true); |
333 group->AddCache(cache); | 333 group->AddCache(cache); |
334 storage->AddStoredGroup(group); | 334 storage->AddStoredGroup(group); |
335 storage->AddStoredCache(cache); | 335 storage->AddStoredCache(cache); |
336 // Hold our refs to simulate the UpdateJob holding these refs. | 336 // Hold our refs to simulate the UpdateJob holding these refs. |
337 | 337 |
338 // Conduct the test. | 338 // Conduct the test. |
339 MockStorageDelegate delegate; | 339 MockStorageDelegate delegate; |
340 EXPECT_FALSE(group->is_obsolete()); | 340 EXPECT_FALSE(group->is_obsolete()); |
341 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); | 341 EXPECT_EQ(size_t(1), storage->stored_caches_.size()); |
(...skipping 21 matching lines...) Expand all Loading... |
363 | 363 |
364 TEST_F(MockAppCacheStorageTest, MarkEntryAsForeign) { | 364 TEST_F(MockAppCacheStorageTest, MarkEntryAsForeign) { |
365 // Should complete syncly. | 365 // Should complete syncly. |
366 MockAppCacheService service; | 366 MockAppCacheService service; |
367 MockAppCacheStorage* storage = | 367 MockAppCacheStorage* storage = |
368 reinterpret_cast<MockAppCacheStorage*>(service.storage()); | 368 reinterpret_cast<MockAppCacheStorage*>(service.storage()); |
369 | 369 |
370 // Setup some preconditions. Create a cache with an entry. | 370 // Setup some preconditions. Create a cache with an entry. |
371 GURL entry_url("http://blah/entry"); | 371 GURL entry_url("http://blah/entry"); |
372 int64 cache_id = storage->NewCacheId(); | 372 int64 cache_id = storage->NewCacheId(); |
373 scoped_refptr<AppCache> cache = new AppCache(&service, cache_id); | 373 scoped_refptr<AppCache> cache(new AppCache(&service, cache_id)); |
374 cache->AddEntry(entry_url, AppCacheEntry(AppCacheEntry::EXPLICIT)); | 374 cache->AddEntry(entry_url, AppCacheEntry(AppCacheEntry::EXPLICIT)); |
375 | 375 |
376 // Conduct the test. | 376 // Conduct the test. |
377 MockStorageDelegate delegate; | 377 MockStorageDelegate delegate; |
378 EXPECT_FALSE(cache->GetEntry(entry_url)->IsForeign()); | 378 EXPECT_FALSE(cache->GetEntry(entry_url)->IsForeign()); |
379 storage->MarkEntryAsForeign(entry_url, cache_id); | 379 storage->MarkEntryAsForeign(entry_url, cache_id); |
380 EXPECT_TRUE(cache->GetEntry(entry_url)->IsForeign()); | 380 EXPECT_TRUE(cache->GetEntry(entry_url)->IsForeign()); |
381 EXPECT_TRUE(cache->GetEntry(entry_url)->IsExplicit()); | 381 EXPECT_TRUE(cache->GetEntry(entry_url)->IsExplicit()); |
382 } | 382 } |
383 | 383 |
(...skipping 23 matching lines...) Expand all Loading... |
407 // Should complete asyncly. | 407 // Should complete asyncly. |
408 MockAppCacheService service; | 408 MockAppCacheService service; |
409 MockAppCacheStorage* storage = | 409 MockAppCacheStorage* storage = |
410 reinterpret_cast<MockAppCacheStorage*>(service.storage()); | 410 reinterpret_cast<MockAppCacheStorage*>(service.storage()); |
411 | 411 |
412 // Setup some preconditions. Create a complete cache with an entry. | 412 // Setup some preconditions. Create a complete cache with an entry. |
413 const int64 kCacheId = storage->NewCacheId(); | 413 const int64 kCacheId = storage->NewCacheId(); |
414 const GURL kEntryUrl("http://blah/entry"); | 414 const GURL kEntryUrl("http://blah/entry"); |
415 const GURL kManifestUrl("http://blah/manifest"); | 415 const GURL kManifestUrl("http://blah/manifest"); |
416 const int64 kResponseId = 1; | 416 const int64 kResponseId = 1; |
417 scoped_refptr<AppCache> cache = new AppCache(&service, kCacheId); | 417 scoped_refptr<AppCache> cache(new AppCache(&service, kCacheId)); |
418 cache->AddEntry( | 418 cache->AddEntry( |
419 kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kResponseId)); | 419 kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kResponseId)); |
420 cache->set_complete(true); | 420 cache->set_complete(true); |
421 scoped_refptr<AppCacheGroup> group = | 421 scoped_refptr<AppCacheGroup> group( |
422 new AppCacheGroup(&service, kManifestUrl, 111); | 422 new AppCacheGroup(&service, kManifestUrl, 111)); |
423 group->AddCache(cache); | 423 group->AddCache(cache); |
424 storage->AddStoredGroup(group); | 424 storage->AddStoredGroup(group); |
425 storage->AddStoredCache(cache); | 425 storage->AddStoredCache(cache); |
426 | 426 |
427 // Conduct the test. | 427 // Conduct the test. |
428 MockStorageDelegate delegate; | 428 MockStorageDelegate delegate; |
429 EXPECT_NE(kEntryUrl, delegate.found_url_); | 429 EXPECT_NE(kEntryUrl, delegate.found_url_); |
430 storage->FindResponseForMainRequest(kEntryUrl, &delegate); | 430 storage->FindResponseForMainRequest(kEntryUrl, &delegate); |
431 EXPECT_NE(kEntryUrl, delegate.found_url_); | 431 EXPECT_NE(kEntryUrl, delegate.found_url_); |
432 MessageLoop::current()->RunAllPending(); // Do async task execution. | 432 MessageLoop::current()->RunAllPending(); // Do async task execution. |
(...skipping 21 matching lines...) Expand all Loading... |
454 const GURL kManifestUrl("http://blah/manifest"); | 454 const GURL kManifestUrl("http://blah/manifest"); |
455 const int64 kResponseId1 = 1; | 455 const int64 kResponseId1 = 1; |
456 const int64 kResponseId2 = 2; | 456 const int64 kResponseId2 = 2; |
457 | 457 |
458 Manifest manifest; | 458 Manifest manifest; |
459 manifest.fallback_namespaces.push_back( | 459 manifest.fallback_namespaces.push_back( |
460 FallbackNamespace(kFallbackNamespaceUrl1, kFallbackEntryUrl1)); | 460 FallbackNamespace(kFallbackNamespaceUrl1, kFallbackEntryUrl1)); |
461 manifest.fallback_namespaces.push_back( | 461 manifest.fallback_namespaces.push_back( |
462 FallbackNamespace(kFallbackNamespaceUrl2, kFallbackEntryUrl2)); | 462 FallbackNamespace(kFallbackNamespaceUrl2, kFallbackEntryUrl2)); |
463 | 463 |
464 scoped_refptr<AppCache> cache = new AppCache(&service, kCacheId); | 464 scoped_refptr<AppCache> cache(new AppCache(&service, kCacheId)); |
465 cache->InitializeWithManifest(&manifest); | 465 cache->InitializeWithManifest(&manifest); |
466 cache->AddEntry( | 466 cache->AddEntry( |
467 kFallbackEntryUrl1, AppCacheEntry(AppCacheEntry::FALLBACK, kResponseId1)); | 467 kFallbackEntryUrl1, AppCacheEntry(AppCacheEntry::FALLBACK, kResponseId1)); |
468 cache->AddEntry( | 468 cache->AddEntry( |
469 kFallbackEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, kResponseId2)); | 469 kFallbackEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, kResponseId2)); |
470 cache->set_complete(true); | 470 cache->set_complete(true); |
471 | 471 |
472 scoped_refptr<AppCacheGroup> group = | 472 scoped_refptr<AppCacheGroup> group( |
473 new AppCacheGroup(&service, kManifestUrl, 111); | 473 new AppCacheGroup(&service, kManifestUrl, 111)); |
474 group->AddCache(cache); | 474 group->AddCache(cache); |
475 storage->AddStoredGroup(group); | 475 storage->AddStoredGroup(group); |
476 storage->AddStoredCache(cache); | 476 storage->AddStoredCache(cache); |
477 | 477 |
478 // The test url is in both fallback namespace urls, but should match | 478 // The test url is in both fallback namespace urls, but should match |
479 // the longer of the two. | 479 // the longer of the two. |
480 const GURL kTestUrl("http://blah/fallback_namespace/longer/test"); | 480 const GURL kTestUrl("http://blah/fallback_namespace/longer/test"); |
481 | 481 |
482 // Conduct the test. | 482 // Conduct the test. |
483 MockStorageDelegate delegate; | 483 MockStorageDelegate delegate; |
(...skipping 20 matching lines...) Expand all Loading... |
504 | 504 |
505 const GURL kEntryUrl("http://blah/entry"); | 505 const GURL kEntryUrl("http://blah/entry"); |
506 const int64 kCacheId1 = storage->NewCacheId(); | 506 const int64 kCacheId1 = storage->NewCacheId(); |
507 const int64 kCacheId2 = storage->NewCacheId(); | 507 const int64 kCacheId2 = storage->NewCacheId(); |
508 const GURL kManifestUrl1("http://blah/manifest1"); | 508 const GURL kManifestUrl1("http://blah/manifest1"); |
509 const GURL kManifestUrl2("http://blah/manifest2"); | 509 const GURL kManifestUrl2("http://blah/manifest2"); |
510 const int64 kResponseId1 = 1; | 510 const int64 kResponseId1 = 1; |
511 const int64 kResponseId2 = 2; | 511 const int64 kResponseId2 = 2; |
512 | 512 |
513 // The first cache. | 513 // The first cache. |
514 scoped_refptr<AppCache> cache = new AppCache(&service, kCacheId1); | 514 scoped_refptr<AppCache> cache(new AppCache(&service, kCacheId1)); |
515 cache->AddEntry( | 515 cache->AddEntry( |
516 kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kResponseId1)); | 516 kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kResponseId1)); |
517 cache->set_complete(true); | 517 cache->set_complete(true); |
518 scoped_refptr<AppCacheGroup> group = | 518 scoped_refptr<AppCacheGroup> group( |
519 new AppCacheGroup(&service, kManifestUrl1, 111); | 519 new AppCacheGroup(&service, kManifestUrl1, 111)); |
520 group->AddCache(cache); | 520 group->AddCache(cache); |
521 storage->AddStoredGroup(group); | 521 storage->AddStoredGroup(group); |
522 storage->AddStoredCache(cache); | 522 storage->AddStoredCache(cache); |
523 // Drop our references to cache1 so it appears as "not in use". | 523 // Drop our references to cache1 so it appears as "not in use". |
524 cache = NULL; | 524 cache = NULL; |
525 group = NULL; | 525 group = NULL; |
526 | 526 |
527 // The second cache. | 527 // The second cache. |
528 cache = new AppCache(&service, kCacheId2); | 528 cache = new AppCache(&service, kCacheId2); |
529 cache->AddEntry( | 529 cache->AddEntry( |
(...skipping 30 matching lines...) Expand all Loading... |
560 | 560 |
561 const int64 kCacheId = storage->NewCacheId(); | 561 const int64 kCacheId = storage->NewCacheId(); |
562 const GURL kEntryUrl("http://blah/entry"); | 562 const GURL kEntryUrl("http://blah/entry"); |
563 const GURL kManifestUrl("http://blah/manifest"); | 563 const GURL kManifestUrl("http://blah/manifest"); |
564 const GURL kOnlineNamespaceUrl("http://blah/online_namespace"); | 564 const GURL kOnlineNamespaceUrl("http://blah/online_namespace"); |
565 const int64 kResponseId = 1; | 565 const int64 kResponseId = 1; |
566 | 566 |
567 Manifest manifest; | 567 Manifest manifest; |
568 manifest.online_whitelist_namespaces.push_back(kOnlineNamespaceUrl); | 568 manifest.online_whitelist_namespaces.push_back(kOnlineNamespaceUrl); |
569 | 569 |
570 scoped_refptr<AppCache> cache = new AppCache(&service, kCacheId); | 570 scoped_refptr<AppCache> cache(new AppCache(&service, kCacheId)); |
571 cache->InitializeWithManifest(&manifest); | 571 cache->InitializeWithManifest(&manifest); |
572 cache->AddEntry( | 572 cache->AddEntry( |
573 kEntryUrl, | 573 kEntryUrl, |
574 AppCacheEntry(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, | 574 AppCacheEntry(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, |
575 kResponseId)); | 575 kResponseId)); |
576 cache->set_complete(true); | 576 cache->set_complete(true); |
577 scoped_refptr<AppCacheGroup> group = | 577 scoped_refptr<AppCacheGroup> group( |
578 new AppCacheGroup(&service, kManifestUrl, 111); | 578 new AppCacheGroup(&service, kManifestUrl, 111)); |
579 group->AddCache(cache); | 579 group->AddCache(cache); |
580 storage->AddStoredGroup(group); | 580 storage->AddStoredGroup(group); |
581 storage->AddStoredCache(cache); | 581 storage->AddStoredCache(cache); |
582 | 582 |
583 MockStorageDelegate delegate; | 583 MockStorageDelegate delegate; |
584 | 584 |
585 // We should not find anything for the foreign entry. | 585 // We should not find anything for the foreign entry. |
586 EXPECT_NE(kEntryUrl, delegate.found_url_); | 586 EXPECT_NE(kEntryUrl, delegate.found_url_); |
587 storage->FindResponseForMainRequest(kEntryUrl, &delegate); | 587 storage->FindResponseForMainRequest(kEntryUrl, &delegate); |
588 EXPECT_NE(kEntryUrl, delegate.found_url_); | 588 EXPECT_NE(kEntryUrl, delegate.found_url_); |
(...skipping 15 matching lines...) Expand all Loading... |
604 EXPECT_TRUE(delegate.found_manifest_url_.is_empty()); | 604 EXPECT_TRUE(delegate.found_manifest_url_.is_empty()); |
605 EXPECT_EQ(kNoCacheId, delegate.found_cache_id_); | 605 EXPECT_EQ(kNoCacheId, delegate.found_cache_id_); |
606 EXPECT_EQ(kNoResponseId, delegate.found_entry_.response_id()); | 606 EXPECT_EQ(kNoResponseId, delegate.found_entry_.response_id()); |
607 EXPECT_EQ(kNoResponseId, delegate.found_fallback_entry_.response_id()); | 607 EXPECT_EQ(kNoResponseId, delegate.found_fallback_entry_.response_id()); |
608 EXPECT_EQ(0, delegate.found_entry_.types()); | 608 EXPECT_EQ(0, delegate.found_entry_.types()); |
609 EXPECT_EQ(0, delegate.found_fallback_entry_.types()); | 609 EXPECT_EQ(0, delegate.found_fallback_entry_.types()); |
610 } | 610 } |
611 | 611 |
612 } // namespace appcache | 612 } // namespace appcache |
613 | 613 |
OLD | NEW |