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

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

Issue 2623033003: Always show counters in the material design Clear Browsing Data dialog. (Closed)
Patch Set: iOS fix #2 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 counter does not count if the deletion preference is false.
247 IN_PROC_BROWSER_TEST_F(CacheCounterTest, PrefIsFalse) {
248 SetCacheDeletionPref(false);
249
250 Profile* profile = browser()->profile();
251 CacheCounter counter(profile);
252 counter.Init(
253 profile->GetPrefs(),
254 base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this)));
255 counter.Restart();
256
257 EXPECT_FALSE(counter.Pending());
258 }
259
260 // Tests that the counting is restarted when the time period changes. Currently, 246 // Tests that the counting is restarted when the time period changes. Currently,
261 // the results should be the same for every period. This is because the counter 247 // the results should be the same for every period. This is because the counter
262 // always counts the size of the entire cache, and it is up to the UI 248 // always counts the size of the entire cache, and it is up to the UI
263 // to interpret it as exact value or upper bound. 249 // to interpret it as exact value or upper bound.
264 IN_PROC_BROWSER_TEST_F(CacheCounterTest, PeriodChanged) { 250 IN_PROC_BROWSER_TEST_F(CacheCounterTest, PeriodChanged) {
265 CreateCacheEntry(); 251 CreateCacheEntry();
266 252
267 Profile* profile = browser()->profile(); 253 Profile* profile = browser()->profile();
268 CacheCounter counter(profile); 254 CacheCounter counter(profile);
269 counter.Init( 255 counter.Init(
(...skipping 20 matching lines...) Expand all
290 EXPECT_EQ(result, GetResult()); 276 EXPECT_EQ(result, GetResult());
291 EXPECT_TRUE(IsUpperLimit()); 277 EXPECT_TRUE(IsUpperLimit());
292 278
293 SetDeletionPeriodPref(browsing_data::ALL_TIME); 279 SetDeletionPeriodPref(browsing_data::ALL_TIME);
294 WaitForIOThread(); 280 WaitForIOThread();
295 EXPECT_EQ(result, GetResult()); 281 EXPECT_EQ(result, GetResult());
296 EXPECT_FALSE(IsUpperLimit()); 282 EXPECT_FALSE(IsUpperLimit());
297 } 283 }
298 284
299 } // namespace 285 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/cache_counter.cc ('k') | chrome/browser/browsing_data/history_counter_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698