Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: webkit/appcache/appcache_storage_unittest.cc

Issue 16155009: Update webkit/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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.storage(), 111)); 29 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 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( 45 scoped_refptr<AppCacheGroup> group(
46 new AppCacheGroup(service.storage(), GURL(), 111)); 46 new AppCacheGroup(service.storage(), GURL(), 111));
47 47
48 EXPECT_EQ(group.get(), service.storage()->working_set()->GetGroup(GURL())); 48 EXPECT_EQ(group.get(), service.storage()->working_set()->GetGroup(GURL()));
49 49
50 service.storage()->working_set()->RemoveGroup(group); 50 service.storage()->working_set()->RemoveGroup(group.get());
51 51
52 EXPECT_TRUE(!service.storage()->working_set()->GetGroup(GURL())); 52 EXPECT_TRUE(!service.storage()->working_set()->GetGroup(GURL()));
53 53
54 // Removing non-existing group from service should not fail. 54 // Removing non-existing group from service should not fail.
55 MockAppCacheService dummy; 55 MockAppCacheService dummy;
56 dummy.storage()->working_set()->RemoveGroup(group); 56 dummy.storage()->working_set()->RemoveGroup(group.get());
57 } 57 }
58 58
59 TEST_F(AppCacheStorageTest, AddRemoveResponseInfo) { 59 TEST_F(AppCacheStorageTest, AddRemoveResponseInfo) {
60 MockAppCacheService service; 60 MockAppCacheService service;
61 scoped_refptr<AppCacheResponseInfo> info( 61 scoped_refptr<AppCacheResponseInfo> info(
62 new AppCacheResponseInfo(&service, GURL(), 62 new AppCacheResponseInfo(&service, GURL(),
63 111, new net::HttpResponseInfo, 63 111, new net::HttpResponseInfo,
64 kUnkownResponseDataSize)); 64 kUnkownResponseDataSize));
65 65
66 EXPECT_EQ(info.get(), 66 EXPECT_EQ(info.get(),
67 service.storage()->working_set()->GetResponseInfo(111)); 67 service.storage()->working_set()->GetResponseInfo(111));
68 68
69 service.storage()->working_set()->RemoveResponseInfo(info); 69 service.storage()->working_set()->RemoveResponseInfo(info.get());
70 70
71 EXPECT_TRUE(!service.storage()->working_set()->GetResponseInfo(111)); 71 EXPECT_TRUE(!service.storage()->working_set()->GetResponseInfo(111));
72 72
73 // Removing non-existing info from service should not fail. 73 // Removing non-existing info from service should not fail.
74 MockAppCacheService dummy; 74 MockAppCacheService dummy;
75 dummy.storage()->working_set()->RemoveResponseInfo(info); 75 dummy.storage()->working_set()->RemoveResponseInfo(info.get());
76 } 76 }
77 77
78 TEST_F(AppCacheStorageTest, DelegateReferences) { 78 TEST_F(AppCacheStorageTest, DelegateReferences) {
79 typedef scoped_refptr<AppCacheStorage::DelegateReference> 79 typedef scoped_refptr<AppCacheStorage::DelegateReference>
80 ScopedDelegateReference; 80 ScopedDelegateReference;
81 MockAppCacheService service; 81 MockAppCacheService service;
82 MockStorageDelegate delegate; 82 MockStorageDelegate delegate;
83 ScopedDelegateReference delegate_reference1; 83 ScopedDelegateReference delegate_reference1;
84 ScopedDelegateReference delegate_reference2; 84 ScopedDelegateReference delegate_reference2;
85 85
(...skipping 27 matching lines...) Expand all
113 EXPECT_NE(delegate_reference1.get(), delegate_reference2.get()); 113 EXPECT_NE(delegate_reference1.get(), delegate_reference2.get());
114 } 114 }
115 115
116 TEST_F(AppCacheStorageTest, UsageMap) { 116 TEST_F(AppCacheStorageTest, UsageMap) {
117 const GURL kOrigin("http://origin/"); 117 const GURL kOrigin("http://origin/");
118 const GURL kOrigin2("http://origin2/"); 118 const GURL kOrigin2("http://origin2/");
119 119
120 MockAppCacheService service; 120 MockAppCacheService service;
121 scoped_refptr<quota::MockQuotaManagerProxy> mock_proxy( 121 scoped_refptr<quota::MockQuotaManagerProxy> mock_proxy(
122 new quota::MockQuotaManagerProxy(NULL, NULL)); 122 new quota::MockQuotaManagerProxy(NULL, NULL));
123 service.set_quota_manager_proxy(mock_proxy); 123 service.set_quota_manager_proxy(mock_proxy.get());
124 124
125 service.storage()->UpdateUsageMapAndNotify(kOrigin, 0); 125 service.storage()->UpdateUsageMapAndNotify(kOrigin, 0);
126 EXPECT_EQ(0, mock_proxy->notify_storage_modified_count()); 126 EXPECT_EQ(0, mock_proxy->notify_storage_modified_count());
127 127
128 service.storage()->UpdateUsageMapAndNotify(kOrigin, 10); 128 service.storage()->UpdateUsageMapAndNotify(kOrigin, 10);
129 EXPECT_EQ(1, mock_proxy->notify_storage_modified_count()); 129 EXPECT_EQ(1, mock_proxy->notify_storage_modified_count());
130 EXPECT_EQ(10, mock_proxy->last_notified_delta()); 130 EXPECT_EQ(10, mock_proxy->last_notified_delta());
131 EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin()); 131 EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin());
132 EXPECT_EQ(kTemp, mock_proxy->last_notified_type()); 132 EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
133 133
(...skipping 22 matching lines...) Expand all
156 service.storage()->usage_map_[kOrigin] = 5000; 156 service.storage()->usage_map_[kOrigin] = 5000;
157 service.storage()->ClearUsageMapAndNotify(); 157 service.storage()->ClearUsageMapAndNotify();
158 EXPECT_EQ(4, mock_proxy->notify_storage_modified_count()); 158 EXPECT_EQ(4, mock_proxy->notify_storage_modified_count());
159 EXPECT_EQ(-5000, mock_proxy->last_notified_delta()); 159 EXPECT_EQ(-5000, mock_proxy->last_notified_delta());
160 EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin()); 160 EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin());
161 EXPECT_EQ(kTemp, mock_proxy->last_notified_type()); 161 EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
162 EXPECT_TRUE(service.storage()->usage_map_.empty()); 162 EXPECT_TRUE(service.storage()->usage_map_.empty());
163 } 163 }
164 164
165 } // namespace appcache 165 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_storage_impl_unittest.cc ('k') | webkit/appcache/appcache_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698