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

Unified Diff: chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc

Issue 1354543002: Exclude in-use origins from storage evictions for all QuotaEvictionPolicies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hook_it_up_gooood
Patch Set: rebase Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc
diff --git a/chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc b/chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc
index dcdf4191069bacb67f8049761ac573ce3e3e0d5b..3a3f9bd70f6916231df3f0f55533c3e289e22335 100644
--- a/chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc
+++ b/chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc
@@ -157,9 +157,15 @@ class SiteEngagementEvictionPolicyTest : public testing::Test {
~SiteEngagementEvictionPolicyTest() override {}
- GURL CalculateEvictionOrigin(const std::map<GURL, int64>& usage) {
+ GURL CalculateEvictionOrigin(const std::map<GURL, int64>& usage,
raymes 2015/09/22 07:16:10 nit: suggest renaming this to CalculatEvictionOrig
calamity 2015/09/23 01:55:21 Good call. Done.
+ const std::set<GURL>& exceptions) {
return SiteEngagementEvictionPolicy::CalculateEvictionOriginForTests(
- storage_policy_, score_provider_.get(), usage, kGlobalQuota);
+ storage_policy_, score_provider_.get(), exceptions, usage,
+ kGlobalQuota);
+ }
+
+ GURL CalculateEvictionOrigin(const std::map<GURL, int64>& usage) {
+ return CalculateEvictionOrigin(usage, std::set<GURL>());
}
TestSiteEngagementScoreProvider* score_provider() {
@@ -237,3 +243,22 @@ TEST_F(SiteEngagementEvictionPolicyTest, SpecialStoragePolicy) {
storage_policy()->AddUnlimited(url1);
EXPECT_EQ(GURL(), CalculateEvictionOrigin(usage));
}
+
+TEST_F(SiteEngagementEvictionPolicyTest, Exceptions) {
+ GURL url1("http://www.google.com");
+ GURL url2("http://www.example.com");
+
+ std::map<GURL, int64> usage;
+ usage[url1] = 10 * 1024;
+ usage[url2] = 10 * 1024;
+
+ score_provider()->SetScore(url1, 50);
+ score_provider()->SetScore(url2, 25);
+
+ EXPECT_EQ(url2, CalculateEvictionOrigin(usage));
+
+ // The policy should respect exceptions.
+ std::set<GURL> exceptions;
+ exceptions.insert(url2);
+ EXPECT_EQ(url1, CalculateEvictionOrigin(usage, exceptions));
+}

Powered by Google App Engine
This is Rietveld 408576698