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

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

Issue 2268163002: Add sub-metrics for Event.Latency.TouchToFirstScrollUpdateSwapBegin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: submetric Created 4 years 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 "base/test/histogram_tester.h" 5 #include "base/test/histogram_tester.h"
6 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h" 6 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h"
7 #include "content/common/input/synthetic_web_input_event_builders.h" 7 #include "content/common/input/synthetic_web_input_event_builders.h"
8 #include "content/public/browser/native_web_keyboard_event.h" 8 #include "content/public/browser/native_web_keyboard_event.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 10 matching lines...) Expand all
21 ui::LatencyInfo* latency, 21 ui::LatencyInfo* latency,
22 base::TimeTicks time_stamp) { 22 base::TimeTicks time_stamp) {
23 latency->AddLatencyNumberWithTimestamp(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 23 latency->AddLatencyNumberWithTimestamp(ui::INPUT_EVENT_LATENCY_UI_COMPONENT,
24 0, 0, time_stamp, 1); 24 0, 0, time_stamp, 1);
25 latency->AddLatencyNumberWithTimestamp( 25 latency->AddLatencyNumberWithTimestamp(
26 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, time_stamp, 26 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, time_stamp,
27 1); 27 1);
28 latency->AddLatencyNumberWithTimestamp( 28 latency->AddLatencyNumberWithTimestamp(
29 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, time_stamp, 1); 29 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, time_stamp, 1);
30 latency->AddLatencyNumberWithTimestamp( 30 latency->AddLatencyNumberWithTimestamp(
31 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
32 tracker.latency_component_id(), 0, time_stamp, 1);
33 latency->AddLatencyNumberWithTimestamp(
34 ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, 0, time_stamp, 1); 31 ui::INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT, 0, 0, time_stamp, 1);
35 latency->AddLatencyNumberWithTimestamp( 32 latency->AddLatencyNumberWithTimestamp(
36 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0, 33 ui::INPUT_EVENT_BROWSER_RECEIVED_RENDERER_SWAP_COMPONENT, 0, 0,
37 time_stamp, 1); 34 time_stamp, 1);
38 } 35 }
39 36
40 void AddFakeComponents(const RenderWidgetHostLatencyTracker& tracker, 37 void AddFakeComponents(const RenderWidgetHostLatencyTracker& tracker,
41 ui::LatencyInfo* latency) { 38 ui::LatencyInfo* latency) {
39 latency->AddLatencyNumberWithTimestamp(
40 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
41 tracker.latency_component_id(), 0, base::TimeTicks::Now(), 1);
42 AddFakeComponentsWithTimeStamp(tracker, latency, base::TimeTicks::Now()); 42 AddFakeComponentsWithTimeStamp(tracker, latency, base::TimeTicks::Now());
43 } 43 }
44 44
45 void AddRenderingScheduledComponent(ui::LatencyInfo* latency, 45 void AddRenderingScheduledComponent(ui::LatencyInfo* latency,
46 bool main, 46 bool main,
47 base::TimeTicks time_stamp) { 47 base::TimeTicks time_stamp) {
48 if (main) { 48 if (main) {
49 latency->AddLatencyNumberWithTimestamp( 49 latency->AddLatencyNumberWithTimestamp(
50 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, 0, 50 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT, 0, 0,
51 time_stamp, 1); 51 time_stamp, 1);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return *histogram_tester_; 88 return *histogram_tester_;
89 } 89 }
90 90
91 private: 91 private:
92 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostLatencyTrackerTest); 92 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostLatencyTrackerTest);
93 const int kTestRoutingId = 3; 93 const int kTestRoutingId = 3;
94 const int kTestProcessId = 1; 94 const int kTestProcessId = 1;
95 std::unique_ptr<base::HistogramTester> histogram_tester_; 95 std::unique_ptr<base::HistogramTester> histogram_tester_;
96 RenderWidgetHostLatencyTracker tracker_; 96 RenderWidgetHostLatencyTracker tracker_;
97 }; 97 };
98 TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelHistograms) { 98
99 TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToFirstScrollHistograms) {
99 for (bool rendering_on_main : {false, true}) { 100 for (bool rendering_on_main : {false, true}) {
100 for (bool is_running_navigation_hint_task : {false, true}) { 101 for (bool is_running_navigation_hint_task : {false, true}) {
101 ResetHistograms(); 102 ResetHistograms();
102 { 103 {
103 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( 104 auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
104 blink::WebMouseWheelEvent::PhaseChanged); 105 blink::WebMouseWheelEvent::PhaseChanged);
105 base::TimeTicks now = base::TimeTicks::Now(); 106 base::TimeTicks now = base::TimeTicks::Now();
106 wheel.timeStampSeconds = (now - base::TimeTicks()).InSecondsF(); 107 wheel.timeStampSeconds = (now - base::TimeTicks()).InSecondsF();
107 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL); 108 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL);
109 wheel_latency.AddLatencyNumberWithTimestamp(
110 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
111 tracker()->latency_component_id(), 0, now, 1);
108 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now); 112 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now);
109 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now); 113 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now);
110 tracker()->OnInputEvent(wheel, &wheel_latency); 114 tracker()->OnInputEvent(wheel, &wheel_latency);
111 EXPECT_TRUE(wheel_latency.FindLatency( 115 EXPECT_TRUE(wheel_latency.FindLatency(
112 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 116 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
113 tracker()->latency_component_id(), nullptr)); 117 tracker()->latency_component_id(), nullptr));
114 EXPECT_TRUE(wheel_latency.FindLatency( 118 EXPECT_TRUE(wheel_latency.FindLatency(
115 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 119 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
116 EXPECT_EQ(1U, wheel_latency.input_coordinates_size()); 120 EXPECT_EQ(1U, wheel_latency.input_coordinates_size());
117 tracker()->OnInputEventAck(wheel, &wheel_latency, 121 tracker()->OnInputEventAck(wheel, &wheel_latency,
118 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 122 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
119 tracker()->OnFrameSwapped(wheel_latency, 123 tracker()->OnFrameSwapped(wheel_latency,
120 is_running_navigation_hint_task); 124 is_running_navigation_hint_task);
121 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelUI", 1)); 125 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelUI", 1));
122 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelAcked", 1)); 126 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelAcked", 1));
123 127
124 EXPECT_TRUE( 128 EXPECT_TRUE(
125 HistogramSizeEq("Event.Latency.ScrollUpdate.Wheel." 129 HistogramSizeEq("Event.Latency.ScrollBegin.Wheel."
126 "TimeToFirstScrollUpdateSwapBegin2", 130 "TimeToScrollUpdateSwapBegin2",
127 1)); 131 1));
132 EXPECT_TRUE(HistogramSizeEq(
133 "Event.Latency.ScrollBegin.Wheel.TimeToHandled2_Main",
134 rendering_on_main ? 1 : 0));
135 EXPECT_TRUE(HistogramSizeEq(
136 "Event.Latency.ScrollBegin.Wheel.TimeToHandled2_Impl",
137 rendering_on_main ? 0 : 1));
138 EXPECT_TRUE(HistogramSizeEq(
139 "Event.Latency.ScrollBegin.Wheel.HandledToRendererSwap2_Main",
140 rendering_on_main ? 1 : 0));
141 EXPECT_TRUE(HistogramSizeEq(
142 "Event.Latency.ScrollBegin.Wheel.HandledToRendererSwap2_Impl",
143 rendering_on_main ? 0 : 1));
144 EXPECT_TRUE(
145 HistogramSizeEq("Event.Latency.ScrollBegin.Wheel."
146 "RendererSwapToBrowserNotified2",
147 1));
148 EXPECT_TRUE(
149 HistogramSizeEq("Event.Latency.ScrollBegin.Wheel."
150 "BrowserNotifiedToBeforeGpuSwap2",
151 1));
152 EXPECT_TRUE(
153 HistogramSizeEq("Event.Latency.ScrollBegin.Wheel.GpuSwap2", 1));
154
155 EXPECT_TRUE(HistogramSizeEq(
156 "Event.Latency.ScrollUpdate.Wheel.TimeToHandled2_Main", 0));
157 EXPECT_TRUE(HistogramSizeEq(
158 "Event.Latency.ScrollUpdate.Wheel.TimeToHandled2_Impl", 0));
159 EXPECT_TRUE(HistogramSizeEq(
160 "Event.Latency.ScrollUpdate.Wheel.HandledToRendererSwap2_Main", 0));
161 EXPECT_TRUE(HistogramSizeEq(
162 "Event.Latency.ScrollUpdate.Wheel.HandledToRendererSwap2_Impl", 0));
163 EXPECT_TRUE(HistogramSizeEq(
164 "Event.Latency.ScrollUpdate.Wheel.RendererSwapToBrowserNotified2",
165 0));
166 EXPECT_TRUE(HistogramSizeEq(
167 "Event.Latency.ScrollUpdate.Wheel.BrowserNotifiedToBeforeGpuSwap2",
168 0));
169 EXPECT_TRUE(
170 HistogramSizeEq("Event.Latency.ScrollUpdate.Wheel.GpuSwap2", 0));
171 }
172 }
173 }
174 }
175
176 TEST_F(RenderWidgetHostLatencyTrackerTest, TestWheelToScrollHistograms) {
177 for (bool rendering_on_main : {false, true}) {
178 for (bool is_running_navigation_hint_task : {false, true}) {
179 ResetHistograms();
180 {
181 auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
182 blink::WebMouseWheelEvent::PhaseChanged);
183 base::TimeTicks now = base::TimeTicks::Now();
184 wheel.timeStampSeconds = (now - base::TimeTicks()).InSecondsF();
185 ui::LatencyInfo wheel_latency(ui::SourceEventType::WHEEL);
186 wheel_latency.AddLatencyNumberWithTimestamp(
187 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
188 tracker()->latency_component_id(), 0, now, 1);
189 AddFakeComponentsWithTimeStamp(*tracker(), &wheel_latency, now);
190 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main, now);
191 tracker()->OnInputEvent(wheel, &wheel_latency);
192 EXPECT_TRUE(wheel_latency.FindLatency(
193 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
194 tracker()->latency_component_id(), nullptr));
195 EXPECT_TRUE(wheel_latency.FindLatency(
196 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
197 EXPECT_EQ(1U, wheel_latency.input_coordinates_size());
198 tracker()->OnInputEventAck(wheel, &wheel_latency,
199 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
200 tracker()->OnFrameSwapped(wheel_latency,
201 is_running_navigation_hint_task);
202 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelUI", 1));
203 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelAcked", 1));
204
205 EXPECT_TRUE(
206 HistogramSizeEq("Event.Latency.ScrollBegin.Wheel."
207 "TimeToScrollUpdateSwapBegin2",
208 0));
209 EXPECT_TRUE(HistogramSizeEq(
210 "Event.Latency.ScrollBegin.Wheel.TimeToHandled2_Main", 0));
211 EXPECT_TRUE(HistogramSizeEq(
212 "Event.Latency.ScrollBegin.Wheel.TimeToHandled2_Impl", 0));
213 EXPECT_TRUE(HistogramSizeEq(
214 "Event.Latency.ScrollBegin.Wheel.HandledToRendererSwap2_Main", 0));
215 EXPECT_TRUE(HistogramSizeEq(
216 "Event.Latency.ScrollBegin.Wheel.HandledToRendererSwap2_Impl", 0));
217 EXPECT_TRUE(
218 HistogramSizeEq("Event.Latency.ScrollBegin.Wheel."
219 "RendererSwapToBrowserNotified2",
220 0));
221 EXPECT_TRUE(
222 HistogramSizeEq("Event.Latency.ScrollBegin.Wheel."
223 "BrowserNotifiedToBeforeGpuSwap2",
224 0));
225 EXPECT_TRUE(
226 HistogramSizeEq("Event.Latency.ScrollBegin.Wheel.GpuSwap2", 0));
128 227
129 EXPECT_TRUE(HistogramSizeEq( 228 EXPECT_TRUE(HistogramSizeEq(
130 "Event.Latency.ScrollUpdate.Wheel.TimeToHandled2_Main", 229 "Event.Latency.ScrollUpdate.Wheel.TimeToHandled2_Main",
131 rendering_on_main ? 1 : 0)); 230 rendering_on_main ? 1 : 0));
132 EXPECT_TRUE(HistogramSizeEq( 231 EXPECT_TRUE(HistogramSizeEq(
133 "Event.Latency.ScrollUpdate.Wheel.TimeToHandled2_Impl", 232 "Event.Latency.ScrollUpdate.Wheel.TimeToHandled2_Impl",
134 rendering_on_main ? 0 : 1)); 233 rendering_on_main ? 0 : 1));
135 EXPECT_TRUE(HistogramSizeEq( 234 EXPECT_TRUE(HistogramSizeEq(
136 "Event.Latency.ScrollUpdate.Wheel.HandledToRendererSwap2_Main", 235 "Event.Latency.ScrollUpdate.Wheel.HandledToRendererSwap2_Main",
137 rendering_on_main ? 1 : 0)); 236 rendering_on_main ? 1 : 0));
138 EXPECT_TRUE(HistogramSizeEq( 237 EXPECT_TRUE(HistogramSizeEq(
139 "Event.Latency.ScrollUpdate.Wheel.HandledToRendererSwap2_Impl", 238 "Event.Latency.ScrollUpdate.Wheel.HandledToRendererSwap2_Impl",
140 rendering_on_main ? 0 : 1)); 239 rendering_on_main ? 0 : 1));
141 EXPECT_TRUE(HistogramSizeEq( 240 EXPECT_TRUE(HistogramSizeEq(
142 "Event.Latency.ScrollUpdate.Wheel.RendererSwapToBrowserNotified2", 241 "Event.Latency.ScrollUpdate.Wheel.RendererSwapToBrowserNotified2",
143 1)); 242 1));
144 EXPECT_TRUE(HistogramSizeEq( 243 EXPECT_TRUE(HistogramSizeEq(
145 "Event.Latency.ScrollUpdate.Wheel.BrowserNotifiedToBeforeGpuSwap2", 244 "Event.Latency.ScrollUpdate.Wheel.BrowserNotifiedToBeforeGpuSwap2",
146 1)); 245 1));
147 EXPECT_TRUE( 246 EXPECT_TRUE(
148 HistogramSizeEq("Event.Latency.ScrollUpdate.Wheel.GpuSwap2", 1)); 247 HistogramSizeEq("Event.Latency.ScrollUpdate.Wheel.GpuSwap2", 1));
149 } 248 }
150 } 249 }
151 } 250 }
152 } 251 }
153 252
154 TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchHistograms) { 253 TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToFirstScrollHistograms) {
155 for (bool rendering_on_main : {false, true}) { 254 for (bool rendering_on_main : {false, true}) {
156 for (bool is_running_navigation_hint_task : {false, true}) { 255 for (bool is_running_navigation_hint_task : {false, true}) {
157 ResetHistograms(); 256 ResetHistograms();
158 { 257 {
159 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( 258 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
160 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen); 259 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen);
161 base::TimeTicks now = base::TimeTicks::Now(); 260 base::TimeTicks now = base::TimeTicks::Now();
162 scroll.timeStampSeconds = (now - base::TimeTicks()).InSecondsF(); 261 scroll.timeStampSeconds = (now - base::TimeTicks()).InSecondsF();
163 ui::LatencyInfo scroll_latency; 262 ui::LatencyInfo scroll_latency;
263 scroll_latency.AddLatencyNumberWithTimestamp(
264 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
265 tracker()->latency_component_id(), 0, now, 1);
164 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now); 266 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now);
165 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now); 267 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
166 tracker()->OnInputEvent(scroll, &scroll_latency); 268 tracker()->OnInputEvent(scroll, &scroll_latency);
167 EXPECT_TRUE(scroll_latency.FindLatency( 269 EXPECT_TRUE(scroll_latency.FindLatency(
168 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 270 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
169 tracker()->latency_component_id(), nullptr)); 271 tracker()->latency_component_id(), nullptr));
170 EXPECT_TRUE(scroll_latency.FindLatency( 272 EXPECT_TRUE(scroll_latency.FindLatency(
171 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 273 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
172 EXPECT_EQ(1U, scroll_latency.input_coordinates_size()); 274 EXPECT_EQ(1U, scroll_latency.input_coordinates_size());
173 tracker()->OnInputEventAck(scroll, &scroll_latency, 275 tracker()->OnInputEventAck(scroll, &scroll_latency,
174 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 276 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
175 } 277 }
176 278
177 { 279 {
178 SyntheticWebTouchEvent touch; 280 SyntheticWebTouchEvent touch;
179 touch.PressPoint(0, 0); 281 touch.PressPoint(0, 0);
180 touch.PressPoint(1, 1); 282 touch.PressPoint(1, 1);
181 ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH); 283 ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH);
182 base::TimeTicks now = base::TimeTicks::Now(); 284 base::TimeTicks now = base::TimeTicks::Now();
285 touch_latency.AddLatencyNumberWithTimestamp(
286 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
287 tracker()->latency_component_id(), 0, now, 1);
183 AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now); 288 AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now);
184 AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now); 289 AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now);
185 tracker()->OnInputEvent(touch, &touch_latency); 290 tracker()->OnInputEvent(touch, &touch_latency);
186 EXPECT_TRUE(touch_latency.FindLatency( 291 EXPECT_TRUE(touch_latency.FindLatency(
187 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 292 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
188 tracker()->latency_component_id(), nullptr)); 293 tracker()->latency_component_id(), nullptr));
189 EXPECT_TRUE(touch_latency.FindLatency( 294 EXPECT_TRUE(touch_latency.FindLatency(
190 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 295 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
191 EXPECT_EQ(2U, touch_latency.input_coordinates_size()); 296 EXPECT_EQ(2U, touch_latency.input_coordinates_size());
192 tracker()->OnInputEventAck(touch, &touch_latency, 297 tracker()->OnInputEventAck(touch, &touch_latency,
(...skipping 27 matching lines...) Expand all
220 rendering_on_main ? 1 : 0)); 325 rendering_on_main ? 1 : 0));
221 EXPECT_TRUE(HistogramSizeEq( 326 EXPECT_TRUE(HistogramSizeEq(
222 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl", 327 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl",
223 rendering_on_main ? 0 : 1)); 328 rendering_on_main ? 0 : 1));
224 EXPECT_TRUE(HistogramSizeEq( 329 EXPECT_TRUE(HistogramSizeEq(
225 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", 1)); 330 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", 1));
226 EXPECT_TRUE(HistogramSizeEq( 331 EXPECT_TRUE(HistogramSizeEq(
227 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 1)); 332 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 1));
228 EXPECT_TRUE(HistogramSizeEq("Event.Latency.ScrollUpdate.GpuSwap", 1)); 333 EXPECT_TRUE(HistogramSizeEq("Event.Latency.ScrollUpdate.GpuSwap", 1));
229 EXPECT_TRUE(HistogramSizeEq( 334 EXPECT_TRUE(HistogramSizeEq(
230 "Event.Latency.ScrollUpdate.Touch.TimeToFirstScrollUpdateSwapBegin2", 335 "Event.Latency.ScrollBegin.Touch.TimeToScrollUpdateSwapBegin2", 1));
231 1));
232 336
233 EXPECT_TRUE(HistogramSizeEq( 337 EXPECT_TRUE(HistogramSizeEq(
234 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", 0)); 338 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", 0));
235 339
340 EXPECT_TRUE(
341 HistogramSizeEq("Event.Latency.ScrollBegin.Touch.TimeToHandled2_Main",
342 rendering_on_main ? 1 : 0));
343 EXPECT_TRUE(
344 HistogramSizeEq("Event.Latency.ScrollBegin.Touch.TimeToHandled2_Impl",
345 rendering_on_main ? 0 : 1));
346 EXPECT_TRUE(HistogramSizeEq(
347 "Event.Latency.ScrollBegin.Touch.HandledToRendererSwap2_Main",
348 rendering_on_main ? 1 : 0));
349 EXPECT_TRUE(HistogramSizeEq(
350 "Event.Latency.ScrollBegin.Touch.HandledToRendererSwap2_Impl",
351 rendering_on_main ? 0 : 1));
352 EXPECT_TRUE(
353 HistogramSizeEq("Event.Latency.ScrollBegin.Touch."
354 "RendererSwapToBrowserNotified2",
355 1));
356 EXPECT_TRUE(
357 HistogramSizeEq("Event.Latency.ScrollBegin.Touch."
358 "BrowserNotifiedToBeforeGpuSwap2",
359 1));
360 EXPECT_TRUE(
361 HistogramSizeEq("Event.Latency.ScrollBegin.Touch.GpuSwap2", 1));
362
363 EXPECT_TRUE(HistogramSizeEq(
364 "Event.Latency.ScrollUpdate.Touch.TimeToHandled2_Main", 0));
365 EXPECT_TRUE(HistogramSizeEq(
366 "Event.Latency.ScrollUpdate.Touch.TimeToHandled2_Impl", 0));
367 EXPECT_TRUE(HistogramSizeEq(
368 "Event.Latency.ScrollUpdate.Touch.HandledToRendererSwap2_Main", 0));
369 EXPECT_TRUE(HistogramSizeEq(
370 "Event.Latency.ScrollUpdate.Touch.HandledToRendererSwap2_Impl", 0));
371 EXPECT_TRUE(HistogramSizeEq(
372 "Event.Latency.ScrollUpdate.Touch.RendererSwapToBrowserNotified2",
373 0));
374 EXPECT_TRUE(HistogramSizeEq(
375 "Event.Latency.ScrollUpdate.Touch.BrowserNotifiedToBeforeGpuSwap2",
376 0));
377 EXPECT_TRUE(
378 HistogramSizeEq("Event.Latency.ScrollUpdate.Touch.GpuSwap2", 0));
379 }
380 }
381 }
382
383 TEST_F(RenderWidgetHostLatencyTrackerTest, TestTouchToScrollHistograms) {
384 for (bool rendering_on_main : {false, true}) {
385 for (bool is_running_navigation_hint_task : {false, true}) {
386 ResetHistograms();
387 {
388 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
389 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen);
390 base::TimeTicks now = base::TimeTicks::Now();
391 scroll.timeStampSeconds = (now - base::TimeTicks()).InSecondsF();
392 ui::LatencyInfo scroll_latency;
393 scroll_latency.AddLatencyNumberWithTimestamp(
394 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
395 tracker()->latency_component_id(), 0, now, 1);
396 AddFakeComponentsWithTimeStamp(*tracker(), &scroll_latency, now);
397 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main, now);
398 tracker()->OnInputEvent(scroll, &scroll_latency);
399 EXPECT_TRUE(scroll_latency.FindLatency(
400 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
401 tracker()->latency_component_id(), nullptr));
402 EXPECT_TRUE(scroll_latency.FindLatency(
403 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
404 EXPECT_EQ(1U, scroll_latency.input_coordinates_size());
405 tracker()->OnInputEventAck(scroll, &scroll_latency,
406 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
407 }
408
409 {
410 SyntheticWebTouchEvent touch;
411 touch.PressPoint(0, 0);
412 touch.PressPoint(1, 1);
413 ui::LatencyInfo touch_latency(ui::SourceEventType::TOUCH);
414 base::TimeTicks now = base::TimeTicks::Now();
415 touch_latency.AddLatencyNumberWithTimestamp(
416 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
417 tracker()->latency_component_id(), 0, now, 1);
418 AddFakeComponentsWithTimeStamp(*tracker(), &touch_latency, now);
419 AddRenderingScheduledComponent(&touch_latency, rendering_on_main, now);
420 tracker()->OnInputEvent(touch, &touch_latency);
421 EXPECT_TRUE(touch_latency.FindLatency(
422 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
423 tracker()->latency_component_id(), nullptr));
424 EXPECT_TRUE(touch_latency.FindLatency(
425 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
426 EXPECT_EQ(2U, touch_latency.input_coordinates_size());
427 tracker()->OnInputEventAck(touch, &touch_latency,
428 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
429 tracker()->OnFrameSwapped(touch_latency,
430 is_running_navigation_hint_task);
431 }
432
433 EXPECT_TRUE(HistogramSizeEq(
434 "Event.Latency.ScrollBegin.Touch.TimeToScrollUpdateSwapBegin2", 0));
435 EXPECT_TRUE(HistogramSizeEq(
436 "Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin2", 1));
437 EXPECT_TRUE(HistogramSizeEq(
438 "Event.Latency.ScrollBegin.Touch.TimeToHandled2_Main", 0));
439 EXPECT_TRUE(HistogramSizeEq(
440 "Event.Latency.ScrollBegin.Touch.TimeToHandled2_Impl", 0));
441 EXPECT_TRUE(HistogramSizeEq(
442 "Event.Latency.ScrollBegin.Touch.HandledToRendererSwap2_Main", 0));
443 EXPECT_TRUE(HistogramSizeEq(
444 "Event.Latency.ScrollBegin.Touch.HandledToRendererSwap2_Impl", 0));
445 EXPECT_TRUE(
446 HistogramSizeEq("Event.Latency.ScrollBegin.Touch."
447 "RendererSwapToBrowserNotified2",
448 0));
449 EXPECT_TRUE(
450 HistogramSizeEq("Event.Latency.ScrollBegin.Touch."
451 "BrowserNotifiedToBeforeGpuSwap2",
452 0));
453 EXPECT_TRUE(
454 HistogramSizeEq("Event.Latency.ScrollBegin.Touch.GpuSwap2", 0));
455
236 EXPECT_TRUE(HistogramSizeEq( 456 EXPECT_TRUE(HistogramSizeEq(
237 "Event.Latency.ScrollUpdate.Touch.TimeToHandled2_Main", 457 "Event.Latency.ScrollUpdate.Touch.TimeToHandled2_Main",
238 rendering_on_main ? 1 : 0)); 458 rendering_on_main ? 1 : 0));
239 EXPECT_TRUE(HistogramSizeEq( 459 EXPECT_TRUE(HistogramSizeEq(
240 "Event.Latency.ScrollUpdate.Touch.TimeToHandled2_Impl", 460 "Event.Latency.ScrollUpdate.Touch.TimeToHandled2_Impl",
241 rendering_on_main ? 0 : 1)); 461 rendering_on_main ? 0 : 1));
242 EXPECT_TRUE(HistogramSizeEq( 462 EXPECT_TRUE(HistogramSizeEq(
243 "Event.Latency.ScrollUpdate.Touch.HandledToRendererSwap2_Main", 463 "Event.Latency.ScrollUpdate.Touch.HandledToRendererSwap2_Main",
244 rendering_on_main ? 1 : 0)); 464 rendering_on_main ? 1 : 0));
245 EXPECT_TRUE(HistogramSizeEq( 465 EXPECT_TRUE(HistogramSizeEq(
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), 861 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"),
642 ElementsAre(Bucket( 862 ElementsAre(Bucket(
643 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); 863 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1)));
644 EXPECT_THAT(histogram_tester().GetAllSamples( 864 EXPECT_THAT(histogram_tester().GetAllSamples(
645 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), 865 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"),
646 ElementsAre(Bucket( 866 ElementsAre(Bucket(
647 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); 867 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1)));
648 } 868 }
649 869
650 } // namespace content 870 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698