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

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

Issue 2211783003: Track input latency while starting a ServiceWorker for a navigation hint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 4 years, 4 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 "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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 private: 84 private:
85 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostLatencyTrackerTest); 85 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostLatencyTrackerTest);
86 const int kTestRoutingId = 3; 86 const int kTestRoutingId = 3;
87 const int kTestProcessId = 1; 87 const int kTestProcessId = 1;
88 std::unique_ptr<base::HistogramTester> histogram_tester_; 88 std::unique_ptr<base::HistogramTester> histogram_tester_;
89 RenderWidgetHostLatencyTracker tracker_; 89 RenderWidgetHostLatencyTracker tracker_;
90 }; 90 };
91 91
92 TEST_F(RenderWidgetHostLatencyTrackerTest, TestHistograms) { 92 TEST_F(RenderWidgetHostLatencyTrackerTest, TestHistograms) {
93 for (bool rendering_on_main : { false, true }) { 93 for (bool rendering_on_main : { false, true }) {
94 ResetHistograms(); 94 for (bool is_running_navigation_hint_task : {false, true}) {
95 { 95 ResetHistograms();
96 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate( 96 {
97 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen); 97 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollUpdate(
98 scroll.timeStampSeconds = 98 5.f, -5.f, 0, blink::WebGestureDeviceTouchscreen);
99 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); 99 scroll.timeStampSeconds =
100 ui::LatencyInfo scroll_latency; 100 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
101 AddFakeComponents(*tracker(), &scroll_latency); 101 ui::LatencyInfo scroll_latency;
102 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main); 102 AddFakeComponents(*tracker(), &scroll_latency);
103 tracker()->OnInputEvent(scroll, &scroll_latency); 103 AddRenderingScheduledComponent(&scroll_latency, rendering_on_main);
104 EXPECT_TRUE(scroll_latency.FindLatency( 104 tracker()->OnInputEvent(scroll, &scroll_latency);
105 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 105 EXPECT_TRUE(scroll_latency.FindLatency(
106 tracker()->latency_component_id(), nullptr)); 106 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
107 EXPECT_TRUE(scroll_latency.FindLatency( 107 tracker()->latency_component_id(), nullptr));
108 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 108 EXPECT_TRUE(scroll_latency.FindLatency(
109 EXPECT_EQ(1U, scroll_latency.input_coordinates_size()); 109 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
110 tracker()->OnInputEventAck(scroll, &scroll_latency, 110 EXPECT_EQ(1U, scroll_latency.input_coordinates_size());
111 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 111 tracker()->OnInputEventAck(scroll, &scroll_latency,
112 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
113 }
114
115 {
116 auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
117 blink::WebMouseWheelEvent::PhaseChanged);
118 wheel.timeStampSeconds =
119 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
120 ui::LatencyInfo wheel_latency;
121 AddFakeComponents(*tracker(), &wheel_latency);
122 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main);
123 tracker()->OnInputEvent(wheel, &wheel_latency);
124 EXPECT_TRUE(wheel_latency.FindLatency(
125 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
126 tracker()->latency_component_id(), nullptr));
127 EXPECT_TRUE(wheel_latency.FindLatency(
128 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
129 EXPECT_EQ(1U, wheel_latency.input_coordinates_size());
130 tracker()->OnInputEventAck(wheel, &wheel_latency,
131 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
132 }
133
134 {
135 SyntheticWebTouchEvent touch;
136 touch.PressPoint(0, 0);
137 touch.PressPoint(1, 1);
138 ui::LatencyInfo touch_latency;
139 AddFakeComponents(*tracker(), &touch_latency);
140 AddRenderingScheduledComponent(&touch_latency, rendering_on_main);
141 tracker()->OnInputEvent(touch, &touch_latency);
142 EXPECT_TRUE(touch_latency.FindLatency(
143 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
144 tracker()->latency_component_id(), nullptr));
145 EXPECT_TRUE(touch_latency.FindLatency(
146 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
147 EXPECT_EQ(2U, touch_latency.input_coordinates_size());
148 tracker()->OnInputEventAck(touch, &touch_latency,
149 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
150 tracker()->OnFrameSwapped(touch_latency,
151 is_running_navigation_hint_task);
152 }
153
154 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelUI", 1));
155 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchUI", 1));
156 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelAcked", 1));
157 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchAcked", 1));
158 EXPECT_TRUE(HistogramSizeEq(
159 "Event.Latency.TouchToFirstScrollUpdateSwapBegin", 1));
160 EXPECT_TRUE(
161 HistogramSizeEq("Event.Latency.TouchToFirstScrollUpdateSwapBegin_"
162 "IsRunningNavigationHintTask",
163 is_running_navigation_hint_task ? 1 : 0));
164 EXPECT_TRUE(
165 HistogramSizeEq("Event.Latency.TouchToScrollUpdateSwapBegin", 1));
166 EXPECT_TRUE(
167 HistogramSizeEq("Event.Latency.TouchToScrollUpdateSwapBegin_"
168 "IsRunningNavigationHintTask",
169 is_running_navigation_hint_task ? 1 : 0));
170 EXPECT_TRUE(
171 HistogramSizeEq("Event.Latency.ScrollUpdate.TouchToHandled_Main",
172 rendering_on_main ? 1 : 0));
173 EXPECT_TRUE(
174 HistogramSizeEq("Event.Latency.ScrollUpdate.TouchToHandled_Impl",
175 rendering_on_main ? 0 : 1));
176 EXPECT_TRUE(HistogramSizeEq(
177 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Main",
178 rendering_on_main ? 1 : 0));
179 EXPECT_TRUE(HistogramSizeEq(
180 "Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl",
181 rendering_on_main ? 0 : 1));
182 EXPECT_TRUE(HistogramSizeEq(
183 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", 1));
184 EXPECT_TRUE(HistogramSizeEq(
185 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 1));
186 EXPECT_TRUE(HistogramSizeEq("Event.Latency.ScrollUpdate.GpuSwap", 1));
112 } 187 }
113
114 {
115 auto wheel = SyntheticWebMouseWheelEventBuilder::Build(
116 blink::WebMouseWheelEvent::PhaseChanged);
117 wheel.timeStampSeconds =
118 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
119 ui::LatencyInfo wheel_latency;
120 AddFakeComponents(*tracker(), &wheel_latency);
121 AddRenderingScheduledComponent(&wheel_latency, rendering_on_main);
122 tracker()->OnInputEvent(wheel, &wheel_latency);
123 EXPECT_TRUE(wheel_latency.FindLatency(
124 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
125 tracker()->latency_component_id(), nullptr));
126 EXPECT_TRUE(wheel_latency.FindLatency(
127 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
128 EXPECT_EQ(1U, wheel_latency.input_coordinates_size());
129 tracker()->OnInputEventAck(wheel, &wheel_latency,
130 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
131 }
132
133 {
134 SyntheticWebTouchEvent touch;
135 touch.PressPoint(0, 0);
136 touch.PressPoint(1, 1);
137 ui::LatencyInfo touch_latency;
138 AddFakeComponents(*tracker(), &touch_latency);
139 AddRenderingScheduledComponent(&touch_latency, rendering_on_main);
140 tracker()->OnInputEvent(touch, &touch_latency);
141 EXPECT_TRUE(touch_latency.FindLatency(
142 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
143 tracker()->latency_component_id(), nullptr));
144 EXPECT_TRUE(touch_latency.FindLatency(
145 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
146 EXPECT_EQ(2U, touch_latency.input_coordinates_size());
147 tracker()->OnInputEventAck(touch, &touch_latency,
148 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
149 tracker()->OnFrameSwapped(touch_latency);
150 }
151
152 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelUI", 1));
153 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchUI", 1));
154 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.WheelAcked", 1));
155 EXPECT_TRUE(HistogramSizeEq("Event.Latency.Browser.TouchAcked", 1));
156 EXPECT_TRUE(
157 HistogramSizeEq("Event.Latency.TouchToFirstScrollUpdateSwapBegin", 1));
158 EXPECT_TRUE(
159 HistogramSizeEq("Event.Latency.TouchToScrollUpdateSwapBegin", 1));
160 EXPECT_TRUE(
161 HistogramSizeEq("Event.Latency.ScrollUpdate.TouchToHandled_Main",
162 rendering_on_main ? 1 : 0));
163 EXPECT_TRUE(
164 HistogramSizeEq("Event.Latency.ScrollUpdate.TouchToHandled_Impl",
165 rendering_on_main ? 0 : 1));
166 EXPECT_TRUE(
167 HistogramSizeEq("Event.Latency.ScrollUpdate.HandledToRendererSwap_Main",
168 rendering_on_main ? 1 : 0));
169 EXPECT_TRUE(
170 HistogramSizeEq("Event.Latency.ScrollUpdate.HandledToRendererSwap_Impl",
171 rendering_on_main ? 0 : 1));
172 EXPECT_TRUE(HistogramSizeEq(
173 "Event.Latency.ScrollUpdate.RendererSwapToBrowserNotified", 1));
174 EXPECT_TRUE(HistogramSizeEq(
175 "Event.Latency.ScrollUpdate.BrowserNotifiedToBeforeGpuSwap", 1));
176 EXPECT_TRUE(HistogramSizeEq("Event.Latency.ScrollUpdate.GpuSwap", 1));
177 } 188 }
178 } 189 }
179 190
180 TEST_F(RenderWidgetHostLatencyTrackerTest, 191 TEST_F(RenderWidgetHostLatencyTrackerTest,
181 LatencyTerminatedOnAckIfRenderingNotScheduled) { 192 LatencyTerminatedOnAckIfRenderingNotScheduled) {
182 { 193 {
183 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollBegin( 194 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollBegin(
184 5.f, -5.f, blink::WebGestureDeviceTouchscreen); 195 5.f, -5.f, blink::WebGestureDeviceTouchscreen);
185 ui::LatencyInfo scroll_latency; 196 ui::LatencyInfo scroll_latency;
186 AddFakeComponents(*tracker(), &scroll_latency); 197 AddFakeComponents(*tracker(), &scroll_latency);
(...skipping 24 matching lines...) Expand all
211 SyntheticWebTouchEvent touch; 222 SyntheticWebTouchEvent touch;
212 touch.PressPoint(0, 0); 223 touch.PressPoint(0, 0);
213 ui::LatencyInfo touch_latency; 224 ui::LatencyInfo touch_latency;
214 AddFakeComponents(*tracker(), &touch_latency); 225 AddFakeComponents(*tracker(), &touch_latency);
215 tracker()->OnInputEvent(touch, &touch_latency); 226 tracker()->OnInputEvent(touch, &touch_latency);
216 tracker()->OnInputEventAck(touch, &touch_latency, 227 tracker()->OnInputEventAck(touch, &touch_latency,
217 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 228 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
218 EXPECT_TRUE(touch_latency.FindLatency( 229 EXPECT_TRUE(touch_latency.FindLatency(
219 ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, nullptr)); 230 ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, nullptr));
220 EXPECT_TRUE(touch_latency.terminated()); 231 EXPECT_TRUE(touch_latency.terminated());
221 tracker()->OnFrameSwapped(touch_latency); 232 tracker()->OnFrameSwapped(touch_latency, false);
222 } 233 }
223 234
224 { 235 {
225 auto mouse_move = SyntheticWebMouseEventBuilder::Build( 236 auto mouse_move = SyntheticWebMouseEventBuilder::Build(
226 blink::WebMouseEvent::MouseMove); 237 blink::WebMouseEvent::MouseMove);
227 ui::LatencyInfo mouse_latency; 238 ui::LatencyInfo mouse_latency;
228 AddFakeComponents(*tracker(), &mouse_latency); 239 AddFakeComponents(*tracker(), &mouse_latency);
229 tracker()->OnInputEvent(mouse_move, &mouse_latency); 240 tracker()->OnInputEvent(mouse_move, &mouse_latency);
230 tracker()->OnInputEventAck(mouse_move, &mouse_latency, 241 tracker()->OnInputEventAck(mouse_move, &mouse_latency,
231 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 242 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"), 572 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"),
562 ElementsAre(Bucket( 573 ElementsAre(Bucket(
563 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); 574 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1)));
564 EXPECT_THAT(histogram_tester().GetAllSamples( 575 EXPECT_THAT(histogram_tester().GetAllSamples(
565 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"), 576 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"),
566 ElementsAre(Bucket( 577 ElementsAre(Bucket(
567 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1))); 578 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1)));
568 } 579 }
569 580
570 } // namespace content 581 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698