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/timer/mock_timer.h" | 7 #include "base/timer/mock_timer.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_service.h" | 10 #include "chrome/browser/engagement/site_engagement_service.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // be called in tests. | 22 // be called in tests. |
23 scoped_ptr<SiteEngagementHelper> CreateHelper( | 23 scoped_ptr<SiteEngagementHelper> CreateHelper( |
24 content::WebContents* web_contents) { | 24 content::WebContents* web_contents) { |
25 scoped_ptr<SiteEngagementHelper> helper( | 25 scoped_ptr<SiteEngagementHelper> helper( |
26 new SiteEngagementHelper(web_contents)); | 26 new SiteEngagementHelper(web_contents)); |
27 DCHECK(helper.get()); | 27 DCHECK(helper.get()); |
28 | 28 |
29 return helper.Pass(); | 29 return helper.Pass(); |
30 } | 30 } |
31 | 31 |
32 void StartTracking(SiteEngagementHelper* helper) { | 32 void TrackingStarted(SiteEngagementHelper* helper) { |
33 helper->input_tracker_.StartTracking(); | 33 helper->input_tracker_.TrackingStarted(); |
| 34 helper->media_tracker_.TrackingStarted(); |
34 } | 35 } |
35 | 36 |
36 // Simulate a user interaction event and handle it. | 37 // Simulate a user interaction event and handle it. |
37 void HandleUserInput(SiteEngagementHelper* helper, | 38 void HandleUserInput(SiteEngagementHelper* helper, |
38 blink::WebInputEvent::Type type) { | 39 blink::WebInputEvent::Type type) { |
39 helper->input_tracker_.DidGetUserInteraction(type); | 40 helper->input_tracker_.DidGetUserInteraction(type); |
40 } | 41 } |
41 | 42 |
42 // Simulate a user interaction event and handle it. Reactivates tracking | 43 // Simulate a user interaction event and handle it. Reactivates tracking |
43 // immediately. | 44 // immediately. |
44 void HandleUserInputAndRestartTracking(SiteEngagementHelper* helper, | 45 void HandleUserInputAndRestartTracking(SiteEngagementHelper* helper, |
45 blink::WebInputEvent::Type type) { | 46 blink::WebInputEvent::Type type) { |
46 helper->input_tracker_.DidGetUserInteraction(type); | 47 helper->input_tracker_.DidGetUserInteraction(type); |
47 helper->input_tracker_.StartTracking(); | 48 helper->input_tracker_.TrackingStarted(); |
| 49 } |
| 50 |
| 51 void HandleMediaPlaying(SiteEngagementHelper* helper, bool is_hidden) { |
| 52 helper->RecordMediaPlaying(is_hidden); |
| 53 } |
| 54 |
| 55 void MediaStartedPlaying(SiteEngagementHelper* helper) { |
| 56 helper->media_tracker_.MediaStartedPlaying(); |
| 57 } |
| 58 |
| 59 void MediaPaused(SiteEngagementHelper* helper) { |
| 60 helper->media_tracker_.MediaPaused(); |
48 } | 61 } |
49 | 62 |
50 // Set a pause timer on the input tracker for test purposes. | 63 // Set a pause timer on the input tracker for test purposes. |
51 void SetInputTrackerPauseTimer(SiteEngagementHelper* helper, | 64 void SetInputTrackerPauseTimer(SiteEngagementHelper* helper, |
52 scoped_ptr<base::Timer> timer) { | 65 scoped_ptr<base::Timer> timer) { |
53 helper->input_tracker_.SetPauseTimerForTesting(timer.Pass()); | 66 helper->input_tracker_.SetPauseTimerForTesting(timer.Pass()); |
54 } | 67 } |
55 | 68 |
56 bool IsTracking(SiteEngagementHelper* helper) { | 69 bool IsTracking(SiteEngagementHelper* helper) { |
57 return helper->input_tracker_.is_tracking(); | 70 return helper->input_tracker_.is_tracking(); |
(...skipping 15 matching lines...) Expand all Loading... |
73 content::WebContents* web_contents = | 86 content::WebContents* web_contents = |
74 browser()->tab_strip_model()->GetActiveWebContents(); | 87 browser()->tab_strip_model()->GetActiveWebContents(); |
75 | 88 |
76 scoped_ptr<SiteEngagementHelper> helper(CreateHelper(web_contents)); | 89 scoped_ptr<SiteEngagementHelper> helper(CreateHelper(web_contents)); |
77 SiteEngagementService* service = | 90 SiteEngagementService* service = |
78 SiteEngagementServiceFactory::GetForProfile(browser()->profile()); | 91 SiteEngagementServiceFactory::GetForProfile(browser()->profile()); |
79 DCHECK(service); | 92 DCHECK(service); |
80 | 93 |
81 // Check that navigation triggers engagement. | 94 // Check that navigation triggers engagement. |
82 NavigateWithDisposition(url1, CURRENT_TAB); | 95 NavigateWithDisposition(url1, CURRENT_TAB); |
83 StartTracking(helper.get()); | 96 TrackingStarted(helper.get()); |
84 | 97 |
85 EXPECT_DOUBLE_EQ(0.5, service->GetScore(url1)); | 98 EXPECT_DOUBLE_EQ(0.5, service->GetScore(url1)); |
86 EXPECT_EQ(0, service->GetScore(url2)); | 99 EXPECT_EQ(0, service->GetScore(url2)); |
87 | 100 |
88 // Simulate a user input trigger and ensure it is treated correctly. | 101 // Simulate a user input trigger and ensure it is treated correctly. |
89 HandleUserInputAndRestartTracking(helper.get(), type); | 102 HandleUserInputAndRestartTracking(helper.get(), type); |
90 | 103 |
91 EXPECT_DOUBLE_EQ(0.55, service->GetScore(url1)); | 104 EXPECT_DOUBLE_EQ(0.55, service->GetScore(url1)); |
92 EXPECT_EQ(0, service->GetScore(url2)); | 105 EXPECT_EQ(0, service->GetScore(url2)); |
93 | 106 |
94 // Simulate three inputs , and ensure they are treated correctly. | 107 // Simulate three inputs , and ensure they are treated correctly. |
95 HandleUserInputAndRestartTracking(helper.get(), type); | 108 HandleUserInputAndRestartTracking(helper.get(), type); |
96 HandleUserInputAndRestartTracking(helper.get(), type); | 109 HandleUserInputAndRestartTracking(helper.get(), type); |
97 HandleUserInputAndRestartTracking(helper.get(), type); | 110 HandleUserInputAndRestartTracking(helper.get(), type); |
98 | 111 |
99 EXPECT_DOUBLE_EQ(0.7, service->GetScore(url1)); | 112 EXPECT_DOUBLE_EQ(0.7, service->GetScore(url1)); |
100 EXPECT_EQ(0, service->GetScore(url2)); | 113 EXPECT_EQ(0, service->GetScore(url2)); |
101 | 114 |
102 // Simulate inputs for a different link. | 115 // Simulate inputs for a different link. |
103 NavigateWithDisposition(url2, CURRENT_TAB); | 116 NavigateWithDisposition(url2, CURRENT_TAB); |
104 StartTracking(helper.get()); | 117 TrackingStarted(helper.get()); |
105 | 118 |
106 EXPECT_DOUBLE_EQ(0.7, service->GetScore(url1)); | 119 EXPECT_DOUBLE_EQ(0.7, service->GetScore(url1)); |
107 EXPECT_DOUBLE_EQ(0.5, service->GetScore(url2)); | 120 EXPECT_DOUBLE_EQ(0.5, service->GetScore(url2)); |
108 EXPECT_DOUBLE_EQ(1.2, service->GetTotalEngagementPoints()); | 121 EXPECT_DOUBLE_EQ(1.2, service->GetTotalEngagementPoints()); |
109 | 122 |
110 HandleUserInputAndRestartTracking(helper.get(), type); | 123 HandleUserInputAndRestartTracking(helper.get(), type); |
111 EXPECT_DOUBLE_EQ(0.7, service->GetScore(url1)); | 124 EXPECT_DOUBLE_EQ(0.7, service->GetScore(url1)); |
112 EXPECT_DOUBLE_EQ(0.55, service->GetScore(url2)); | 125 EXPECT_DOUBLE_EQ(0.55, service->GetScore(url2)); |
113 EXPECT_DOUBLE_EQ(1.25, service->GetTotalEngagementPoints()); | 126 EXPECT_DOUBLE_EQ(1.25, service->GetTotalEngagementPoints()); |
114 } | 127 } |
115 }; | 128 }; |
116 | 129 |
117 TEST_F(SiteEngagementHelperTest, KeyPressEngagementAccumulation) { | 130 TEST_F(SiteEngagementHelperTest, KeyPressEngagementAccumulation) { |
118 UserInputAccumulation(blink::WebInputEvent::RawKeyDown); | 131 UserInputAccumulation(blink::WebInputEvent::RawKeyDown); |
119 } | 132 } |
120 | 133 |
121 TEST_F(SiteEngagementHelperTest, MouseDownEventEngagementAccumulation) { | 134 TEST_F(SiteEngagementHelperTest, MouseDownEventEngagementAccumulation) { |
122 UserInputAccumulation(blink::WebInputEvent::MouseDown); | 135 UserInputAccumulation(blink::WebInputEvent::MouseDown); |
123 } | 136 } |
124 | 137 |
125 TEST_F(SiteEngagementHelperTest, MouseWheelEventEngagementAccumulation) { | 138 TEST_F(SiteEngagementHelperTest, MouseWheelEventEngagementAccumulation) { |
126 UserInputAccumulation(blink::WebInputEvent::MouseWheel); | 139 UserInputAccumulation(blink::WebInputEvent::MouseWheel); |
127 } | 140 } |
128 | 141 |
129 TEST_F(SiteEngagementHelperTest, GestureEngagementAccumulation) { | 142 TEST_F(SiteEngagementHelperTest, GestureEngagementAccumulation) { |
130 UserInputAccumulation(blink::WebInputEvent::GestureTapDown); | 143 UserInputAccumulation(blink::WebInputEvent::GestureTapDown); |
131 } | 144 } |
132 | 145 |
| 146 TEST_F(SiteEngagementHelperTest, MediaEngagementAccumulation) { |
| 147 AddTab(browser(), GURL("about:blank")); |
| 148 GURL url1("https://www.google.com/"); |
| 149 GURL url2("http://www.google.com/"); |
| 150 content::WebContents* web_contents = |
| 151 browser()->tab_strip_model()->GetActiveWebContents(); |
| 152 |
| 153 scoped_ptr<SiteEngagementHelper> helper(CreateHelper(web_contents)); |
| 154 SiteEngagementService* service = |
| 155 SiteEngagementServiceFactory::GetForProfile(browser()->profile()); |
| 156 DCHECK(service); |
| 157 |
| 158 NavigateWithDisposition(url1, CURRENT_TAB); |
| 159 TrackingStarted(helper.get()); |
| 160 |
| 161 EXPECT_DOUBLE_EQ(0.5, service->GetScore(url1)); |
| 162 EXPECT_EQ(0, service->GetScore(url2)); |
| 163 |
| 164 // Simulate a foreground media input and ensure it is treated correctly. |
| 165 HandleMediaPlaying(helper.get(), false); |
| 166 |
| 167 EXPECT_DOUBLE_EQ(0.52, service->GetScore(url1)); |
| 168 EXPECT_EQ(0, service->GetScore(url2)); |
| 169 |
| 170 // Simulate continual media playing, and ensure it is treated correctly. |
| 171 HandleMediaPlaying(helper.get(), false); |
| 172 HandleMediaPlaying(helper.get(), false); |
| 173 HandleMediaPlaying(helper.get(), false); |
| 174 |
| 175 EXPECT_DOUBLE_EQ(0.58, service->GetScore(url1)); |
| 176 EXPECT_EQ(0, service->GetScore(url2)); |
| 177 |
| 178 // Simulate backgrounding the media. |
| 179 HandleMediaPlaying(helper.get(), true); |
| 180 HandleMediaPlaying(helper.get(), true); |
| 181 |
| 182 EXPECT_DOUBLE_EQ(0.60, service->GetScore(url1)); |
| 183 EXPECT_EQ(0, service->GetScore(url2)); |
| 184 |
| 185 // Simulate inputs for a different link. |
| 186 NavigateWithDisposition(url2, CURRENT_TAB); |
| 187 TrackingStarted(helper.get()); |
| 188 |
| 189 EXPECT_DOUBLE_EQ(0.6, service->GetScore(url1)); |
| 190 EXPECT_DOUBLE_EQ(0.5, service->GetScore(url2)); |
| 191 EXPECT_DOUBLE_EQ(1.1, service->GetTotalEngagementPoints()); |
| 192 |
| 193 HandleMediaPlaying(helper.get(), false); |
| 194 HandleMediaPlaying(helper.get(), false); |
| 195 EXPECT_DOUBLE_EQ(0.6, service->GetScore(url1)); |
| 196 EXPECT_DOUBLE_EQ(0.54, service->GetScore(url2)); |
| 197 EXPECT_DOUBLE_EQ(1.14, service->GetTotalEngagementPoints()); |
| 198 } |
| 199 |
| 200 TEST_F(SiteEngagementHelperTest, MediaEngagement) { |
| 201 AddTab(browser(), GURL("about:blank")); |
| 202 GURL url1("https://www.google.com/"); |
| 203 GURL url2("http://www.google.com/"); |
| 204 content::WebContents* web_contents = |
| 205 browser()->tab_strip_model()->GetActiveWebContents(); |
| 206 |
| 207 scoped_ptr<SiteEngagementHelper> helper(CreateHelper(web_contents)); |
| 208 SiteEngagementService* service = |
| 209 SiteEngagementServiceFactory::GetForProfile(browser()->profile()); |
| 210 DCHECK(service); |
| 211 |
| 212 NavigateWithDisposition(url1, CURRENT_TAB); |
| 213 // Start media playing before tracking begins |
| 214 MediaStartedPlaying(helper.get()); |
| 215 TrackingStarted(helper.get()); |
| 216 |
| 217 EXPECT_DOUBLE_EQ(0.52, service->GetScore(url1)); |
| 218 EXPECT_EQ(0, service->GetScore(url2)); |
| 219 } |
| 220 |
133 TEST_F(SiteEngagementHelperTest, MixedInputEngagementAccumulation) { | 221 TEST_F(SiteEngagementHelperTest, MixedInputEngagementAccumulation) { |
134 AddTab(browser(), GURL("about:blank")); | 222 AddTab(browser(), GURL("about:blank")); |
135 GURL url1("https://www.google.com/"); | 223 GURL url1("https://www.google.com/"); |
136 GURL url2("http://www.google.com/"); | 224 GURL url2("http://www.google.com/"); |
137 content::WebContents* web_contents = | 225 content::WebContents* web_contents = |
138 browser()->tab_strip_model()->GetActiveWebContents(); | 226 browser()->tab_strip_model()->GetActiveWebContents(); |
139 | 227 |
140 scoped_ptr<SiteEngagementHelper> helper(CreateHelper(web_contents)); | 228 scoped_ptr<SiteEngagementHelper> helper(CreateHelper(web_contents)); |
141 SiteEngagementService* service = | 229 SiteEngagementService* service = |
142 SiteEngagementServiceFactory::GetForProfile(browser()->profile()); | 230 SiteEngagementServiceFactory::GetForProfile(browser()->profile()); |
143 DCHECK(service); | 231 DCHECK(service); |
144 | 232 |
145 base::HistogramTester histograms; | 233 base::HistogramTester histograms; |
146 | 234 |
147 // Histograms should start off empty. | 235 // Histograms should start off empty. |
148 histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 236 histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
149 0); | 237 0); |
150 | 238 |
151 NavigateWithDisposition(url1, CURRENT_TAB); | 239 NavigateWithDisposition(url1, CURRENT_TAB); |
152 StartTracking(helper.get()); | 240 TrackingStarted(helper.get()); |
153 | 241 |
154 EXPECT_DOUBLE_EQ(0.5, service->GetScore(url1)); | 242 EXPECT_DOUBLE_EQ(0.5, service->GetScore(url1)); |
155 EXPECT_EQ(0, service->GetScore(url2)); | 243 EXPECT_EQ(0, service->GetScore(url2)); |
156 histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 244 histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
157 1); | 245 1); |
158 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 246 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
159 SiteEngagementMetrics::ENGAGEMENT_NAVIGATION, 1); | 247 SiteEngagementMetrics::ENGAGEMENT_NAVIGATION, 1); |
160 | 248 |
161 HandleUserInputAndRestartTracking(helper.get(), | 249 HandleUserInputAndRestartTracking(helper.get(), |
162 blink::WebInputEvent::RawKeyDown); | 250 blink::WebInputEvent::RawKeyDown); |
(...skipping 17 matching lines...) Expand all Loading... |
180 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 268 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
181 SiteEngagementMetrics::ENGAGEMENT_MOUSE, 1); | 269 SiteEngagementMetrics::ENGAGEMENT_MOUSE, 1); |
182 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 270 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
183 SiteEngagementMetrics::ENGAGEMENT_TOUCH_GESTURE, | 271 SiteEngagementMetrics::ENGAGEMENT_TOUCH_GESTURE, |
184 2); | 272 2); |
185 | 273 |
186 HandleUserInputAndRestartTracking(helper.get(), | 274 HandleUserInputAndRestartTracking(helper.get(), |
187 blink::WebInputEvent::MouseWheel); | 275 blink::WebInputEvent::MouseWheel); |
188 HandleUserInputAndRestartTracking(helper.get(), | 276 HandleUserInputAndRestartTracking(helper.get(), |
189 blink::WebInputEvent::MouseDown); | 277 blink::WebInputEvent::MouseDown); |
| 278 HandleMediaPlaying(helper.get(), true); |
190 HandleUserInputAndRestartTracking(helper.get(), | 279 HandleUserInputAndRestartTracking(helper.get(), |
191 blink::WebInputEvent::GestureTapDown); | 280 blink::WebInputEvent::GestureTapDown); |
| 281 HandleMediaPlaying(helper.get(), false); |
192 | 282 |
193 EXPECT_DOUBLE_EQ(0.9, service->GetScore(url1)); | 283 EXPECT_DOUBLE_EQ(0.93, service->GetScore(url1)); |
194 EXPECT_EQ(0, service->GetScore(url2)); | 284 EXPECT_EQ(0, service->GetScore(url2)); |
195 histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 285 histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
196 9); | 286 11); |
197 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 287 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
198 SiteEngagementMetrics::ENGAGEMENT_MOUSE, 2); | 288 SiteEngagementMetrics::ENGAGEMENT_MOUSE, 2); |
199 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 289 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
200 SiteEngagementMetrics::ENGAGEMENT_WHEEL, 1); | 290 SiteEngagementMetrics::ENGAGEMENT_WHEEL, 1); |
201 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 291 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
202 SiteEngagementMetrics::ENGAGEMENT_TOUCH_GESTURE, | 292 SiteEngagementMetrics::ENGAGEMENT_TOUCH_GESTURE, |
203 3); | 293 3); |
| 294 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
| 295 SiteEngagementMetrics::ENGAGEMENT_MEDIA_VISIBLE, |
| 296 1); |
| 297 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
| 298 SiteEngagementMetrics::ENGAGEMENT_MEDIA_HIDDEN, |
| 299 1); |
204 | 300 |
205 NavigateWithDisposition(url2, CURRENT_TAB); | 301 NavigateWithDisposition(url2, CURRENT_TAB); |
206 StartTracking(helper.get()); | 302 TrackingStarted(helper.get()); |
207 | 303 |
208 EXPECT_DOUBLE_EQ(0.9, service->GetScore(url1)); | 304 EXPECT_DOUBLE_EQ(0.93, service->GetScore(url1)); |
209 EXPECT_DOUBLE_EQ(0.5, service->GetScore(url2)); | 305 EXPECT_DOUBLE_EQ(0.5, service->GetScore(url2)); |
210 EXPECT_DOUBLE_EQ(1.4, service->GetTotalEngagementPoints()); | 306 EXPECT_DOUBLE_EQ(1.43, service->GetTotalEngagementPoints()); |
211 | 307 |
212 HandleUserInputAndRestartTracking(helper.get(), | 308 HandleUserInputAndRestartTracking(helper.get(), |
213 blink::WebInputEvent::GestureTapDown); | 309 blink::WebInputEvent::GestureTapDown); |
214 HandleUserInputAndRestartTracking(helper.get(), | 310 HandleUserInputAndRestartTracking(helper.get(), |
215 blink::WebInputEvent::RawKeyDown); | 311 blink::WebInputEvent::RawKeyDown); |
216 | 312 |
217 EXPECT_DOUBLE_EQ(0.9, service->GetScore(url1)); | 313 EXPECT_DOUBLE_EQ(0.93, service->GetScore(url1)); |
218 EXPECT_DOUBLE_EQ(0.6, service->GetScore(url2)); | 314 EXPECT_DOUBLE_EQ(0.6, service->GetScore(url2)); |
219 EXPECT_DOUBLE_EQ(1.5, service->GetTotalEngagementPoints()); | 315 EXPECT_DOUBLE_EQ(1.53, service->GetTotalEngagementPoints()); |
220 histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 316 histograms.ExpectTotalCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
221 12); | 317 14); |
222 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 318 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
223 SiteEngagementMetrics::ENGAGEMENT_NAVIGATION, 2); | 319 SiteEngagementMetrics::ENGAGEMENT_NAVIGATION, 2); |
224 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 320 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
225 SiteEngagementMetrics::ENGAGEMENT_KEYPRESS, 3); | 321 SiteEngagementMetrics::ENGAGEMENT_KEYPRESS, 3); |
226 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, | 322 histograms.ExpectBucketCount(SiteEngagementMetrics::kEngagementTypeHistogram, |
227 SiteEngagementMetrics::ENGAGEMENT_TOUCH_GESTURE, | 323 SiteEngagementMetrics::ENGAGEMENT_TOUCH_GESTURE, |
228 4); | 324 4); |
229 } | 325 } |
230 | 326 |
231 TEST_F(SiteEngagementHelperTest, CheckTimerAndCallbacks) { | 327 TEST_F(SiteEngagementHelperTest, CheckTimerAndCallbacks) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // When the timer fires, callbacks are added. | 455 // When the timer fires, callbacks are added. |
360 input_tracker_timer->Fire(); | 456 input_tracker_timer->Fire(); |
361 EXPECT_FALSE(input_tracker_timer->IsRunning()); | 457 EXPECT_FALSE(input_tracker_timer->IsRunning()); |
362 EXPECT_TRUE(IsTracking(helper.get())); | 458 EXPECT_TRUE(IsTracking(helper.get())); |
363 | 459 |
364 // Navigation should start the initial delay timer again. | 460 // Navigation should start the initial delay timer again. |
365 NavigateWithDisposition(url1, CURRENT_TAB); | 461 NavigateWithDisposition(url1, CURRENT_TAB); |
366 EXPECT_TRUE(input_tracker_timer->IsRunning()); | 462 EXPECT_TRUE(input_tracker_timer->IsRunning()); |
367 EXPECT_FALSE(IsTracking(helper.get())); | 463 EXPECT_FALSE(IsTracking(helper.get())); |
368 } | 464 } |
OLD | NEW |