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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/test/histogram_tester.h" | 6 #include "base/test/histogram_tester.h" |
7 #include "base/test/simple_test_clock.h" | 7 #include "base/test/simple_test_clock.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/engagement/site_engagement_helper.h" | 9 #include "chrome/browser/engagement/site_engagement_helper.h" |
10 #include "chrome/browser/engagement/site_engagement_metrics.h" | 10 #include "chrome/browser/engagement/site_engagement_metrics.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 EXPECT_TRUE(initial_score.UpdateScoreDict(score_dict)); | 86 EXPECT_TRUE(initial_score.UpdateScoreDict(score_dict)); |
87 SiteEngagementScore updated_score(&test_clock_, *score_dict); | 87 SiteEngagementScore updated_score(&test_clock_, *score_dict); |
88 VerifyScore(updated_score, 5, 10, different_day); | 88 VerifyScore(updated_score, 5, 10, different_day); |
89 } | 89 } |
90 | 90 |
91 base::SimpleTestClock test_clock_; | 91 base::SimpleTestClock test_clock_; |
92 SiteEngagementScore score_; | 92 SiteEngagementScore score_; |
93 }; | 93 }; |
94 | 94 |
95 // Accumulate score many times on the same day. Ensure each time the score goes | 95 // Accumulate score many times on the same day. Ensure each time the score goes |
96 // up by kNavigationPoints, but not more than kMaxPointsPerDay. | 96 // up by g_navigation_points, but not more than g_max_points_per_day. |
97 TEST_F(SiteEngagementScoreTest, AccumulateOnSameDay) { | 97 TEST_F(SiteEngagementScoreTest, AccumulateOnSameDay) { |
98 base::Time reference_time = GetReferenceTime(); | 98 base::Time reference_time = GetReferenceTime(); |
99 | 99 |
100 test_clock_.SetNow(reference_time); | 100 test_clock_.SetNow(reference_time); |
101 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { | 101 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { |
102 score_.AddPoints(SiteEngagementScore::kNavigationPoints); | 102 score_.AddPoints(SiteEngagementScore::g_navigation_points); |
103 EXPECT_EQ(std::min(SiteEngagementScore::kMaxPointsPerDay, | 103 EXPECT_EQ(std::min(SiteEngagementScore::g_max_points_per_day, |
104 (i + 1) * SiteEngagementScore::kNavigationPoints), | 104 (i + 1) * SiteEngagementScore::g_navigation_points), |
105 score_.Score()); | 105 score_.Score()); |
106 } | 106 } |
107 | 107 |
108 EXPECT_EQ(SiteEngagementScore::kMaxPointsPerDay, score_.Score()); | 108 EXPECT_EQ(SiteEngagementScore::g_max_points_per_day, score_.Score()); |
109 } | 109 } |
110 | 110 |
111 // Accumulate on the first day to max that day's engagement, then accumulate on | 111 // Accumulate on the first day to max that day's engagement, then accumulate on |
112 // a different day. | 112 // a different day. |
113 TEST_F(SiteEngagementScoreTest, AccumulateOnTwoDays) { | 113 TEST_F(SiteEngagementScoreTest, AccumulateOnTwoDays) { |
114 base::Time reference_time = GetReferenceTime(); | 114 base::Time reference_time = GetReferenceTime(); |
115 base::Time later_date = reference_time + base::TimeDelta::FromDays(2); | 115 base::Time later_date = reference_time + base::TimeDelta::FromDays(2); |
116 | 116 |
117 test_clock_.SetNow(reference_time); | 117 test_clock_.SetNow(reference_time); |
118 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) | 118 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) |
119 score_.AddPoints(SiteEngagementScore::kNavigationPoints); | 119 score_.AddPoints(SiteEngagementScore::g_navigation_points); |
120 | 120 |
121 EXPECT_EQ(SiteEngagementScore::kMaxPointsPerDay, score_.Score()); | 121 EXPECT_EQ(SiteEngagementScore::g_max_points_per_day, score_.Score()); |
122 | 122 |
123 test_clock_.SetNow(later_date); | 123 test_clock_.SetNow(later_date); |
124 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { | 124 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { |
125 score_.AddPoints(SiteEngagementScore::kNavigationPoints); | 125 score_.AddPoints(SiteEngagementScore::g_navigation_points); |
126 double day_score = | 126 double day_score = |
127 std::min(SiteEngagementScore::kMaxPointsPerDay, | 127 std::min(SiteEngagementScore::g_max_points_per_day, |
128 (i + 1) * SiteEngagementScore::kNavigationPoints); | 128 (i + 1) * SiteEngagementScore::g_navigation_points); |
129 EXPECT_EQ(day_score + SiteEngagementScore::kMaxPointsPerDay, | 129 EXPECT_EQ(day_score + SiteEngagementScore::g_max_points_per_day, |
130 score_.Score()); | 130 score_.Score()); |
131 } | 131 } |
132 | 132 |
133 EXPECT_EQ(2 * SiteEngagementScore::kMaxPointsPerDay, score_.Score()); | 133 EXPECT_EQ(2 * SiteEngagementScore::g_max_points_per_day, score_.Score()); |
134 } | 134 } |
135 | 135 |
136 // Accumulate score on many consecutive days and ensure the score doesn't exceed | 136 // Accumulate score on many consecutive days and ensure the score doesn't exceed |
137 // the maximum allowed. | 137 // the maximum allowed. |
138 TEST_F(SiteEngagementScoreTest, AccumulateALotOnManyDays) { | 138 TEST_F(SiteEngagementScoreTest, AccumulateALotOnManyDays) { |
139 base::Time current_day = GetReferenceTime(); | 139 base::Time current_day = GetReferenceTime(); |
140 | 140 |
141 for (int i = 0; i < kMoreDaysThanNeededToMaxTotalEngagement; ++i) { | 141 for (int i = 0; i < kMoreDaysThanNeededToMaxTotalEngagement; ++i) { |
142 current_day += base::TimeDelta::FromDays(1); | 142 current_day += base::TimeDelta::FromDays(1); |
143 test_clock_.SetNow(current_day); | 143 test_clock_.SetNow(current_day); |
144 for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) | 144 for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) |
145 score_.AddPoints(SiteEngagementScore::kNavigationPoints); | 145 score_.AddPoints(SiteEngagementScore::g_navigation_points); |
146 | 146 |
147 EXPECT_EQ(std::min(SiteEngagementScore::kMaxPoints, | 147 EXPECT_EQ(std::min(SiteEngagementScore::kMaxPoints, |
148 (i + 1) * SiteEngagementScore::kMaxPointsPerDay), | 148 (i + 1) * SiteEngagementScore::g_max_points_per_day), |
149 score_.Score()); | 149 score_.Score()); |
150 } | 150 } |
151 | 151 |
152 EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); | 152 EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); |
153 } | 153 } |
154 | 154 |
155 // Accumulate a little on many consecutive days and ensure the score doesn't | 155 // Accumulate a little on many consecutive days and ensure the score doesn't |
156 // exceed the maximum allowed. | 156 // exceed the maximum allowed. |
157 TEST_F(SiteEngagementScoreTest, AccumulateALittleOnManyDays) { | 157 TEST_F(SiteEngagementScoreTest, AccumulateALittleOnManyDays) { |
158 base::Time current_day = GetReferenceTime(); | 158 base::Time current_day = GetReferenceTime(); |
159 | 159 |
160 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxTotalEngagement; ++i) { | 160 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxTotalEngagement; ++i) { |
161 current_day += base::TimeDelta::FromDays(1); | 161 current_day += base::TimeDelta::FromDays(1); |
162 test_clock_.SetNow(current_day); | 162 test_clock_.SetNow(current_day); |
163 | 163 |
164 for (int j = 0; j < kLessAccumulationsThanNeededToMaxDailyEngagement; ++j) | 164 for (int j = 0; j < kLessAccumulationsThanNeededToMaxDailyEngagement; ++j) |
165 score_.AddPoints(SiteEngagementScore::kNavigationPoints); | 165 score_.AddPoints(SiteEngagementScore::g_navigation_points); |
166 | 166 |
167 EXPECT_EQ( | 167 EXPECT_EQ( |
168 std::min(SiteEngagementScore::kMaxPoints, | 168 std::min(SiteEngagementScore::kMaxPoints, |
169 (i + 1) * kLessAccumulationsThanNeededToMaxDailyEngagement * | 169 (i + 1) * kLessAccumulationsThanNeededToMaxDailyEngagement * |
170 SiteEngagementScore::kNavigationPoints), | 170 SiteEngagementScore::g_navigation_points), |
171 score_.Score()); | 171 score_.Score()); |
172 } | 172 } |
173 | 173 |
174 EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); | 174 EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); |
175 } | 175 } |
176 | 176 |
177 // Accumulate a bit, then check the score decays properly for a range of times. | 177 // Accumulate a bit, then check the score decays properly for a range of times. |
178 TEST_F(SiteEngagementScoreTest, ScoresDecayOverTime) { | 178 TEST_F(SiteEngagementScoreTest, ScoresDecayOverTime) { |
179 base::Time current_day = GetReferenceTime(); | 179 base::Time current_day = GetReferenceTime(); |
180 | 180 |
181 // First max the score. | 181 // First max the score. |
182 for (int i = 0; i < kMoreDaysThanNeededToMaxTotalEngagement; ++i) { | 182 for (int i = 0; i < kMoreDaysThanNeededToMaxTotalEngagement; ++i) { |
183 current_day += base::TimeDelta::FromDays(1); | 183 current_day += base::TimeDelta::FromDays(1); |
184 test_clock_.SetNow(current_day); | 184 test_clock_.SetNow(current_day); |
185 | 185 |
186 for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) | 186 for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) |
187 score_.AddPoints(SiteEngagementScore::kNavigationPoints); | 187 score_.AddPoints(SiteEngagementScore::g_navigation_points); |
188 } | 188 } |
189 | 189 |
190 EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); | 190 EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); |
191 | 191 |
192 // The score should not have decayed before the first decay period has | 192 // The score should not have decayed before the first decay period has |
193 // elapsed. | 193 // elapsed. |
194 test_clock_.SetNow( | 194 test_clock_.SetNow(current_day + |
195 current_day + | 195 base::TimeDelta::FromDays( |
196 base::TimeDelta::FromDays(SiteEngagementScore::kDecayPeriodInDays - 1)); | 196 SiteEngagementScore::g_decay_period_in_days - 1)); |
197 EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); | 197 EXPECT_EQ(SiteEngagementScore::kMaxPoints, score_.Score()); |
198 | 198 |
199 // The score should have decayed by one chunk after one decay period has | 199 // The score should have decayed by one chunk after one decay period has |
200 // elapsed. | 200 // elapsed. |
201 test_clock_.SetNow( | 201 test_clock_.SetNow( |
202 current_day + | 202 current_day + |
203 base::TimeDelta::FromDays(SiteEngagementScore::kDecayPeriodInDays)); | 203 base::TimeDelta::FromDays(SiteEngagementScore::g_decay_period_in_days)); |
204 EXPECT_EQ(SiteEngagementScore::kMaxPoints - SiteEngagementScore::kDecayPoints, | 204 EXPECT_EQ( |
205 score_.Score()); | 205 SiteEngagementScore::kMaxPoints - SiteEngagementScore::g_decay_points, |
| 206 score_.Score()); |
206 | 207 |
207 // The score should have decayed by the right number of chunks after a few | 208 // The score should have decayed by the right number of chunks after a few |
208 // decay periods have elapsed. | 209 // decay periods have elapsed. |
209 test_clock_.SetNow( | 210 test_clock_.SetNow( |
210 current_day + | 211 current_day + |
211 base::TimeDelta::FromDays(kLessPeriodsThanNeededToDecayMaxScore * | 212 base::TimeDelta::FromDays(kLessPeriodsThanNeededToDecayMaxScore * |
212 SiteEngagementScore::kDecayPeriodInDays)); | 213 SiteEngagementScore::g_decay_period_in_days)); |
213 EXPECT_EQ(SiteEngagementScore::kMaxPoints - | 214 EXPECT_EQ(SiteEngagementScore::kMaxPoints - |
214 kLessPeriodsThanNeededToDecayMaxScore * | 215 kLessPeriodsThanNeededToDecayMaxScore * |
215 SiteEngagementScore::kDecayPoints, | 216 SiteEngagementScore::g_decay_points, |
216 score_.Score()); | 217 score_.Score()); |
217 | 218 |
218 // The score should not decay below zero. | 219 // The score should not decay below zero. |
219 test_clock_.SetNow( | 220 test_clock_.SetNow( |
220 current_day + | 221 current_day + |
221 base::TimeDelta::FromDays(kMorePeriodsThanNeededToDecayMaxScore * | 222 base::TimeDelta::FromDays(kMorePeriodsThanNeededToDecayMaxScore * |
222 SiteEngagementScore::kDecayPeriodInDays)); | 223 SiteEngagementScore::g_decay_period_in_days)); |
223 EXPECT_EQ(0, score_.Score()); | 224 EXPECT_EQ(0, score_.Score()); |
224 } | 225 } |
225 | 226 |
226 // Test that any expected decays are applied before adding points. | 227 // Test that any expected decays are applied before adding points. |
227 TEST_F(SiteEngagementScoreTest, DecaysAppliedBeforeAdd) { | 228 TEST_F(SiteEngagementScoreTest, DecaysAppliedBeforeAdd) { |
228 base::Time current_day = GetReferenceTime(); | 229 base::Time current_day = GetReferenceTime(); |
229 | 230 |
230 // Get the score up to something that can handle a bit of decay before | 231 // Get the score up to something that can handle a bit of decay before |
231 for (int i = 0; i < kLessDaysThanNeededToMaxTotalEngagement; ++i) { | 232 for (int i = 0; i < kLessDaysThanNeededToMaxTotalEngagement; ++i) { |
232 current_day += base::TimeDelta::FromDays(1); | 233 current_day += base::TimeDelta::FromDays(1); |
233 test_clock_.SetNow(current_day); | 234 test_clock_.SetNow(current_day); |
234 | 235 |
235 for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) | 236 for (int j = 0; j < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++j) |
236 score_.AddPoints(SiteEngagementScore::kNavigationPoints); | 237 score_.AddPoints(SiteEngagementScore::g_navigation_points); |
237 } | 238 } |
238 | 239 |
239 double initial_score = kLessDaysThanNeededToMaxTotalEngagement * | 240 double initial_score = kLessDaysThanNeededToMaxTotalEngagement * |
240 SiteEngagementScore::kMaxPointsPerDay; | 241 SiteEngagementScore::g_max_points_per_day; |
241 EXPECT_EQ(initial_score, score_.Score()); | 242 EXPECT_EQ(initial_score, score_.Score()); |
242 | 243 |
243 // Go forward a few decay periods. | 244 // Go forward a few decay periods. |
244 test_clock_.SetNow( | 245 test_clock_.SetNow( |
245 current_day + | 246 current_day + |
246 base::TimeDelta::FromDays(kLessPeriodsThanNeededToDecayMaxScore * | 247 base::TimeDelta::FromDays(kLessPeriodsThanNeededToDecayMaxScore * |
247 SiteEngagementScore::kDecayPeriodInDays)); | 248 SiteEngagementScore::g_decay_period_in_days)); |
248 | 249 |
249 double decayed_score = | 250 double decayed_score = initial_score - |
250 initial_score - | 251 kLessPeriodsThanNeededToDecayMaxScore * |
251 kLessPeriodsThanNeededToDecayMaxScore * SiteEngagementScore::kDecayPoints; | 252 SiteEngagementScore::g_decay_points; |
252 EXPECT_EQ(decayed_score, score_.Score()); | 253 EXPECT_EQ(decayed_score, score_.Score()); |
253 | 254 |
254 // Now add some points. | 255 // Now add some points. |
255 score_.AddPoints(SiteEngagementScore::kNavigationPoints); | 256 score_.AddPoints(SiteEngagementScore::g_navigation_points); |
256 EXPECT_EQ(decayed_score + SiteEngagementScore::kNavigationPoints, | 257 EXPECT_EQ(decayed_score + SiteEngagementScore::g_navigation_points, |
257 score_.Score()); | 258 score_.Score()); |
258 } | 259 } |
259 | 260 |
260 // Test that going back in time is handled properly. | 261 // Test that going back in time is handled properly. |
261 TEST_F(SiteEngagementScoreTest, GoBackInTime) { | 262 TEST_F(SiteEngagementScoreTest, GoBackInTime) { |
262 base::Time current_day = GetReferenceTime(); | 263 base::Time current_day = GetReferenceTime(); |
263 | 264 |
264 test_clock_.SetNow(current_day); | 265 test_clock_.SetNow(current_day); |
265 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) | 266 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) |
266 score_.AddPoints(SiteEngagementScore::kNavigationPoints); | 267 score_.AddPoints(SiteEngagementScore::g_navigation_points); |
267 | 268 |
268 EXPECT_EQ(SiteEngagementScore::kMaxPointsPerDay, score_.Score()); | 269 EXPECT_EQ(SiteEngagementScore::g_max_points_per_day, score_.Score()); |
269 | 270 |
270 // Adding to the score on an earlier date should be treated like another day, | 271 // Adding to the score on an earlier date should be treated like another day, |
271 // and should not cause any decay. | 272 // and should not cause any decay. |
272 test_clock_.SetNow(current_day - base::TimeDelta::FromDays( | 273 test_clock_.SetNow(current_day - base::TimeDelta::FromDays( |
273 kMorePeriodsThanNeededToDecayMaxScore * | 274 kMorePeriodsThanNeededToDecayMaxScore * |
274 SiteEngagementScore::kDecayPoints)); | 275 SiteEngagementScore::g_decay_points)); |
275 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { | 276 for (int i = 0; i < kMoreAccumulationsThanNeededToMaxDailyEngagement; ++i) { |
276 score_.AddPoints(SiteEngagementScore::kNavigationPoints); | 277 score_.AddPoints(SiteEngagementScore::g_navigation_points); |
277 double day_score = | 278 double day_score = |
278 std::min(SiteEngagementScore::kMaxPointsPerDay, | 279 std::min(SiteEngagementScore::g_max_points_per_day, |
279 (i + 1) * SiteEngagementScore::kNavigationPoints); | 280 (i + 1) * SiteEngagementScore::g_navigation_points); |
280 EXPECT_EQ(day_score + SiteEngagementScore::kMaxPointsPerDay, | 281 EXPECT_EQ(day_score + SiteEngagementScore::g_max_points_per_day, |
281 score_.Score()); | 282 score_.Score()); |
282 } | 283 } |
283 | 284 |
284 EXPECT_EQ(2 * SiteEngagementScore::kMaxPointsPerDay, score_.Score()); | 285 EXPECT_EQ(2 * SiteEngagementScore::g_max_points_per_day, score_.Score()); |
285 } | 286 } |
286 | 287 |
287 // Test that scores are read / written correctly from / to empty score | 288 // Test that scores are read / written correctly from / to empty score |
288 // dictionaries. | 289 // dictionaries. |
289 TEST_F(SiteEngagementScoreTest, EmptyDictionary) { | 290 TEST_F(SiteEngagementScoreTest, EmptyDictionary) { |
290 base::DictionaryValue dict; | 291 base::DictionaryValue dict; |
291 TestScoreInitializesAndUpdates(&dict, 0, 0, base::Time()); | 292 TestScoreInitializesAndUpdates(&dict, 0, 0, base::Time()); |
292 } | 293 } |
293 | 294 |
294 // Test that scores are read / written correctly from / to partially empty | 295 // Test that scores are read / written correctly from / to partially empty |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 701 |
701 service->AddPoints(url1, 5.0); | 702 service->AddPoints(url1, 5.0); |
702 EXPECT_EQ(10.0, service->GetScore(url1)); | 703 EXPECT_EQ(10.0, service->GetScore(url1)); |
703 | 704 |
704 { | 705 { |
705 // Decay one origin to zero by advancing time and expect the engagement | 706 // Decay one origin to zero by advancing time and expect the engagement |
706 // score to be cleaned up. The other score was changed a day later so it | 707 // score to be cleaned up. The other score was changed a day later so it |
707 // will not have decayed at all. | 708 // will not have decayed at all. |
708 clock->SetNow( | 709 clock->SetNow( |
709 GetReferenceTime() + | 710 GetReferenceTime() + |
710 base::TimeDelta::FromDays(SiteEngagementScore::kDecayPeriodInDays)); | 711 base::TimeDelta::FromDays(SiteEngagementScore::g_decay_period_in_days)); |
711 | 712 |
712 std::map<GURL, double> score_map = service->GetScoreMap(); | 713 std::map<GURL, double> score_map = service->GetScoreMap(); |
713 EXPECT_EQ(2u, score_map.size()); | 714 EXPECT_EQ(2u, score_map.size()); |
714 EXPECT_EQ(10, score_map[url1]); | 715 EXPECT_EQ(10, score_map[url1]); |
715 EXPECT_EQ(0, score_map[url2]); | 716 EXPECT_EQ(0, score_map[url2]); |
716 | 717 |
717 service->CleanupEngagementScores(); | 718 service->CleanupEngagementScores(); |
718 | 719 |
719 score_map = service->GetScoreMap(); | 720 score_map = service->GetScoreMap(); |
720 EXPECT_EQ(1u, score_map.size()); | 721 EXPECT_EQ(1u, score_map.size()); |
721 EXPECT_EQ(10, score_map[url1]); | 722 EXPECT_EQ(10, score_map[url1]); |
722 EXPECT_EQ(0, service->GetScore(url2)); | 723 EXPECT_EQ(0, service->GetScore(url2)); |
723 } | 724 } |
724 | 725 |
725 { | 726 { |
726 // Decay the other origin to zero by advancing time and expect the | 727 // Decay the other origin to zero by advancing time and expect the |
727 // engagement score to be cleaned up. | 728 // engagement score to be cleaned up. |
728 clock->SetNow( | 729 clock->SetNow(GetReferenceTime() + |
729 GetReferenceTime() + | 730 base::TimeDelta::FromDays( |
730 base::TimeDelta::FromDays(3 * SiteEngagementScore::kDecayPeriodInDays)); | 731 3 * SiteEngagementScore::g_decay_period_in_days)); |
731 | 732 |
732 std::map<GURL, double> score_map = service->GetScoreMap(); | 733 std::map<GURL, double> score_map = service->GetScoreMap(); |
733 EXPECT_EQ(1u, score_map.size()); | 734 EXPECT_EQ(1u, score_map.size()); |
734 EXPECT_EQ(0, score_map[url1]); | 735 EXPECT_EQ(0, score_map[url1]); |
735 | 736 |
736 service->CleanupEngagementScores(); | 737 service->CleanupEngagementScores(); |
737 | 738 |
738 score_map = service->GetScoreMap(); | 739 score_map = service->GetScoreMap(); |
739 EXPECT_EQ(0u, score_map.size()); | 740 EXPECT_EQ(0u, score_map.size()); |
740 EXPECT_EQ(0, service->GetScore(url1)); | 741 EXPECT_EQ(0, service->GetScore(url1)); |
(...skipping 21 matching lines...) Expand all Loading... |
762 // Other transition types should not accumulate engagement. | 763 // Other transition types should not accumulate engagement. |
763 NavigateWithTransitionAndExpectEqualScore(service, url, | 764 NavigateWithTransitionAndExpectEqualScore(service, url, |
764 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); | 765 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); |
765 NavigateWithTransitionAndExpectEqualScore(service, url, | 766 NavigateWithTransitionAndExpectEqualScore(service, url, |
766 ui::PAGE_TRANSITION_LINK); | 767 ui::PAGE_TRANSITION_LINK); |
767 NavigateWithTransitionAndExpectEqualScore(service, url, | 768 NavigateWithTransitionAndExpectEqualScore(service, url, |
768 ui::PAGE_TRANSITION_RELOAD); | 769 ui::PAGE_TRANSITION_RELOAD); |
769 NavigateWithTransitionAndExpectEqualScore(service, url, | 770 NavigateWithTransitionAndExpectEqualScore(service, url, |
770 ui::PAGE_TRANSITION_FORM_SUBMIT); | 771 ui::PAGE_TRANSITION_FORM_SUBMIT); |
771 } | 772 } |
OLD | NEW |