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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
959 EXPECT_THAT(histogram_tester().GetAllSamples( | 959 EXPECT_THAT(histogram_tester().GetAllSamples( |
960 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), | 960 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), |
961 ElementsAre(Bucket( | 961 ElementsAre(Bucket( |
962 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); | 962 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); |
963 EXPECT_THAT(histogram_tester().GetAllSamples( | 963 EXPECT_THAT(histogram_tester().GetAllSamples( |
964 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), | 964 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), |
965 ElementsAre(Bucket( | 965 ElementsAre(Bucket( |
966 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); | 966 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); |
967 } | 967 } |
968 | 968 |
969 // Some touch input histograms aren't reported for multi-finger touch. | |
mfomitchev
2017/04/06 15:27:04
aren't -> should not be? Or maybe just say that Ev
tdresser
2017/04/06 20:50:09
Done.
| |
970 TEST_F(RenderWidgetHostLatencyTrackerTest, MultiFingerTouchIgnored) { | |
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. | |
mfomitchev
2017/04/06 15:27:04
It't not completely ignored, right? We are still l
tdresser
2017/04/06 20:50:09
Done.
| |
984 int touchstart_timestamps_ms[] = {11, 25, 35}; | |
985 ui::LatencyInfo latency; | |
986 event.PressPoint(1, 1); | |
987 tracker()->OnInputEvent(event, &latency); | |
988 | |
989 ui::LatencyInfo fake_latency; | |
990 fake_latency.AddLatencyNumberWithTimestamp( | |
991 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | |
992 tracker()->latency_component_id(), 0, | |
993 base::TimeTicks() + | |
994 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]), | |
995 1); | |
996 | |
997 fake_latency.AddLatencyNumberWithTimestamp( | |
998 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, | |
999 base::TimeTicks() + | |
1000 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[1]), | |
1001 1); | |
1002 | |
1003 fake_latency.AddLatencyNumberWithTimestamp( | |
1004 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, | |
1005 base::TimeTicks() + | |
1006 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]), | |
1007 1); | |
1008 | |
1009 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck | |
1010 // overwriting components. | |
1011 tracker()->ComputeInputLatencyHistograms(event.type(), | |
1012 tracker()->latency_component_id(), | |
1013 fake_latency, ack_state); | |
1014 | |
1015 tracker()->OnInputEventAck(event, &latency, ack_state); | |
1016 } | |
1017 | |
1018 // Touch start. | |
mfomitchev
2017/04/06 15:27:04
I am not sure if this comment is helpful (maybe I
tdresser
2017/04/06 20:50:09
Copy/paste fail, thanks.
| |
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 | |
969 } // namespace content | 1087 } // namespace content |
OLD | NEW |