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
3 // found in the LICENSE file.
6 #include "base/bind_helpers.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h"
9 #include "content/browser/appcache/appcache.h"
10 #include "content/browser/appcache/appcache_backend_impl.h"
11 #include "content/browser/appcache/appcache_group.h"
12 #include "content/browser/appcache/appcache_host.h"
13 #include "content/browser/appcache/mock_appcache_policy.h"
14 #include "content/browser/appcache/mock_appcache_service.h"
15 #include "net/url_request/url_request.h"
16 #include "storage/browser/quota/quota_manager.h"
17 #include "testing/gtest/include/gtest/gtest.h"
21 class AppCacheHostTest
: public testing::Test
{
24 get_status_callback_
=
25 base::Bind(&AppCacheHostTest::GetStatusCallback
,
26 base::Unretained(this));
27 start_update_callback_
=
28 base::Bind(&AppCacheHostTest::StartUpdateCallback
,
29 base::Unretained(this));
30 swap_cache_callback_
=
31 base::Bind(&AppCacheHostTest::SwapCacheCallback
,
32 base::Unretained(this));
35 class MockFrontend
: public AppCacheFrontend
{
38 : last_host_id_(-222), last_cache_id_(-222),
39 last_status_(APPCACHE_STATUS_OBSOLETE
),
40 last_status_changed_(APPCACHE_STATUS_OBSOLETE
),
41 last_event_id_(APPCACHE_OBSOLETE_EVENT
),
42 content_blocked_(false) {
45 void OnCacheSelected(int host_id
, const AppCacheInfo
& info
) override
{
46 last_host_id_
= host_id
;
47 last_cache_id_
= info
.cache_id
;
48 last_status_
= info
.status
;
51 void OnStatusChanged(const std::vector
<int>& host_ids
,
52 AppCacheStatus status
) override
{
53 last_status_changed_
= status
;
56 void OnEventRaised(const std::vector
<int>& host_ids
,
57 AppCacheEventID event_id
) override
{
58 last_event_id_
= event_id
;
61 void OnErrorEventRaised(const std::vector
<int>& host_ids
,
62 const AppCacheErrorDetails
& details
) override
{
63 last_event_id_
= APPCACHE_ERROR_EVENT
;
66 void OnProgressEventRaised(const std::vector
<int>& host_ids
,
69 int num_complete
) override
{
70 last_event_id_
= APPCACHE_PROGRESS_EVENT
;
73 void OnLogMessage(int host_id
,
74 AppCacheLogLevel log_level
,
75 const std::string
& message
) override
{}
77 void OnContentBlocked(int host_id
, const GURL
& manifest_url
) override
{
78 content_blocked_
= true;
83 AppCacheStatus last_status_
;
84 AppCacheStatus last_status_changed_
;
85 AppCacheEventID last_event_id_
;
86 bool content_blocked_
;
89 class MockQuotaManagerProxy
: public storage::QuotaManagerProxy
{
91 MockQuotaManagerProxy() : QuotaManagerProxy(NULL
, NULL
) {}
93 // Not needed for our tests.
94 void RegisterClient(storage::QuotaClient
* client
) override
{}
95 void NotifyStorageAccessed(storage::QuotaClient::ID client_id
,
97 storage::StorageType type
) override
{}
98 void NotifyStorageModified(storage::QuotaClient::ID client_id
,
100 storage::StorageType type
,
101 int64 delta
) override
{}
102 void SetUsageCacheEnabled(storage::QuotaClient::ID client_id
,
104 storage::StorageType type
,
105 bool enabled
) override
{}
106 void GetUsageAndQuota(base::SequencedTaskRunner
* original_task_runner
,
108 storage::StorageType type
,
109 const GetUsageAndQuotaCallback
& callback
) override
{}
111 void NotifyOriginInUse(const GURL
& origin
) override
{ inuse_
[origin
] += 1; }
113 void NotifyOriginNoLongerInUse(const GURL
& origin
) override
{
117 int GetInUseCount(const GURL
& origin
) {
118 return inuse_
[origin
];
125 // Map from origin to count of inuse notifications.
126 std::map
<GURL
, int> inuse_
;
129 ~MockQuotaManagerProxy() override
{}
132 void GetStatusCallback(AppCacheStatus status
, void* param
) {
133 last_status_result_
= status
;
134 last_callback_param_
= param
;
137 void StartUpdateCallback(bool result
, void* param
) {
138 last_start_result_
= result
;
139 last_callback_param_
= param
;
142 void SwapCacheCallback(bool result
, void* param
) {
143 last_swap_result_
= result
;
144 last_callback_param_
= param
;
147 base::MessageLoop message_loop_
;
149 // Mock classes for the 'host' to work with
150 MockAppCacheService service_
;
151 MockFrontend mock_frontend_
;
153 // Mock callbacks we expect to receive from the 'host'
154 content::GetStatusCallback get_status_callback_
;
155 content::StartUpdateCallback start_update_callback_
;
156 content::SwapCacheCallback swap_cache_callback_
;
158 AppCacheStatus last_status_result_
;
159 bool last_swap_result_
;
160 bool last_start_result_
;
161 void* last_callback_param_
;
164 TEST_F(AppCacheHostTest
, Basic
) {
165 // Construct a host and test what state it appears to be in.
166 AppCacheHost
host(1, &mock_frontend_
, &service_
);
167 EXPECT_EQ(1, host
.host_id());
168 EXPECT_EQ(&service_
, host
.service());
169 EXPECT_EQ(&mock_frontend_
, host
.frontend());
170 EXPECT_EQ(NULL
, host
.associated_cache());
171 EXPECT_FALSE(host
.is_selection_pending());
173 // See that the callbacks are delivered immediately
174 // and respond as if there is no cache selected.
175 last_status_result_
= APPCACHE_STATUS_OBSOLETE
;
176 host
.GetStatusWithCallback(get_status_callback_
, reinterpret_cast<void*>(1));
177 EXPECT_EQ(APPCACHE_STATUS_UNCACHED
, last_status_result_
);
178 EXPECT_EQ(reinterpret_cast<void*>(1), last_callback_param_
);
180 last_start_result_
= true;
181 host
.StartUpdateWithCallback(start_update_callback_
,
182 reinterpret_cast<void*>(2));
183 EXPECT_FALSE(last_start_result_
);
184 EXPECT_EQ(reinterpret_cast<void*>(2), last_callback_param_
);
186 last_swap_result_
= true;
187 host
.SwapCacheWithCallback(swap_cache_callback_
, reinterpret_cast<void*>(3));
188 EXPECT_FALSE(last_swap_result_
);
189 EXPECT_EQ(reinterpret_cast<void*>(3), last_callback_param_
);
192 TEST_F(AppCacheHostTest
, SelectNoCache
) {
193 scoped_refptr
<MockQuotaManagerProxy
> mock_quota_proxy(
194 new MockQuotaManagerProxy
);
195 service_
.set_quota_manager_proxy(mock_quota_proxy
.get());
197 // Reset our mock frontend
198 mock_frontend_
.last_cache_id_
= -333;
199 mock_frontend_
.last_host_id_
= -333;
200 mock_frontend_
.last_status_
= APPCACHE_STATUS_OBSOLETE
;
202 const GURL
kDocAndOriginUrl(GURL("http://whatever/").GetOrigin());
204 AppCacheHost
host(1, &mock_frontend_
, &service_
);
205 host
.SelectCache(kDocAndOriginUrl
, kAppCacheNoCacheId
, GURL());
206 EXPECT_EQ(1, mock_quota_proxy
->GetInUseCount(kDocAndOriginUrl
));
208 // We should have received an OnCacheSelected msg
209 EXPECT_EQ(1, mock_frontend_
.last_host_id_
);
210 EXPECT_EQ(kAppCacheNoCacheId
, mock_frontend_
.last_cache_id_
);
211 EXPECT_EQ(APPCACHE_STATUS_UNCACHED
, mock_frontend_
.last_status_
);
213 // Otherwise, see that it respond as if there is no cache selected.
214 EXPECT_EQ(1, host
.host_id());
215 EXPECT_EQ(&service_
, host
.service());
216 EXPECT_EQ(&mock_frontend_
, host
.frontend());
217 EXPECT_EQ(NULL
, host
.associated_cache());
218 EXPECT_FALSE(host
.is_selection_pending());
219 EXPECT_TRUE(host
.preferred_manifest_url().is_empty());
221 EXPECT_EQ(0, mock_quota_proxy
->GetInUseCount(kDocAndOriginUrl
));
222 service_
.set_quota_manager_proxy(NULL
);
225 TEST_F(AppCacheHostTest
, ForeignEntry
) {
226 // Reset our mock frontend
227 mock_frontend_
.last_cache_id_
= -333;
228 mock_frontend_
.last_host_id_
= -333;
229 mock_frontend_
.last_status_
= APPCACHE_STATUS_OBSOLETE
;
231 // Precondition, a cache with an entry that is not marked as foreign.
232 const int kCacheId
= 22;
233 const GURL
kDocumentURL("http://origin/document");
234 scoped_refptr
<AppCache
> cache
= new AppCache(service_
.storage(), kCacheId
);
235 cache
->AddEntry(kDocumentURL
, AppCacheEntry(AppCacheEntry::EXPLICIT
));
237 AppCacheHost
host(1, &mock_frontend_
, &service_
);
238 host
.MarkAsForeignEntry(kDocumentURL
, kCacheId
);
240 // We should have received an OnCacheSelected msg for kAppCacheNoCacheId.
241 EXPECT_EQ(1, mock_frontend_
.last_host_id_
);
242 EXPECT_EQ(kAppCacheNoCacheId
, mock_frontend_
.last_cache_id_
);
243 EXPECT_EQ(APPCACHE_STATUS_UNCACHED
, mock_frontend_
.last_status_
);
245 // See that it respond as if there is no cache selected.
246 EXPECT_EQ(1, host
.host_id());
247 EXPECT_EQ(&service_
, host
.service());
248 EXPECT_EQ(&mock_frontend_
, host
.frontend());
249 EXPECT_EQ(NULL
, host
.associated_cache());
250 EXPECT_FALSE(host
.is_selection_pending());
252 // See that the entry was marked as foreign.
253 EXPECT_TRUE(cache
->GetEntry(kDocumentURL
)->IsForeign());
256 TEST_F(AppCacheHostTest
, ForeignFallbackEntry
) {
257 // Reset our mock frontend
258 mock_frontend_
.last_cache_id_
= -333;
259 mock_frontend_
.last_host_id_
= -333;
260 mock_frontend_
.last_status_
= APPCACHE_STATUS_OBSOLETE
;
262 // Precondition, a cache with a fallback entry that is not marked as foreign.
263 const int kCacheId
= 22;
264 const GURL
kFallbackURL("http://origin/fallback_resource");
265 scoped_refptr
<AppCache
> cache
= new AppCache(service_
.storage(), kCacheId
);
266 cache
->AddEntry(kFallbackURL
, AppCacheEntry(AppCacheEntry::FALLBACK
));
268 AppCacheHost
host(1, &mock_frontend_
, &service_
);
269 host
.NotifyMainResourceIsNamespaceEntry(kFallbackURL
);
270 host
.MarkAsForeignEntry(GURL("http://origin/missing_document"), kCacheId
);
272 // We should have received an OnCacheSelected msg for kAppCacheNoCacheId.
273 EXPECT_EQ(1, mock_frontend_
.last_host_id_
);
274 EXPECT_EQ(kAppCacheNoCacheId
, mock_frontend_
.last_cache_id_
);
275 EXPECT_EQ(APPCACHE_STATUS_UNCACHED
, mock_frontend_
.last_status_
);
277 // See that the fallback entry was marked as foreign.
278 EXPECT_TRUE(cache
->GetEntry(kFallbackURL
)->IsForeign());
281 TEST_F(AppCacheHostTest
, FailedCacheLoad
) {
282 // Reset our mock frontend
283 mock_frontend_
.last_cache_id_
= -333;
284 mock_frontend_
.last_host_id_
= -333;
285 mock_frontend_
.last_status_
= APPCACHE_STATUS_OBSOLETE
;
287 AppCacheHost
host(1, &mock_frontend_
, &service_
);
288 EXPECT_FALSE(host
.is_selection_pending());
290 const int kMockCacheId
= 333;
292 // Put it in a state where we're waiting on a cache
293 // load prior to finishing cache selection.
294 host
.pending_selected_cache_id_
= kMockCacheId
;
295 EXPECT_TRUE(host
.is_selection_pending());
297 // The callback should not occur until we finish cache selection.
298 last_status_result_
= APPCACHE_STATUS_OBSOLETE
;
299 last_callback_param_
= reinterpret_cast<void*>(-1);
300 host
.GetStatusWithCallback(get_status_callback_
, reinterpret_cast<void*>(1));
301 EXPECT_EQ(APPCACHE_STATUS_OBSOLETE
, last_status_result_
);
302 EXPECT_EQ(reinterpret_cast<void*>(-1), last_callback_param_
);
304 // Satisfy the load with NULL, a failure.
305 host
.OnCacheLoaded(NULL
, kMockCacheId
);
307 // Cache selection should have finished
308 EXPECT_FALSE(host
.is_selection_pending());
309 EXPECT_EQ(1, mock_frontend_
.last_host_id_
);
310 EXPECT_EQ(kAppCacheNoCacheId
, mock_frontend_
.last_cache_id_
);
311 EXPECT_EQ(APPCACHE_STATUS_UNCACHED
, mock_frontend_
.last_status_
);
313 // Callback should have fired upon completing the cache load too.
314 EXPECT_EQ(APPCACHE_STATUS_UNCACHED
, last_status_result_
);
315 EXPECT_EQ(reinterpret_cast<void*>(1), last_callback_param_
);
318 TEST_F(AppCacheHostTest
, FailedGroupLoad
) {
319 AppCacheHost
host(1, &mock_frontend_
, &service_
);
321 const GURL
kMockManifestUrl("http://foo.bar/baz");
323 // Put it in a state where we're waiting on a cache
324 // load prior to finishing cache selection.
325 host
.pending_selected_manifest_url_
= kMockManifestUrl
;
326 EXPECT_TRUE(host
.is_selection_pending());
328 // The callback should not occur until we finish cache selection.
329 last_status_result_
= APPCACHE_STATUS_OBSOLETE
;
330 last_callback_param_
= reinterpret_cast<void*>(-1);
331 host
.GetStatusWithCallback(get_status_callback_
, reinterpret_cast<void*>(1));
332 EXPECT_EQ(APPCACHE_STATUS_OBSOLETE
, last_status_result_
);
333 EXPECT_EQ(reinterpret_cast<void*>(-1), last_callback_param_
);
335 // Satisfy the load will NULL, a failure.
336 host
.OnGroupLoaded(NULL
, kMockManifestUrl
);
338 // Cache selection should have finished
339 EXPECT_FALSE(host
.is_selection_pending());
340 EXPECT_EQ(1, mock_frontend_
.last_host_id_
);
341 EXPECT_EQ(kAppCacheNoCacheId
, mock_frontend_
.last_cache_id_
);
342 EXPECT_EQ(APPCACHE_STATUS_UNCACHED
, mock_frontend_
.last_status_
);
344 // Callback should have fired upon completing the group load.
345 EXPECT_EQ(APPCACHE_STATUS_UNCACHED
, last_status_result_
);
346 EXPECT_EQ(reinterpret_cast<void*>(1), last_callback_param_
);
349 TEST_F(AppCacheHostTest
, SetSwappableCache
) {
350 AppCacheHost
host(1, &mock_frontend_
, &service_
);
351 host
.SetSwappableCache(NULL
);
352 EXPECT_FALSE(host
.swappable_cache_
.get());
354 scoped_refptr
<AppCacheGroup
> group1(new AppCacheGroup(
355 service_
.storage(), GURL(), service_
.storage()->NewGroupId()));
356 host
.SetSwappableCache(group1
.get());
357 EXPECT_FALSE(host
.swappable_cache_
.get());
359 AppCache
* cache1
= new AppCache(service_
.storage(), 111);
360 cache1
->set_complete(true);
361 group1
->AddCache(cache1
);
362 host
.SetSwappableCache(group1
.get());
363 EXPECT_EQ(cache1
, host
.swappable_cache_
.get());
365 mock_frontend_
.last_host_id_
= -222; // to verify we received OnCacheSelected
367 host
.AssociateCompleteCache(cache1
);
368 EXPECT_FALSE(host
.swappable_cache_
.get()); // was same as associated cache
369 EXPECT_EQ(APPCACHE_STATUS_IDLE
, host
.GetStatus());
370 // verify OnCacheSelected was called
371 EXPECT_EQ(host
.host_id(), mock_frontend_
.last_host_id_
);
372 EXPECT_EQ(cache1
->cache_id(), mock_frontend_
.last_cache_id_
);
373 EXPECT_EQ(APPCACHE_STATUS_IDLE
, mock_frontend_
.last_status_
);
375 AppCache
* cache2
= new AppCache(service_
.storage(), 222);
376 cache2
->set_complete(true);
377 group1
->AddCache(cache2
);
378 EXPECT_EQ(cache2
, host
.swappable_cache_
.get()); // updated to newest
380 scoped_refptr
<AppCacheGroup
> group2(
381 new AppCacheGroup(service_
.storage(), GURL("http://foo.com"),
382 service_
.storage()->NewGroupId()));
383 AppCache
* cache3
= new AppCache(service_
.storage(), 333);
384 cache3
->set_complete(true);
385 group2
->AddCache(cache3
);
387 AppCache
* cache4
= new AppCache(service_
.storage(), 444);
388 cache4
->set_complete(true);
389 group2
->AddCache(cache4
);
390 EXPECT_EQ(cache2
, host
.swappable_cache_
.get()); // unchanged
392 host
.AssociateCompleteCache(cache3
);
393 EXPECT_EQ(cache4
, host
.swappable_cache_
.get()); // newest cache in group2
394 EXPECT_FALSE(group1
->HasCache()); // both caches in group1 have refcount 0
396 host
.AssociateNoCache(GURL());
397 EXPECT_FALSE(host
.swappable_cache_
.get());
398 EXPECT_FALSE(group2
->HasCache()); // both caches in group2 have refcount 0
400 // Host adds reference to newest cache when an update is complete.
401 AppCache
* cache5
= new AppCache(service_
.storage(), 555);
402 cache5
->set_complete(true);
403 group2
->AddCache(cache5
);
404 host
.group_being_updated_
= group2
;
405 host
.OnUpdateComplete(group2
.get());
406 EXPECT_FALSE(host
.group_being_updated_
.get());
407 EXPECT_EQ(cache5
, host
.swappable_cache_
.get());
409 group2
->RemoveCache(cache5
);
410 EXPECT_FALSE(group2
->HasCache());
411 host
.group_being_updated_
= group2
;
412 host
.OnUpdateComplete(group2
.get());
413 EXPECT_FALSE(host
.group_being_updated_
.get());
414 EXPECT_FALSE(host
.swappable_cache_
.get()); // group2 had no newest cache
417 TEST_F(AppCacheHostTest
, ForDedicatedWorker
) {
418 const int kMockProcessId
= 1;
419 const int kParentHostId
= 1;
420 const int kWorkerHostId
= 2;
422 AppCacheBackendImpl backend_impl
;
423 backend_impl
.Initialize(&service_
, &mock_frontend_
, kMockProcessId
);
424 backend_impl
.RegisterHost(kParentHostId
);
425 backend_impl
.RegisterHost(kWorkerHostId
);
427 AppCacheHost
* parent_host
= backend_impl
.GetHost(kParentHostId
);
428 EXPECT_FALSE(parent_host
->is_for_dedicated_worker());
430 AppCacheHost
* worker_host
= backend_impl
.GetHost(kWorkerHostId
);
431 worker_host
->SelectCacheForWorker(kParentHostId
, kMockProcessId
);
432 EXPECT_TRUE(worker_host
->is_for_dedicated_worker());
433 EXPECT_EQ(parent_host
, worker_host
->GetParentAppCacheHost());
435 // We should have received an OnCacheSelected msg for the worker_host.
436 // The host for workers always indicates 'no cache selected' regardless
437 // of its parent's state. This is OK because the worker cannot access
438 // the scriptable interface, the only function available is resource
439 // loading (see appcache_request_handler_unittests those tests).
440 EXPECT_EQ(kWorkerHostId
, mock_frontend_
.last_host_id_
);
441 EXPECT_EQ(kAppCacheNoCacheId
, mock_frontend_
.last_cache_id_
);
442 EXPECT_EQ(APPCACHE_STATUS_UNCACHED
, mock_frontend_
.last_status_
);
444 // Simulate the parent being torn down.
445 backend_impl
.UnregisterHost(kParentHostId
);
447 EXPECT_EQ(NULL
, backend_impl
.GetHost(kParentHostId
));
448 EXPECT_EQ(NULL
, worker_host
->GetParentAppCacheHost());
451 TEST_F(AppCacheHostTest
, SelectCacheAllowed
) {
452 scoped_refptr
<MockQuotaManagerProxy
> mock_quota_proxy(
453 new MockQuotaManagerProxy
);
454 MockAppCachePolicy mock_appcache_policy
;
455 mock_appcache_policy
.can_create_return_value_
= true;
456 service_
.set_quota_manager_proxy(mock_quota_proxy
.get());
457 service_
.set_appcache_policy(&mock_appcache_policy
);
459 // Reset our mock frontend
460 mock_frontend_
.last_cache_id_
= -333;
461 mock_frontend_
.last_host_id_
= -333;
462 mock_frontend_
.last_status_
= APPCACHE_STATUS_OBSOLETE
;
463 mock_frontend_
.last_event_id_
= APPCACHE_OBSOLETE_EVENT
;
464 mock_frontend_
.content_blocked_
= false;
466 const GURL
kDocAndOriginUrl(GURL("http://whatever/").GetOrigin());
467 const GURL
kManifestUrl(GURL("http://whatever/cache.manifest"));
469 AppCacheHost
host(1, &mock_frontend_
, &service_
);
470 host
.first_party_url_
= kDocAndOriginUrl
;
471 host
.SelectCache(kDocAndOriginUrl
, kAppCacheNoCacheId
, kManifestUrl
);
472 EXPECT_EQ(1, mock_quota_proxy
->GetInUseCount(kDocAndOriginUrl
));
474 // MockAppCacheService::LoadOrCreateGroup is asynchronous, so we shouldn't
475 // have received an OnCacheSelected msg yet.
476 EXPECT_EQ(-333, mock_frontend_
.last_host_id_
);
477 EXPECT_EQ(-333, mock_frontend_
.last_cache_id_
);
478 EXPECT_EQ(APPCACHE_STATUS_OBSOLETE
, mock_frontend_
.last_status_
);
479 // No error events either
480 EXPECT_EQ(APPCACHE_OBSOLETE_EVENT
, mock_frontend_
.last_event_id_
);
481 EXPECT_FALSE(mock_frontend_
.content_blocked_
);
483 EXPECT_TRUE(host
.is_selection_pending());
485 EXPECT_EQ(0, mock_quota_proxy
->GetInUseCount(kDocAndOriginUrl
));
486 service_
.set_quota_manager_proxy(NULL
);
489 TEST_F(AppCacheHostTest
, SelectCacheBlocked
) {
490 scoped_refptr
<MockQuotaManagerProxy
> mock_quota_proxy(
491 new MockQuotaManagerProxy
);
492 MockAppCachePolicy mock_appcache_policy
;
493 mock_appcache_policy
.can_create_return_value_
= false;
494 service_
.set_quota_manager_proxy(mock_quota_proxy
.get());
495 service_
.set_appcache_policy(&mock_appcache_policy
);
497 // Reset our mock frontend
498 mock_frontend_
.last_cache_id_
= -333;
499 mock_frontend_
.last_host_id_
= -333;
500 mock_frontend_
.last_status_
= APPCACHE_STATUS_OBSOLETE
;
501 mock_frontend_
.last_event_id_
= APPCACHE_OBSOLETE_EVENT
;
502 mock_frontend_
.content_blocked_
= false;
504 const GURL
kDocAndOriginUrl(GURL("http://whatever/").GetOrigin());
505 const GURL
kManifestUrl(GURL("http://whatever/cache.manifest"));
507 AppCacheHost
host(1, &mock_frontend_
, &service_
);
508 host
.first_party_url_
= kDocAndOriginUrl
;
509 host
.SelectCache(kDocAndOriginUrl
, kAppCacheNoCacheId
, kManifestUrl
);
510 EXPECT_EQ(1, mock_quota_proxy
->GetInUseCount(kDocAndOriginUrl
));
512 // We should have received an OnCacheSelected msg
513 EXPECT_EQ(1, mock_frontend_
.last_host_id_
);
514 EXPECT_EQ(kAppCacheNoCacheId
, mock_frontend_
.last_cache_id_
);
515 EXPECT_EQ(APPCACHE_STATUS_UNCACHED
, mock_frontend_
.last_status_
);
517 // Also, an error event was raised
518 EXPECT_EQ(APPCACHE_ERROR_EVENT
, mock_frontend_
.last_event_id_
);
519 EXPECT_TRUE(mock_frontend_
.content_blocked_
);
521 // Otherwise, see that it respond as if there is no cache selected.
522 EXPECT_EQ(1, host
.host_id());
523 EXPECT_EQ(&service_
, host
.service());
524 EXPECT_EQ(&mock_frontend_
, host
.frontend());
525 EXPECT_EQ(NULL
, host
.associated_cache());
526 EXPECT_FALSE(host
.is_selection_pending());
527 EXPECT_TRUE(host
.preferred_manifest_url().is_empty());
529 EXPECT_EQ(0, mock_quota_proxy
->GetInUseCount(kDocAndOriginUrl
));
530 service_
.set_quota_manager_proxy(NULL
);
533 } // namespace content