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

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: address comment 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 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 19c948e8d020a7fb32787ed4c4b57253db2fdf32..abef52d2889d1320c9c34232d5b2dcc824be2e21 100644
--- a/chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc
+++ b/chrome/browser/engagement/site_engagement_eviction_policy_unittest.cc
@@ -57,9 +57,15 @@ class SiteEngagementEvictionPolicyTest : public testing::Test {
~SiteEngagementEvictionPolicyTest() override {}
- GURL CalculateEvictionOrigin(const std::map<GURL, int64>& usage) {
+ GURL CalculateEvictionOriginWithExceptions(const std::map<GURL, int64>& usage,
+ 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 CalculateEvictionOriginWithExceptions(usage, std::set<GURL>());
}
TestSiteEngagementScoreProvider* score_provider() {
@@ -137,3 +143,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, CalculateEvictionOriginWithExceptions(usage, exceptions));
+}
« 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