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

Side by Side Diff: ios/chrome/browser/browsing_data/cache_counter_unittest.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
« no previous file with comments | « ios/chrome/browser/browsing_data/cache_counter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 CacheCounter counter(browser_state()); 273 CacheCounter counter(browser_state());
274 counter.Init(prefs(), base::Bind(&CacheCounterTest::CountingCallback, 274 counter.Init(prefs(), base::Bind(&CacheCounterTest::CountingCallback,
275 base::Unretained(this))); 275 base::Unretained(this)));
276 SetCacheDeletionPref(true); 276 SetCacheDeletionPref(true);
277 277
278 WaitForIOThread(); 278 WaitForIOThread();
279 EXPECT_EQ(0u, GetResult()); 279 EXPECT_EQ(0u, GetResult());
280 } 280 }
281 281
282 // Tests that the counter does not count if the deletion preference is false.
283 TEST_F(CacheCounterTest, PrefIsFalse) {
284 SetCacheDeletionPref(false);
285
286 CacheCounter counter(browser_state());
287 counter.Init(prefs(), base::Bind(&CacheCounterTest::CountingCallback,
288 base::Unretained(this)));
289 counter.Restart();
290
291 EXPECT_FALSE(counter.pending());
292 }
293
294 // Tests that the counting is restarted when the time period changes. Currently, 282 // Tests that the counting is restarted when the time period changes. Currently,
295 // the results should be the same for every period. This is because the counter 283 // the results should be the same for every period. This is because the counter
296 // always counts the size of the entire cache, and it is up to the UI 284 // always counts the size of the entire cache, and it is up to the UI
297 // to interpret it as exact value or upper bound. 285 // to interpret it as exact value or upper bound.
298 TEST_F(CacheCounterTest, PeriodChanged) { 286 TEST_F(CacheCounterTest, PeriodChanged) {
299 CreateCacheEntry(); 287 CreateCacheEntry();
300 288
301 CacheCounter counter(browser_state()); 289 CacheCounter counter(browser_state());
302 counter.Init(prefs(), base::Bind(&CacheCounterTest::CountingCallback, 290 counter.Init(prefs(), base::Bind(&CacheCounterTest::CountingCallback,
303 base::Unretained(this))); 291 base::Unretained(this)));
(...skipping 13 matching lines...) Expand all
317 SetDeletionPeriodPref(browsing_data::FOUR_WEEKS); 305 SetDeletionPeriodPref(browsing_data::FOUR_WEEKS);
318 WaitForIOThread(); 306 WaitForIOThread();
319 EXPECT_EQ(result, GetResult()); 307 EXPECT_EQ(result, GetResult());
320 308
321 SetDeletionPeriodPref(browsing_data::ALL_TIME); 309 SetDeletionPeriodPref(browsing_data::ALL_TIME);
322 WaitForIOThread(); 310 WaitForIOThread();
323 EXPECT_EQ(result, GetResult()); 311 EXPECT_EQ(result, GetResult());
324 } 312 }
325 313
326 } // namespace 314 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/browsing_data/cache_counter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698