OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "webkit/appcache/appcache.h" | 7 #include "webkit/appcache/appcache.h" |
8 #include "webkit/appcache/appcache_group.h" | 8 #include "webkit/appcache/appcache_group.h" |
9 #include "webkit/appcache/appcache_response.h" | 9 #include "webkit/appcache/appcache_response.h" |
10 #include "webkit/appcache/appcache_storage.h" | 10 #include "webkit/appcache/appcache_storage.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 }; | 24 }; |
25 }; | 25 }; |
26 | 26 |
27 TEST_F(AppCacheStorageTest, AddRemoveCache) { | 27 TEST_F(AppCacheStorageTest, AddRemoveCache) { |
28 MockAppCacheService service; | 28 MockAppCacheService service; |
29 scoped_refptr<AppCache> cache(new AppCache(&service, 111)); | 29 scoped_refptr<AppCache> cache(new AppCache(&service, 111)); |
30 | 30 |
31 EXPECT_EQ(cache.get(), | 31 EXPECT_EQ(cache.get(), |
32 service.storage()->working_set()->GetCache(111)); | 32 service.storage()->working_set()->GetCache(111)); |
33 | 33 |
34 service.storage()->working_set()->RemoveCache(cache); | 34 service.storage()->working_set()->RemoveCache(cache.get()); |
35 | 35 |
36 EXPECT_TRUE(!service.storage()->working_set()->GetCache(111)); | 36 EXPECT_TRUE(!service.storage()->working_set()->GetCache(111)); |
37 | 37 |
38 // Removing non-existing cache from service should not fail. | 38 // Removing non-existing cache from service should not fail. |
39 MockAppCacheService dummy; | 39 MockAppCacheService dummy; |
40 dummy.storage()->working_set()->RemoveCache(cache); | 40 dummy.storage()->working_set()->RemoveCache(cache.get()); |
41 } | 41 } |
42 | 42 |
43 TEST_F(AppCacheStorageTest, AddRemoveGroup) { | 43 TEST_F(AppCacheStorageTest, AddRemoveGroup) { |
44 MockAppCacheService service; | 44 MockAppCacheService service; |
45 scoped_refptr<AppCacheGroup> group(new AppCacheGroup(&service, GURL(), 111)); | 45 scoped_refptr<AppCacheGroup> group(new AppCacheGroup(&service, GURL(), 111)); |
46 | 46 |
47 EXPECT_EQ(group.get(), service.storage()->working_set()->GetGroup(GURL())); | 47 EXPECT_EQ(group.get(), service.storage()->working_set()->GetGroup(GURL())); |
48 | 48 |
49 service.storage()->working_set()->RemoveGroup(group); | 49 service.storage()->working_set()->RemoveGroup(group.get()); |
50 | 50 |
51 EXPECT_TRUE(!service.storage()->working_set()->GetGroup(GURL())); | 51 EXPECT_TRUE(!service.storage()->working_set()->GetGroup(GURL())); |
52 | 52 |
53 // Removing non-existing group from service should not fail. | 53 // Removing non-existing group from service should not fail. |
54 MockAppCacheService dummy; | 54 MockAppCacheService dummy; |
55 dummy.storage()->working_set()->RemoveGroup(group); | 55 dummy.storage()->working_set()->RemoveGroup(group.get()); |
56 } | 56 } |
57 | 57 |
58 TEST_F(AppCacheStorageTest, AddRemoveResponseInfo) { | 58 TEST_F(AppCacheStorageTest, AddRemoveResponseInfo) { |
59 MockAppCacheService service; | 59 MockAppCacheService service; |
60 scoped_refptr<AppCacheResponseInfo> info( | 60 scoped_refptr<AppCacheResponseInfo> info( |
61 new AppCacheResponseInfo(&service, GURL(), | 61 new AppCacheResponseInfo(&service, GURL(), |
62 111, new net::HttpResponseInfo, | 62 111, new net::HttpResponseInfo, |
63 kUnkownResponseDataSize)); | 63 kUnkownResponseDataSize)); |
64 | 64 |
65 EXPECT_EQ(info.get(), | 65 EXPECT_EQ(info.get(), |
66 service.storage()->working_set()->GetResponseInfo(111)); | 66 service.storage()->working_set()->GetResponseInfo(111)); |
67 | 67 |
68 service.storage()->working_set()->RemoveResponseInfo(info); | 68 service.storage()->working_set()->RemoveResponseInfo(info.get()); |
69 | 69 |
70 EXPECT_TRUE(!service.storage()->working_set()->GetResponseInfo(111)); | 70 EXPECT_TRUE(!service.storage()->working_set()->GetResponseInfo(111)); |
71 | 71 |
72 // Removing non-existing info from service should not fail. | 72 // Removing non-existing info from service should not fail. |
73 MockAppCacheService dummy; | 73 MockAppCacheService dummy; |
74 dummy.storage()->working_set()->RemoveResponseInfo(info); | 74 dummy.storage()->working_set()->RemoveResponseInfo(info.get()); |
75 } | 75 } |
76 | 76 |
77 TEST_F(AppCacheStorageTest, DelegateReferences) { | 77 TEST_F(AppCacheStorageTest, DelegateReferences) { |
78 typedef scoped_refptr<AppCacheStorage::DelegateReference> | 78 typedef scoped_refptr<AppCacheStorage::DelegateReference> |
79 ScopedDelegateReference; | 79 ScopedDelegateReference; |
80 MockAppCacheService service; | 80 MockAppCacheService service; |
81 MockStorageDelegate delegate; | 81 MockStorageDelegate delegate; |
82 ScopedDelegateReference delegate_reference1; | 82 ScopedDelegateReference delegate_reference1; |
83 ScopedDelegateReference delegate_reference2; | 83 ScopedDelegateReference delegate_reference2; |
84 | 84 |
(...skipping 27 matching lines...) Expand all Loading... |
112 EXPECT_NE(delegate_reference1.get(), delegate_reference2.get()); | 112 EXPECT_NE(delegate_reference1.get(), delegate_reference2.get()); |
113 } | 113 } |
114 | 114 |
115 TEST_F(AppCacheStorageTest, UsageMap) { | 115 TEST_F(AppCacheStorageTest, UsageMap) { |
116 const GURL kOrigin("http://origin/"); | 116 const GURL kOrigin("http://origin/"); |
117 const GURL kOrigin2("http://origin2/"); | 117 const GURL kOrigin2("http://origin2/"); |
118 | 118 |
119 MockAppCacheService service; | 119 MockAppCacheService service; |
120 scoped_refptr<quota::MockQuotaManagerProxy> mock_proxy( | 120 scoped_refptr<quota::MockQuotaManagerProxy> mock_proxy( |
121 new quota::MockQuotaManagerProxy(NULL, NULL)); | 121 new quota::MockQuotaManagerProxy(NULL, NULL)); |
122 service.set_quota_manager_proxy(mock_proxy); | 122 service.set_quota_manager_proxy(mock_proxy.get()); |
123 | 123 |
124 service.storage()->UpdateUsageMapAndNotify(kOrigin, 0); | 124 service.storage()->UpdateUsageMapAndNotify(kOrigin, 0); |
125 EXPECT_EQ(0, mock_proxy->notify_storage_modified_count()); | 125 EXPECT_EQ(0, mock_proxy->notify_storage_modified_count()); |
126 | 126 |
127 service.storage()->UpdateUsageMapAndNotify(kOrigin, 10); | 127 service.storage()->UpdateUsageMapAndNotify(kOrigin, 10); |
128 EXPECT_EQ(1, mock_proxy->notify_storage_modified_count()); | 128 EXPECT_EQ(1, mock_proxy->notify_storage_modified_count()); |
129 EXPECT_EQ(10, mock_proxy->last_notified_delta()); | 129 EXPECT_EQ(10, mock_proxy->last_notified_delta()); |
130 EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin()); | 130 EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin()); |
131 EXPECT_EQ(kTemp, mock_proxy->last_notified_type()); | 131 EXPECT_EQ(kTemp, mock_proxy->last_notified_type()); |
132 | 132 |
(...skipping 22 matching lines...) Expand all Loading... |
155 service.storage()->usage_map_[kOrigin] = 5000; | 155 service.storage()->usage_map_[kOrigin] = 5000; |
156 service.storage()->ClearUsageMapAndNotify(); | 156 service.storage()->ClearUsageMapAndNotify(); |
157 EXPECT_EQ(4, mock_proxy->notify_storage_modified_count()); | 157 EXPECT_EQ(4, mock_proxy->notify_storage_modified_count()); |
158 EXPECT_EQ(-5000, mock_proxy->last_notified_delta()); | 158 EXPECT_EQ(-5000, mock_proxy->last_notified_delta()); |
159 EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin()); | 159 EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin()); |
160 EXPECT_EQ(kTemp, mock_proxy->last_notified_type()); | 160 EXPECT_EQ(kTemp, mock_proxy->last_notified_type()); |
161 EXPECT_TRUE(service.storage()->usage_map_.empty()); | 161 EXPECT_TRUE(service.storage()->usage_map_.empty()); |
162 } | 162 } |
163 | 163 |
164 } // namespace appcache | 164 } // namespace appcache |
OLD | NEW |