| Index: chrome/browser/browsing_data/cache_counter_browsertest.cc
|
| diff --git a/chrome/browser/browsing_data/cache_counter_browsertest.cc b/chrome/browser/browsing_data/cache_counter_browsertest.cc
|
| index a953f7fb4a0f0cbd1953107c68704e0f9e78c9e9..aeb9656223b8657f5409d6a4cccad01ca1de78e6 100644
|
| --- a/chrome/browser/browsing_data/cache_counter_browsertest.cc
|
| +++ b/chrome/browser/browsing_data/cache_counter_browsertest.cc
|
| @@ -138,10 +138,9 @@ class CacheCounterTest : public InProcessBrowserTest {
|
| finished_ = result->Finished();
|
|
|
| if (finished_) {
|
| - result_ =
|
| - static_cast<browsing_data::BrowsingDataCounter::FinishedResult*>(
|
| - result.get())
|
| - ->Value();
|
| + auto cache_result = static_cast<CacheCounter::CacheResult*>(result.get());
|
| + result_ = cache_result->cache_size();
|
| + is_upper_limit_ = cache_result->is_upper_limit();
|
| }
|
|
|
| if (run_loop_ && finished_)
|
| @@ -153,6 +152,11 @@ class CacheCounterTest : public InProcessBrowserTest {
|
| return result_;
|
| }
|
|
|
| + bool IsUpperLimit() {
|
| + DCHECK(finished_);
|
| + return is_upper_limit_;
|
| + }
|
| +
|
| private:
|
| enum CacheEntryCreationStep {
|
| GET_CACHE,
|
| @@ -169,6 +173,7 @@ class CacheCounterTest : public InProcessBrowserTest {
|
|
|
| bool finished_;
|
| browsing_data::BrowsingDataCounter::ResultInt result_;
|
| + bool is_upper_limit_;
|
| };
|
|
|
| // Tests that for the empty cache, the result is zero.
|
| @@ -252,10 +257,7 @@ IN_PROC_BROWSER_TEST_F(CacheCounterTest, PrefIsFalse) {
|
| EXPECT_FALSE(counter.Pending());
|
| }
|
|
|
| -// Tests that the counting is restarted when the time period changes. Currently,
|
| -// the results should be the same for every period. This is because the counter
|
| -// always counts the size of the entire cache, and it is up to the UI
|
| -// to interpret it as exact value or upper bound.
|
| +// Tests that the counting is restarted when the time period changes.
|
| IN_PROC_BROWSER_TEST_F(CacheCounterTest, PeriodChanged) {
|
| CreateCacheEntry();
|
|
|
| @@ -268,22 +270,50 @@ IN_PROC_BROWSER_TEST_F(CacheCounterTest, PeriodChanged) {
|
| SetDeletionPeriodPref(browsing_data::LAST_HOUR);
|
| WaitForIOThread();
|
| browsing_data::BrowsingDataCounter::ResultInt result = GetResult();
|
| + EXPECT_FALSE(IsUpperLimit());
|
|
|
| SetDeletionPeriodPref(browsing_data::LAST_DAY);
|
| WaitForIOThread();
|
| EXPECT_EQ(result, GetResult());
|
| + EXPECT_FALSE(IsUpperLimit());
|
|
|
| SetDeletionPeriodPref(browsing_data::LAST_WEEK);
|
| WaitForIOThread();
|
| EXPECT_EQ(result, GetResult());
|
| + EXPECT_FALSE(IsUpperLimit());
|
|
|
| SetDeletionPeriodPref(browsing_data::FOUR_WEEKS);
|
| WaitForIOThread();
|
| EXPECT_EQ(result, GetResult());
|
| + EXPECT_FALSE(IsUpperLimit());
|
|
|
| SetDeletionPeriodPref(browsing_data::ALL_TIME);
|
| WaitForIOThread();
|
| EXPECT_EQ(result, GetResult());
|
| + EXPECT_FALSE(IsUpperLimit());
|
| +}
|
| +
|
| +// Tests the cache size is estimated if the timeout runs out.
|
| +IN_PROC_BROWSER_TEST_F(CacheCounterTest, Timeout) {
|
| + CreateCacheEntry();
|
| +
|
| + Profile* profile = browser()->profile();
|
| + CacheCounter counter(profile);
|
| + counter.SetTimeout(base::TimeDelta());
|
| + counter.Init(
|
| + profile->GetPrefs(),
|
| + base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this)));
|
| +
|
| + SetDeletionPeriodPref(browsing_data::LAST_DAY);
|
| + WaitForIOThread();
|
| + EXPECT_GT(GetResult(), 0);
|
| + EXPECT_TRUE(IsUpperLimit());
|
| +
|
| + // Even with a timeout of 0, ALL_TIME shouldn't be returned as upper limit.
|
| + SetDeletionPeriodPref(browsing_data::ALL_TIME);
|
| + WaitForIOThread();
|
| + EXPECT_GT(GetResult(), 0);
|
| + EXPECT_FALSE(IsUpperLimit());
|
| }
|
|
|
| } // namespace
|
|
|