| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <tuple> | 9 #include <tuple> |
| 10 | 10 |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 bool handle_wheel_event_called_; | 505 bool handle_wheel_event_called_; |
| 506 | 506 |
| 507 bool unresponsive_timer_fired_; | 507 bool unresponsive_timer_fired_; |
| 508 | 508 |
| 509 ScreenInfo screen_info_; | 509 ScreenInfo screen_info_; |
| 510 | 510 |
| 511 std::unique_ptr<MockRenderViewHostDelegateView> | 511 std::unique_ptr<MockRenderViewHostDelegateView> |
| 512 render_view_host_delegate_view_; | 512 render_view_host_delegate_view_; |
| 513 }; | 513 }; |
| 514 | 514 |
| 515 enum WheelScrollingMode { |
| 516 kWheelScrollingModeNone, |
| 517 kWheelScrollLatching, |
| 518 kAsyncWheelEvents, |
| 519 }; |
| 520 |
| 515 // RenderWidgetHostTest -------------------------------------------------------- | 521 // RenderWidgetHostTest -------------------------------------------------------- |
| 516 | 522 |
| 517 class RenderWidgetHostTest : public testing::Test { | 523 class RenderWidgetHostTest : public testing::Test { |
| 518 public: | 524 public: |
| 519 RenderWidgetHostTest() | 525 RenderWidgetHostTest( |
| 526 WheelScrollingMode wheel_scrolling_mode = kWheelScrollLatching) |
| 520 : process_(NULL), | 527 : process_(NULL), |
| 521 handle_key_press_event_(false), | 528 handle_key_press_event_(false), |
| 522 handle_mouse_event_(false), | 529 handle_mouse_event_(false), |
| 523 simulated_event_time_delta_seconds_(0) { | 530 simulated_event_time_delta_seconds_(0), |
| 531 wheel_scroll_latching_enabled_(wheel_scrolling_mode != |
| 532 kWheelScrollingModeNone) { |
| 533 switch (wheel_scrolling_mode) { |
| 534 case kWheelScrollingModeNone: |
| 535 feature_list_.InitWithFeatures( |
| 536 {features::kRafAlignedTouchInputEvents}, |
| 537 {features::kTouchpadAndWheelScrollLatching, |
| 538 features::kAsyncWheelEvents}); |
| 539 break; |
| 540 case kWheelScrollLatching: |
| 541 feature_list_.InitWithFeatures( |
| 542 {features::kRafAlignedTouchInputEvents, |
| 543 features::kTouchpadAndWheelScrollLatching}, |
| 544 {features::kAsyncWheelEvents}); |
| 545 break; |
| 546 case kAsyncWheelEvents: |
| 547 feature_list_.InitWithFeatures( |
| 548 {features::kRafAlignedTouchInputEvents, |
| 549 features::kTouchpadAndWheelScrollLatching, |
| 550 features::kAsyncWheelEvents}, |
| 551 {}); |
| 552 } |
| 524 last_simulated_event_time_seconds_ = | 553 last_simulated_event_time_seconds_ = |
| 525 ui::EventTimeStampToSeconds(ui::EventTimeForNow()); | 554 ui::EventTimeStampToSeconds(ui::EventTimeForNow()); |
| 526 } | 555 } |
| 527 ~RenderWidgetHostTest() override {} | 556 ~RenderWidgetHostTest() override {} |
| 528 | 557 |
| 529 bool KeyPressEventCallback(const NativeWebKeyboardEvent& /* event */) { | 558 bool KeyPressEventCallback(const NativeWebKeyboardEvent& /* event */) { |
| 530 return handle_key_press_event_; | 559 return handle_key_press_event_; |
| 531 } | 560 } |
| 532 bool MouseEventCallback(const blink::WebMouseEvent& /* event */) { | 561 bool MouseEventCallback(const blink::WebMouseEvent& /* event */) { |
| 533 return handle_mouse_event_; | 562 return handle_mouse_event_; |
| 534 } | 563 } |
| 535 | 564 |
| 536 protected: | 565 protected: |
| 537 // testing::Test | 566 // testing::Test |
| 538 void SetUp() override { | 567 void SetUp() override { |
| 539 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 568 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 540 command_line->AppendSwitch(switches::kValidateInputEventStream); | 569 command_line->AppendSwitch(switches::kValidateInputEventStream); |
| 541 feature_list_.InitFromCommandLine( | |
| 542 features::kRafAlignedTouchInputEvents.name, ""); | |
| 543 | |
| 544 browser_context_.reset(new TestBrowserContext()); | 570 browser_context_.reset(new TestBrowserContext()); |
| 545 delegate_.reset(new MockRenderWidgetHostDelegate()); | 571 delegate_.reset(new MockRenderWidgetHostDelegate()); |
| 546 process_ = new RenderWidgetHostProcess(browser_context_.get()); | 572 process_ = new RenderWidgetHostProcess(browser_context_.get()); |
| 547 sink_ = &process_->sink(); | 573 sink_ = &process_->sink(); |
| 548 #if defined(USE_AURA) || defined(OS_MACOSX) | 574 #if defined(USE_AURA) || defined(OS_MACOSX) |
| 549 ImageTransportFactory::InitializeForUnitTests( | 575 ImageTransportFactory::InitializeForUnitTests( |
| 550 std::unique_ptr<ImageTransportFactory>( | 576 std::unique_ptr<ImageTransportFactory>( |
| 551 new NoTransportImageTransportFactory)); | 577 new NoTransportImageTransportFactory)); |
| 552 #endif | 578 #endif |
| 553 #if defined(OS_ANDROID) | 579 #if defined(OS_ANDROID) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 host_->ForwardMouseEventWithLatencyInfo( | 678 host_->ForwardMouseEventWithLatencyInfo( |
| 653 SyntheticWebMouseEventBuilder::Build(type), | 679 SyntheticWebMouseEventBuilder::Build(type), |
| 654 ui_latency); | 680 ui_latency); |
| 655 } | 681 } |
| 656 | 682 |
| 657 void SimulateWheelEvent(float dX, float dY, int modifiers, bool precise) { | 683 void SimulateWheelEvent(float dX, float dY, int modifiers, bool precise) { |
| 658 host_->ForwardWheelEvent(SyntheticWebMouseWheelEventBuilder::Build( | 684 host_->ForwardWheelEvent(SyntheticWebMouseWheelEventBuilder::Build( |
| 659 0, 0, dX, dY, modifiers, precise)); | 685 0, 0, dX, dY, modifiers, precise)); |
| 660 } | 686 } |
| 661 | 687 |
| 688 void SimulateWheelEventPossiblyIncludingPhase( |
| 689 float dX, |
| 690 float dY, |
| 691 int modifiers, |
| 692 bool precise, |
| 693 WebMouseWheelEvent::Phase phase) { |
| 694 WebMouseWheelEvent wheel_event = SyntheticWebMouseWheelEventBuilder::Build( |
| 695 0, 0, dX, dY, modifiers, precise); |
| 696 if (wheel_scroll_latching_enabled_) |
| 697 wheel_event.phase = phase; |
| 698 host_->ForwardWheelEvent(wheel_event); |
| 699 } |
| 700 |
| 662 void SimulateWheelEventWithLatencyInfo(float dX, | 701 void SimulateWheelEventWithLatencyInfo(float dX, |
| 663 float dY, | 702 float dY, |
| 664 int modifiers, | 703 int modifiers, |
| 665 bool precise, | 704 bool precise, |
| 666 const ui::LatencyInfo& ui_latency) { | 705 const ui::LatencyInfo& ui_latency) { |
| 667 host_->ForwardWheelEventWithLatencyInfo( | 706 host_->ForwardWheelEventWithLatencyInfo( |
| 668 SyntheticWebMouseWheelEventBuilder::Build(0, 0, dX, dY, modifiers, | 707 SyntheticWebMouseWheelEventBuilder::Build(0, 0, dX, dY, modifiers, |
| 669 precise), | 708 precise), |
| 670 ui_latency); | 709 ui_latency); |
| 671 } | 710 } |
| 672 | 711 |
| 712 void SimulateWheelEventWithLatencyInfoAndPossiblyPhase( |
| 713 float dX, |
| 714 float dY, |
| 715 int modifiers, |
| 716 bool precise, |
| 717 const ui::LatencyInfo& ui_latency, |
| 718 WebMouseWheelEvent::Phase phase) { |
| 719 WebMouseWheelEvent wheel_event = SyntheticWebMouseWheelEventBuilder::Build( |
| 720 0, 0, dX, dY, modifiers, precise); |
| 721 if (wheel_scroll_latching_enabled_) |
| 722 wheel_event.phase = phase; |
| 723 host_->ForwardWheelEventWithLatencyInfo(wheel_event, ui_latency); |
| 724 } |
| 725 |
| 673 void SimulateMouseMove(int x, int y, int modifiers) { | 726 void SimulateMouseMove(int x, int y, int modifiers) { |
| 674 SimulateMouseEvent(WebInputEvent::kMouseMove, x, y, modifiers, false); | 727 SimulateMouseEvent(WebInputEvent::kMouseMove, x, y, modifiers, false); |
| 675 } | 728 } |
| 676 | 729 |
| 677 void SimulateMouseEvent( | 730 void SimulateMouseEvent( |
| 678 WebInputEvent::Type type, int x, int y, int modifiers, bool pressed) { | 731 WebInputEvent::Type type, int x, int y, int modifiers, bool pressed) { |
| 679 WebMouseEvent event = | 732 WebMouseEvent event = |
| 680 SyntheticWebMouseEventBuilder::Build(type, x, y, modifiers); | 733 SyntheticWebMouseEventBuilder::Build(type, x, y, modifiers); |
| 681 if (pressed) | 734 if (pressed) |
| 682 event.button = WebMouseEvent::Button::kLeft; | 735 event.button = WebMouseEvent::Button::kLeft; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 | 781 |
| 729 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { | 782 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { |
| 730 base::PickleIterator iter(message); | 783 base::PickleIterator iter(message); |
| 731 const char* data; | 784 const char* data; |
| 732 int data_length; | 785 int data_length; |
| 733 if (!iter.ReadData(&data, &data_length)) | 786 if (!iter.ReadData(&data, &data_length)) |
| 734 return NULL; | 787 return NULL; |
| 735 return reinterpret_cast<const WebInputEvent*>(data); | 788 return reinterpret_cast<const WebInputEvent*>(data); |
| 736 } | 789 } |
| 737 | 790 |
| 791 void UnhandledWheelEvent(); |
| 792 void HandleWheelEvent(); |
| 793 void InputEventRWHLatencyComponent(); |
| 794 |
| 738 std::unique_ptr<TestBrowserContext> browser_context_; | 795 std::unique_ptr<TestBrowserContext> browser_context_; |
| 739 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. | 796 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. |
| 740 std::unique_ptr<MockRenderWidgetHostDelegate> delegate_; | 797 std::unique_ptr<MockRenderWidgetHostDelegate> delegate_; |
| 741 std::unique_ptr<MockRenderWidgetHost> host_; | 798 std::unique_ptr<MockRenderWidgetHost> host_; |
| 742 std::unique_ptr<TestView> view_; | 799 std::unique_ptr<TestView> view_; |
| 743 std::unique_ptr<display::Screen> screen_; | 800 std::unique_ptr<display::Screen> screen_; |
| 744 bool handle_key_press_event_; | 801 bool handle_key_press_event_; |
| 745 bool handle_mouse_event_; | 802 bool handle_mouse_event_; |
| 746 double last_simulated_event_time_seconds_; | 803 double last_simulated_event_time_seconds_; |
| 747 double simulated_event_time_delta_seconds_; | 804 double simulated_event_time_delta_seconds_; |
| 748 IPC::TestSink* sink_; | 805 IPC::TestSink* sink_; |
| 749 std::unique_ptr<FakeRendererCompositorFrameSink> | 806 std::unique_ptr<FakeRendererCompositorFrameSink> |
| 750 renderer_compositor_frame_sink_; | 807 renderer_compositor_frame_sink_; |
| 808 bool wheel_scroll_latching_enabled_; |
| 751 | 809 |
| 752 private: | 810 private: |
| 753 SyntheticWebTouchEvent touch_event_; | 811 SyntheticWebTouchEvent touch_event_; |
| 754 | 812 |
| 755 TestBrowserThreadBundle thread_bundle_; | 813 TestBrowserThreadBundle thread_bundle_; |
| 756 base::test::ScopedFeatureList feature_list_; | 814 base::test::ScopedFeatureList feature_list_; |
| 757 cc::mojom::MojoCompositorFrameSinkClientPtr | 815 cc::mojom::MojoCompositorFrameSinkClientPtr |
| 758 renderer_compositor_frame_sink_ptr_; | 816 renderer_compositor_frame_sink_ptr_; |
| 759 | 817 |
| 760 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); | 818 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); |
| 761 }; | 819 }; |
| 762 | 820 |
| 821 class RenderWidgetHostWheelScrollLatchingDisabledTest |
| 822 : public RenderWidgetHostTest { |
| 823 public: |
| 824 RenderWidgetHostWheelScrollLatchingDisabledTest() |
| 825 : RenderWidgetHostTest(kWheelScrollingModeNone) {} |
| 826 }; |
| 827 |
| 828 class RenderWidgetHostAsyncWheelEventsEnabledTest |
| 829 : public RenderWidgetHostTest { |
| 830 public: |
| 831 RenderWidgetHostAsyncWheelEventsEnabledTest() |
| 832 : RenderWidgetHostTest(kAsyncWheelEvents) {} |
| 833 }; |
| 834 |
| 763 #if GTEST_HAS_PARAM_TEST | 835 #if GTEST_HAS_PARAM_TEST |
| 764 // RenderWidgetHostWithSourceTest ---------------------------------------------- | 836 // RenderWidgetHostWithSourceTest ---------------------------------------------- |
| 765 | 837 |
| 766 // This is for tests that are to be run for all source devices. | 838 // This is for tests that are to be run for all source devices. |
| 767 class RenderWidgetHostWithSourceTest | 839 class RenderWidgetHostWithSourceTest |
| 768 : public RenderWidgetHostTest, | 840 : public RenderWidgetHostTest, |
| 769 public testing::WithParamInterface<WebGestureDevice> {}; | 841 public testing::WithParamInterface<WebGestureDevice> {}; |
| 770 #endif // GTEST_HAS_PARAM_TEST | 842 #endif // GTEST_HAS_PARAM_TEST |
| 771 | 843 |
| 772 } // namespace | 844 } // namespace |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 // Make sure only KeyUp was sent to the renderer. | 1219 // Make sure only KeyUp was sent to the renderer. |
| 1148 EXPECT_EQ(1U, process_->sink().message_count()); | 1220 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1149 EXPECT_EQ("KeyUp", GetInputMessageTypes(process_)); | 1221 EXPECT_EQ("KeyUp", GetInputMessageTypes(process_)); |
| 1150 process_->sink().ClearMessages(); | 1222 process_->sink().ClearMessages(); |
| 1151 | 1223 |
| 1152 // Send the simulated response from the renderer back. | 1224 // Send the simulated response from the renderer back. |
| 1153 SendInputEventACK(WebInputEvent::kKeyUp, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1225 SendInputEventACK(WebInputEvent::kKeyUp, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1154 EXPECT_EQ(WebInputEvent::kKeyUp, delegate_->unhandled_keyboard_event_type()); | 1226 EXPECT_EQ(WebInputEvent::kKeyUp, delegate_->unhandled_keyboard_event_type()); |
| 1155 } | 1227 } |
| 1156 | 1228 |
| 1157 TEST_F(RenderWidgetHostTest, UnhandledWheelEvent) { | 1229 void RenderWidgetHostTest::UnhandledWheelEvent() { |
| 1158 SimulateWheelEvent(-5, 0, 0, true); | 1230 SimulateWheelEventPossiblyIncludingPhase(-5, 0, 0, true, |
| 1231 WebMouseWheelEvent::kPhaseBegan); |
| 1159 | 1232 |
| 1160 // Make sure we sent the input event to the renderer. | 1233 // Make sure we sent the input event to the renderer. |
| 1161 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1234 EXPECT_TRUE( |
| 1162 InputMsg_HandleInputEvent::ID)); | 1235 process_->sink().GetUniqueMessageMatching(InputMsg_HandleInputEvent::ID)); |
| 1163 process_->sink().ClearMessages(); | 1236 process_->sink().ClearMessages(); |
| 1164 | 1237 |
| 1165 // Send the simulated response from the renderer back. | 1238 // Send the simulated response from the renderer back. |
| 1166 SendInputEventACK(WebInputEvent::kMouseWheel, | 1239 SendInputEventACK(WebInputEvent::kMouseWheel, |
| 1167 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1240 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1168 EXPECT_TRUE(delegate_->handle_wheel_event_called()); | 1241 EXPECT_TRUE(delegate_->handle_wheel_event_called()); |
| 1169 EXPECT_EQ(1, view_->unhandled_wheel_event_count()); | 1242 EXPECT_EQ(1, view_->unhandled_wheel_event_count()); |
| 1170 EXPECT_EQ(-5, view_->unhandled_wheel_event().delta_x); | 1243 EXPECT_EQ(-5, view_->unhandled_wheel_event().delta_x); |
| 1171 } | 1244 } |
| 1245 TEST_F(RenderWidgetHostTest, UnhandledWheelEvent) { |
| 1246 UnhandledWheelEvent(); |
| 1247 } |
| 1248 TEST_F(RenderWidgetHostWheelScrollLatchingDisabledTest, UnhandledWheelEvent) { |
| 1249 UnhandledWheelEvent(); |
| 1250 } |
| 1251 TEST_F(RenderWidgetHostAsyncWheelEventsEnabledTest, UnhandledWheelEvent) { |
| 1252 UnhandledWheelEvent(); |
| 1253 } |
| 1172 | 1254 |
| 1173 TEST_F(RenderWidgetHostTest, HandleWheelEvent) { | 1255 void RenderWidgetHostTest::HandleWheelEvent() { |
| 1174 // Indicate that we're going to handle this wheel event | 1256 // Indicate that we're going to handle this wheel event |
| 1175 delegate_->set_handle_wheel_event(true); | 1257 delegate_->set_handle_wheel_event(true); |
| 1176 | 1258 |
| 1177 SimulateWheelEvent(-5, 0, 0, true); | 1259 SimulateWheelEventPossiblyIncludingPhase(-5, 0, 0, true, |
| 1260 WebMouseWheelEvent::kPhaseBegan); |
| 1178 | 1261 |
| 1179 // Make sure we sent the input event to the renderer. | 1262 // Make sure we sent the input event to the renderer. |
| 1180 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1263 EXPECT_TRUE( |
| 1181 InputMsg_HandleInputEvent::ID)); | 1264 process_->sink().GetUniqueMessageMatching(InputMsg_HandleInputEvent::ID)); |
| 1182 process_->sink().ClearMessages(); | 1265 process_->sink().ClearMessages(); |
| 1183 | 1266 |
| 1184 // Send the simulated response from the renderer back. | 1267 // Send the simulated response from the renderer back. |
| 1185 SendInputEventACK(WebInputEvent::kMouseWheel, | 1268 SendInputEventACK(WebInputEvent::kMouseWheel, |
| 1186 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1269 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1187 | 1270 |
| 1188 // ensure the wheel event handler was invoked | 1271 // ensure the wheel event handler was invoked |
| 1189 EXPECT_TRUE(delegate_->handle_wheel_event_called()); | 1272 EXPECT_TRUE(delegate_->handle_wheel_event_called()); |
| 1190 | 1273 |
| 1191 // and that it suppressed the unhandled wheel event handler. | 1274 // and that it suppressed the unhandled wheel event handler. |
| 1192 EXPECT_EQ(0, view_->unhandled_wheel_event_count()); | 1275 EXPECT_EQ(0, view_->unhandled_wheel_event_count()); |
| 1193 } | 1276 } |
| 1277 TEST_F(RenderWidgetHostTest, HandleWheelEvent) { |
| 1278 HandleWheelEvent(); |
| 1279 } |
| 1280 TEST_F(RenderWidgetHostWheelScrollLatchingDisabledTest, HandleWheelEvent) { |
| 1281 HandleWheelEvent(); |
| 1282 } |
| 1283 TEST_F(RenderWidgetHostAsyncWheelEventsEnabledTest, HandleWheelEvent) { |
| 1284 HandleWheelEvent(); |
| 1285 } |
| 1194 | 1286 |
| 1195 TEST_F(RenderWidgetHostTest, UnhandledGestureEvent) { | 1287 TEST_F(RenderWidgetHostTest, UnhandledGestureEvent) { |
| 1196 SimulateGestureEvent(WebInputEvent::kGestureTwoFingerTap, | 1288 SimulateGestureEvent(WebInputEvent::kGestureTwoFingerTap, |
| 1197 blink::kWebGestureDeviceTouchscreen); | 1289 blink::kWebGestureDeviceTouchscreen); |
| 1198 | 1290 |
| 1199 // Make sure we sent the input event to the renderer. | 1291 // Make sure we sent the input event to the renderer. |
| 1200 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1292 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
| 1201 InputMsg_HandleInputEvent::ID)); | 1293 InputMsg_HandleInputEvent::ID)); |
| 1202 process_->sink().ClearMessages(); | 1294 process_->sink().ClearMessages(); |
| 1203 | 1295 |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1787 EXPECT_TRUE(latency_info.FindLatency( | 1879 EXPECT_TRUE(latency_info.FindLatency( |
| 1788 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, component_id, NULL)); | 1880 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, component_id, NULL)); |
| 1789 | 1881 |
| 1790 process->sink().ClearMessages(); | 1882 process->sink().ClearMessages(); |
| 1791 } | 1883 } |
| 1792 | 1884 |
| 1793 // Tests that after input event passes through RWHI through ForwardXXXEvent() | 1885 // Tests that after input event passes through RWHI through ForwardXXXEvent() |
| 1794 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component | 1886 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component |
| 1795 // ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will always present in the | 1887 // ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will always present in the |
| 1796 // event's LatencyInfo. | 1888 // event's LatencyInfo. |
| 1797 TEST_F(RenderWidgetHostTest, InputEventRWHLatencyComponent) { | 1889 void RenderWidgetHostTest::InputEventRWHLatencyComponent() { |
| 1798 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1890 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 1799 process_->sink().ClearMessages(); | 1891 process_->sink().ClearMessages(); |
| 1800 | 1892 |
| 1801 // Tests RWHI::ForwardWheelEvent(). | 1893 // Tests RWHI::ForwardWheelEvent(). |
| 1802 SimulateWheelEvent(-5, 0, 0, true); | 1894 SimulateWheelEventPossiblyIncludingPhase(-5, 0, 0, true, |
| 1895 WebMouseWheelEvent::kPhaseBegan); |
| 1803 CheckLatencyInfoComponentInMessage(process_, GetLatencyComponentId(), | 1896 CheckLatencyInfoComponentInMessage(process_, GetLatencyComponentId(), |
| 1804 WebInputEvent::kMouseWheel); | 1897 WebInputEvent::kMouseWheel); |
| 1805 SendInputEventACK(WebInputEvent::kMouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); | 1898 SendInputEventACK(WebInputEvent::kMouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1806 | 1899 |
| 1807 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1900 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
| 1808 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1901 SimulateWheelEventWithLatencyInfoAndPossiblyPhase( |
| 1902 -5, 0, 0, true, ui::LatencyInfo(), WebMouseWheelEvent::kPhaseChanged); |
| 1809 CheckLatencyInfoComponentInMessage(process_, GetLatencyComponentId(), | 1903 CheckLatencyInfoComponentInMessage(process_, GetLatencyComponentId(), |
| 1810 WebInputEvent::kMouseWheel); | 1904 WebInputEvent::kMouseWheel); |
| 1811 SendInputEventACK(WebInputEvent::kMouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); | 1905 SendInputEventACK(WebInputEvent::kMouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1812 | 1906 |
| 1813 // Tests RWHI::ForwardMouseEvent(). | 1907 // Tests RWHI::ForwardMouseEvent(). |
| 1814 SimulateMouseEvent(WebInputEvent::kMouseMove); | 1908 SimulateMouseEvent(WebInputEvent::kMouseMove); |
| 1815 CheckLatencyInfoComponentInMessage(process_, GetLatencyComponentId(), | 1909 CheckLatencyInfoComponentInMessage(process_, GetLatencyComponentId(), |
| 1816 WebInputEvent::kMouseMove); | 1910 WebInputEvent::kMouseMove); |
| 1817 SendInputEventACK(WebInputEvent::kMouseMove, INPUT_EVENT_ACK_STATE_CONSUMED); | 1911 SendInputEventACK(WebInputEvent::kMouseMove, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1818 | 1912 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1841 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). | 1935 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). |
| 1842 PressTouchPoint(0, 1); | 1936 PressTouchPoint(0, 1); |
| 1843 uint32_t touch_event_id = SendTouchEvent(); | 1937 uint32_t touch_event_id = SendTouchEvent(); |
| 1844 InputEventAck ack(InputEventAckSource::COMPOSITOR_THREAD, | 1938 InputEventAck ack(InputEventAckSource::COMPOSITOR_THREAD, |
| 1845 WebInputEvent::kTouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, | 1939 WebInputEvent::kTouchStart, INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1846 touch_event_id); | 1940 touch_event_id); |
| 1847 host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); | 1941 host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); |
| 1848 CheckLatencyInfoComponentInMessage(process_, GetLatencyComponentId(), | 1942 CheckLatencyInfoComponentInMessage(process_, GetLatencyComponentId(), |
| 1849 WebInputEvent::kTouchStart); | 1943 WebInputEvent::kTouchStart); |
| 1850 } | 1944 } |
| 1945 TEST_F(RenderWidgetHostTest, InputEventRWHLatencyComponent) { |
| 1946 InputEventRWHLatencyComponent(); |
| 1947 } |
| 1948 TEST_F(RenderWidgetHostWheelScrollLatchingDisabledTest, |
| 1949 InputEventRWHLatencyComponent) { |
| 1950 InputEventRWHLatencyComponent(); |
| 1951 } |
| 1952 TEST_F(RenderWidgetHostAsyncWheelEventsEnabledTest, |
| 1953 InputEventRWHLatencyComponent) { |
| 1954 InputEventRWHLatencyComponent(); |
| 1955 } |
| 1851 | 1956 |
| 1852 TEST_F(RenderWidgetHostTest, RendererExitedResetsInputRouter) { | 1957 TEST_F(RenderWidgetHostTest, RendererExitedResetsInputRouter) { |
| 1853 // RendererExited will delete the view. | 1958 // RendererExited will delete the view. |
| 1854 host_->SetView(new TestView(host_.get())); | 1959 host_->SetView(new TestView(host_.get())); |
| 1855 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | 1960 host_->RendererExited(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
| 1856 | 1961 |
| 1857 // Make sure the input router is in a fresh state. | 1962 // Make sure the input router is in a fresh state. |
| 1858 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1963 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
| 1859 } | 1964 } |
| 1860 | 1965 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2156 EXPECT_EQ(0u, host_->processed_frame_messages_count()); | 2261 EXPECT_EQ(0u, host_->processed_frame_messages_count()); |
| 2157 | 2262 |
| 2158 frame = MakeCompositorFrame(1.f, frame_size); | 2263 frame = MakeCompositorFrame(1.f, frame_size); |
| 2159 frame.metadata.frame_token = frame_token3; | 2264 frame.metadata.frame_token = frame_token3; |
| 2160 host_->SubmitCompositorFrame(local_surface_id, std::move(frame)); | 2265 host_->SubmitCompositorFrame(local_surface_id, std::move(frame)); |
| 2161 EXPECT_EQ(0u, host_->queued_messages_.size()); | 2266 EXPECT_EQ(0u, host_->queued_messages_.size()); |
| 2162 EXPECT_EQ(1u, host_->processed_frame_messages_count()); | 2267 EXPECT_EQ(1u, host_->processed_frame_messages_count()); |
| 2163 } | 2268 } |
| 2164 | 2269 |
| 2165 } // namespace content | 2270 } // namespace content |
| OLD | NEW |