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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 }; | 135 }; |
136 | 136 |
137 TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToFirstScrollHistograms) { | 137 TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToFirstScrollHistograms) { |
138 for (bool rendering_on_main : {false, true}) { | 138 for (bool rendering_on_main : {false, true}) { |
139 for (bool is_running_navigation_hint_task : {false, true}) { | 139 for (bool is_running_navigation_hint_task : {false, true}) { |
140 ResetHistograms(); | 140 ResetHistograms(); |
141 { | 141 { |
142 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( | 142 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( |
143 blink::WebMouseWheelEvent::PhaseChanged); | 143 blink::WebMouseWheelEvent::PhaseChanged); |
144 base::TimeTicks now = base::TimeTicks::Now(); | 144 base::TimeTicks now = base::TimeTicks::Now(); |
145 wheel.timeStampSeconds = (now - base::TimeTicks()).InSecondsF(); | 145 wheel.setTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); |
146 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); | 146 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); |
147 wheel_latency.AddLatencyNumberWithTimestamp( | 147 wheel_latency.AddLatencyNumberWithTimestamp( |
148 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 148 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
149 tracker()->latency_component_id(), 0, now, 1); | 149 tracker()->latency_component_id(), 0, now, 1); |
150 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); | 150 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); |
151 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); | 151 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); |
152 tracker()->OnInputEvent(wheel, &wheel_latency); | 152 tracker()->OnInputEvent(wheel, &wheel_latency); |
153 EXPECT_TRUE(wheel_latency.FindLatency( | 153 EXPECT_TRUE(wheel_latency.FindLatency( |
154 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 154 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
155 tracker()->latency_component_id(), nullptr)); | 155 tracker()->latency_component_id(), nullptr)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 212 } |
213 | 213 |
214 TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToScrollHistograms) { | 214 TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToScrollHistograms) { |
215 for (bool rendering_on_main : {false, true}) { | 215 for (bool rendering_on_main : {false, true}) { |
216 for (bool is_running_navigation_hint_task : {false, true}) { | 216 for (bool is_running_navigation_hint_task : {false, true}) { |
217 ResetHistograms(); | 217 ResetHistograms(); |
218 { | 218 { |
219 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( | 219 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( |
220 blink::WebMouseWheelEvent::PhaseChanged); | 220 blink::WebMouseWheelEvent::PhaseChanged); |
221 base::TimeTicks now = base::TimeTicks::Now(); | 221 base::TimeTicks now = base::TimeTicks::Now(); |
222 wheel.timeStampSeconds = (now - base::TimeTicks()).InSecondsF(); | 222 wheel.setTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); |
223 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); | 223 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); |
224 wheel_latency.AddLatencyNumberWithTimestamp( | 224 wheel_latency.AddLatencyNumberWithTimestamp( |
225 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 225 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
226 tracker()->latency_component_id(), 0, now, 1); | 226 tracker()->latency_component_id(), 0, now, 1); |
227 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); | 227 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); |
228 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); | 228 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); |
229 tracker()->OnInputEvent(wheel, &wheel_latency); | 229 tracker()->OnInputEvent(wheel, &wheel_latency); |
230 EXPECT_TRUE(wheel_latency.FindLatency( | 230 EXPECT_TRUE(wheel_latency.FindLatency( |
231 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 231 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
232 tracker()->latency_component_id(), nullptr)); | 232 tracker()->latency_component_id(), nullptr)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 289 } |
290 | 290 |
291 TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) { | 291 TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) { |
292 for (bool rendering_on_main : {false, true}) { | 292 for (bool rendering_on_main : {false, true}) { |
293 for (bool is_running_navigation_hint_task : {false, true}) { | 293 for (bool is_running_navigation_hint_task : {false, true}) { |
294 ResetHistograms(); | 294 ResetHistograms(); |
295 { | 295 { |
296 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( | 296 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( |
297 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen); | 297 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen); |
298 base::TimeTicks now = base::TimeTicks::Now(); | 298 base::TimeTicks now = base::TimeTicks::Now(); |
299 scroll.timeStampSeconds = (now - base::TimeTicks()).InSecondsF(); | 299 scroll.setTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); |
300 ui::LatencyInfo scroll_latency; | 300 ui::LatencyInfo scroll_latency; |
301 scroll_latency.AddLatencyNumberWithTimestamp( | 301 scroll_latency.AddLatencyNumberWithTimestamp( |
302 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 302 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
303 tracker()->latency_component_id(), 0, now, 1); | 303 tracker()->latency_component_id(), 0, now, 1); |
304 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); | 304 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); |
305 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); | 305 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); |
306 tracker()->OnInputEvent(scroll, &scroll_latency); | 306 tracker()->OnInputEvent(scroll, &scroll_latency); |
307 EXPECT_TRUE(scroll_latency.FindLatency( | 307 EXPECT_TRUE(scroll_latency.FindLatency( |
308 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 308 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
309 tracker()->latency_component_id(), nullptr)); | 309 tracker()->latency_component_id(), nullptr)); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 contents()->NavigateAndCommit(url); | 423 contents()->NavigateAndCommit(url); |
424 for (bool rendering_on_main : {false, true}) { | 424 for (bool rendering_on_main : {false, true}) { |
425 for (bool is_running_navigation_hint_task : {false, true}) { | 425 for (bool is_running_navigation_hint_task : {false, true}) { |
426 ResetHistograms(); | 426 ResetHistograms(); |
427 EXPECT_EQ(0, | 427 EXPECT_EQ(0, |
428 test_browser_client_.getTestRapporService()->GetReportsCount()); | 428 test_browser_client_.getTestRapporService()->GetReportsCount()); |
429 { | 429 { |
430 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( | 430 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( |
431 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen); | 431 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen); |
432 base::TimeTicks now = base::TimeTicks::Now(); | 432 base::TimeTicks now = base::TimeTicks::Now(); |
433 scroll.timeStampSeconds = (now - base::TimeTicks()).InSecondsF(); | 433 scroll.setTimeStampSeconds((now - base::TimeTicks()).InSecondsF()); |
434 ui::LatencyInfo scroll_latency; | 434 ui::LatencyInfo scroll_latency; |
435 scroll_latency.AddLatencyNumberWithTimestamp( | 435 scroll_latency.AddLatencyNumberWithTimestamp( |
436 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 436 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
437 tracker()->latency_component_id(), 0, now, 1); | 437 tracker()->latency_component_id(), 0, now, 1); |
438 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); | 438 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); |
439 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); | 439 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); |
440 tracker()->OnInputEvent(scroll, &scroll_latency); | 440 tracker()->OnInputEvent(scroll, &scroll_latency); |
441 EXPECT_TRUE(scroll_latency.FindLatency( | 441 EXPECT_TRUE(scroll_latency.FindLatency( |
442 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 442 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
443 tracker()->latency_component_id(), nullptr)); | 443 tracker()->latency_component_id(), nullptr)); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 ui::LatencyInfo latency_info; | 673 ui::LatencyInfo latency_info; |
674 tracker()->OnInputEvent(event, &latency_info); | 674 tracker()->OnInputEvent(event, &latency_info); |
675 EXPECT_EQ(2u, latency_info.input_coordinates_size()); | 675 EXPECT_EQ(2u, latency_info.input_coordinates_size()); |
676 EXPECT_EQ(700, latency_info.input_coordinates()[0].x()); | 676 EXPECT_EQ(700, latency_info.input_coordinates()[0].x()); |
677 EXPECT_EQ(800, latency_info.input_coordinates()[0].y()); | 677 EXPECT_EQ(800, latency_info.input_coordinates()[0].y()); |
678 EXPECT_EQ(900, latency_info.input_coordinates()[1].x()); | 678 EXPECT_EQ(900, latency_info.input_coordinates()[1].x()); |
679 EXPECT_EQ(1000, latency_info.input_coordinates()[1].y()); | 679 EXPECT_EQ(1000, latency_info.input_coordinates()[1].y()); |
680 } | 680 } |
681 | 681 |
682 { | 682 { |
683 NativeWebKeyboardEvent event; | 683 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::KeyDown, |
684 event.type = blink::WebKeyboardEvent::KeyDown; | 684 blink::WebInputEvent::NoModifiers, |
| 685 base::TimeTicks::Now()); |
685 ui::LatencyInfo latency_info; | 686 ui::LatencyInfo latency_info; |
686 tracker()->OnInputEvent(event, &latency_info); | 687 tracker()->OnInputEvent(event, &latency_info); |
687 EXPECT_EQ(0u, latency_info.input_coordinates_size()); | 688 EXPECT_EQ(0u, latency_info.input_coordinates_size()); |
688 } | 689 } |
689 } | 690 } |
690 | 691 |
691 TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) { | 692 TEST_F(RenderWidgetHostLatencyTrackerTest, ScrollLatency) { |
692 auto scroll_begin = SyntheticWebGestureEventBuilder::BuildScrollBegin( | 693 auto scroll_begin = SyntheticWebGestureEventBuilder::BuildScrollBegin( |
693 5, -5, blink::WebGestureDeviceTouchscreen); | 694 5, -5, blink::WebGestureDeviceTouchscreen); |
694 ui::LatencyInfo scroll_latency; | 695 ui::LatencyInfo scroll_latency; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), | 922 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), |
922 ElementsAre(Bucket( | 923 ElementsAre(Bucket( |
923 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); | 924 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); |
924 EXPECT_THAT(histogram_tester().GetAllSamples( | 925 EXPECT_THAT(histogram_tester().GetAllSamples( |
925 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), | 926 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), |
926 ElementsAre(Bucket( | 927 ElementsAre(Bucket( |
927 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); | 928 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); |
928 } | 929 } |
929 | 930 |
930 } // namespace content | 931 } // namespace content |
OLD | NEW |