| Index: content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc
|
| diff --git a/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc b/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc
|
| index 12ffdff2f047afe70ad58f34948518b27d6f91fd..9eaea1570775b76d7ff51e3ad3743953000f216c 100644
|
| --- a/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc
|
| +++ b/content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc
|
| @@ -966,4 +966,170 @@ TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) {
|
| touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1)));
|
| }
|
|
|
| +TEST_F(RenderWidgetHostLatencyTrackerTest, KeyBlockingAndQueueingTime) {
|
| + // These numbers are sensitive to where the histogram buckets are.
|
| + int event_timestamps_ms[] = {11, 25, 35};
|
| +
|
| + for (InputEventAckState blocking :
|
| + {INPUT_EVENT_ACK_STATE_NOT_CONSUMED, INPUT_EVENT_ACK_STATE_CONSUMED}) {
|
| + {
|
| + NativeWebKeyboardEvent event(blink::WebKeyboardEvent::KeyDown,
|
| + blink::WebInputEvent::NoModifiers,
|
| + base::TimeTicks::Now());
|
| + ui::LatencyInfo latency_info;
|
| + tracker()->OnInputEvent(event, &latency_info);
|
| +
|
| + ui::LatencyInfo fake_latency;
|
| + fake_latency.AddLatencyNumberWithTimestamp(
|
| + ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
|
| + tracker()->latency_component_id(), 0,
|
| + base::TimeTicks() +
|
| + base::TimeDelta::FromMilliseconds(event_timestamps_ms[0]),
|
| + 1);
|
| +
|
| + fake_latency.AddLatencyNumberWithTimestamp(
|
| + ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0,
|
| + base::TimeTicks() +
|
| + base::TimeDelta::FromMilliseconds(event_timestamps_ms[1]),
|
| + 1);
|
| +
|
| + fake_latency.AddLatencyNumberWithTimestamp(
|
| + ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0,
|
| + base::TimeTicks() +
|
| + base::TimeDelta::FromMilliseconds(event_timestamps_ms[2]),
|
| + 1);
|
| +
|
| + // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
|
| + // overwriting components.
|
| + tracker()->ComputeInputLatencyHistograms(
|
| + event.type(), tracker()->latency_component_id(), fake_latency,
|
| + blocking);
|
| +
|
| + tracker()->OnInputEventAck(event, &latency_info, blocking);
|
| + }
|
| + }
|
| +
|
| + EXPECT_THAT(
|
| + histogram_tester().GetAllSamples(
|
| + "Event.Latency.QueueingTime.KeyEventDefaultPrevented"),
|
| + ElementsAre(Bucket(event_timestamps_ms[1] - event_timestamps_ms[0], 1)));
|
| + EXPECT_THAT(
|
| + histogram_tester().GetAllSamples(
|
| + "Event.Latency.QueueingTime.KeyEventDefaultAllowed"),
|
| + ElementsAre(Bucket(event_timestamps_ms[1] - event_timestamps_ms[0], 1)));
|
| + EXPECT_THAT(
|
| + histogram_tester().GetAllSamples(
|
| + "Event.Latency.BlockingTime.KeyEventDefaultPrevented"),
|
| + ElementsAre(Bucket(event_timestamps_ms[2] - event_timestamps_ms[1], 1)));
|
| + EXPECT_THAT(
|
| + histogram_tester().GetAllSamples(
|
| + "Event.Latency.BlockingTime.KeyEventDefaultAllowed"),
|
| + ElementsAre(Bucket(event_timestamps_ms[2] - event_timestamps_ms[1], 1)));
|
| +}
|
| +
|
| +TEST_F(RenderWidgetHostLatencyTrackerTest, KeyUILatency) {
|
| + // These numbers are sensitive to where the histogram buckets are.
|
| + int event_timestamps_microseconds[] = {100, 185};
|
| +
|
| + NativeWebKeyboardEvent event(blink::WebKeyboardEvent::KeyDown,
|
| + blink::WebInputEvent::NoModifiers,
|
| + base::TimeTicks::Now());
|
| + ui::LatencyInfo latency_info;
|
| + latency_info.AddLatencyNumberWithTimestamp(
|
| + ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0,
|
| + base::TimeTicks() +
|
| + base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
|
| + 1);
|
| +
|
| + latency_info.AddLatencyNumberWithTimestamp(
|
| + ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
|
| + tracker()->latency_component_id(), 0,
|
| + base::TimeTicks() +
|
| + base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
|
| + 1);
|
| +
|
| + tracker()->OnInputEvent(event, &latency_info);
|
| + tracker()->OnInputEventAck(event, &latency_info,
|
| + InputEventAckState::INPUT_EVENT_ACK_STATE_UNKNOWN);
|
| + EXPECT_THAT(histogram_tester().GetAllSamples("Event.Latency.Browser.KeyUI"),
|
| + ElementsAre(Bucket(event_timestamps_microseconds[1] -
|
| + event_timestamps_microseconds[0],
|
| + 1)));
|
| +}
|
| +
|
| +TEST_F(RenderWidgetHostLatencyTrackerTest, KeyAckedLatency) {
|
| + // These numbers are sensitive to where the histogram buckets are.
|
| + int event_timestamps_microseconds[] = {11, 24};
|
| +
|
| + NativeWebKeyboardEvent event(blink::WebKeyboardEvent::KeyDown,
|
| + blink::WebInputEvent::NoModifiers,
|
| + base::TimeTicks::Now());
|
| + ui::LatencyInfo latency_info;
|
| +
|
| + latency_info.AddLatencyNumberWithTimestamp(
|
| + ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
|
| + tracker()->latency_component_id(), 0,
|
| + base::TimeTicks() +
|
| + base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
|
| + 1);
|
| +
|
| + latency_info.AddLatencyNumberWithTimestamp(
|
| + ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0,
|
| + base::TimeTicks() +
|
| + base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
|
| + 1);
|
| +
|
| + tracker()->OnInputEvent(event, &latency_info);
|
| + // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
|
| + // overwriting components.
|
| + tracker()->ComputeInputLatencyHistograms(
|
| + event.type(), tracker()->latency_component_id(), latency_info,
|
| + InputEventAckState::INPUT_EVENT_ACK_STATE_UNKNOWN);
|
| +
|
| + EXPECT_THAT(
|
| + histogram_tester().GetAllSamples("Event.Latency.Browser.KeyAcked"),
|
| + ElementsAre(Bucket(
|
| + event_timestamps_microseconds[1] - event_timestamps_microseconds[0],
|
| + 1)));
|
| +}
|
| +
|
| +TEST_F(RenderWidgetHostLatencyTrackerTest, KeyEndToEndLatency) {
|
| + // These numbers are sensitive to where the histogram buckets are.
|
| + int event_timestamps_microseconds[] = {11, 24};
|
| +
|
| + ui::LatencyInfo latency_info;
|
| + latency_info.set_source_event_type(ui::SourceEventType::KEY);
|
| + latency_info.AddLatencyNumberWithTimestamp(
|
| + ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
|
| + base::TimeTicks() +
|
| + base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
|
| + 1);
|
| +
|
| + latency_info.AddLatencyNumberWithTimestamp(
|
| + ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
|
| + tracker()->latency_component_id(), 0,
|
| + base::TimeTicks() +
|
| + base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
|
| + 1);
|
| +
|
| + latency_info.AddLatencyNumberWithTimestamp(
|
| + ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0,
|
| + base::TimeTicks() +
|
| + base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
|
| + 1);
|
| +
|
| + latency_info.AddLatencyNumberWithTimestamp(
|
| + ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0,
|
| + base::TimeTicks() +
|
| + base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[1]),
|
| + 1);
|
| +
|
| + tracker()->OnFrameSwapped(latency_info);
|
| +
|
| + EXPECT_THAT(histogram_tester().GetAllSamples("Event.Latency.EndToEnd.Key"),
|
| + ElementsAre(Bucket(event_timestamps_microseconds[1] -
|
| + event_timestamps_microseconds[0],
|
| + 1)));
|
| +}
|
| +
|
| } // namespace content
|
|
|