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

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

Issue 1376143003: Revert of Implement a site engagement score based on time-on-site. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/engagement/site_engagement_eviction_policy.h" 5 #include "chrome/browser/engagement/site_engagement_eviction_policy.h"
6 #include "chrome/browser/engagement/site_engagement_service.h" 6 #include "chrome/browser/engagement/site_engagement_service.h"
7 #include "content/public/test/mock_special_storage_policy.h" 7 #include "content/public/test/mock_special_storage_policy.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace { 10 namespace {
11 11
12 const int64 kGlobalQuota = 25 * 1024; 12 const int64 kGlobalQuota = 25 * 1024;
13 13
14 } // namespace 14 } // namespace
15 15
16 class TestSiteEngagementScoreProvider : public SiteEngagementScoreProvider { 16 class TestSiteEngagementScoreProvider : public SiteEngagementScoreProvider {
17 public: 17 public:
18 TestSiteEngagementScoreProvider() {} 18 TestSiteEngagementScoreProvider() {}
19 19
20 virtual ~TestSiteEngagementScoreProvider() {} 20 virtual ~TestSiteEngagementScoreProvider() {}
21 21
22 double GetScore(const GURL& url) override { 22 int GetScore(const GURL& url) override { return engagement_score_map_[url]; }
23 return engagement_score_map_[url];
24 }
25 23
26 double GetTotalEngagementPoints() override { 24 int GetTotalEngagementPoints() override {
27 double total = 0; 25 int total = 0;
28 for (const auto& site : engagement_score_map_) 26 for (const auto& site : engagement_score_map_)
29 total += site.second; 27 total += site.second;
30 return total; 28 return total;
31 } 29 }
32 30
33 void SetScore(const GURL& origin, double score) { 31 void SetScore(const GURL& origin, int score) {
34 engagement_score_map_[origin] = score; 32 engagement_score_map_[origin] = score;
35 } 33 }
36 34
37 private: 35 private:
38 std::map<GURL, double> engagement_score_map_; 36 std::map<GURL, int> engagement_score_map_;
39 37
40 DISALLOW_COPY_AND_ASSIGN(TestSiteEngagementScoreProvider); 38 DISALLOW_COPY_AND_ASSIGN(TestSiteEngagementScoreProvider);
41 }; 39 };
42 40
43 class SiteEngagementEvictionPolicyTest : public testing::Test { 41 class SiteEngagementEvictionPolicyTest : public testing::Test {
44 public: 42 public:
45 SiteEngagementEvictionPolicyTest() 43 SiteEngagementEvictionPolicyTest()
46 : score_provider_(new TestSiteEngagementScoreProvider()), 44 : score_provider_(new TestSiteEngagementScoreProvider()),
47 storage_policy_(new content::MockSpecialStoragePolicy()) {} 45 storage_policy_(new content::MockSpecialStoragePolicy()) {}
48 46
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 EXPECT_EQ(url2, CalculateEvictionOrigin(usage)); 119 EXPECT_EQ(url2, CalculateEvictionOrigin(usage));
122 120
123 // Durable storage doesn't get evicted. 121 // Durable storage doesn't get evicted.
124 storage_policy()->AddDurable(url2); 122 storage_policy()->AddDurable(url2);
125 EXPECT_EQ(url1, CalculateEvictionOrigin(usage)); 123 EXPECT_EQ(url1, CalculateEvictionOrigin(usage));
126 124
127 // Unlimited storage doesn't get evicted. 125 // Unlimited storage doesn't get evicted.
128 storage_policy()->AddUnlimited(url1); 126 storage_policy()->AddUnlimited(url1);
129 EXPECT_EQ(GURL(), CalculateEvictionOrigin(usage)); 127 EXPECT_EQ(GURL(), CalculateEvictionOrigin(usage));
130 } 128 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698