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" | 6 #include "content/browser/appcache/appcache.h" |
7 #include "content/browser/appcache/appcache_group.h" | 7 #include "content/browser/appcache/appcache_group.h" |
8 #include "content/browser/appcache/appcache_response.h" | 8 #include "content/browser/appcache/appcache_response.h" |
9 #include "content/browser/appcache/appcache_storage.h" | 9 #include "content/browser/appcache/appcache_storage.h" |
10 #include "content/browser/appcache/mock_appcache_service.h" | 10 #include "content/browser/appcache/mock_appcache_service.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 class MockAppCacheStorageTest : public testing::Test { | 15 class MockAppCacheStorageTest : public testing::Test { |
16 public: | 16 public: |
17 class MockStorageDelegate : public AppCacheStorage::Delegate { | 17 class MockStorageDelegate : public AppCacheStorage::Delegate { |
18 public: | 18 public: |
19 explicit MockStorageDelegate() | 19 explicit MockStorageDelegate() |
20 : loaded_cache_id_(0), stored_group_success_(false), | 20 : loaded_cache_id_(0), stored_group_success_(false), |
21 obsoleted_success_(false), found_cache_id_(kAppCacheNoCacheId) { | 21 obsoleted_success_(false), found_cache_id_(kAppCacheNoCacheId) { |
22 } | 22 } |
23 | 23 |
24 virtual void OnCacheLoaded(AppCache* cache, int64 cache_id) OVERRIDE { | 24 virtual void OnCacheLoaded(AppCache* cache, int64 cache_id) override { |
25 loaded_cache_ = cache; | 25 loaded_cache_ = cache; |
26 loaded_cache_id_ = cache_id; | 26 loaded_cache_id_ = cache_id; |
27 } | 27 } |
28 | 28 |
29 virtual void OnGroupLoaded(AppCacheGroup* group, | 29 virtual void OnGroupLoaded(AppCacheGroup* group, |
30 const GURL& manifest_url) OVERRIDE { | 30 const GURL& manifest_url) override { |
31 loaded_group_ = group; | 31 loaded_group_ = group; |
32 loaded_manifest_url_ = manifest_url; | 32 loaded_manifest_url_ = manifest_url; |
33 } | 33 } |
34 | 34 |
35 virtual void OnGroupAndNewestCacheStored( | 35 virtual void OnGroupAndNewestCacheStored( |
36 AppCacheGroup* group, AppCache* newest_cache, bool success, | 36 AppCacheGroup* group, AppCache* newest_cache, bool success, |
37 bool would_exceed_quota) OVERRIDE { | 37 bool would_exceed_quota) override { |
38 stored_group_ = group; | 38 stored_group_ = group; |
39 stored_group_success_ = success; | 39 stored_group_success_ = success; |
40 } | 40 } |
41 | 41 |
42 virtual void OnGroupMadeObsolete(AppCacheGroup* group, | 42 virtual void OnGroupMadeObsolete(AppCacheGroup* group, |
43 bool success, | 43 bool success, |
44 int response_code) OVERRIDE { | 44 int response_code) override { |
45 obsoleted_group_ = group; | 45 obsoleted_group_ = group; |
46 obsoleted_success_ = success; | 46 obsoleted_success_ = success; |
47 } | 47 } |
48 | 48 |
49 virtual void OnMainResponseFound(const GURL& url, | 49 virtual void OnMainResponseFound(const GURL& url, |
50 const AppCacheEntry& entry, | 50 const AppCacheEntry& entry, |
51 const GURL& fallback_url, | 51 const GURL& fallback_url, |
52 const AppCacheEntry& fallback_entry, | 52 const AppCacheEntry& fallback_entry, |
53 int64 cache_id, | 53 int64 cache_id, |
54 int64 group_id, | 54 int64 group_id, |
55 const GURL& manifest_url) OVERRIDE { | 55 const GURL& manifest_url) override { |
56 found_url_ = url; | 56 found_url_ = url; |
57 found_entry_ = entry; | 57 found_entry_ = entry; |
58 found_fallback_url_ = fallback_url; | 58 found_fallback_url_ = fallback_url; |
59 found_fallback_entry_ = fallback_entry; | 59 found_fallback_entry_ = fallback_entry; |
60 found_cache_id_ = cache_id; | 60 found_cache_id_ = cache_id; |
61 found_manifest_url_ = manifest_url; | 61 found_manifest_url_ = manifest_url; |
62 } | 62 } |
63 | 63 |
64 scoped_refptr<AppCache> loaded_cache_; | 64 scoped_refptr<AppCache> loaded_cache_; |
65 int64 loaded_cache_id_; | 65 int64 loaded_cache_id_; |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 EXPECT_EQ(kAppCacheNoCacheId, delegate.found_cache_id_); | 625 EXPECT_EQ(kAppCacheNoCacheId, delegate.found_cache_id_); |
626 EXPECT_EQ(kAppCacheNoResponseId, delegate.found_entry_.response_id()); | 626 EXPECT_EQ(kAppCacheNoResponseId, delegate.found_entry_.response_id()); |
627 EXPECT_EQ(kAppCacheNoResponseId, | 627 EXPECT_EQ(kAppCacheNoResponseId, |
628 delegate.found_fallback_entry_.response_id()); | 628 delegate.found_fallback_entry_.response_id()); |
629 EXPECT_TRUE(delegate.found_fallback_url_.is_empty()); | 629 EXPECT_TRUE(delegate.found_fallback_url_.is_empty()); |
630 EXPECT_EQ(0, delegate.found_entry_.types()); | 630 EXPECT_EQ(0, delegate.found_entry_.types()); |
631 EXPECT_EQ(0, delegate.found_fallback_entry_.types()); | 631 EXPECT_EQ(0, delegate.found_fallback_entry_.types()); |
632 } | 632 } |
633 | 633 |
634 } // namespace content | 634 } // namespace content |
OLD | NEW |