Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Side by Side Diff: content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc

Issue 2953073002: LatencyInfo trace_id_ no longer dependent on sequence_number. (Closed)
Patch Set: Fix cc_unittests Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/browser/renderer_host/input/render_widget_host_latency_tracker .h" 5 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h"
6 #include "base/metrics/metrics_hashes.h" 6 #include "base/metrics/metrics_hashes.h"
7 #include "base/test/histogram_tester.h" 7 #include "base/test/histogram_tester.h"
8 #include "components/metrics/proto/ukm/entry.pb.h" 8 #include "components/metrics/proto/ukm/entry.pb.h"
9 #include "components/rappor/public/rappor_utils.h" 9 #include "components/rappor/public/rappor_utils.h"
10 #include "components/rappor/test_rappor_service.h" 10 #include "components/rappor/test_rappor_service.h"
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 SyntheticWebTouchEvent event; 806 SyntheticWebTouchEvent event;
807 { 807 {
808 // Touch start. 808 // Touch start.
809 event.PressPoint(1, 1); 809 event.PressPoint(1, 1);
810 810
811 ui::LatencyInfo latency; 811 ui::LatencyInfo latency;
812 latency.set_source_event_type(ui::SourceEventType::TOUCH); 812 latency.set_source_event_type(ui::SourceEventType::TOUCH);
813 tracker()->OnInputEvent(event, &latency); 813 tracker()->OnInputEvent(event, &latency);
814 814
815 ui::LatencyInfo fake_latency; 815 ui::LatencyInfo fake_latency;
816 fake_latency.set_trace_id(5);
brianderson 2017/06/27 18:00:58 Would it make sense to have 5 be a const variable
tdresser 2017/06/27 18:33:12 Done.
816 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 817 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
817 fake_latency.AddLatencyNumberWithTimestamp( 818 fake_latency.AddLatencyNumberWithTimestamp(
818 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 819 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
819 tracker()->latency_component_id(), 0, 820 tracker()->latency_component_id(), 0,
820 base::TimeTicks() + 821 base::TimeTicks() +
821 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]), 822 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]),
822 1); 823 1);
823 824
824 fake_latency.AddLatencyNumberWithTimestamp( 825 fake_latency.AddLatencyNumberWithTimestamp(
825 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 826 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0,
(...skipping 26 matching lines...) Expand all
852 853
853 EXPECT_TRUE(latency.FindLatency( 854 EXPECT_TRUE(latency.FindLatency(
854 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 855 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
855 EXPECT_TRUE( 856 EXPECT_TRUE(
856 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 857 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
857 tracker()->latency_component_id(), nullptr)); 858 tracker()->latency_component_id(), nullptr));
858 859
859 EXPECT_EQ(2U, latency.latency_components().size()); 860 EXPECT_EQ(2U, latency.latency_components().size());
860 861
861 ui::LatencyInfo fake_latency; 862 ui::LatencyInfo fake_latency;
863 fake_latency.set_trace_id(5);
862 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 864 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
863 fake_latency.AddLatencyNumberWithTimestamp( 865 fake_latency.AddLatencyNumberWithTimestamp(
864 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 866 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
865 tracker()->latency_component_id(), 0, 867 tracker()->latency_component_id(), 0,
866 base::TimeTicks() + 868 base::TimeTicks() +
867 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[0]), 869 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[0]),
868 1); 870 1);
869 871
870 fake_latency.AddLatencyNumberWithTimestamp( 872 fake_latency.AddLatencyNumberWithTimestamp(
871 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 873 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0,
(...skipping 23 matching lines...) Expand all
895 897
896 EXPECT_TRUE(latency.FindLatency( 898 EXPECT_TRUE(latency.FindLatency(
897 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 899 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
898 EXPECT_TRUE( 900 EXPECT_TRUE(
899 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 901 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
900 tracker()->latency_component_id(), nullptr)); 902 tracker()->latency_component_id(), nullptr));
901 903
902 EXPECT_EQ(2U, latency.latency_components().size()); 904 EXPECT_EQ(2U, latency.latency_components().size());
903 905
904 ui::LatencyInfo fake_latency; 906 ui::LatencyInfo fake_latency;
907 fake_latency.set_trace_id(5);
905 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 908 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
906 fake_latency.AddLatencyNumberWithTimestamp( 909 fake_latency.AddLatencyNumberWithTimestamp(
907 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 910 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
908 tracker()->latency_component_id(), 0, 911 tracker()->latency_component_id(), 0,
909 base::TimeTicks() + 912 base::TimeTicks() +
910 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[0]), 913 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[0]),
911 1); 914 1);
912 915
913 fake_latency.AddLatencyNumberWithTimestamp( 916 fake_latency.AddLatencyNumberWithTimestamp(
914 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 917 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 {INPUT_EVENT_ACK_STATE_NOT_CONSUMED, INPUT_EVENT_ACK_STATE_CONSUMED}) { 1000 {INPUT_EVENT_ACK_STATE_NOT_CONSUMED, INPUT_EVENT_ACK_STATE_CONSUMED}) {
998 { 1001 {
999 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown, 1002 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown,
1000 blink::WebInputEvent::kNoModifiers, 1003 blink::WebInputEvent::kNoModifiers,
1001 base::TimeTicks::Now()); 1004 base::TimeTicks::Now());
1002 ui::LatencyInfo latency_info; 1005 ui::LatencyInfo latency_info;
1003 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1006 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1004 tracker()->OnInputEvent(event, &latency_info); 1007 tracker()->OnInputEvent(event, &latency_info);
1005 1008
1006 ui::LatencyInfo fake_latency; 1009 ui::LatencyInfo fake_latency;
1010 fake_latency.set_trace_id(5);
1007 fake_latency.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1011 fake_latency.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1008 fake_latency.AddLatencyNumberWithTimestamp( 1012 fake_latency.AddLatencyNumberWithTimestamp(
1009 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1013 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1010 tracker()->latency_component_id(), 0, 1014 tracker()->latency_component_id(), 0,
1011 base::TimeTicks() + 1015 base::TimeTicks() +
1012 base::TimeDelta::FromMilliseconds(event_timestamps_ms[0]), 1016 base::TimeDelta::FromMilliseconds(event_timestamps_ms[0]),
1013 1); 1017 1);
1014 1018
1015 fake_latency.AddLatencyNumberWithTimestamp( 1019 fake_latency.AddLatencyNumberWithTimestamp(
1016 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 1020 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 } 1057 }
1054 1058
1055 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyUILatency) { 1059 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyUILatency) {
1056 // These numbers are sensitive to where the histogram buckets are. 1060 // These numbers are sensitive to where the histogram buckets are.
1057 int event_timestamps_microseconds[] = {100, 185}; 1061 int event_timestamps_microseconds[] = {100, 185};
1058 1062
1059 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kChar, 1063 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kChar,
1060 blink::WebInputEvent::kNoModifiers, 1064 blink::WebInputEvent::kNoModifiers,
1061 base::TimeTicks::Now()); 1065 base::TimeTicks::Now());
1062 ui::LatencyInfo latency_info; 1066 ui::LatencyInfo latency_info;
1067 latency_info.set_trace_id(5);
1063 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1068 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1064 latency_info.AddLatencyNumberWithTimestamp( 1069 latency_info.AddLatencyNumberWithTimestamp(
1065 ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0, 1070 ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0,
1066 base::TimeTicks() + 1071 base::TimeTicks() +
1067 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), 1072 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1068 1); 1073 1);
1069 1074
1070 latency_info.AddLatencyNumberWithTimestamp( 1075 latency_info.AddLatencyNumberWithTimestamp(
1071 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1076 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1072 tracker()->latency_component_id(), 0, 1077 tracker()->latency_component_id(), 0,
(...skipping 12 matching lines...) Expand all
1085 } 1090 }
1086 1091
1087 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyAckedLatency) { 1092 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyAckedLatency) {
1088 // These numbers are sensitive to where the histogram buckets are. 1093 // These numbers are sensitive to where the histogram buckets are.
1089 int event_timestamps_microseconds[] = {11, 24}; 1094 int event_timestamps_microseconds[] = {11, 24};
1090 1095
1091 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown, 1096 NativeWebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown,
1092 blink::WebInputEvent::kNoModifiers, 1097 blink::WebInputEvent::kNoModifiers,
1093 base::TimeTicks::Now()); 1098 base::TimeTicks::Now());
1094 ui::LatencyInfo latency_info; 1099 ui::LatencyInfo latency_info;
1100 latency_info.set_trace_id(5);
1095 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1101 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1096 1102
1097 latency_info.AddLatencyNumberWithTimestamp( 1103 latency_info.AddLatencyNumberWithTimestamp(
1098 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1104 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1099 tracker()->latency_component_id(), 0, 1105 tracker()->latency_component_id(), 0,
1100 base::TimeTicks() + 1106 base::TimeTicks() +
1101 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), 1107 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1102 1); 1108 1);
1103 1109
1104 latency_info.AddLatencyNumberWithTimestamp( 1110 latency_info.AddLatencyNumberWithTimestamp(
(...skipping 14 matching lines...) Expand all
1119 ElementsAre(Bucket( 1125 ElementsAre(Bucket(
1120 event_timestamps_microseconds[1] - event_timestamps_microseconds[0], 1126 event_timestamps_microseconds[1] - event_timestamps_microseconds[0],
1121 1))); 1127 1)));
1122 } 1128 }
1123 1129
1124 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyEndToEndLatency) { 1130 TEST_F(RenderWidgetHostLatencyTrackerTest, KeyEndToEndLatency) {
1125 // These numbers are sensitive to where the histogram buckets are. 1131 // These numbers are sensitive to where the histogram buckets are.
1126 int event_timestamps_microseconds[] = {11, 24}; 1132 int event_timestamps_microseconds[] = {11, 24};
1127 1133
1128 ui::LatencyInfo latency_info; 1134 ui::LatencyInfo latency_info;
1135 latency_info.set_trace_id(5);
1129 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS); 1136 latency_info.set_source_event_type(ui::SourceEventType::KEY_PRESS);
1130 latency_info.AddLatencyNumberWithTimestamp( 1137 latency_info.AddLatencyNumberWithTimestamp(
1131 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0, 1138 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, 0,
1132 base::TimeTicks() + 1139 base::TimeTicks() +
1133 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]), 1140 base::TimeDelta::FromMicroseconds(event_timestamps_microseconds[0]),
1134 1); 1141 1);
1135 1142
1136 latency_info.AddLatencyNumberWithTimestamp( 1143 latency_info.AddLatencyNumberWithTimestamp(
1137 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1144 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1138 tracker()->latency_component_id(), 0, 1145 tracker()->latency_component_id(), 0,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 1185
1179 { 1186 {
1180 // Additional touch start will be ignored for queueing and blocking time 1187 // Additional touch start will be ignored for queueing and blocking time
1181 // metrics. 1188 // metrics.
1182 int touchstart_timestamps_ms[] = {11, 25, 35}; 1189 int touchstart_timestamps_ms[] = {11, 25, 35};
1183 ui::LatencyInfo latency; 1190 ui::LatencyInfo latency;
1184 event.PressPoint(1, 1); 1191 event.PressPoint(1, 1);
1185 tracker()->OnInputEvent(event, &latency); 1192 tracker()->OnInputEvent(event, &latency);
1186 1193
1187 ui::LatencyInfo fake_latency; 1194 ui::LatencyInfo fake_latency;
1195 fake_latency.set_trace_id(5);
1188 fake_latency.AddLatencyNumberWithTimestamp( 1196 fake_latency.AddLatencyNumberWithTimestamp(
1189 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1197 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1190 tracker()->latency_component_id(), 0, 1198 tracker()->latency_component_id(), 0,
1191 base::TimeTicks() + 1199 base::TimeTicks() +
1192 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]), 1200 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]),
1193 1); 1201 1);
1194 1202
1195 fake_latency.AddLatencyNumberWithTimestamp( 1203 fake_latency.AddLatencyNumberWithTimestamp(
1196 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 1204 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0,
1197 base::TimeTicks() + 1205 base::TimeTicks() +
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 // Wheel event. 1255 // Wheel event.
1248 ui::LatencyInfo latency; 1256 ui::LatencyInfo latency;
1249 latency.set_source_event_type(ui::SourceEventType::WHEEL); 1257 latency.set_source_event_type(ui::SourceEventType::WHEEL);
1250 // These numbers are sensitive to where the histogram buckets are. 1258 // These numbers are sensitive to where the histogram buckets are.
1251 int timestamps_ms[] = {11, 25, 35}; 1259 int timestamps_ms[] = {11, 25, 35};
1252 auto wheel_event = SyntheticWebMouseWheelEventBuilder::Build( 1260 auto wheel_event = SyntheticWebMouseWheelEventBuilder::Build(
1253 blink::WebMouseWheelEvent::kPhaseChanged); 1261 blink::WebMouseWheelEvent::kPhaseChanged);
1254 tracker()->OnInputEvent(touch_event, &latency); 1262 tracker()->OnInputEvent(touch_event, &latency);
1255 1263
1256 ui::LatencyInfo fake_latency; 1264 ui::LatencyInfo fake_latency;
1265 fake_latency.set_trace_id(5);
1257 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH); 1266 fake_latency.set_source_event_type(ui::SourceEventType::TOUCH);
1258 fake_latency.AddLatencyNumberWithTimestamp( 1267 fake_latency.AddLatencyNumberWithTimestamp(
1259 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 1268 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
1260 tracker()->latency_component_id(), 0, 1269 tracker()->latency_component_id(), 0,
1261 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[0]), 1270 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[0]),
1262 1); 1271 1);
1263 1272
1264 fake_latency.AddLatencyNumberWithTimestamp( 1273 fake_latency.AddLatencyNumberWithTimestamp(
1265 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 1274 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0,
1266 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[1]), 1275 base::TimeTicks() + base::TimeDelta::FromMilliseconds(timestamps_ms[1]),
(...skipping 12 matching lines...) Expand all
1279 1288
1280 tracker()->OnInputEventAck(wheel_event, &latency, ack_state); 1289 tracker()->OnInputEventAck(wheel_event, &latency, ack_state);
1281 } 1290 }
1282 1291
1283 EXPECT_THAT(histogram_tester().GetAllSamples( 1292 EXPECT_THAT(histogram_tester().GetAllSamples(
1284 "Event.Latency.QueueingTime.MouseWheelDefaultAllowed"), 1293 "Event.Latency.QueueingTime.MouseWheelDefaultAllowed"),
1285 ElementsAre(Bucket(14, 1))); 1294 ElementsAre(Bucket(14, 1)));
1286 } 1295 }
1287 1296
1288 } // namespace content 1297 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698