1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include "base/bind_helpers.h"
9 #include "base/callback.h"
10 #include "base/message_loop.h"
11 #include "base/threading/thread.h"
12 #include "base/synchronization/waitable_event.h"
13 #include "net/base/net_errors.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "webkit/appcache/appcache.h"
16 #include "webkit/appcache/appcache_database.h"
17 #include "webkit/appcache/appcache_entry.h"
18 #include "webkit/appcache/appcache_group.h"
19 #include "webkit/appcache/appcache_service.h"
20 #include "webkit/appcache/appcache_storage_impl.h"
21 #include "webkit/quota/quota_manager.h"
27 const base::Time kZeroTime
;
28 const GURL
kManifestUrl("http://blah/manifest");
29 const GURL
kManifestUrl2("http://blah/manifest2");
30 const GURL
kManifestUrl3("http://blah/manifest3");
31 const GURL
kEntryUrl("http://blah/entry");
32 const GURL
kEntryUrl2("http://blah/entry2");
33 const GURL
kFallbackNamespace("http://blah/fallback_namespace/");
34 const GURL
kFallbackNamespace2("http://blah/fallback_namespace/longer");
35 const GURL
kFallbackTestUrl("http://blah/fallback_namespace/longer/test");
36 const GURL
kOnlineNamespace("http://blah/online_namespace");
37 const GURL
kOnlineNamespaceWithinFallback(
38 "http://blah/fallback_namespace/online/");
39 const GURL
kInterceptNamespace("http://blah/intercept_namespace/");
40 const GURL
kInterceptNamespace2("http://blah/intercept_namespace/longer/");
41 const GURL
kInterceptTestUrl("http://blah/intercept_namespace/longer/test");
42 const GURL
kInterceptPatternNamespace("http://blah/intercept_pattern/*/bar");
43 const GURL
kInterceptPatternTestPositiveUrl(
44 "http://blah/intercept_pattern/foo/bar");
45 const GURL
kInterceptPatternTestNegativeUrl(
46 "http://blah/intercept_pattern/foo/not_bar");
47 const GURL
kFallbackPatternNamespace("http://blah/fallback_pattern/*/bar");
48 const GURL
kFallbackPatternTestPositiveUrl(
49 "http://blah/fallback_pattern/foo/bar");
50 const GURL
kFallbackPatternTestNegativeUrl(
51 "http://blah/fallback_pattern/foo/not_bar");
52 const GURL
kOrigin(kManifestUrl
.GetOrigin());
54 const int kManifestEntryIdOffset
= 100;
55 const int kFallbackEntryIdOffset
= 1000;
57 const GURL
kDefaultEntryUrl("http://blah/makecacheandgroup_default_entry");
58 const int kDefaultEntrySize
= 10;
59 const int kDefaultEntryIdOffset
= 12345;
61 const int kMockQuota
= 5000;
63 scoped_ptr
<base::Thread
> io_thread
;
64 scoped_ptr
<base::Thread
> db_thread
;
68 class AppCacheStorageImplTest
: public testing::Test
{
70 class MockStorageDelegate
: public AppCacheStorage::Delegate
{
72 explicit MockStorageDelegate(AppCacheStorageImplTest
* test
)
73 : loaded_cache_id_(0), stored_group_success_(false),
74 would_exceed_quota_(false), obsoleted_success_(false),
75 found_cache_id_(kNoCacheId
), test_(test
) {
78 virtual void OnCacheLoaded(AppCache
* cache
, int64 cache_id
) OVERRIDE
{
79 loaded_cache_
= cache
;
80 loaded_cache_id_
= cache_id
;
81 test_
->ScheduleNextTask();
84 virtual void OnGroupLoaded(AppCacheGroup
* group
,
85 const GURL
& manifest_url
) OVERRIDE
{
86 loaded_group_
= group
;
87 loaded_manifest_url_
= manifest_url
;
88 loaded_groups_newest_cache_
= group
? group
->newest_complete_cache()
90 test_
->ScheduleNextTask();
93 virtual void OnGroupAndNewestCacheStored(
94 AppCacheGroup
* group
, AppCache
* newest_cache
, bool success
,
95 bool would_exceed_quota
) OVERRIDE
{
96 stored_group_
= group
;
97 stored_group_success_
= success
;
98 would_exceed_quota_
= would_exceed_quota
;
99 test_
->ScheduleNextTask();
102 virtual void OnGroupMadeObsolete(AppCacheGroup
* group
,
103 bool success
) OVERRIDE
{
104 obsoleted_group_
= group
;
105 obsoleted_success_
= success
;
106 test_
->ScheduleNextTask();
109 virtual void OnMainResponseFound(const GURL
& url
,
110 const AppCacheEntry
& entry
,
111 const GURL
& namespace_entry_url
,
112 const AppCacheEntry
& fallback_entry
,
115 const GURL
& manifest_url
) OVERRIDE
{
117 found_entry_
= entry
;
118 found_namespace_entry_url_
= namespace_entry_url
;
119 found_fallback_entry_
= fallback_entry
;
120 found_cache_id_
= cache_id
;
121 found_group_id_
= group_id
;
122 found_manifest_url_
= manifest_url
;
123 test_
->ScheduleNextTask();
126 scoped_refptr
<AppCache
> loaded_cache_
;
127 int64 loaded_cache_id_
;
128 scoped_refptr
<AppCacheGroup
> loaded_group_
;
129 GURL loaded_manifest_url_
;
130 scoped_refptr
<AppCache
> loaded_groups_newest_cache_
;
131 scoped_refptr
<AppCacheGroup
> stored_group_
;
132 bool stored_group_success_
;
133 bool would_exceed_quota_
;
134 scoped_refptr
<AppCacheGroup
> obsoleted_group_
;
135 bool obsoleted_success_
;
137 AppCacheEntry found_entry_
;
138 GURL found_namespace_entry_url_
;
139 AppCacheEntry found_fallback_entry_
;
140 int64 found_cache_id_
;
141 int64 found_group_id_
;
142 GURL found_manifest_url_
;
143 AppCacheStorageImplTest
* test_
;
146 class MockQuotaManager
: public quota::QuotaManager
{
149 : QuotaManager(true /* is_incognito */, base::FilePath(),
150 io_thread
->message_loop_proxy(),
151 db_thread
->message_loop_proxy(),
155 virtual void GetUsageAndQuota(
157 quota::StorageType type
,
158 const GetUsageAndQuotaCallback
& callback
) OVERRIDE
{
159 EXPECT_EQ(kOrigin
, origin
);
160 EXPECT_EQ(quota::kStorageTypeTemporary
, type
);
162 base::MessageLoop::current()->PostTask(
164 base::Bind(&MockQuotaManager::CallCallback
,
165 base::Unretained(this),
169 CallCallback(callback
);
172 void CallCallback(const GetUsageAndQuotaCallback
& callback
) {
173 callback
.Run(quota::kQuotaStatusOk
, 0, kMockQuota
);
179 virtual ~MockQuotaManager() {}
182 class MockQuotaManagerProxy
: public quota::QuotaManagerProxy
{
184 MockQuotaManagerProxy()
185 : QuotaManagerProxy(NULL
, NULL
),
186 notify_storage_accessed_count_(0),
187 notify_storage_modified_count_(0),
189 mock_manager_(new MockQuotaManager
) {
190 manager_
= mock_manager_
;
193 virtual void NotifyStorageAccessed(quota::QuotaClient::ID client_id
,
195 quota::StorageType type
) OVERRIDE
{
196 EXPECT_EQ(quota::QuotaClient::kAppcache
, client_id
);
197 EXPECT_EQ(quota::kStorageTypeTemporary
, type
);
198 ++notify_storage_accessed_count_
;
199 last_origin_
= origin
;
202 virtual void NotifyStorageModified(quota::QuotaClient::ID client_id
,
204 quota::StorageType type
,
205 int64 delta
) OVERRIDE
{
206 EXPECT_EQ(quota::QuotaClient::kAppcache
, client_id
);
207 EXPECT_EQ(quota::kStorageTypeTemporary
, type
);
208 ++notify_storage_modified_count_
;
209 last_origin_
= origin
;
213 // Not needed for our tests.
214 virtual void RegisterClient(quota::QuotaClient
* client
) OVERRIDE
{}
215 virtual void NotifyOriginInUse(const GURL
& origin
) OVERRIDE
{}
216 virtual void NotifyOriginNoLongerInUse(const GURL
& origin
) OVERRIDE
{}
218 int notify_storage_accessed_count_
;
219 int notify_storage_modified_count_
;
222 scoped_refptr
<MockQuotaManager
> mock_manager_
;
225 virtual ~MockQuotaManagerProxy() {}
228 template <class Method
>
229 void RunMethod(Method method
) {
233 // Helper callback to run a test on our io_thread. The io_thread is spun up
234 // once and reused for all tests.
235 template <class Method
>
236 void MethodWrapper(Method method
) {
239 // Ensure InitTask execution prior to conducting a test.
240 FlushDbThreadTasks();
242 // We also have to wait for InitTask completion call to be performed
243 // on the IO thread prior to running the test. Its guaranteed to be
244 // queued by this time.
245 base::MessageLoop::current()->PostTask(
247 base::Bind(&AppCacheStorageImplTest::RunMethod
<Method
>,
248 base::Unretained(this),
252 static void SetUpTestCase() {
253 io_thread
.reset(new base::Thread("AppCacheTest.IOThread"));
254 base::Thread::Options
options(base::MessageLoop::TYPE_IO
, 0);
255 ASSERT_TRUE(io_thread
->StartWithOptions(options
));
257 db_thread
.reset(new base::Thread("AppCacheTest::DBThread"));
258 ASSERT_TRUE(db_thread
->Start());
261 static void TearDownTestCase() {
262 io_thread
.reset(NULL
);
263 db_thread
.reset(NULL
);
266 // Test harness --------------------------------------------------
268 AppCacheStorageImplTest() {
271 template <class Method
>
272 void RunTestOnIOThread(Method method
) {
273 test_finished_event_
.reset(new base::WaitableEvent(false, false));
274 io_thread
->message_loop()->PostTask(
275 FROM_HERE
, base::Bind(&AppCacheStorageImplTest::MethodWrapper
<Method
>,
276 base::Unretained(this), method
));
277 test_finished_event_
->Wait();
281 DCHECK(base::MessageLoop::current() == io_thread
->message_loop());
282 service_
.reset(new AppCacheService(NULL
));
283 service_
->Initialize(
284 base::FilePath(), db_thread
->message_loop_proxy(), NULL
);
285 mock_quota_manager_proxy_
= new MockQuotaManagerProxy();
286 service_
->quota_manager_proxy_
= mock_quota_manager_proxy_
;
287 delegate_
.reset(new MockStorageDelegate(this));
290 void TearDownTest() {
291 DCHECK(base::MessageLoop::current() == io_thread
->message_loop());
292 storage()->CancelDelegateCallbacks(delegate());
296 mock_quota_manager_proxy_
= NULL
;
299 FlushDbThreadTasks();
302 void TestFinished() {
303 // We unwind the stack prior to finishing up to let stack
304 // based objects get deleted.
305 DCHECK(base::MessageLoop::current() == io_thread
->message_loop());
306 base::MessageLoop::current()->PostTask(
308 base::Bind(&AppCacheStorageImplTest::TestFinishedUnwound
,
309 base::Unretained(this)));
312 void TestFinishedUnwound() {
314 test_finished_event_
->Signal();
317 void PushNextTask(const base::Closure
& task
) {
318 task_stack_
.push(task
);
321 void ScheduleNextTask() {
322 DCHECK(base::MessageLoop::current() == io_thread
->message_loop());
323 if (task_stack_
.empty()) {
326 base::MessageLoop::current()->PostTask(FROM_HERE
, task_stack_
.top());
330 static void SignalEvent(base::WaitableEvent
* event
) {
334 void FlushDbThreadTasks() {
335 // We pump a task thru the db thread to ensure any tasks previously
336 // scheduled on that thread have been performed prior to return.
337 base::WaitableEvent
event(false, false);
338 db_thread
->message_loop()->PostTask(
339 FROM_HERE
, base::Bind(&AppCacheStorageImplTest::SignalEvent
, &event
));
343 // LoadCache_Miss ----------------------------------------------------
345 void LoadCache_Miss() {
346 // Attempt to load a cache that doesn't exist. Should
347 // complete asynchronously.
348 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadCache_Miss
,
349 base::Unretained(this)));
351 storage()->LoadCache(111, delegate());
352 EXPECT_NE(111, delegate()->loaded_cache_id_
);
355 void Verify_LoadCache_Miss() {
356 EXPECT_EQ(111, delegate()->loaded_cache_id_
);
357 EXPECT_FALSE(delegate()->loaded_cache_
);
358 EXPECT_EQ(0, mock_quota_manager_proxy_
->notify_storage_accessed_count_
);
359 EXPECT_EQ(0, mock_quota_manager_proxy_
->notify_storage_modified_count_
);
363 // LoadCache_NearHit -------------------------------------------------
365 void LoadCache_NearHit() {
366 // Attempt to load a cache that is currently in use
367 // and does not require loading from storage. This
368 // load should complete syncly.
370 // Setup some preconditions. Make an 'unstored' cache for
371 // us to load. The ctor should put it in the working set.
372 int64 cache_id
= storage()->NewCacheId();
373 scoped_refptr
<AppCache
> cache(new AppCache(storage(), cache_id
));
376 storage()->LoadCache(cache_id
, delegate());
377 EXPECT_EQ(cache_id
, delegate()->loaded_cache_id_
);
378 EXPECT_EQ(cache
.get(), delegate()->loaded_cache_
.get());
379 EXPECT_EQ(0, mock_quota_manager_proxy_
->notify_storage_accessed_count_
);
380 EXPECT_EQ(0, mock_quota_manager_proxy_
->notify_storage_modified_count_
);
384 // CreateGroup --------------------------------------------
386 void CreateGroupInEmptyOrigin() {
387 // Attempt to load a group that doesn't exist, one should
388 // be created for us, but not stored.
390 // Since the origin has no groups, the storage class will respond
392 storage()->LoadOrCreateGroup(kManifestUrl
, delegate());
393 Verify_CreateGroup();
396 void CreateGroupInPopulatedOrigin() {
397 // Attempt to load a group that doesn't exist, one should
398 // be created for us, but not stored.
399 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_CreateGroup
,
400 base::Unretained(this)));
402 // Since the origin has groups, storage class will have to
403 // consult the database and completion will be async.
404 storage()->usage_map_
[kOrigin
] = kDefaultEntrySize
;
406 storage()->LoadOrCreateGroup(kManifestUrl
, delegate());
407 EXPECT_FALSE(delegate()->loaded_group_
.get());
410 void Verify_CreateGroup() {
411 EXPECT_EQ(kManifestUrl
, delegate()->loaded_manifest_url_
);
412 EXPECT_TRUE(delegate()->loaded_group_
.get());
413 EXPECT_TRUE(delegate()->loaded_group_
->HasOneRef());
414 EXPECT_FALSE(delegate()->loaded_group_
->newest_complete_cache());
416 // Should not have been stored in the database.
417 AppCacheDatabase::GroupRecord record
;
418 EXPECT_FALSE(database()->FindGroup(
419 delegate()->loaded_group_
->group_id(), &record
));
421 EXPECT_EQ(0, mock_quota_manager_proxy_
->notify_storage_accessed_count_
);
422 EXPECT_EQ(0, mock_quota_manager_proxy_
->notify_storage_modified_count_
);
427 // LoadGroupAndCache_FarHit --------------------------------------
429 void LoadGroupAndCache_FarHit() {
430 // Attempt to load a cache that is not currently in use
431 // and does require loading from disk. This
432 // load should complete asynchronously.
433 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadCache_Far_Hit
,
434 base::Unretained(this)));
436 // Setup some preconditions. Create a group and newest cache that
437 // appear to be "stored" and "not currently in use".
438 MakeCacheAndGroup(kManifestUrl
, 1, 1, true);
442 // Conduct the cache load test, completes async
443 storage()->LoadCache(1, delegate());
446 void Verify_LoadCache_Far_Hit() {
447 EXPECT_TRUE(delegate()->loaded_cache_
);
448 EXPECT_TRUE(delegate()->loaded_cache_
->HasOneRef());
449 EXPECT_EQ(1, delegate()->loaded_cache_id_
);
451 // The group should also have been loaded.
452 EXPECT_TRUE(delegate()->loaded_cache_
->owning_group());
453 EXPECT_TRUE(delegate()->loaded_cache_
->owning_group()->HasOneRef());
454 EXPECT_EQ(1, delegate()->loaded_cache_
->owning_group()->group_id());
456 EXPECT_EQ(1, mock_quota_manager_proxy_
->notify_storage_accessed_count_
);
457 EXPECT_EQ(0, mock_quota_manager_proxy_
->notify_storage_modified_count_
);
459 // Drop things from the working set.
460 delegate()->loaded_cache_
= NULL
;
461 EXPECT_FALSE(delegate()->loaded_group_
);
463 // Conduct the group load test, also complete asynchronously.
464 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadGroup_Far_Hit
,
465 base::Unretained(this)));
467 storage()->LoadOrCreateGroup(kManifestUrl
, delegate());
470 void Verify_LoadGroup_Far_Hit() {
471 EXPECT_TRUE(delegate()->loaded_group_
);
472 EXPECT_EQ(kManifestUrl
, delegate()->loaded_manifest_url_
);
473 EXPECT_TRUE(delegate()->loaded_group_
->newest_complete_cache());
474 delegate()->loaded_groups_newest_cache_
= NULL
;
475 EXPECT_TRUE(delegate()->loaded_group_
->HasOneRef());
476 EXPECT_EQ(2, mock_quota_manager_proxy_
->notify_storage_accessed_count_
);
477 EXPECT_EQ(0, mock_quota_manager_proxy_
->notify_storage_modified_count_
);
481 // StoreNewGroup --------------------------------------
483 void StoreNewGroup() {
484 // Store a group and its newest cache. Should complete asynchronously.
485 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_StoreNewGroup
,
486 base::Unretained(this)));
488 // Setup some preconditions. Create a group and newest cache that
489 // appear to be "unstored".
490 group_
= new AppCacheGroup(
491 storage(), kManifestUrl
, storage()->NewGroupId());
492 cache_
= new AppCache(storage(), storage()->NewCacheId());
493 cache_
->AddEntry(kEntryUrl
, AppCacheEntry(AppCacheEntry::EXPLICIT
, 1,
495 // Hold a ref to the cache simulate the UpdateJob holding that ref,
496 // and hold a ref to the group to simulate the CacheHost holding that ref.
498 // Have the quota manager retrun asynchronously for this test.
499 mock_quota_manager_proxy_
->mock_manager_
->async_
= true;
501 // Conduct the store test.
502 storage()->StoreGroupAndNewestCache(group_
, cache_
, delegate());
503 EXPECT_FALSE(delegate()->stored_group_success_
);
506 void Verify_StoreNewGroup() {
507 EXPECT_TRUE(delegate()->stored_group_success_
);
508 EXPECT_EQ(group_
.get(), delegate()->stored_group_
.get());
509 EXPECT_EQ(cache_
.get(), group_
->newest_complete_cache());
510 EXPECT_TRUE(cache_
->is_complete());
512 // Should have been stored in the database.
513 AppCacheDatabase::GroupRecord group_record
;
514 AppCacheDatabase::CacheRecord cache_record
;
515 EXPECT_TRUE(database()->FindGroup(group_
->group_id(), &group_record
));
516 EXPECT_TRUE(database()->FindCache(cache_
->cache_id(), &cache_record
));
518 // Verify quota bookkeeping
519 EXPECT_EQ(kDefaultEntrySize
, storage()->usage_map_
[kOrigin
]);
520 EXPECT_EQ(1, mock_quota_manager_proxy_
->notify_storage_modified_count_
);
521 EXPECT_EQ(kOrigin
, mock_quota_manager_proxy_
->last_origin_
);
522 EXPECT_EQ(kDefaultEntrySize
, mock_quota_manager_proxy_
->last_delta_
);
527 // StoreExistingGroup --------------------------------------
529 void StoreExistingGroup() {
530 // Store a group and its newest cache. Should complete asynchronously.
531 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_StoreExistingGroup
,
532 base::Unretained(this)));
534 // Setup some preconditions. Create a group and old complete cache
535 // that appear to be "stored"
536 MakeCacheAndGroup(kManifestUrl
, 1, 1, true);
537 EXPECT_EQ(kDefaultEntrySize
, storage()->usage_map_
[kOrigin
]);
539 // And a newest unstored complete cache.
540 cache2_
= new AppCache(storage(), 2);
541 cache2_
->AddEntry(kEntryUrl
, AppCacheEntry(AppCacheEntry::MASTER
, 1,
542 kDefaultEntrySize
+ 100));
545 storage()->StoreGroupAndNewestCache(group_
, cache2_
, delegate());
546 EXPECT_FALSE(delegate()->stored_group_success_
);
549 void Verify_StoreExistingGroup() {
550 EXPECT_TRUE(delegate()->stored_group_success_
);
551 EXPECT_EQ(group_
.get(), delegate()->stored_group_
.get());
552 EXPECT_EQ(cache2_
.get(), group_
->newest_complete_cache());
553 EXPECT_TRUE(cache2_
->is_complete());
555 // The new cache should have been stored in the database.
556 AppCacheDatabase::GroupRecord group_record
;
557 AppCacheDatabase::CacheRecord cache_record
;
558 EXPECT_TRUE(database()->FindGroup(1, &group_record
));
559 EXPECT_TRUE(database()->FindCache(2, &cache_record
));
561 // The old cache should have been deleted
562 EXPECT_FALSE(database()->FindCache(1, &cache_record
));
564 // Verify quota bookkeeping
565 EXPECT_EQ(kDefaultEntrySize
+ 100, storage()->usage_map_
[kOrigin
]);
566 EXPECT_EQ(1, mock_quota_manager_proxy_
->notify_storage_modified_count_
);
567 EXPECT_EQ(kOrigin
, mock_quota_manager_proxy_
->last_origin_
);
568 EXPECT_EQ(100, mock_quota_manager_proxy_
->last_delta_
);
573 // StoreExistingGroupExistingCache -------------------------------
575 void StoreExistingGroupExistingCache() {
576 // Store a group with updates to its existing newest complete cache.
577 // Setup some preconditions. Create a group and a complete cache that
578 // appear to be "stored".
580 // Setup some preconditions. Create a group and old complete cache
581 // that appear to be "stored"
582 MakeCacheAndGroup(kManifestUrl
, 1, 1, true);
583 EXPECT_EQ(kDefaultEntrySize
, storage()->usage_map_
[kOrigin
]);
586 base::Time now
= base::Time::Now();
587 cache_
->AddEntry(kEntryUrl
, AppCacheEntry(AppCacheEntry::MASTER
, 1, 100));
588 cache_
->set_update_time(now
);
590 PushNextTask(base::Bind(
591 &AppCacheStorageImplTest::Verify_StoreExistingGroupExistingCache
,
592 base::Unretained(this), now
));
595 EXPECT_EQ(cache_
, group_
->newest_complete_cache());
596 storage()->StoreGroupAndNewestCache(group_
, cache_
, delegate());
597 EXPECT_FALSE(delegate()->stored_group_success_
);
600 void Verify_StoreExistingGroupExistingCache(
601 base::Time expected_update_time
) {
602 EXPECT_TRUE(delegate()->stored_group_success_
);
603 EXPECT_EQ(cache_
, group_
->newest_complete_cache());
605 AppCacheDatabase::CacheRecord cache_record
;
606 EXPECT_TRUE(database()->FindCache(1, &cache_record
));
607 EXPECT_EQ(1, cache_record
.cache_id
);
608 EXPECT_EQ(1, cache_record
.group_id
);
609 EXPECT_FALSE(cache_record
.online_wildcard
);
610 EXPECT_TRUE(expected_update_time
== cache_record
.update_time
);
611 EXPECT_EQ(100 + kDefaultEntrySize
, cache_record
.cache_size
);
613 std::vector
<AppCacheDatabase::EntryRecord
> entry_records
;
614 EXPECT_TRUE(database()->FindEntriesForCache(1, &entry_records
));
615 EXPECT_EQ(2U, entry_records
.size());
616 if (entry_records
[0].url
== kDefaultEntryUrl
)
617 entry_records
.erase(entry_records
.begin());
618 EXPECT_EQ(1 , entry_records
[0].cache_id
);
619 EXPECT_EQ(kEntryUrl
, entry_records
[0].url
);
620 EXPECT_EQ(AppCacheEntry::MASTER
, entry_records
[0].flags
);
621 EXPECT_EQ(1, entry_records
[0].response_id
);
622 EXPECT_EQ(100, entry_records
[0].response_size
);
624 // Verify quota bookkeeping
625 EXPECT_EQ(100 + kDefaultEntrySize
, storage()->usage_map_
[kOrigin
]);
626 EXPECT_EQ(1, mock_quota_manager_proxy_
->notify_storage_modified_count_
);
627 EXPECT_EQ(kOrigin
, mock_quota_manager_proxy_
->last_origin_
);
628 EXPECT_EQ(100, mock_quota_manager_proxy_
->last_delta_
);
633 // FailStoreGroup --------------------------------------
635 void FailStoreGroup() {
636 // Store a group and its newest cache. Should complete asynchronously.
637 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_FailStoreGroup
,
638 base::Unretained(this)));
640 // Setup some preconditions. Create a group and newest cache that
641 // appear to be "unstored" and big enough to exceed the 5M limit.
642 const int64 kTooBig
= 10 * 1024 * 1024; // 10M
643 group_
= new AppCacheGroup(
644 storage(), kManifestUrl
, storage()->NewGroupId());
645 cache_
= new AppCache(storage(), storage()->NewCacheId());
646 cache_
->AddEntry(kManifestUrl
,
647 AppCacheEntry(AppCacheEntry::MANIFEST
, 1, kTooBig
));
648 // Hold a ref to the cache simulate the UpdateJob holding that ref,
649 // and hold a ref to the group to simulate the CacheHost holding that ref.
651 // Conduct the store test.
652 storage()->StoreGroupAndNewestCache(group_
, cache_
, delegate());
653 EXPECT_FALSE(delegate()->stored_group_success_
); // Expected to be async.
656 void Verify_FailStoreGroup() {
657 EXPECT_FALSE(delegate()->stored_group_success_
);
658 EXPECT_TRUE(delegate()->would_exceed_quota_
);
660 // Should not have been stored in the database.
661 AppCacheDatabase::GroupRecord group_record
;
662 AppCacheDatabase::CacheRecord cache_record
;
663 EXPECT_FALSE(database()->FindGroup(group_
->group_id(), &group_record
));
664 EXPECT_FALSE(database()->FindCache(cache_
->cache_id(), &cache_record
));
666 EXPECT_EQ(0, mock_quota_manager_proxy_
->notify_storage_accessed_count_
);
667 EXPECT_EQ(0, mock_quota_manager_proxy_
->notify_storage_modified_count_
);
672 // MakeGroupObsolete -------------------------------
674 void MakeGroupObsolete() {
675 // Make a group obsolete, should complete asynchronously.
676 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_MakeGroupObsolete
,
677 base::Unretained(this)));
679 // Setup some preconditions. Create a group and newest cache that
680 // appears to be "stored" and "currently in use".
681 MakeCacheAndGroup(kManifestUrl
, 1, 1, true);
682 EXPECT_EQ(kDefaultEntrySize
, storage()->usage_map_
[kOrigin
]);
684 // Also insert some related records.
685 AppCacheDatabase::EntryRecord entry_record
;
686 entry_record
.cache_id
= 1;
687 entry_record
.flags
= AppCacheEntry::FALLBACK
;
688 entry_record
.response_id
= 1;
689 entry_record
.url
= kEntryUrl
;
690 EXPECT_TRUE(database()->InsertEntry(&entry_record
));
692 AppCacheDatabase::NamespaceRecord fallback_namespace_record
;
693 fallback_namespace_record
.cache_id
= 1;
694 fallback_namespace_record
.namespace_
.target_url
= kEntryUrl
;
695 fallback_namespace_record
.namespace_
.namespace_url
= kFallbackNamespace
;
696 fallback_namespace_record
.origin
= kManifestUrl
.GetOrigin();
697 EXPECT_TRUE(database()->InsertNamespace(&fallback_namespace_record
));
699 AppCacheDatabase::OnlineWhiteListRecord online_whitelist_record
;
700 online_whitelist_record
.cache_id
= 1;
701 online_whitelist_record
.namespace_url
= kOnlineNamespace
;
702 EXPECT_TRUE(database()->InsertOnlineWhiteList(&online_whitelist_record
));
705 storage()->MakeGroupObsolete(group_
, delegate());
706 EXPECT_FALSE(group_
->is_obsolete());
709 void Verify_MakeGroupObsolete() {
710 EXPECT_TRUE(delegate()->obsoleted_success_
);
711 EXPECT_EQ(group_
.get(), delegate()->obsoleted_group_
.get());
712 EXPECT_TRUE(group_
->is_obsolete());
713 EXPECT_TRUE(storage()->usage_map_
.empty());
715 // The cache and group have been deleted from the database.
716 AppCacheDatabase::GroupRecord group_record
;
717 AppCacheDatabase::CacheRecord cache_record
;
718 EXPECT_FALSE(database()->FindGroup(1, &group_record
));
719 EXPECT_FALSE(database()->FindCache(1, &cache_record
));
721 // The related records should have been deleted too.
722 std::vector
<AppCacheDatabase::EntryRecord
> entry_records
;
723 database()->FindEntriesForCache(1, &entry_records
);
724 EXPECT_TRUE(entry_records
.empty());
725 std::vector
<AppCacheDatabase::NamespaceRecord
> intercept_records
;
726 std::vector
<AppCacheDatabase::NamespaceRecord
> fallback_records
;
727 database()->FindNamespacesForCache(
728 1, &intercept_records
, &fallback_records
);
729 EXPECT_TRUE(fallback_records
.empty());
730 std::vector
<AppCacheDatabase::OnlineWhiteListRecord
> whitelist_records
;
731 database()->FindOnlineWhiteListForCache(1, &whitelist_records
);
732 EXPECT_TRUE(whitelist_records
.empty());
734 // Verify quota bookkeeping
735 EXPECT_TRUE(storage()->usage_map_
.empty());
736 EXPECT_EQ(1, mock_quota_manager_proxy_
->notify_storage_modified_count_
);
737 EXPECT_EQ(kOrigin
, mock_quota_manager_proxy_
->last_origin_
);
738 EXPECT_EQ(-kDefaultEntrySize
, mock_quota_manager_proxy_
->last_delta_
);
743 // MarkEntryAsForeign -------------------------------
745 void MarkEntryAsForeign() {
746 // Setup some preconditions. Create a cache with an entry
747 // in storage and in the working set.
748 MakeCacheAndGroup(kManifestUrl
, 1, 1, true);
749 cache_
->AddEntry(kEntryUrl
, AppCacheEntry(AppCacheEntry::EXPLICIT
));
750 AppCacheDatabase::EntryRecord entry_record
;
751 entry_record
.cache_id
= 1;
752 entry_record
.url
= kEntryUrl
;
753 entry_record
.flags
= AppCacheEntry::EXPLICIT
;
754 entry_record
.response_id
= 0;
755 EXPECT_TRUE(database()->InsertEntry(&entry_record
));
756 EXPECT_FALSE(cache_
->GetEntry(kEntryUrl
)->IsForeign());
759 storage()->MarkEntryAsForeign(kEntryUrl
, 1);
761 // The entry in the working set should have been updated syncly.
762 EXPECT_TRUE(cache_
->GetEntry(kEntryUrl
)->IsForeign());
763 EXPECT_TRUE(cache_
->GetEntry(kEntryUrl
)->IsExplicit());
765 // And the entry in storage should also be updated, but that
766 // happens asynchronously on the db thread.
767 FlushDbThreadTasks();
768 AppCacheDatabase::EntryRecord entry_record2
;
769 EXPECT_TRUE(database()->FindEntry(1, kEntryUrl
, &entry_record2
));
770 EXPECT_EQ(AppCacheEntry::EXPLICIT
| AppCacheEntry::FOREIGN
,
771 entry_record2
.flags
);
775 // MarkEntryAsForeignWithLoadInProgress -------------------------------
777 void MarkEntryAsForeignWithLoadInProgress() {
778 PushNextTask(base::Bind(
779 &AppCacheStorageImplTest::Verify_MarkEntryAsForeignWithLoadInProgress
,
780 base::Unretained(this)));
782 // Setup some preconditions. Create a cache with an entry
783 // in storage, but not in the working set.
784 MakeCacheAndGroup(kManifestUrl
, 1, 1, true);
785 cache_
->AddEntry(kEntryUrl
, AppCacheEntry(AppCacheEntry::EXPLICIT
));
786 AppCacheDatabase::EntryRecord entry_record
;
787 entry_record
.cache_id
= 1;
788 entry_record
.url
= kEntryUrl
;
789 entry_record
.flags
= AppCacheEntry::EXPLICIT
;
790 entry_record
.response_id
= 0;
791 EXPECT_TRUE(database()->InsertEntry(&entry_record
));
792 EXPECT_FALSE(cache_
->GetEntry(kEntryUrl
)->IsForeign());
793 EXPECT_TRUE(cache_
->HasOneRef());
797 // Conduct the test, start a cache load, and prior to completion
798 // of that load, mark the entry as foreign.
799 storage()->LoadCache(1, delegate());
800 storage()->MarkEntryAsForeign(kEntryUrl
, 1);
803 void Verify_MarkEntryAsForeignWithLoadInProgress() {
804 EXPECT_EQ(1, delegate()->loaded_cache_id_
);
805 EXPECT_TRUE(delegate()->loaded_cache_
.get());
807 // The entry in the working set should have been updated upon load.
808 EXPECT_TRUE(delegate()->loaded_cache_
->GetEntry(kEntryUrl
)->IsForeign());
809 EXPECT_TRUE(delegate()->loaded_cache_
->GetEntry(kEntryUrl
)->IsExplicit());
811 // And the entry in storage should also be updated.
812 FlushDbThreadTasks();
813 AppCacheDatabase::EntryRecord entry_record
;
814 EXPECT_TRUE(database()->FindEntry(1, kEntryUrl
, &entry_record
));
815 EXPECT_EQ(AppCacheEntry::EXPLICIT
| AppCacheEntry::FOREIGN
,
820 // FindNoMainResponse -------------------------------
822 void FindNoMainResponse() {
823 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_FindNoMainResponse
,
824 base::Unretained(this)));
827 storage()->FindResponseForMainRequest(kEntryUrl
, GURL(), delegate());
828 EXPECT_NE(kEntryUrl
, delegate()->found_url_
);
831 void Verify_FindNoMainResponse() {
832 EXPECT_EQ(kEntryUrl
, delegate()->found_url_
);
833 EXPECT_TRUE(delegate()->found_manifest_url_
.is_empty());
834 EXPECT_EQ(kNoCacheId
, delegate()->found_cache_id_
);
835 EXPECT_EQ(kNoResponseId
, delegate()->found_entry_
.response_id());
836 EXPECT_EQ(kNoResponseId
, delegate()->found_fallback_entry_
.response_id());
837 EXPECT_TRUE(delegate()->found_namespace_entry_url_
.is_empty());
838 EXPECT_EQ(0, delegate()->found_entry_
.types());
839 EXPECT_EQ(0, delegate()->found_fallback_entry_
.types());
843 // BasicFindMainResponse -------------------------------
845 void BasicFindMainResponseInDatabase() {
846 BasicFindMainResponse(true);
849 void BasicFindMainResponseInWorkingSet() {
850 BasicFindMainResponse(false);
853 void BasicFindMainResponse(bool drop_from_working_set
) {
854 PushNextTask(base::Bind(
855 &AppCacheStorageImplTest::Verify_BasicFindMainResponse
,
856 base::Unretained(this)));
858 // Setup some preconditions. Create a complete cache with an entry
860 MakeCacheAndGroup(kManifestUrl
, 2, 1, true);
861 cache_
->AddEntry(kEntryUrl
, AppCacheEntry(AppCacheEntry::EXPLICIT
, 1));
862 AppCacheDatabase::EntryRecord entry_record
;
863 entry_record
.cache_id
= 1;
864 entry_record
.url
= kEntryUrl
;
865 entry_record
.flags
= AppCacheEntry::EXPLICIT
;
866 entry_record
.response_id
= 1;
867 EXPECT_TRUE(database()->InsertEntry(&entry_record
));
869 // Optionally drop the cache/group pair from the working set.
870 if (drop_from_working_set
) {
871 EXPECT_TRUE(cache_
->HasOneRef());
873 EXPECT_TRUE(group_
->HasOneRef());
878 storage()->FindResponseForMainRequest(kEntryUrl
, GURL(), delegate());
879 EXPECT_NE(kEntryUrl
, delegate()->found_url_
);
882 void Verify_BasicFindMainResponse() {
883 EXPECT_EQ(kEntryUrl
, delegate()->found_url_
);
884 EXPECT_EQ(kManifestUrl
, delegate()->found_manifest_url_
);
885 EXPECT_EQ(1, delegate()->found_cache_id_
);
886 EXPECT_EQ(2, delegate()->found_group_id_
);
887 EXPECT_EQ(1, delegate()->found_entry_
.response_id());
888 EXPECT_TRUE(delegate()->found_entry_
.IsExplicit());
889 EXPECT_FALSE(delegate()->found_fallback_entry_
.has_response_id());
893 // BasicFindMainFallbackResponse -------------------------------
895 void BasicFindMainFallbackResponseInDatabase() {
896 BasicFindMainFallbackResponse(true);
899 void BasicFindMainFallbackResponseInWorkingSet() {
900 BasicFindMainFallbackResponse(false);
903 void BasicFindMainFallbackResponse(bool drop_from_working_set
) {
904 PushNextTask(base::Bind(
905 &AppCacheStorageImplTest::Verify_BasicFindMainFallbackResponse
,
906 base::Unretained(this)));
908 // Setup some preconditions. Create a complete cache with a
909 // fallback namespace and entry.
910 MakeCacheAndGroup(kManifestUrl
, 2, 1, true);
911 cache_
->AddEntry(kEntryUrl
, AppCacheEntry(AppCacheEntry::FALLBACK
, 1));
912 cache_
->AddEntry(kEntryUrl2
, AppCacheEntry(AppCacheEntry::FALLBACK
, 2));
913 cache_
->fallback_namespaces_
.push_back(
914 Namespace(FALLBACK_NAMESPACE
, kFallbackNamespace2
, kEntryUrl2
, false));
915 cache_
->fallback_namespaces_
.push_back(
916 Namespace(FALLBACK_NAMESPACE
, kFallbackNamespace
, kEntryUrl
, false));
917 AppCacheDatabase::CacheRecord cache_record
;
918 std::vector
<AppCacheDatabase::EntryRecord
> entries
;
919 std::vector
<AppCacheDatabase::NamespaceRecord
> intercepts
;
920 std::vector
<AppCacheDatabase::NamespaceRecord
> fallbacks
;
921 std::vector
<AppCacheDatabase::OnlineWhiteListRecord
> whitelists
;
922 cache_
->ToDatabaseRecords(group_
,
923 &cache_record
, &entries
, &intercepts
, &fallbacks
, &whitelists
);
925 std::vector
<AppCacheDatabase::EntryRecord
>::const_iterator iter
=
927 while (iter
!= entries
.end()) {
928 // MakeCacheAndGroup has inserted the default entry record already.
929 if (iter
->url
!= kDefaultEntryUrl
)
930 EXPECT_TRUE(database()->InsertEntry(&(*iter
)));
934 EXPECT_TRUE(database()->InsertNamespaceRecords(fallbacks
));
935 EXPECT_TRUE(database()->InsertOnlineWhiteListRecords(whitelists
));
936 if (drop_from_working_set
) {
937 EXPECT_TRUE(cache_
->HasOneRef());
939 EXPECT_TRUE(group_
->HasOneRef());
943 // Conduct the test. The test url is in both fallback namespace urls,
944 // but should match the longer of the two.
945 storage()->FindResponseForMainRequest(kFallbackTestUrl
, GURL(), delegate());
946 EXPECT_NE(kFallbackTestUrl
, delegate()->found_url_
);
949 void Verify_BasicFindMainFallbackResponse() {
950 EXPECT_EQ(kFallbackTestUrl
, delegate()->found_url_
);
951 EXPECT_EQ(kManifestUrl
, delegate()->found_manifest_url_
);
952 EXPECT_EQ(1, delegate()->found_cache_id_
);
953 EXPECT_EQ(2, delegate()->found_group_id_
);
954 EXPECT_FALSE(delegate()->found_entry_
.has_response_id());
955 EXPECT_EQ(2, delegate()->found_fallback_entry_
.response_id());
956 EXPECT_EQ(kEntryUrl2
, delegate()->found_namespace_entry_url_
);
957 EXPECT_TRUE(delegate()->found_fallback_entry_
.IsFallback());
961 // BasicFindMainInterceptResponse -------------------------------
963 void BasicFindMainInterceptResponseInDatabase() {
964 BasicFindMainInterceptResponse(true);
967 void BasicFindMainInterceptResponseInWorkingSet() {
968 BasicFindMainInterceptResponse(false);
971 void BasicFindMainInterceptResponse(bool drop_from_working_set
) {
972 PushNextTask(base::Bind(
973 &AppCacheStorageImplTest::Verify_BasicFindMainInterceptResponse
,
974 base::Unretained(this)));
976 // Setup some preconditions. Create a complete cache with an
977 // intercept namespace and entry.
978 MakeCacheAndGroup(kManifestUrl
, 2, 1, true);
979 cache_
->AddEntry(kEntryUrl
, AppCacheEntry(AppCacheEntry::INTERCEPT
, 1));
980 cache_
->AddEntry(kEntryUrl2
, AppCacheEntry(AppCacheEntry::INTERCEPT
, 2));
981 cache_
->intercept_namespaces_
.push_back(
982 Namespace(INTERCEPT_NAMESPACE
, kInterceptNamespace2
,
984 cache_
->intercept_namespaces_
.push_back(
985 Namespace(INTERCEPT_NAMESPACE
, kInterceptNamespace
,
987 AppCacheDatabase::CacheRecord cache_record
;
988 std::vector
<AppCacheDatabase::EntryRecord
> entries
;
989 std::vector
<AppCacheDatabase::NamespaceRecord
> intercepts
;
990 std::vector
<AppCacheDatabase::NamespaceRecord
> fallbacks
;
991 std::vector
<AppCacheDatabase::OnlineWhiteListRecord
> whitelists
;
992 cache_
->ToDatabaseRecords(group_
,
993 &cache_record
, &entries
, &intercepts
, &fallbacks
, &whitelists
);
995 std::vector
<AppCacheDatabase::EntryRecord
>::const_iterator iter
=
997 while (iter
!= entries
.end()) {
998 // MakeCacheAndGroup has inserted the default entry record already
999 if (iter
->url
!= kDefaultEntryUrl
)
1000 EXPECT_TRUE(database()->InsertEntry(&(*iter
)));
1004 EXPECT_TRUE(database()->InsertNamespaceRecords(intercepts
));
1005 EXPECT_TRUE(database()->InsertOnlineWhiteListRecords(whitelists
));
1006 if (drop_from_working_set
) {
1007 EXPECT_TRUE(cache_
->HasOneRef());
1009 EXPECT_TRUE(group_
->HasOneRef());
1013 // Conduct the test. The test url is in both intercept namespaces,
1014 // but should match the longer of the two.
1015 storage()->FindResponseForMainRequest(
1016 kInterceptTestUrl
, GURL(), delegate());
1017 EXPECT_NE(kInterceptTestUrl
, delegate()->found_url_
);
1020 void Verify_BasicFindMainInterceptResponse() {
1021 EXPECT_EQ(kInterceptTestUrl
, delegate()->found_url_
);
1022 EXPECT_EQ(kManifestUrl
, delegate()->found_manifest_url_
);
1023 EXPECT_EQ(1, delegate()->found_cache_id_
);
1024 EXPECT_EQ(2, delegate()->found_group_id_
);
1025 EXPECT_EQ(2, delegate()->found_entry_
.response_id());
1026 EXPECT_TRUE(delegate()->found_entry_
.IsIntercept());
1027 EXPECT_EQ(kEntryUrl2
, delegate()->found_namespace_entry_url_
);
1028 EXPECT_FALSE(delegate()->found_fallback_entry_
.has_response_id());
1032 // FindInterceptPatternMatch ----------------------------------------
1034 void FindInterceptPatternMatchInDatabase() {
1035 FindInterceptPatternMatch(true);
1038 void FindInterceptPatternMatchInWorkingSet() {
1039 FindInterceptPatternMatch(false);
1042 void FindInterceptPatternMatch(bool drop_from_working_set
) {
1043 // Setup some preconditions. Create a complete cache with an
1044 // pattern matching intercept namespace and entry.
1045 MakeCacheAndGroup(kManifestUrl
, 2, 1, true);
1046 cache_
->AddEntry(kEntryUrl
, AppCacheEntry(AppCacheEntry::INTERCEPT
, 1));
1047 cache_
->intercept_namespaces_
.push_back(
1048 Namespace(INTERCEPT_NAMESPACE
, kInterceptPatternNamespace
,
1050 AppCacheDatabase::CacheRecord cache_record
;
1051 std::vector
<AppCacheDatabase::EntryRecord
> entries
;
1052 std::vector
<AppCacheDatabase::NamespaceRecord
> intercepts
;
1053 std::vector
<AppCacheDatabase::NamespaceRecord
> fallbacks
;
1054 std::vector
<AppCacheDatabase::OnlineWhiteListRecord
> whitelists
;
1055 cache_
->ToDatabaseRecords(group_
,
1056 &cache_record
, &entries
, &intercepts
, &fallbacks
, &whitelists
);
1058 std::vector
<AppCacheDatabase::EntryRecord
>::const_iterator iter
=
1060 while (iter
!= entries
.end()) {
1061 // MakeCacheAndGroup has inserted the default entry record already
1062 if (iter
->url
!= kDefaultEntryUrl
)
1063 EXPECT_TRUE(database()->InsertEntry(&(*iter
)));
1067 EXPECT_TRUE(database()->InsertNamespaceRecords(intercepts
));
1068 if (drop_from_working_set
) {
1069 EXPECT_TRUE(cache_
->HasOneRef());
1071 EXPECT_TRUE(group_
->HasOneRef());
1075 // First test something that does not match the pattern.
1076 PushNextTask(base::Bind(
1077 &AppCacheStorageImplTest::Verify_FindInterceptPatternMatchNegative
,
1078 base::Unretained(this)));
1079 storage()->FindResponseForMainRequest(
1080 kInterceptPatternTestNegativeUrl
, GURL(), delegate());
1081 EXPECT_EQ(GURL(), delegate()->found_url_
); // Is always async.
1084 void Verify_FindInterceptPatternMatchNegative() {
1085 EXPECT_EQ(kInterceptPatternTestNegativeUrl
, delegate()->found_url_
);
1086 EXPECT_TRUE(delegate()->found_manifest_url_
.is_empty());
1087 EXPECT_EQ(kNoCacheId
, delegate()->found_cache_id_
);
1088 EXPECT_EQ(kNoResponseId
, delegate()->found_entry_
.response_id());
1089 EXPECT_EQ(kNoResponseId
, delegate()->found_fallback_entry_
.response_id());
1090 EXPECT_TRUE(delegate()->found_namespace_entry_url_
.is_empty());
1091 EXPECT_EQ(0, delegate()->found_entry_
.types());
1092 EXPECT_EQ(0, delegate()->found_fallback_entry_
.types());
1094 // Then test something that matches.
1095 PushNextTask(base::Bind(
1096 &AppCacheStorageImplTest::Verify_FindInterceptPatternMatchPositive
,
1097 base::Unretained(this)));
1098 storage()->FindResponseForMainRequest(
1099 kInterceptPatternTestPositiveUrl
, GURL(), delegate());
1102 void Verify_FindInterceptPatternMatchPositive() {
1103 EXPECT_EQ(kInterceptPatternTestPositiveUrl
, delegate()->found_url_
);
1104 EXPECT_EQ(kManifestUrl
, delegate()->found_manifest_url_
);
1105 EXPECT_EQ(1, delegate()->found_cache_id_
);
1106 EXPECT_EQ(2, delegate()->found_group_id_
);
1107 EXPECT_EQ(1, delegate()->found_entry_
.response_id());
1108 EXPECT_TRUE(delegate()->found_entry_
.IsIntercept());
1109 EXPECT_EQ(kEntryUrl
, delegate()->found_namespace_entry_url_
);
1110 EXPECT_FALSE(delegate()->found_fallback_entry_
.has_response_id());
1114 // FindFallbackPatternMatch -------------------------------
1116 void FindFallbackPatternMatchInDatabase() {
1117 FindFallbackPatternMatch(true);
1120 void FindFallbackPatternMatchInWorkingSet() {
1121 FindFallbackPatternMatch(false);
1124 void FindFallbackPatternMatch(bool drop_from_working_set
) {
1125 // Setup some preconditions. Create a complete cache with a
1126 // pattern matching fallback namespace and entry.
1127 MakeCacheAndGroup(kManifestUrl
, 2, 1, true);
1128 cache_
->AddEntry(kEntryUrl
, AppCacheEntry(AppCacheEntry::FALLBACK
, 1));
1129 cache_
->fallback_namespaces_
.push_back(
1130 Namespace(FALLBACK_NAMESPACE
, kFallbackPatternNamespace
,
1132 AppCacheDatabase::CacheRecord cache_record
;
1133 std::vector
<AppCacheDatabase::EntryRecord
> entries
;
1134 std::vector
<AppCacheDatabase::NamespaceRecord
> intercepts
;
1135 std::vector
<AppCacheDatabase::NamespaceRecord
> fallbacks
;
1136 std::vector
<AppCacheDatabase::OnlineWhiteListRecord
> whitelists
;
1137 cache_
->ToDatabaseRecords(group_
,
1138 &cache_record
, &entries
, &intercepts
, &fallbacks
, &whitelists
);
1140 std::vector
<AppCacheDatabase::EntryRecord
>::const_iterator iter
=
1142 while (iter
!= entries
.end()) {
1143 // MakeCacheAndGroup has inserted the default entry record already.
1144 if (iter
->url
!= kDefaultEntryUrl
)
1145 EXPECT_TRUE(database()->InsertEntry(&(*iter
)));
1149 EXPECT_TRUE(database()->InsertNamespaceRecords(fallbacks
));
1150 if (drop_from_working_set
) {
1151 EXPECT_TRUE(cache_
->HasOneRef());
1153 EXPECT_TRUE(group_
->HasOneRef());
1157 // First test something that does not match the pattern.
1158 PushNextTask(base::Bind(
1159 &AppCacheStorageImplTest::Verify_FindFallbackPatternMatchNegative
,
1160 base::Unretained(this)));
1161 storage()->FindResponseForMainRequest(
1162 kFallbackPatternTestNegativeUrl
, GURL(), delegate());
1163 EXPECT_EQ(GURL(), delegate()->found_url_
); // Is always async.
1166 void Verify_FindFallbackPatternMatchNegative() {
1167 EXPECT_EQ(kFallbackPatternTestNegativeUrl
, delegate()->found_url_
);
1168 EXPECT_TRUE(delegate()->found_manifest_url_
.is_empty());
1169 EXPECT_EQ(kNoCacheId
, delegate()->found_cache_id_
);
1170 EXPECT_EQ(kNoResponseId
, delegate()->found_entry_
.response_id());
1171 EXPECT_EQ(kNoResponseId
, delegate()->found_fallback_entry_
.response_id());
1172 EXPECT_TRUE(delegate()->found_namespace_entry_url_
.is_empty());
1173 EXPECT_EQ(0, delegate()->found_entry_
.types());
1174 EXPECT_EQ(0, delegate()->found_fallback_entry_
.types());
1176 // Then test something that matches.
1177 PushNextTask(base::Bind(
1178 &AppCacheStorageImplTest::Verify_FindFallbackPatternMatchPositive
,
1179 base::Unretained(this)));
1180 storage()->FindResponseForMainRequest(
1181 kFallbackPatternTestPositiveUrl
, GURL(), delegate());
1184 void Verify_FindFallbackPatternMatchPositive() {
1185 EXPECT_EQ(kFallbackPatternTestPositiveUrl
, delegate()->found_url_
);
1186 EXPECT_EQ(kManifestUrl
, delegate()->found_manifest_url_
);
1187 EXPECT_EQ(1, delegate()->found_cache_id_
);
1188 EXPECT_EQ(2, delegate()->found_group_id_
);
1189 EXPECT_EQ(1, delegate()->found_fallback_entry_
.response_id());
1190 EXPECT_TRUE(delegate()->found_fallback_entry_
.IsFallback());
1191 EXPECT_EQ(kEntryUrl
, delegate()->found_namespace_entry_url_
);
1192 EXPECT_FALSE(delegate()->found_entry_
.has_response_id());
1196 // FindMainResponseWithMultipleHits -------------------------------
1198 void FindMainResponseWithMultipleHits() {
1199 PushNextTask(base::Bind(
1200 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits
,
1201 base::Unretained(this)));
1203 // Setup some preconditions, create a few caches with an identical set
1204 // of entries and fallback namespaces. Only the last one remains in
1205 // the working set to simulate appearing as "in use".
1206 MakeMultipleHitCacheAndGroup(kManifestUrl
, 1);
1207 MakeMultipleHitCacheAndGroup(kManifestUrl2
, 2);
1208 MakeMultipleHitCacheAndGroup(kManifestUrl3
, 3);
1210 // Conduct the test, we should find the response from the last cache
1211 // since it's "in use".
1212 storage()->FindResponseForMainRequest(kEntryUrl
, GURL(), delegate());
1213 EXPECT_NE(kEntryUrl
, delegate()->found_url_
);
1216 void MakeMultipleHitCacheAndGroup(const GURL
& manifest_url
, int id
) {
1217 MakeCacheAndGroup(manifest_url
, id
, id
, true);
1218 AppCacheDatabase::EntryRecord entry_record
;
1220 // Add an entry for kEntryUrl
1221 entry_record
.cache_id
= id
;
1222 entry_record
.url
= kEntryUrl
;
1223 entry_record
.flags
= AppCacheEntry::EXPLICIT
;
1224 entry_record
.response_id
= id
;
1225 EXPECT_TRUE(database()->InsertEntry(&entry_record
));
1228 AppCacheEntry(entry_record
.flags
, entry_record
.response_id
));
1230 // Add an entry for the manifestUrl
1231 entry_record
.cache_id
= id
;
1232 entry_record
.url
= manifest_url
;
1233 entry_record
.flags
= AppCacheEntry::MANIFEST
;
1234 entry_record
.response_id
= id
+ kManifestEntryIdOffset
;
1235 EXPECT_TRUE(database()->InsertEntry(&entry_record
));
1238 AppCacheEntry(entry_record
.flags
, entry_record
.response_id
));
1240 // Add a fallback entry and namespace
1241 entry_record
.cache_id
= id
;
1242 entry_record
.url
= kEntryUrl2
;
1243 entry_record
.flags
= AppCacheEntry::FALLBACK
;
1244 entry_record
.response_id
= id
+ kFallbackEntryIdOffset
;
1245 EXPECT_TRUE(database()->InsertEntry(&entry_record
));
1248 AppCacheEntry(entry_record
.flags
, entry_record
.response_id
));
1249 AppCacheDatabase::NamespaceRecord fallback_namespace_record
;
1250 fallback_namespace_record
.cache_id
= id
;
1251 fallback_namespace_record
.namespace_
.target_url
= entry_record
.url
;
1252 fallback_namespace_record
.namespace_
.namespace_url
= kFallbackNamespace
;
1253 fallback_namespace_record
.origin
= manifest_url
.GetOrigin();
1254 EXPECT_TRUE(database()->InsertNamespace(&fallback_namespace_record
));
1255 cache_
->fallback_namespaces_
.push_back(
1256 Namespace(FALLBACK_NAMESPACE
, kFallbackNamespace
, kEntryUrl2
, false));
1259 void Verify_FindMainResponseWithMultipleHits() {
1260 EXPECT_EQ(kEntryUrl
, delegate()->found_url_
);
1261 EXPECT_EQ(kManifestUrl3
, delegate()->found_manifest_url_
);
1262 EXPECT_EQ(3, delegate()->found_cache_id_
);
1263 EXPECT_EQ(3, delegate()->found_group_id_
);
1264 EXPECT_EQ(3, delegate()->found_entry_
.response_id());
1265 EXPECT_TRUE(delegate()->found_entry_
.IsExplicit());
1266 EXPECT_FALSE(delegate()->found_fallback_entry_
.has_response_id());
1268 // Conduct another test perferring kManifestUrl
1269 delegate_
.reset(new MockStorageDelegate(this));
1270 PushNextTask(base::Bind(
1271 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits2
,
1272 base::Unretained(this)));
1273 storage()->FindResponseForMainRequest(kEntryUrl
, kManifestUrl
, delegate());
1274 EXPECT_NE(kEntryUrl
, delegate()->found_url_
);
1277 void Verify_FindMainResponseWithMultipleHits2() {
1278 EXPECT_EQ(kEntryUrl
, delegate()->found_url_
);
1279 EXPECT_EQ(kManifestUrl
, delegate()->found_manifest_url_
);
1280 EXPECT_EQ(1, delegate()->found_cache_id_
);
1281 EXPECT_EQ(1, delegate()->found_group_id_
);
1282 EXPECT_EQ(1, delegate()->found_entry_
.response_id());
1283 EXPECT_TRUE(delegate()->found_entry_
.IsExplicit());
1284 EXPECT_FALSE(delegate()->found_fallback_entry_
.has_response_id());
1286 // Conduct the another test perferring kManifestUrl2
1287 delegate_
.reset(new MockStorageDelegate(this));
1288 PushNextTask(base::Bind(
1289 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits3
,
1290 base::Unretained(this)));
1291 storage()->FindResponseForMainRequest(kEntryUrl
, kManifestUrl2
, delegate());
1292 EXPECT_NE(kEntryUrl
, delegate()->found_url_
);
1295 void Verify_FindMainResponseWithMultipleHits3() {
1296 EXPECT_EQ(kEntryUrl
, delegate()->found_url_
);
1297 EXPECT_EQ(kManifestUrl2
, delegate()->found_manifest_url_
);
1298 EXPECT_EQ(2, delegate()->found_cache_id_
);
1299 EXPECT_EQ(2, delegate()->found_group_id_
);
1300 EXPECT_EQ(2, delegate()->found_entry_
.response_id());
1301 EXPECT_TRUE(delegate()->found_entry_
.IsExplicit());
1302 EXPECT_FALSE(delegate()->found_fallback_entry_
.has_response_id());
1304 // Conduct another test with no preferred manifest that hits the fallback.
1305 delegate_
.reset(new MockStorageDelegate(this));
1306 PushNextTask(base::Bind(
1307 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits4
,
1308 base::Unretained(this)));
1309 storage()->FindResponseForMainRequest(
1310 kFallbackTestUrl
, GURL(), delegate());
1311 EXPECT_NE(kFallbackTestUrl
, delegate()->found_url_
);
1314 void Verify_FindMainResponseWithMultipleHits4() {
1315 EXPECT_EQ(kFallbackTestUrl
, delegate()->found_url_
);
1316 EXPECT_EQ(kManifestUrl3
, delegate()->found_manifest_url_
);
1317 EXPECT_EQ(3, delegate()->found_cache_id_
);
1318 EXPECT_EQ(3, delegate()->found_group_id_
);
1319 EXPECT_FALSE(delegate()->found_entry_
.has_response_id());
1320 EXPECT_EQ(3 + kFallbackEntryIdOffset
,
1321 delegate()->found_fallback_entry_
.response_id());
1322 EXPECT_TRUE(delegate()->found_fallback_entry_
.IsFallback());
1323 EXPECT_EQ(kEntryUrl2
, delegate()->found_namespace_entry_url_
);
1325 // Conduct another test preferring kManifestUrl2 that hits the fallback.
1326 delegate_
.reset(new MockStorageDelegate(this));
1327 PushNextTask(base::Bind(
1328 &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits5
,
1329 base::Unretained(this)));
1330 storage()->FindResponseForMainRequest(
1331 kFallbackTestUrl
, kManifestUrl2
, delegate());
1332 EXPECT_NE(kFallbackTestUrl
, delegate()->found_url_
);
1335 void Verify_FindMainResponseWithMultipleHits5() {
1336 EXPECT_EQ(kFallbackTestUrl
, delegate()->found_url_
);
1337 EXPECT_EQ(kManifestUrl2
, delegate()->found_manifest_url_
);
1338 EXPECT_EQ(2, delegate()->found_cache_id_
);
1339 EXPECT_EQ(2, delegate()->found_group_id_
);
1340 EXPECT_FALSE(delegate()->found_entry_
.has_response_id());
1341 EXPECT_EQ(2 + kFallbackEntryIdOffset
,
1342 delegate()->found_fallback_entry_
.response_id());
1343 EXPECT_TRUE(delegate()->found_fallback_entry_
.IsFallback());
1344 EXPECT_EQ(kEntryUrl2
, delegate()->found_namespace_entry_url_
);
1349 // FindMainResponseExclusions -------------------------------
1351 void FindMainResponseExclusionsInDatabase() {
1352 FindMainResponseExclusions(true);
1355 void FindMainResponseExclusionsInWorkingSet() {
1356 FindMainResponseExclusions(false);
1359 void FindMainResponseExclusions(bool drop_from_working_set
) {
1360 // Setup some preconditions. Create a complete cache with a
1361 // foreign entry, an online namespace, and a second online
1362 // namespace nested within a fallback namespace.
1363 MakeCacheAndGroup(kManifestUrl
, 1, 1, true);
1364 cache_
->AddEntry(kEntryUrl
,
1365 AppCacheEntry(AppCacheEntry::EXPLICIT
| AppCacheEntry::FOREIGN
, 1));
1366 cache_
->AddEntry(kEntryUrl2
, AppCacheEntry(AppCacheEntry::FALLBACK
, 2));
1367 cache_
->fallback_namespaces_
.push_back(
1368 Namespace(FALLBACK_NAMESPACE
, kFallbackNamespace
, kEntryUrl2
, false));
1369 cache_
->online_whitelist_namespaces_
.push_back(
1370 Namespace(NETWORK_NAMESPACE
, kOnlineNamespace
,
1372 cache_
->online_whitelist_namespaces_
.push_back(
1373 Namespace(NETWORK_NAMESPACE
, kOnlineNamespaceWithinFallback
,
1376 AppCacheDatabase::EntryRecord entry_record
;
1377 entry_record
.cache_id
= 1;
1378 entry_record
.url
= kEntryUrl
;
1379 entry_record
.flags
= AppCacheEntry::EXPLICIT
| AppCacheEntry::FOREIGN
;
1380 entry_record
.response_id
= 1;
1381 EXPECT_TRUE(database()->InsertEntry(&entry_record
));
1382 AppCacheDatabase::OnlineWhiteListRecord whitelist_record
;
1383 whitelist_record
.cache_id
= 1;
1384 whitelist_record
.namespace_url
= kOnlineNamespace
;
1385 EXPECT_TRUE(database()->InsertOnlineWhiteList(&whitelist_record
));
1386 AppCacheDatabase::NamespaceRecord fallback_namespace_record
;
1387 fallback_namespace_record
.cache_id
= 1;
1388 fallback_namespace_record
.namespace_
.target_url
= kEntryUrl2
;
1389 fallback_namespace_record
.namespace_
.namespace_url
= kFallbackNamespace
;
1390 fallback_namespace_record
.origin
= kManifestUrl
.GetOrigin();
1391 EXPECT_TRUE(database()->InsertNamespace(&fallback_namespace_record
));
1392 whitelist_record
.cache_id
= 1;
1393 whitelist_record
.namespace_url
= kOnlineNamespaceWithinFallback
;
1394 EXPECT_TRUE(database()->InsertOnlineWhiteList(&whitelist_record
));
1395 if (drop_from_working_set
) {
1400 // We should not find anything for the foreign entry.
1401 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_ExclusionNotFound
,
1402 base::Unretained(this), kEntryUrl
, 1));
1403 storage()->FindResponseForMainRequest(kEntryUrl
, GURL(), delegate());
1406 void Verify_ExclusionNotFound(GURL expected_url
, int phase
) {
1407 EXPECT_EQ(expected_url
, delegate()->found_url_
);
1408 EXPECT_TRUE(delegate()->found_manifest_url_
.is_empty());
1409 EXPECT_EQ(kNoCacheId
, delegate()->found_cache_id_
);
1410 EXPECT_EQ(0, delegate()->found_group_id_
);
1411 EXPECT_EQ(kNoResponseId
, delegate()->found_entry_
.response_id());
1412 EXPECT_EQ(kNoResponseId
, delegate()->found_fallback_entry_
.response_id());
1413 EXPECT_TRUE(delegate()->found_namespace_entry_url_
.is_empty());
1414 EXPECT_EQ(0, delegate()->found_entry_
.types());
1415 EXPECT_EQ(0, delegate()->found_fallback_entry_
.types());
1418 // We should not find anything for the online namespace.
1420 base::Bind(&AppCacheStorageImplTest::Verify_ExclusionNotFound
,
1421 base::Unretained(this), kOnlineNamespace
, 2));
1422 storage()->FindResponseForMainRequest(
1423 kOnlineNamespace
, GURL(), delegate());
1427 // We should not find anything for the online namespace nested within
1428 // the fallback namespace.
1429 PushNextTask(base::Bind(
1430 &AppCacheStorageImplTest::Verify_ExclusionNotFound
,
1431 base::Unretained(this), kOnlineNamespaceWithinFallback
, 3));
1432 storage()->FindResponseForMainRequest(
1433 kOnlineNamespaceWithinFallback
, GURL(), delegate());
1440 // Test case helpers --------------------------------------------------
1442 AppCacheService
* service() {
1443 return service_
.get();
1446 AppCacheStorageImpl
* storage() {
1447 return static_cast<AppCacheStorageImpl
*>(service()->storage());
1450 AppCacheDatabase
* database() {
1451 return storage()->database_
;
1454 MockStorageDelegate
* delegate() {
1455 return delegate_
.get();
1458 void MakeCacheAndGroup(
1459 const GURL
& manifest_url
, int64 group_id
, int64 cache_id
,
1460 bool add_to_database
) {
1461 AppCacheEntry
default_entry(
1462 AppCacheEntry::EXPLICIT
, cache_id
+ kDefaultEntryIdOffset
,
1464 group_
= new AppCacheGroup(storage(), manifest_url
, group_id
);
1465 cache_
= new AppCache(storage(), cache_id
);
1466 cache_
->AddEntry(kDefaultEntryUrl
, default_entry
);
1467 cache_
->set_complete(true);
1468 group_
->AddCache(cache_
);
1469 if (add_to_database
) {
1470 AppCacheDatabase::GroupRecord group_record
;
1471 group_record
.group_id
= group_id
;
1472 group_record
.manifest_url
= manifest_url
;
1473 group_record
.origin
= manifest_url
.GetOrigin();
1474 EXPECT_TRUE(database()->InsertGroup(&group_record
));
1475 AppCacheDatabase::CacheRecord cache_record
;
1476 cache_record
.cache_id
= cache_id
;
1477 cache_record
.group_id
= group_id
;
1478 cache_record
.online_wildcard
= false;
1479 cache_record
.update_time
= kZeroTime
;
1480 cache_record
.cache_size
= kDefaultEntrySize
;
1481 EXPECT_TRUE(database()->InsertCache(&cache_record
));
1482 AppCacheDatabase::EntryRecord entry_record
;
1483 entry_record
.cache_id
= cache_id
;
1484 entry_record
.url
= kDefaultEntryUrl
;
1485 entry_record
.flags
= default_entry
.types();
1486 entry_record
.response_id
= default_entry
.response_id();
1487 entry_record
.response_size
= default_entry
.response_size();
1488 EXPECT_TRUE(database()->InsertEntry(&entry_record
));
1490 storage()->usage_map_
[manifest_url
.GetOrigin()] =
1491 default_entry
.response_size();
1495 // Data members --------------------------------------------------
1497 scoped_ptr
<base::WaitableEvent
> test_finished_event_
;
1498 std::stack
<base::Closure
> task_stack_
;
1499 scoped_ptr
<AppCacheService
> service_
;
1500 scoped_ptr
<MockStorageDelegate
> delegate_
;
1501 scoped_refptr
<MockQuotaManagerProxy
> mock_quota_manager_proxy_
;
1502 scoped_refptr
<AppCacheGroup
> group_
;
1503 scoped_refptr
<AppCache
> cache_
;
1504 scoped_refptr
<AppCache
> cache2_
;
1508 TEST_F(AppCacheStorageImplTest
, LoadCache_Miss
) {
1509 RunTestOnIOThread(&AppCacheStorageImplTest::LoadCache_Miss
);
1512 TEST_F(AppCacheStorageImplTest
, LoadCache_NearHit
) {
1513 RunTestOnIOThread(&AppCacheStorageImplTest::LoadCache_NearHit
);
1516 TEST_F(AppCacheStorageImplTest
, CreateGroupInEmptyOrigin
) {
1517 RunTestOnIOThread(&AppCacheStorageImplTest::CreateGroupInEmptyOrigin
);
1520 TEST_F(AppCacheStorageImplTest
, CreateGroupInPopulatedOrigin
) {
1521 RunTestOnIOThread(&AppCacheStorageImplTest::CreateGroupInPopulatedOrigin
);
1524 TEST_F(AppCacheStorageImplTest
, LoadGroupAndCache_FarHit
) {
1525 RunTestOnIOThread(&AppCacheStorageImplTest::LoadGroupAndCache_FarHit
);
1528 TEST_F(AppCacheStorageImplTest
, StoreNewGroup
) {
1529 RunTestOnIOThread(&AppCacheStorageImplTest::StoreNewGroup
);
1532 TEST_F(AppCacheStorageImplTest
, StoreExistingGroup
) {
1533 RunTestOnIOThread(&AppCacheStorageImplTest::StoreExistingGroup
);
1536 TEST_F(AppCacheStorageImplTest
, StoreExistingGroupExistingCache
) {
1537 RunTestOnIOThread(&AppCacheStorageImplTest::StoreExistingGroupExistingCache
);
1540 TEST_F(AppCacheStorageImplTest
, FailStoreGroup
) {
1541 RunTestOnIOThread(&AppCacheStorageImplTest::FailStoreGroup
);
1544 TEST_F(AppCacheStorageImplTest
, MakeGroupObsolete
) {
1545 RunTestOnIOThread(&AppCacheStorageImplTest::MakeGroupObsolete
);
1548 TEST_F(AppCacheStorageImplTest
, MarkEntryAsForeign
) {
1549 RunTestOnIOThread(&AppCacheStorageImplTest::MarkEntryAsForeign
);
1552 TEST_F(AppCacheStorageImplTest
, MarkEntryAsForeignWithLoadInProgress
) {
1554 &AppCacheStorageImplTest::MarkEntryAsForeignWithLoadInProgress
);
1557 TEST_F(AppCacheStorageImplTest
, FindNoMainResponse
) {
1558 RunTestOnIOThread(&AppCacheStorageImplTest::FindNoMainResponse
);
1561 TEST_F(AppCacheStorageImplTest
, BasicFindMainResponseInDatabase
) {
1563 &AppCacheStorageImplTest::BasicFindMainResponseInDatabase
);
1566 TEST_F(AppCacheStorageImplTest
, BasicFindMainResponseInWorkingSet
) {
1568 &AppCacheStorageImplTest::BasicFindMainResponseInWorkingSet
);
1571 TEST_F(AppCacheStorageImplTest
, BasicFindMainFallbackResponseInDatabase
) {
1573 &AppCacheStorageImplTest::BasicFindMainFallbackResponseInDatabase
);
1576 TEST_F(AppCacheStorageImplTest
, BasicFindMainFallbackResponseInWorkingSet
) {
1578 &AppCacheStorageImplTest::BasicFindMainFallbackResponseInWorkingSet
);
1581 TEST_F(AppCacheStorageImplTest
, BasicFindMainInterceptResponseInDatabase
) {
1583 &AppCacheStorageImplTest::BasicFindMainInterceptResponseInDatabase
);
1586 TEST_F(AppCacheStorageImplTest
, BasicFindMainInterceptResponseInWorkingSet
) {
1588 &AppCacheStorageImplTest::BasicFindMainInterceptResponseInWorkingSet
);
1591 TEST_F(AppCacheStorageImplTest
, FindMainResponseWithMultipleHits
) {
1593 &AppCacheStorageImplTest::FindMainResponseWithMultipleHits
);
1596 TEST_F(AppCacheStorageImplTest
, FindMainResponseExclusionsInDatabase
) {
1598 &AppCacheStorageImplTest::FindMainResponseExclusionsInDatabase
);
1601 TEST_F(AppCacheStorageImplTest
, FindMainResponseExclusionsInWorkingSet
) {
1603 &AppCacheStorageImplTest::FindMainResponseExclusionsInWorkingSet
);
1606 TEST_F(AppCacheStorageImplTest
, FindInterceptPatternMatchInWorkingSet
) {
1608 &AppCacheStorageImplTest::FindInterceptPatternMatchInWorkingSet
);
1611 TEST_F(AppCacheStorageImplTest
, FindInterceptPatternMatchInDatabase
) {
1613 &AppCacheStorageImplTest::FindInterceptPatternMatchInDatabase
);
1616 TEST_F(AppCacheStorageImplTest
, FindFallbackPatternMatchInWorkingSet
) {
1618 &AppCacheStorageImplTest::FindFallbackPatternMatchInWorkingSet
);
1621 TEST_F(AppCacheStorageImplTest
, FindFallbackPatternMatchInDatabase
) {
1623 &AppCacheStorageImplTest::FindFallbackPatternMatchInDatabase
);
1626 // That's all folks!
1628 } // namespace appcache