OLD | NEW |
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_service.h" | 5 #include "chrome/browser/engagement/site_engagement_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 TEST_F(SiteEngagementServiceTest, CleanupMovesScoreBackToRebase) { | 1679 TEST_F(SiteEngagementServiceTest, CleanupMovesScoreBackToRebase) { |
1680 base::SimpleTestClock* clock = new base::SimpleTestClock(); | 1680 base::SimpleTestClock* clock = new base::SimpleTestClock(); |
1681 std::unique_ptr<SiteEngagementService> service( | 1681 std::unique_ptr<SiteEngagementService> service( |
1682 new SiteEngagementService(profile(), base::WrapUnique(clock))); | 1682 new SiteEngagementService(profile(), base::WrapUnique(clock))); |
1683 base::Time last_engagement_time; | 1683 base::Time last_engagement_time; |
1684 | 1684 |
1685 base::Time current_day = GetReferenceTime(); | 1685 base::Time current_day = GetReferenceTime(); |
1686 clock->SetNow(current_day); | 1686 clock->SetNow(current_day); |
1687 | 1687 |
1688 GURL origin("http://www.google.com/"); | 1688 GURL origin("http://www.google.com/"); |
1689 service->ResetScoreForURL(origin, 5); | 1689 service->ResetBaseScoreForURL(origin, 5); |
1690 service->AddPoints(origin, 5); | 1690 service->AddPoints(origin, 5); |
1691 EXPECT_EQ(10, service->GetScore(origin)); | 1691 EXPECT_EQ(10, service->GetScore(origin)); |
1692 EXPECT_EQ(current_day, service->GetLastEngagementTime()); | 1692 EXPECT_EQ(current_day, service->GetLastEngagementTime()); |
1693 | 1693 |
1694 // Send the clock back in time before the stale period and add engagement for | 1694 // Send the clock back in time before the stale period and add engagement for |
1695 // a new origin. | 1695 // a new origin. |
1696 base::Time before_stale_period = | 1696 base::Time before_stale_period = |
1697 clock->Now() - service->GetStalePeriod() - service->GetMaxDecayPeriod(); | 1697 clock->Now() - service->GetStalePeriod() - service->GetMaxDecayPeriod(); |
1698 clock->SetNow(before_stale_period); | 1698 clock->SetNow(before_stale_period); |
1699 | 1699 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 | 1809 |
1810 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::IO, | 1810 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::IO, |
1811 settings_map, url1)); | 1811 settings_map, url1)); |
1812 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::FILE, | 1812 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::FILE, |
1813 settings_map, url2)); | 1813 settings_map, url2)); |
1814 EXPECT_EQ(4, CheckScoreFromSettingsOnThread(content::BrowserThread::FILE, | 1814 EXPECT_EQ(4, CheckScoreFromSettingsOnThread(content::BrowserThread::FILE, |
1815 incognito_settings_map, url1)); | 1815 incognito_settings_map, url1)); |
1816 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::IO, | 1816 EXPECT_EQ(3, CheckScoreFromSettingsOnThread(content::BrowserThread::IO, |
1817 incognito_settings_map, url2)); | 1817 incognito_settings_map, url2)); |
1818 } | 1818 } |
OLD | NEW |