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

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

Issue 2293793002: Make Site Engagement behave for adding 0 points. (Closed)
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/engagement/site_engagement_service.cc ('k') | no next file » | 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_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 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 base::Time rebased_time = current_day - service->GetMaxDecayPeriod(); 1452 base::Time rebased_time = current_day - service->GetMaxDecayPeriod();
1453 clock->SetNow(current_day); 1453 clock->SetNow(current_day);
1454 service->CleanupEngagementScores(true); 1454 service->CleanupEngagementScores(true);
1455 1455
1456 last_engagement_time = base::Time::FromInternalValue( 1456 last_engagement_time = base::Time::FromInternalValue(
1457 profile()->GetPrefs()->GetInt64(prefs::kSiteEngagementLastUpdateTime)); 1457 profile()->GetPrefs()->GetInt64(prefs::kSiteEngagementLastUpdateTime));
1458 1458
1459 EXPECT_EQ(rebased_time, last_engagement_time); 1459 EXPECT_EQ(rebased_time, last_engagement_time);
1460 EXPECT_EQ(rebased_time, service->GetLastEngagementTime()); 1460 EXPECT_EQ(rebased_time, service->GetLastEngagementTime());
1461 1461
1462 // Adding 0 points shouldn't update the last engagement time.
1463 base::Time later_in_day = current_day + base::TimeDelta::FromSeconds(30);
1464 clock->SetNow(later_in_day);
1465 service->AddPoints(origin, 0);
1466
1467 last_engagement_time = base::Time::FromInternalValue(
1468 profile()->GetPrefs()->GetInt64(prefs::kSiteEngagementLastUpdateTime));
1469 EXPECT_EQ(rebased_time, last_engagement_time);
1470 EXPECT_EQ(rebased_time, service->GetLastEngagementTime());
1471
1462 // Add some more points and ensure the value is persisted. 1472 // Add some more points and ensure the value is persisted.
1463 base::Time later_in_day = current_day + base::TimeDelta::FromSeconds(30);
1464 clock->SetNow(later_in_day);
1465 service->AddPoints(origin, 3); 1473 service->AddPoints(origin, 3);
1466 1474
1467 last_engagement_time = base::Time::FromInternalValue( 1475 last_engagement_time = base::Time::FromInternalValue(
1468 profile()->GetPrefs()->GetInt64(prefs::kSiteEngagementLastUpdateTime)); 1476 profile()->GetPrefs()->GetInt64(prefs::kSiteEngagementLastUpdateTime));
1469 1477
1470 EXPECT_EQ(later_in_day, last_engagement_time); 1478 EXPECT_EQ(later_in_day, last_engagement_time);
1471 EXPECT_EQ(later_in_day, service->GetLastEngagementTime()); 1479 EXPECT_EQ(later_in_day, service->GetLastEngagementTime());
1472 } 1480 }
1473 1481
1474 TEST_F(SiteEngagementServiceTest, IncognitoEngagementService) { 1482 TEST_F(SiteEngagementServiceTest, IncognitoEngagementService) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 1517
1510 std::map<GURL, double> score_map = incognito_service->GetScoreMap(); 1518 std::map<GURL, double> score_map = incognito_service->GetScoreMap();
1511 EXPECT_EQ(4u, score_map.size()); 1519 EXPECT_EQ(4u, score_map.size());
1512 EXPECT_EQ(1, score_map[url1]); 1520 EXPECT_EQ(1, score_map[url1]);
1513 EXPECT_EQ(3, score_map[url2]); 1521 EXPECT_EQ(3, score_map[url2]);
1514 EXPECT_EQ(1, score_map[url3]); 1522 EXPECT_EQ(1, score_map[url3]);
1515 EXPECT_EQ(2, score_map[url4]); 1523 EXPECT_EQ(2, score_map[url4]);
1516 1524
1517 EXPECT_EQ(7, incognito_service->GetTotalEngagementPoints()); 1525 EXPECT_EQ(7, incognito_service->GetTotalEngagementPoints());
1518 } 1526 }
OLDNEW
« no previous file with comments | « chrome/browser/engagement/site_engagement_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698