OLD | NEW |
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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "content/browser/appcache/appcache.h" |
| 7 #include "content/browser/appcache/appcache_group.h" |
| 8 #include "content/browser/appcache/appcache_response.h" |
| 9 #include "content/browser/appcache/appcache_storage.h" |
6 #include "content/browser/appcache/mock_appcache_service.h" | 10 #include "content/browser/appcache/mock_appcache_service.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "webkit/browser/appcache/appcache.h" | |
9 #include "webkit/browser/appcache/appcache_group.h" | |
10 #include "webkit/browser/appcache/appcache_response.h" | |
11 #include "webkit/browser/appcache/appcache_storage.h" | |
12 | |
13 using appcache::AppCache; | |
14 using appcache::AppCacheEntry; | |
15 using appcache::AppCacheGroup; | |
16 using appcache::AppCacheStorage; | |
17 using appcache::APPCACHE_FALLBACK_NAMESPACE; | |
18 using appcache::APPCACHE_INTERCEPT_NAMESPACE; | |
19 using appcache::kAppCacheNoCacheId; | |
20 using appcache::kAppCacheNoResponseId; | |
21 using appcache::Manifest; | |
22 using appcache::Namespace; | |
23 using appcache::APPCACHE_NETWORK_NAMESPACE; | |
24 | 12 |
25 namespace content { | 13 namespace content { |
26 | 14 |
27 class MockAppCacheStorageTest : public testing::Test { | 15 class MockAppCacheStorageTest : public testing::Test { |
28 public: | 16 public: |
29 class MockStorageDelegate : public AppCacheStorage::Delegate { | 17 class MockStorageDelegate : public AppCacheStorage::Delegate { |
30 public: | 18 public: |
31 explicit MockStorageDelegate() | 19 explicit MockStorageDelegate() |
32 : loaded_cache_id_(0), stored_group_success_(false), | 20 : loaded_cache_id_(0), stored_group_success_(false), |
33 obsoleted_success_(false), found_cache_id_(kAppCacheNoCacheId) { | 21 obsoleted_success_(false), found_cache_id_(kAppCacheNoCacheId) { |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 const GURL kFallbackEntryUrl1("http://blah/fallback_entry1"); | 464 const GURL kFallbackEntryUrl1("http://blah/fallback_entry1"); |
477 const GURL kFallbackNamespaceUrl1("http://blah/fallback_namespace/"); | 465 const GURL kFallbackNamespaceUrl1("http://blah/fallback_namespace/"); |
478 const GURL kFallbackEntryUrl2("http://blah/fallback_entry2"); | 466 const GURL kFallbackEntryUrl2("http://blah/fallback_entry2"); |
479 const GURL kFallbackNamespaceUrl2("http://blah/fallback_namespace/longer"); | 467 const GURL kFallbackNamespaceUrl2("http://blah/fallback_namespace/longer"); |
480 const GURL kManifestUrl("http://blah/manifest"); | 468 const GURL kManifestUrl("http://blah/manifest"); |
481 const int64 kResponseId1 = 1; | 469 const int64 kResponseId1 = 1; |
482 const int64 kResponseId2 = 2; | 470 const int64 kResponseId2 = 2; |
483 | 471 |
484 Manifest manifest; | 472 Manifest manifest; |
485 manifest.fallback_namespaces.push_back( | 473 manifest.fallback_namespaces.push_back( |
486 Namespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl1, | 474 AppCacheNamespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl1, |
487 kFallbackEntryUrl1, false)); | 475 kFallbackEntryUrl1, false)); |
488 manifest.fallback_namespaces.push_back( | 476 manifest.fallback_namespaces.push_back( |
489 Namespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl2, | 477 AppCacheNamespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl2, |
490 kFallbackEntryUrl2, false)); | 478 kFallbackEntryUrl2, false)); |
491 | 479 |
492 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId)); | 480 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId)); |
493 cache->InitializeWithManifest(&manifest); | 481 cache->InitializeWithManifest(&manifest); |
494 cache->AddEntry(kFallbackEntryUrl1, | 482 cache->AddEntry(kFallbackEntryUrl1, |
495 AppCacheEntry(AppCacheEntry::FALLBACK, kResponseId1)); | 483 AppCacheEntry(AppCacheEntry::FALLBACK, kResponseId1)); |
496 cache->AddEntry(kFallbackEntryUrl2, | 484 cache->AddEntry(kFallbackEntryUrl2, |
497 AppCacheEntry(AppCacheEntry::FALLBACK, kResponseId2)); | 485 AppCacheEntry(AppCacheEntry::FALLBACK, kResponseId2)); |
498 cache->set_complete(true); | 486 cache->set_complete(true); |
499 | 487 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 // foreign entry and an online namespace. | 576 // foreign entry and an online namespace. |
589 | 577 |
590 const int64 kCacheId = storage->NewCacheId(); | 578 const int64 kCacheId = storage->NewCacheId(); |
591 const GURL kEntryUrl("http://blah/entry"); | 579 const GURL kEntryUrl("http://blah/entry"); |
592 const GURL kManifestUrl("http://blah/manifest"); | 580 const GURL kManifestUrl("http://blah/manifest"); |
593 const GURL kOnlineNamespaceUrl("http://blah/online_namespace"); | 581 const GURL kOnlineNamespaceUrl("http://blah/online_namespace"); |
594 const int64 kResponseId = 1; | 582 const int64 kResponseId = 1; |
595 | 583 |
596 Manifest manifest; | 584 Manifest manifest; |
597 manifest.online_whitelist_namespaces.push_back( | 585 manifest.online_whitelist_namespaces.push_back( |
598 Namespace(APPCACHE_NETWORK_NAMESPACE, kOnlineNamespaceUrl, | 586 AppCacheNamespace(APPCACHE_NETWORK_NAMESPACE, kOnlineNamespaceUrl, |
599 GURL(), false)); | 587 GURL(), false)); |
600 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId)); | 588 scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId)); |
601 cache->InitializeWithManifest(&manifest); | 589 cache->InitializeWithManifest(&manifest); |
602 cache->AddEntry( | 590 cache->AddEntry( |
603 kEntryUrl, | 591 kEntryUrl, |
604 AppCacheEntry(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, | 592 AppCacheEntry(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, |
605 kResponseId)); | 593 kResponseId)); |
606 cache->set_complete(true); | 594 cache->set_complete(true); |
607 scoped_refptr<AppCacheGroup> group( | 595 scoped_refptr<AppCacheGroup> group( |
608 new AppCacheGroup(service.storage(), kManifestUrl, 111)); | 596 new AppCacheGroup(service.storage(), kManifestUrl, 111)); |
(...skipping 28 matching lines...) Expand all Loading... |
637 EXPECT_EQ(kAppCacheNoCacheId, delegate.found_cache_id_); | 625 EXPECT_EQ(kAppCacheNoCacheId, delegate.found_cache_id_); |
638 EXPECT_EQ(kAppCacheNoResponseId, delegate.found_entry_.response_id()); | 626 EXPECT_EQ(kAppCacheNoResponseId, delegate.found_entry_.response_id()); |
639 EXPECT_EQ(kAppCacheNoResponseId, | 627 EXPECT_EQ(kAppCacheNoResponseId, |
640 delegate.found_fallback_entry_.response_id()); | 628 delegate.found_fallback_entry_.response_id()); |
641 EXPECT_TRUE(delegate.found_fallback_url_.is_empty()); | 629 EXPECT_TRUE(delegate.found_fallback_url_.is_empty()); |
642 EXPECT_EQ(0, delegate.found_entry_.types()); | 630 EXPECT_EQ(0, delegate.found_entry_.types()); |
643 EXPECT_EQ(0, delegate.found_fallback_entry_.types()); | 631 EXPECT_EQ(0, delegate.found_fallback_entry_.types()); |
644 } | 632 } |
645 | 633 |
646 } // namespace content | 634 } // namespace content |
OLD | NEW |