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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_quota_helper_unittest.cc

Issue 13357004: Clear browsing data clears data for type kStorageTypeTemporary but not for kStorageTypeSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again Created 7 years, 8 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 MessageLoop::current()->RunUntilIdle(); 135 MessageLoop::current()->RunUntilIdle();
136 EXPECT_TRUE(fetching_completed()); 136 EXPECT_TRUE(fetching_completed());
137 EXPECT_TRUE(quota_info().empty()); 137 EXPECT_TRUE(quota_info().empty());
138 } 138 }
139 139
140 TEST_F(BrowsingDataQuotaHelperTest, FetchData) { 140 TEST_F(BrowsingDataQuotaHelperTest, FetchData) {
141 const quota::MockOriginData kOrigins[] = { 141 const quota::MockOriginData kOrigins[] = {
142 {"http://example.com/", quota::kStorageTypeTemporary, 1}, 142 {"http://example.com/", quota::kStorageTypeTemporary, 1},
143 {"https://example.com/", quota::kStorageTypeTemporary, 10}, 143 {"https://example.com/", quota::kStorageTypeTemporary, 10},
144 {"http://example.com/", quota::kStorageTypePersistent, 100}, 144 {"http://example.com/", quota::kStorageTypePersistent, 100},
145 {"https://example.com/", quota::kStorageTypeSyncable, 1},
145 {"http://example2.com/", quota::kStorageTypeTemporary, 1000}, 146 {"http://example2.com/", quota::kStorageTypeTemporary, 1000},
146 }; 147 };
147 148
148 RegisterClient(kOrigins, arraysize(kOrigins)); 149 RegisterClient(kOrigins, arraysize(kOrigins));
149 StartFetching(); 150 StartFetching();
150 MessageLoop::current()->RunUntilIdle(); 151 MessageLoop::current()->RunUntilIdle();
151 EXPECT_TRUE(fetching_completed()); 152 EXPECT_TRUE(fetching_completed());
152 153
153 std::set<QuotaInfo> expected, actual; 154 std::set<QuotaInfo> expected, actual;
154 actual.insert(quota_info().begin(), quota_info().end()); 155 actual.insert(quota_info().begin(), quota_info().end());
155 expected.insert(QuotaInfo("example.com", 11, 100)); 156 expected.insert(QuotaInfo("example.com", 11, 100, 1));
156 expected.insert(QuotaInfo("example2.com", 1000, 0)); 157 expected.insert(QuotaInfo("example2.com", 1000, 0, 0));
157 EXPECT_TRUE(expected == actual); 158 EXPECT_TRUE(expected == actual);
158 } 159 }
159 160
160 TEST_F(BrowsingDataQuotaHelperTest, IgnoreExtensionsAndDevTools) { 161 TEST_F(BrowsingDataQuotaHelperTest, IgnoreExtensionsAndDevTools) {
161 const quota::MockOriginData kOrigins[] = { 162 const quota::MockOriginData kOrigins[] = {
162 {"http://example.com/", quota::kStorageTypeTemporary, 1}, 163 {"http://example.com/", quota::kStorageTypeTemporary, 1},
163 {"https://example.com/", quota::kStorageTypeTemporary, 10}, 164 {"https://example.com/", quota::kStorageTypeTemporary, 10},
164 {"http://example.com/", quota::kStorageTypePersistent, 100}, 165 {"http://example.com/", quota::kStorageTypePersistent, 100},
166 {"https://example.com/", quota::kStorageTypeSyncable, 1},
165 {"http://example2.com/", quota::kStorageTypeTemporary, 1000}, 167 {"http://example2.com/", quota::kStorageTypeTemporary, 1000},
166 {"chrome-extension://abcdefghijklmnopqrstuvwxyz/", 168 {"chrome-extension://abcdefghijklmnopqrstuvwxyz/",
167 quota::kStorageTypeTemporary, 10000}, 169 quota::kStorageTypeTemporary, 10000},
168 {"chrome-extension://abcdefghijklmnopqrstuvwxyz/", 170 {"chrome-extension://abcdefghijklmnopqrstuvwxyz/",
169 quota::kStorageTypePersistent, 100000}, 171 quota::kStorageTypePersistent, 100000},
170 {"chrome-devtools://abcdefghijklmnopqrstuvwxyz/", 172 {"chrome-devtools://abcdefghijklmnopqrstuvwxyz/",
171 quota::kStorageTypeTemporary, 10000}, 173 quota::kStorageTypeTemporary, 10000},
172 {"chrome-devtools://abcdefghijklmnopqrstuvwxyz/", 174 {"chrome-devtools://abcdefghijklmnopqrstuvwxyz/",
173 quota::kStorageTypePersistent, 100000}, 175 quota::kStorageTypePersistent, 100000},
174 }; 176 };
175 177
176 RegisterClient(kOrigins, arraysize(kOrigins)); 178 RegisterClient(kOrigins, arraysize(kOrigins));
177 StartFetching(); 179 StartFetching();
178 MessageLoop::current()->RunUntilIdle(); 180 MessageLoop::current()->RunUntilIdle();
179 EXPECT_TRUE(fetching_completed()); 181 EXPECT_TRUE(fetching_completed());
180 182
181 std::set<QuotaInfo> expected, actual; 183 std::set<QuotaInfo> expected, actual;
182 actual.insert(quota_info().begin(), quota_info().end()); 184 actual.insert(quota_info().begin(), quota_info().end());
183 expected.insert(QuotaInfo("example.com", 11, 100)); 185 expected.insert(QuotaInfo("example.com", 11, 100, 1));
184 expected.insert(QuotaInfo("example2.com", 1000, 0)); 186 expected.insert(QuotaInfo("example2.com", 1000, 0, 0));
185 EXPECT_TRUE(expected == actual); 187 EXPECT_TRUE(expected == actual);
186 } 188 }
187 189
188 TEST_F(BrowsingDataQuotaHelperTest, RevokeHostQuota) { 190 TEST_F(BrowsingDataQuotaHelperTest, RevokeHostQuota) {
189 const std::string kHost1("example1.com"); 191 const std::string kHost1("example1.com");
190 const std::string kHost2("example2.com"); 192 const std::string kHost2("example2.com");
191 193
192 SetPersistentHostQuota(kHost1, 1); 194 SetPersistentHostQuota(kHost1, 1);
193 SetPersistentHostQuota(kHost2, 10); 195 SetPersistentHostQuota(kHost2, 10);
194 MessageLoop::current()->RunUntilIdle(); 196 MessageLoop::current()->RunUntilIdle();
195 197
196 RevokeHostQuota(kHost1); 198 RevokeHostQuota(kHost1);
197 MessageLoop::current()->RunUntilIdle(); 199 MessageLoop::current()->RunUntilIdle();
198 200
199 GetPersistentHostQuota(kHost1); 201 GetPersistentHostQuota(kHost1);
200 MessageLoop::current()->RunUntilIdle(); 202 MessageLoop::current()->RunUntilIdle();
201 EXPECT_EQ(0, quota()); 203 EXPECT_EQ(0, quota());
202 204
203 GetPersistentHostQuota(kHost2); 205 GetPersistentHostQuota(kHost2);
204 MessageLoop::current()->RunUntilIdle(); 206 MessageLoop::current()->RunUntilIdle();
205 EXPECT_EQ(10, quota()); 207 EXPECT_EQ(10, quota());
206 } 208 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_quota_helper_impl.cc ('k') | chrome/browser/browsing_data/browsing_data_remover.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698