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

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

Issue 2626223002: Show the exact cache size for time ranges if supported (Closed)
Patch Set: rebase Created 3 years, 11 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 // Note that this file only tests the basic behavior of the cache counter, as in 5 // Note that this file only tests the basic behavior of the cache counter, as in
6 // when it counts and when not, when result is nonzero and when not. It does not 6 // when it counts and when not, when result is nonzero and when not. It does not
7 // test whether the result of the counting is correct. This is the 7 // test whether the result of the counting is correct. This is the
8 // responsibility of a lower layer, and is tested in 8 // responsibility of a lower layer, and is tested in
9 // DiskCacheBackendTest.CalculateSizeOfAllEntries in net_unittests. 9 // DiskCacheBackendTest.CalculateSizeOfAllEntries in net_unittests.
10 10
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 CacheCounter counter(profile); 236 CacheCounter counter(profile);
237 counter.Init( 237 counter.Init(
238 profile->GetPrefs(), 238 profile->GetPrefs(),
239 base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); 239 base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this)));
240 SetCacheDeletionPref(true); 240 SetCacheDeletionPref(true);
241 241
242 WaitForIOThread(); 242 WaitForIOThread();
243 EXPECT_EQ(0u, GetResult()); 243 EXPECT_EQ(0u, GetResult());
244 } 244 }
245 245
246 // Tests that the counting is restarted when the time period changes. Currently, 246 // Tests that the counting is restarted when the time period changes.
247 // the results should be the same for every period. This is because the counter
248 // always counts the size of the entire cache, and it is up to the UI
249 // to interpret it as exact value or upper bound.
250 IN_PROC_BROWSER_TEST_F(CacheCounterTest, PeriodChanged) { 247 IN_PROC_BROWSER_TEST_F(CacheCounterTest, PeriodChanged) {
251 CreateCacheEntry(); 248 CreateCacheEntry();
252 249
253 Profile* profile = browser()->profile(); 250 Profile* profile = browser()->profile();
254 CacheCounter counter(profile); 251 CacheCounter counter(profile);
255 counter.Init( 252 counter.Init(
256 profile->GetPrefs(), 253 profile->GetPrefs(),
257 base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); 254 base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this)));
258 255
259 SetDeletionPeriodPref(browsing_data::LAST_HOUR); 256 SetDeletionPeriodPref(browsing_data::LAST_HOUR);
260 WaitForIOThread(); 257 WaitForIOThread();
261 browsing_data::BrowsingDataCounter::ResultInt result = GetResult(); 258 browsing_data::BrowsingDataCounter::ResultInt result = GetResult();
262 EXPECT_TRUE(IsUpperLimit());
263 259
264 SetDeletionPeriodPref(browsing_data::LAST_DAY); 260 SetDeletionPeriodPref(browsing_data::LAST_DAY);
265 WaitForIOThread(); 261 WaitForIOThread();
266 EXPECT_EQ(result, GetResult()); 262 EXPECT_EQ(result, GetResult());
267 EXPECT_TRUE(IsUpperLimit());
268 263
269 SetDeletionPeriodPref(browsing_data::LAST_WEEK); 264 SetDeletionPeriodPref(browsing_data::LAST_WEEK);
270 WaitForIOThread(); 265 WaitForIOThread();
271 EXPECT_EQ(result, GetResult()); 266 EXPECT_EQ(result, GetResult());
272 EXPECT_TRUE(IsUpperLimit());
273 267
274 SetDeletionPeriodPref(browsing_data::FOUR_WEEKS); 268 SetDeletionPeriodPref(browsing_data::FOUR_WEEKS);
275 WaitForIOThread(); 269 WaitForIOThread();
276 EXPECT_EQ(result, GetResult()); 270 EXPECT_EQ(result, GetResult());
277 EXPECT_TRUE(IsUpperLimit());
278 271
279 SetDeletionPeriodPref(browsing_data::ALL_TIME); 272 SetDeletionPeriodPref(browsing_data::ALL_TIME);
280 WaitForIOThread(); 273 WaitForIOThread();
281 EXPECT_EQ(result, GetResult()); 274 EXPECT_EQ(result, GetResult());
282 EXPECT_FALSE(IsUpperLimit()); 275 EXPECT_FALSE(IsUpperLimit());
283 } 276 }
284 277
285 } // namespace 278 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698