OLD | NEW |
---|---|
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 Profile* profile = browser()->profile(); | 245 Profile* profile = browser()->profile(); |
246 CacheCounter counter(profile); | 246 CacheCounter counter(profile); |
247 counter.Init( | 247 counter.Init( |
248 profile->GetPrefs(), | 248 profile->GetPrefs(), |
249 base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); | 249 base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); |
250 counter.Restart(); | 250 counter.Restart(); |
251 | 251 |
252 EXPECT_FALSE(counter.Pending()); | 252 EXPECT_FALSE(counter.Pending()); |
253 } | 253 } |
254 | 254 |
255 // Tests that the counting is restarted when the time period changes. Currently, | 255 // Tests that the counting is restarted when the time period changes. |
msramek
2016/12/15 15:58:50
Can you add tests for the new behavior?
At minimu
dullweber
2016/12/16 16:41:10
I added a test that sets timeout to 0 and checks i
| |
256 // the results should be the same for every period. This is because the counter | |
257 // always counts the size of the entire cache, and it is up to the UI | |
258 // to interpret it as exact value or upper bound. | |
259 IN_PROC_BROWSER_TEST_F(CacheCounterTest, PeriodChanged) { | 256 IN_PROC_BROWSER_TEST_F(CacheCounterTest, PeriodChanged) { |
260 CreateCacheEntry(); | 257 CreateCacheEntry(); |
261 | 258 |
262 Profile* profile = browser()->profile(); | 259 Profile* profile = browser()->profile(); |
263 CacheCounter counter(profile); | 260 CacheCounter counter(profile); |
264 counter.Init( | 261 counter.Init( |
265 profile->GetPrefs(), | 262 profile->GetPrefs(), |
266 base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); | 263 base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); |
267 | 264 |
268 SetDeletionPeriodPref(browsing_data::LAST_HOUR); | 265 SetDeletionPeriodPref(browsing_data::LAST_HOUR); |
(...skipping 11 matching lines...) Expand all Loading... | |
280 SetDeletionPeriodPref(browsing_data::FOUR_WEEKS); | 277 SetDeletionPeriodPref(browsing_data::FOUR_WEEKS); |
281 WaitForIOThread(); | 278 WaitForIOThread(); |
282 EXPECT_EQ(result, GetResult()); | 279 EXPECT_EQ(result, GetResult()); |
283 | 280 |
284 SetDeletionPeriodPref(browsing_data::ALL_TIME); | 281 SetDeletionPeriodPref(browsing_data::ALL_TIME); |
285 WaitForIOThread(); | 282 WaitForIOThread(); |
286 EXPECT_EQ(result, GetResult()); | 283 EXPECT_EQ(result, GetResult()); |
287 } | 284 } |
288 | 285 |
289 } // namespace | 286 } // namespace |
OLD | NEW |