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

Side by Side Diff: chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc

Issue 1343273003: Integrate SiteEngagementEvictionPolicy with QuotaManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_eviction_policy
Patch Set: address comments Created 5 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "base/files/scoped_temp_dir.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/weak_ptr.h"
8 #include "base/run_loop.h"
9 #include "base/thread_task_runner_handle.h"
5 #include "chrome/browser/engagement/site_engagement_eviction_policy.h" 10 #include "chrome/browser/engagement/site_engagement_eviction_policy.h"
6 #include "chrome/browser/engagement/site_engagement_service.h" 11 #include "chrome/browser/engagement/site_engagement_service.h"
7 #include "content/public/test/mock_special_storage_policy.h" 12 #include "content/public/test/mock_special_storage_policy.h"
13 #include "content/public/test/mock_storage_client.h"
14 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "storage/browser/quota/quota_manager.h"
16 #include "storage/browser/quota/quota_manager_proxy.h"
8 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
9 18
10 namespace { 19 namespace {
11 20
12 const int64 kGlobalQuota = 25 * 1024; 21 const int64 kGlobalQuota = 25 * 1024;
13 22
14 } // namespace 23 } // namespace
15 24
16 class TestSiteEngagementScoreProvider : public SiteEngagementScoreProvider { 25 class TestSiteEngagementScoreProvider : public SiteEngagementScoreProvider {
17 public: 26 public:
(...skipping 24 matching lines...) Expand all
42 51
43 class SiteEngagementEvictionPolicyTest : public testing::Test { 52 class SiteEngagementEvictionPolicyTest : public testing::Test {
44 public: 53 public:
45 SiteEngagementEvictionPolicyTest() 54 SiteEngagementEvictionPolicyTest()
46 : score_provider_(new TestSiteEngagementScoreProvider()), 55 : score_provider_(new TestSiteEngagementScoreProvider()),
47 storage_policy_(new content::MockSpecialStoragePolicy()) {} 56 storage_policy_(new content::MockSpecialStoragePolicy()) {}
48 57
49 ~SiteEngagementEvictionPolicyTest() override {} 58 ~SiteEngagementEvictionPolicyTest() override {}
50 59
51 GURL CalculateEvictionOrigin(const std::map<GURL, int64>& usage) { 60 GURL CalculateEvictionOrigin(const std::map<GURL, int64>& usage) {
52 return SiteEngagementEvictionPolicy::CalculateEvictionOrigin( 61 return SiteEngagementEvictionPolicy::CalculateEvictionOriginForTests(
53 storage_policy_, score_provider_.get(), usage, kGlobalQuota); 62 storage_policy_, score_provider_.get(), usage, kGlobalQuota);
54 } 63 }
55 64
56 TestSiteEngagementScoreProvider* score_provider() { 65 TestSiteEngagementScoreProvider* score_provider() {
57 return score_provider_.get(); 66 return score_provider_.get();
58 } 67 }
59 68
60 content::MockSpecialStoragePolicy* storage_policy() { 69 content::MockSpecialStoragePolicy* storage_policy() {
61 return storage_policy_.get(); 70 return storage_policy_.get();
62 } 71 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 EXPECT_EQ(url2, CalculateEvictionOrigin(usage)); 130 EXPECT_EQ(url2, CalculateEvictionOrigin(usage));
122 131
123 // Durable storage doesn't get evicted. 132 // Durable storage doesn't get evicted.
124 storage_policy()->AddDurable(url2); 133 storage_policy()->AddDurable(url2);
125 EXPECT_EQ(url1, CalculateEvictionOrigin(usage)); 134 EXPECT_EQ(url1, CalculateEvictionOrigin(usage));
126 135
127 // Unlimited storage doesn't get evicted. 136 // Unlimited storage doesn't get evicted.
128 storage_policy()->AddUnlimited(url1); 137 storage_policy()->AddUnlimited(url1);
129 EXPECT_EQ(GURL(), CalculateEvictionOrigin(usage)); 138 EXPECT_EQ(GURL(), CalculateEvictionOrigin(usage));
130 } 139 }
OLDNEW
« no previous file with comments | « chrome/browser/engagement/site_engagement_eviction_policy.cc ('k') | content/browser/quota/quota_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698