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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 EXPECT_THAT(histogram_tester().GetAllSamples( | 957 EXPECT_THAT(histogram_tester().GetAllSamples( |
958 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), | 958 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), |
959 ElementsAre(Bucket( | 959 ElementsAre(Bucket( |
960 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); | 960 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); |
961 EXPECT_THAT(histogram_tester().GetAllSamples( | 961 EXPECT_THAT(histogram_tester().GetAllSamples( |
962 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), | 962 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), |
963 ElementsAre(Bucket( | 963 ElementsAre(Bucket( |
964 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); | 964 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); |
965 } | 965 } |
966 | 966 |
| 967 // Event.Latency.(Queueing|Blocking)Time.* histograms shouldn't be reported for |
| 968 // multi-finger touch. |
| 969 TEST_F(RenderWidgetHostLatencyTrackerTest, |
| 970 MultiFingerTouchIgnoredForQueueingAndBlockingTimeMetrics) { |
| 971 SyntheticWebTouchEvent event; |
| 972 InputEventAckState ack_state = INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 973 |
| 974 { |
| 975 // First touch start. |
| 976 ui::LatencyInfo latency; |
| 977 event.PressPoint(1, 1); |
| 978 tracker()->OnInputEvent(event, &latency); |
| 979 tracker()->OnInputEventAck(event, &latency, ack_state); |
| 980 } |
| 981 |
| 982 { |
| 983 // Additional touch start will be ignored for queueing and blocking time |
| 984 // metrics. |
| 985 int touchstart_timestamps_ms[] = {11, 25, 35}; |
| 986 ui::LatencyInfo latency; |
| 987 event.PressPoint(1, 1); |
| 988 tracker()->OnInputEvent(event, &latency); |
| 989 |
| 990 ui::LatencyInfo fake_latency; |
| 991 fake_latency.AddLatencyNumberWithTimestamp( |
| 992 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 993 tracker()->latency_component_id(), 0, |
| 994 base::TimeTicks() + |
| 995 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]), |
| 996 1); |
| 997 |
| 998 fake_latency.AddLatencyNumberWithTimestamp( |
| 999 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, |
| 1000 base::TimeTicks() + |
| 1001 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[1]), |
| 1002 1); |
| 1003 |
| 1004 fake_latency.AddLatencyNumberWithTimestamp( |
| 1005 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, |
| 1006 base::TimeTicks() + |
| 1007 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]), |
| 1008 1); |
| 1009 |
| 1010 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck |
| 1011 // overwriting components. |
| 1012 tracker()->ComputeInputLatencyHistograms(event.type(), |
| 1013 tracker()->latency_component_id(), |
| 1014 fake_latency, ack_state); |
| 1015 |
| 1016 tracker()->OnInputEventAck(event, &latency, ack_state); |
| 1017 } |
| 1018 |
| 1019 EXPECT_THAT(histogram_tester().GetAllSamples( |
| 1020 "Event.Latency.QueueingTime.TouchStartDefaultAllowed"), |
| 1021 ElementsAre()); |
| 1022 } |
| 1023 |
| 1024 // Some touch input histograms aren't reported for multi-finger touch. Other |
| 1025 // input modalities shouldn't be impacted by there being an active multi-finger |
| 1026 // touch gesture. |
| 1027 TEST_F(RenderWidgetHostLatencyTrackerTest, WheelDuringMultiFingerTouch) { |
| 1028 SyntheticWebTouchEvent touch_event; |
| 1029 InputEventAckState ack_state = INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 1030 |
| 1031 { |
| 1032 // First touch start. |
| 1033 ui::LatencyInfo latency; |
| 1034 touch_event.PressPoint(1, 1); |
| 1035 tracker()->OnInputEvent(touch_event, &latency); |
| 1036 tracker()->OnInputEventAck(touch_event, &latency, ack_state); |
| 1037 } |
| 1038 |
| 1039 { |
| 1040 // Second touch start. |
| 1041 ui::LatencyInfo latency; |
| 1042 touch_event.PressPoint(1, 1); |
| 1043 tracker()->OnInputEvent(touch_event, &latency); |
| 1044 tracker()->OnInputEventAck(touch_event, &latency, ack_state); |
| 1045 } |
| 1046 |
| 1047 { |
| 1048 // Wheel event. |
| 1049 ui::LatencyInfo latency; |
| 1050 // These numbers are sensitive to where the histogram buckets are. |
| 1051 int timestamps_ms[] = {11, 25, 35}; |
| 1052 auto wheel_event = SyntheticWebMouseWheelEventBuilder::Build( |
| 1053 blink::WebMouseWheelEvent::PhaseChanged); |
| 1054 tracker()->OnInputEvent(touch_event, &latency); |
| 1055 |
| 1056 ui::LatencyInfo fake_latency; |
| 1057 fake_latency.AddLatencyNumberWithTimestamp( |
| 1058 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 1059 tracker()->latency_component_id(), 0, |
| 1060 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[0]), |
| 1061 1); |
| 1062 |
| 1063 fake_latency.AddLatencyNumberWithTimestamp( |
| 1064 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, |
| 1065 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[1]), |
| 1066 1); |
| 1067 |
| 1068 fake_latency.AddLatencyNumberWithTimestamp( |
| 1069 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, |
| 1070 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[2]), |
| 1071 1); |
| 1072 |
| 1073 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck |
| 1074 // overwriting components. |
| 1075 tracker()->ComputeInputLatencyHistograms(wheel_event.type(), |
| 1076 tracker()->latency_component_id(), |
| 1077 fake_latency, ack_state); |
| 1078 |
| 1079 tracker()->OnInputEventAck(wheel_event, &latency, ack_state); |
| 1080 } |
| 1081 |
| 1082 EXPECT_THAT(histogram_tester().GetAllSamples( |
| 1083 "Event.Latency.QueueingTime.MouseWheelDefaultAllowed"), |
| 1084 ElementsAre(Bucket(14, 1))); |
| 1085 } |
| 1086 |
967 } // namespace content | 1087 } // namespace content |
OLD | NEW |