| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/render_widget_host_latency_tracker.h" |
| 6 #include "content/common/input/synthetic_web_input_event_builders.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 |
| 9 namespace content { |
| 10 namespace { |
| 11 |
| 12 const int kTestRoutingId = 3; |
| 13 const int kTestProcessId = 1; |
| 14 |
| 15 } // namespace |
| 16 |
| 17 TEST(RenderWidgetHostLatencyTrackerTest, Basic) { |
| 18 RenderWidgetHostLatencyTracker tracker; |
| 19 tracker.Initialize(kTestRoutingId, kTestProcessId); |
| 20 |
| 21 { |
| 22 auto scroll = |
| 23 SyntheticWebGestureEventBuilder::BuildScrollUpdate(5.f, -5.f, 0); |
| 24 ui::LatencyInfo scroll_latency; |
| 25 tracker.OnInputEvent(scroll, &scroll_latency); |
| 26 EXPECT_TRUE( |
| 27 scroll_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 28 tracker.latency_component_id(), nullptr)); |
| 29 EXPECT_TRUE(scroll_latency.FindLatency( |
| 30 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT, |
| 31 tracker.latency_component_id(), nullptr)); |
| 32 EXPECT_EQ(1U, scroll_latency.input_coordinates_size); |
| 33 } |
| 34 |
| 35 { |
| 36 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( |
| 37 blink::WebMouseWheelEvent::PhaseChanged); |
| 38 ui::LatencyInfo wheel_latency; |
| 39 tracker.OnInputEvent(wheel, &wheel_latency); |
| 40 EXPECT_TRUE( |
| 41 wheel_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 42 tracker.latency_component_id(), nullptr)); |
| 43 EXPECT_EQ(1U, wheel_latency.input_coordinates_size); |
| 44 } |
| 45 |
| 46 { |
| 47 SyntheticWebTouchEvent touch; |
| 48 touch.PressPoint(0, 0); |
| 49 touch.PressPoint(1, 1); |
| 50 ui::LatencyInfo touch_latency; |
| 51 tracker.OnInputEvent(touch, &touch_latency); |
| 52 EXPECT_TRUE( |
| 53 touch_latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 54 tracker.latency_component_id(), nullptr)); |
| 55 EXPECT_EQ(2U, touch_latency.input_coordinates_size); |
| 56 } |
| 57 } |
| 58 |
| 59 TEST(RenderWidgetHostLatencyTrackerTest, |
| 60 LatencyTerminatedOnAckIfRenderingNotScheduled) { |
| 61 RenderWidgetHostLatencyTracker tracker; |
| 62 tracker.Initialize(kTestRoutingId, kTestProcessId); |
| 63 |
| 64 { |
| 65 auto scroll = SyntheticWebGestureEventBuilder::BuildScrollBegin(5.f, -5.f); |
| 66 ui::LatencyInfo scroll_latency; |
| 67 tracker.OnInputEvent(scroll, &scroll_latency); |
| 68 tracker.OnInputEventAck(scroll, &scroll_latency); |
| 69 EXPECT_TRUE(scroll_latency.FindLatency( |
| 70 ui::INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, 0, nullptr)); |
| 71 EXPECT_TRUE(scroll_latency.terminated); |
| 72 } |
| 73 |
| 74 { |
| 75 auto wheel = SyntheticWebMouseWheelEventBuilder::Build( |
| 76 blink::WebMouseWheelEvent::PhaseChanged); |
| 77 ui::LatencyInfo wheel_latency; |
| 78 tracker.OnInputEvent(wheel, &wheel_latency); |
| 79 tracker.OnInputEventAck(wheel, &wheel_latency); |
| 80 EXPECT_TRUE(wheel_latency.FindLatency( |
| 81 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, nullptr)); |
| 82 EXPECT_TRUE(wheel_latency.terminated); |
| 83 } |
| 84 |
| 85 { |
| 86 SyntheticWebTouchEvent touch; |
| 87 touch.PressPoint(0, 0); |
| 88 ui::LatencyInfo touch_latency; |
| 89 tracker.OnInputEvent(touch, &touch_latency); |
| 90 tracker.OnInputEventAck(touch, &touch_latency); |
| 91 EXPECT_TRUE(touch_latency.FindLatency( |
| 92 ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, nullptr)); |
| 93 EXPECT_TRUE(touch_latency.terminated); |
| 94 } |
| 95 } |
| 96 |
| 97 } // namespace content |
| OLD | NEW |