OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test/histogram_tester.h" | 5 #include "base/test/histogram_tester.h" |
6 #include "components/rappor/public/rappor_utils.h" | 6 #include "components/rappor/public/rappor_utils.h" |
7 #include "components/rappor/test_rappor_service.h" | 7 #include "components/rappor/test_rappor_service.h" |
8 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" | 8 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker
.h" |
9 #include "content/common/input/synthetic_web_input_event_builders.h" | 9 #include "content/common/input/synthetic_web_input_event_builders.h" |
10 #include "content/public/browser/native_web_keyboard_event.h" | 10 #include "content/public/browser/native_web_keyboard_event.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToFirstScrollHistograms) { | 180 TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToFirstScrollHistograms) { |
181 const GURL url("http://www.foo.bar.com/subpage/1"); | 181 const GURL url("http://www.foo.bar.com/subpage/1"); |
182 contents()->NavigateAndCommit(url); | 182 contents()->NavigateAndCommit(url); |
183 for (bool rendering_on_main : {false, true}) { | 183 for (bool rendering_on_main : {false, true}) { |
184 for (bool is_running_navigation_hint_task : {false, true}) { | 184 for (bool is_running_navigation_hint_task : {false, true}) { |
185 ResetHistograms(); | 185 ResetHistograms(); |
186 { | 186 { |
187 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( | 187 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( |
188 blink::WebMouseWheelEvent::PhaseChanged); | 188 blink::WebMouseWheelEvent::PhaseChanged); |
189 base::TimeTicks now = base::TimeTicks::Now(); | 189 base::TimeTicks now = base::TimeTicks::Now(); |
190 wheel.timeStampSeconds = (now - base::TimeTicks()).InSecondsF(); | 190 wheel.setTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); |
191 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); | 191 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); |
192 wheel_latency.AddLatencyNumberWithTimestamp( | 192 wheel_latency.AddLatencyNumberWithTimestamp( |
193 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 193 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
194 tracker()->latency_component_id(), 0, now, 1); | 194 tracker()->latency_component_id(), 0, now, 1); |
195 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); | 195 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); |
196 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); | 196 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); |
197 tracker()->OnInputEvent(wheel, &wheel_latency); | 197 tracker()->OnInputEvent(wheel, &wheel_latency); |
198 EXPECT_TRUE(wheel_latency.FindLatency( | 198 EXPECT_TRUE(wheel_latency.FindLatency( |
199 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 199 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
200 tracker()->latency_component_id(), nullptr)); | 200 tracker()->latency_component_id(), nullptr)); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 275 } |
276 | 276 |
277 TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToScrollHistograms) { | 277 TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToScrollHistograms) { |
278 for (bool rendering_on_main : {false, true}) { | 278 for (bool rendering_on_main : {false, true}) { |
279 for (bool is_running_navigation_hint_task : {false, true}) { | 279 for (bool is_running_navigation_hint_task : {false, true}) { |
280 ResetHistograms(); | 280 ResetHistograms(); |
281 { | 281 { |
282 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( | 282 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( |
283 blink::WebMouseWheelEvent::PhaseChanged); | 283 blink::WebMouseWheelEvent::PhaseChanged); |
284 base::TimeTicks now = base::TimeTicks::Now(); | 284 base::TimeTicks now = base::TimeTicks::Now(); |
285 wheel.timeStampSeconds = (now - base::TimeTicks()).InSecondsF(); | 285 wheel.setTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); |
286 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); | 286 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); |
287 wheel_latency.AddLatencyNumberWithTimestamp( | 287 wheel_latency.AddLatencyNumberWithTimestamp( |
288 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 288 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
289 tracker()->latency_component_id(), 0, now, 1); | 289 tracker()->latency_component_id(), 0, now, 1); |
290 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); | 290 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); |
291 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); | 291 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); |
292 tracker()->OnInputEvent(wheel, &wheel_latency); | 292 tracker()->OnInputEvent(wheel, &wheel_latency); |
293 EXPECT_TRUE(wheel_latency.FindLatency( | 293 EXPECT_TRUE(wheel_latency.FindLatency( |
294 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 294 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
295 tracker()->latency_component_id(), nullptr)); | 295 tracker()->latency_component_id(), nullptr)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) { | 354 TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) { |
355 const GURL url("http://www.foo.bar.com/subpage/1"); | 355 const GURL url("http://www.foo.bar.com/subpage/1"); |
356 contents()->NavigateAndCommit(url); | 356 contents()->NavigateAndCommit(url); |
357 for (bool rendering_on_main : {false, true}) { | 357 for (bool rendering_on_main : {false, true}) { |
358 for (bool is_running_navigation_hint_task : {false, true}) { | 358 for (bool is_running_navigation_hint_task : {false, true}) { |
359 ResetHistograms(); | 359 ResetHistograms(); |
360 { | 360 { |
361 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( | 361 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( |
362 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen); | 362 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen); |
363 base::TimeTicks now = base::TimeTicks::Now(); | 363 base::TimeTicks now = base::TimeTicks::Now(); |
364 scroll.timeStampSeconds = (now - base::TimeTicks()).InSecondsF(); | 364 scroll.setTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); |
365 ui::LatencyInfo scroll_latency; | 365 ui::LatencyInfo scroll_latency; |
366 scroll_latency.AddLatencyNumberWithTimestamp( | 366 scroll_latency.AddLatencyNumberWithTimestamp( |
367 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 367 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
368 tracker()->latency_component_id(), 0, now, 1); | 368 tracker()->latency_component_id(), 0, now, 1); |
369 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); | 369 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); |
370 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); | 370 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); |
371 tracker()->OnInputEvent(scroll, &scroll_latency); | 371 tracker()->OnInputEvent(scroll, &scroll_latency); |
372 EXPECT_TRUE(scroll_latency.FindLatency( | 372 EXPECT_TRUE(scroll_latency.FindLatency( |
373 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 373 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
374 tracker()->latency_component_id(), nullptr)); | 374 tracker()->latency_component_id(), nullptr)); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 contents()->NavigateAndCommit(url); | 505 contents()->NavigateAndCommit(url); |
506 for (bool rendering_on_main : {false, true}) { | 506 for (bool rendering_on_main : {false, true}) { |
507 for (bool is_running_navigation_hint_task : {false, true}) { | 507 for (bool is_running_navigation_hint_task : {false, true}) { |
508 ResetHistograms(); | 508 ResetHistograms(); |
509 EXPECT_EQ(0, | 509 EXPECT_EQ(0, |
510 test_browser_client_.getTestRapporService()->GetReportsCount()); | 510 test_browser_client_.getTestRapporService()->GetReportsCount()); |
511 { | 511 { |
512 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( | 512 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( |
513 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen); | 513 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen); |
514 base::TimeTicks now = base::TimeTicks::Now(); | 514 base::TimeTicks now = base::TimeTicks::Now(); |
515 scroll.timeStampSeconds = (now - base::TimeTicks()).InSecondsF(); | 515 scroll.setTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); |
516 ui::LatencyInfo scroll_latency; | 516 ui::LatencyInfo scroll_latency; |
517 scroll_latency.AddLatencyNumberWithTimestamp( | 517 scroll_latency.AddLatencyNumberWithTimestamp( |
518 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 518 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
519 tracker()->latency_component_id(), 0, now, 1); | 519 tracker()->latency_component_id(), 0, now, 1); |
520 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); | 520 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); |
521 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); | 521 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); |
522 tracker()->OnInputEvent(scroll, &scroll_latency); | 522 tracker()->OnInputEvent(scroll, &scroll_latency); |
523 EXPECT_TRUE(scroll_latency.FindLatency( | 523 EXPECT_TRUE(scroll_latency.FindLatency( |
524 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 524 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
525 tracker()->latency_component_id(), nullptr)); | 525 tracker()->latency_component_id(), nullptr)); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 ui::LatencyInfo latency_info; | 754 ui::LatencyInfo latency_info; |
755 tracker()->OnInputEvent(event, &latency_info); | 755 tracker()->OnInputEvent(event, &latency_info); |
756 EXPECT_EQ(2u, latency_info.input_coordinates_size()); | 756 EXPECT_EQ(2u, latency_info.input_coordinates_size()); |
757 EXPECT_EQ(700, latency_info.input_coordinates()[0].x()); | 757 EXPECT_EQ(700, latency_info.input_coordinates()[0].x()); |
758 EXPECT_EQ(800, latency_info.input_coordinates()[0].y()); | 758 EXPECT_EQ(800, latency_info.input_coordinates()[0].y()); |
759 EXPECT_EQ(900, latency_info.input_coordinates()[1].x()); | 759 EXPECT_EQ(900, latency_info.input_coordinates()[1].x()); |
760 EXPECT_EQ(1000, latency_info.input_coordinates()[1].y()); | 760 EXPECT_EQ(1000, latency_info.input_coordinates()[1].y()); |
761 } | 761 } |
762 | 762 |
763 { | 763 { |
764 NativeWebKeyboardEvent event; | 764 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::KeyDown, |
765 event.type = blink::WebKeyboardEvent::KeyDown; | 765 blink::WebInputEvent::NoModifiers, |
| 766 base::TimeTicks::Now()); |
766 ui::LatencyInfo latency_info; | 767 ui::LatencyInfo latency_info; |
767 tracker()->OnInputEvent(event, &latency_info); | 768 tracker()->OnInputEvent(event, &latency_info); |
768 EXPECT_EQ(0u, latency_info.input_coordinates_size()); | 769 EXPECT_EQ(0u, latency_info.input_coordinates_size()); |
769 } | 770 } |
770 } | 771 } |
771 | 772 |
772 TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) { | 773 TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) { |
773 auto scroll_begin = SyntheticWebGestureEventBuilder::BuildScrollBegin( | 774 auto scroll_begin = SyntheticWebGestureEventBuilder::BuildScrollBegin( |
774 5, -5, blink::WebGestureDeviceTouchscreen); | 775 5, -5, blink::WebGestureDeviceTouchscreen); |
775 ui::LatencyInfo scroll_latency; | 776 ui::LatencyInfo scroll_latency; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), | 1003 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), |
1003 ElementsAre(Bucket( | 1004 ElementsAre(Bucket( |
1004 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); | 1005 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); |
1005 EXPECT_THAT(histogram_tester().GetAllSamples( | 1006 EXPECT_THAT(histogram_tester().GetAllSamples( |
1006 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), | 1007 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), |
1007 ElementsAre(Bucket( | 1008 ElementsAre(Bucket( |
1008 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); | 1009 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); |
1009 } | 1010 } |
1010 | 1011 |
1011 } // namespace content | 1012 } // namespace content |
OLD | NEW |