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

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

Issue 1650983002: Add an IsBootstrapped method to the SiteEngagementService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@adjust_constants
Patch Set: address comments Created 4 years, 10 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 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 NavigateWithTransitionAndExpectEqualScore(service, url, 1052 NavigateWithTransitionAndExpectEqualScore(service, url,
1053 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); 1053 ui::PAGE_TRANSITION_AUTO_TOPLEVEL);
1054 NavigateWithTransitionAndExpectEqualScore(service, url, 1054 NavigateWithTransitionAndExpectEqualScore(service, url,
1055 ui::PAGE_TRANSITION_LINK); 1055 ui::PAGE_TRANSITION_LINK);
1056 NavigateWithTransitionAndExpectEqualScore(service, url, 1056 NavigateWithTransitionAndExpectEqualScore(service, url,
1057 ui::PAGE_TRANSITION_RELOAD); 1057 ui::PAGE_TRANSITION_RELOAD);
1058 NavigateWithTransitionAndExpectEqualScore(service, url, 1058 NavigateWithTransitionAndExpectEqualScore(service, url,
1059 ui::PAGE_TRANSITION_FORM_SUBMIT); 1059 ui::PAGE_TRANSITION_FORM_SUBMIT);
1060 } 1060 }
1061 1061
1062 TEST_F(SiteEngagementServiceTest, IsBootstrapped) {
1063 base::SimpleTestClock* clock = new base::SimpleTestClock();
1064 scoped_ptr<SiteEngagementService> service(
1065 new SiteEngagementService(profile(), make_scoped_ptr(clock)));
1066
1067 base::Time current_day = GetReferenceTime();
1068 clock->SetNow(current_day);
1069
1070 GURL url1("https://www.google.com/");
1071 GURL url2("https://www.somewhereelse.com/");
1072
1073 EXPECT_FALSE(service->IsBootstrapped());
1074
1075 service->AddPoints(url1, 5.0);
1076 EXPECT_FALSE(service->IsBootstrapped());
1077
1078 service->AddPoints(url2, 5.0);
1079 EXPECT_TRUE(service->IsBootstrapped());
1080
1081 clock->SetNow(current_day + base::TimeDelta::FromDays(10));
1082 EXPECT_FALSE(service->IsBootstrapped());
1083 }
1084
1062 TEST_F(SiteEngagementServiceTest, CleanupOriginsOnHistoryDeletion) { 1085 TEST_F(SiteEngagementServiceTest, CleanupOriginsOnHistoryDeletion) {
1063 SiteEngagementService* engagement = 1086 SiteEngagementService* engagement =
1064 SiteEngagementServiceFactory::GetForProfile(profile()); 1087 SiteEngagementServiceFactory::GetForProfile(profile());
1065 ASSERT_TRUE(engagement); 1088 ASSERT_TRUE(engagement);
1066 1089
1067 GURL origin1("http://www.google.com/"); 1090 GURL origin1("http://www.google.com/");
1068 GURL origin1a("http://www.google.com/search?q=asdf"); 1091 GURL origin1a("http://www.google.com/search?q=asdf");
1069 GURL origin2("https://drive.google.com/"); 1092 GURL origin2("https://drive.google.com/");
1070 GURL origin2a("https://drive.google.com/somedoc"); 1093 GURL origin2a("https://drive.google.com/somedoc");
1071 GURL origin3("http://notdeleted.com/"); 1094 GURL origin3("http://notdeleted.com/");
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 &task_tracker); 1149 &task_tracker);
1127 waiter.Wait(); 1150 waiter.Wait();
1128 1151
1129 // Only origin3 remains. 1152 // Only origin3 remains.
1130 EXPECT_EQ(0, engagement->GetScore(origin1)); 1153 EXPECT_EQ(0, engagement->GetScore(origin1));
1131 EXPECT_EQ(0, engagement->GetScore(origin2)); 1154 EXPECT_EQ(0, engagement->GetScore(origin2));
1132 EXPECT_EQ(5.0, engagement->GetScore(origin3)); 1155 EXPECT_EQ(5.0, engagement->GetScore(origin3));
1133 EXPECT_EQ(5.0, engagement->GetTotalEngagementPoints()); 1156 EXPECT_EQ(5.0, engagement->GetTotalEngagementPoints());
1134 } 1157 }
1135 } 1158 }
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