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

Side by Side Diff: ui/events/blink/input_handler_proxy_unittest.cc

Issue 1577263004: Communicate whether passive event listeners exist to cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_wheel_passive_listeners
Patch Set: Rebase Created 4 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/events/blink/input_handler_proxy.h" 5 #include "ui/events/blink/input_handler_proxy.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/input/main_thread_scrolling_reason.h" 9 #include "cc/input/main_thread_scrolling_reason.h"
10 #include "cc/trees/swap_promise_monitor.h" 10 #include "cc/trees/swap_promise_monitor.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 void BindToClient(cc::InputHandlerClient* client) override {} 126 void BindToClient(cc::InputHandlerClient* client) override {}
127 127
128 void MouseMoveAt(const gfx::Point& mouse_position) override {} 128 void MouseMoveAt(const gfx::Point& mouse_position) override {}
129 129
130 MOCK_CONST_METHOD2(IsCurrentlyScrollingLayerAt, 130 MOCK_CONST_METHOD2(IsCurrentlyScrollingLayerAt,
131 bool(const gfx::Point& point, 131 bool(const gfx::Point& point,
132 cc::InputHandler::ScrollInputType type)); 132 cc::InputHandler::ScrollInputType type));
133 133
134 MOCK_CONST_METHOD0(HaveWheelEventHandlers, bool()); 134 MOCK_CONST_METHOD1(
135 GetEventListenerProperties,
136 cc::EventListenerProperties(cc::EventListenerClass event_class));
135 MOCK_METHOD1(DoTouchEventsBlockScrollAt, bool(const gfx::Point& point)); 137 MOCK_METHOD1(DoTouchEventsBlockScrollAt, bool(const gfx::Point& point));
136 138
137 MOCK_METHOD0(RequestUpdateForSynchronousInputHandler, void()); 139 MOCK_METHOD0(RequestUpdateForSynchronousInputHandler, void());
138 MOCK_METHOD1(SetSynchronousInputHandlerRootScrollOffset, 140 MOCK_METHOD1(SetSynchronousInputHandlerRootScrollOffset,
139 void(const gfx::ScrollOffset& root_offset)); 141 void(const gfx::ScrollOffset& root_offset));
140 142
141 bool IsCurrentlyScrollingInnerViewport() const override { 143 bool IsCurrentlyScrollingInnerViewport() const override {
142 return is_scrolling_root_; 144 return is_scrolling_root_;
143 } 145 }
144 void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; } 146 void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; }
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 620
619 VERIFY_AND_RESET_MOCKS(); 621 VERIFY_AND_RESET_MOCKS();
620 } 622 }
621 623
622 TEST_P(InputHandlerProxyTest, GesturePinch) { 624 TEST_P(InputHandlerProxyTest, GesturePinch) {
623 // We shouldn't send any events to the widget for this gesture. 625 // We shouldn't send any events to the widget for this gesture.
624 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 626 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
625 VERIFY_AND_RESET_MOCKS(); 627 VERIFY_AND_RESET_MOCKS();
626 628
627 gesture_.type = WebInputEvent::GesturePinchBegin; 629 gesture_.type = WebInputEvent::GesturePinchBegin;
628 EXPECT_CALL(mock_input_handler_, HaveWheelEventHandlers()) 630 EXPECT_CALL(mock_input_handler_,
629 .WillOnce(testing::Return(false)); 631 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
632 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
630 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); 633 EXPECT_CALL(mock_input_handler_, PinchGestureBegin());
631 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 634 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
632 635
633 VERIFY_AND_RESET_MOCKS(); 636 VERIFY_AND_RESET_MOCKS();
634 637
635 gesture_.type = WebInputEvent::GesturePinchUpdate; 638 gesture_.type = WebInputEvent::GesturePinchUpdate;
636 gesture_.data.pinchUpdate.scale = 1.5; 639 gesture_.data.pinchUpdate.scale = 1.5;
637 gesture_.x = 7; 640 gesture_.x = 7;
638 gesture_.y = 13; 641 gesture_.y = 13;
639 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); 642 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13)));
(...skipping 27 matching lines...) Expand all
667 670
668 VERIFY_AND_RESET_MOCKS(); 671 VERIFY_AND_RESET_MOCKS();
669 } 672 }
670 673
671 TEST_P(InputHandlerProxyTest, GesturePinchWithWheelHandler) { 674 TEST_P(InputHandlerProxyTest, GesturePinchWithWheelHandler) {
672 // We will send the synthetic wheel event to the widget. 675 // We will send the synthetic wheel event to the widget.
673 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 676 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
674 VERIFY_AND_RESET_MOCKS(); 677 VERIFY_AND_RESET_MOCKS();
675 678
676 gesture_.type = WebInputEvent::GesturePinchBegin; 679 gesture_.type = WebInputEvent::GesturePinchBegin;
677 EXPECT_CALL(mock_input_handler_, HaveWheelEventHandlers()) 680 EXPECT_CALL(mock_input_handler_,
678 .WillOnce(testing::Return(true)); 681 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
682 .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
679 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 683 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
680 684
681 VERIFY_AND_RESET_MOCKS(); 685 VERIFY_AND_RESET_MOCKS();
682 686
683 gesture_.type = WebInputEvent::GesturePinchUpdate; 687 gesture_.type = WebInputEvent::GesturePinchUpdate;
684 gesture_.data.pinchUpdate.scale = 1.5; 688 gesture_.data.pinchUpdate.scale = 1.5;
685 gesture_.x = 7; 689 gesture_.x = 7;
686 gesture_.y = 13; 690 gesture_.y = 13;
687 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 691 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
688 692
(...skipping 27 matching lines...) Expand all
716 gesture_.type = WebInputEvent::GestureScrollUpdate; 720 gesture_.type = WebInputEvent::GestureScrollUpdate;
717 gesture_.data.scrollUpdate.deltaY = 40; 721 gesture_.data.scrollUpdate.deltaY = 40;
718 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 722 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
719 723
720 // However, after the pinch gesture starts, they should go to the impl 724 // However, after the pinch gesture starts, they should go to the impl
721 // thread. 725 // thread.
722 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 726 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
723 VERIFY_AND_RESET_MOCKS(); 727 VERIFY_AND_RESET_MOCKS();
724 728
725 gesture_.type = WebInputEvent::GesturePinchBegin; 729 gesture_.type = WebInputEvent::GesturePinchBegin;
726 EXPECT_CALL(mock_input_handler_, HaveWheelEventHandlers()) 730 EXPECT_CALL(mock_input_handler_,
727 .WillOnce(testing::Return(false)); 731 GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
732 .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
728 EXPECT_CALL(mock_input_handler_, PinchGestureBegin()); 733 EXPECT_CALL(mock_input_handler_, PinchGestureBegin());
729 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 734 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
730 735
731 VERIFY_AND_RESET_MOCKS(); 736 VERIFY_AND_RESET_MOCKS();
732 737
733 gesture_.type = WebInputEvent::GesturePinchUpdate; 738 gesture_.type = WebInputEvent::GesturePinchUpdate;
734 gesture_.data.pinchUpdate.scale = 1.5; 739 gesture_.data.pinchUpdate.scale = 1.5;
735 gesture_.x = 7; 740 gesture_.x = 7;
736 gesture_.y = 13; 741 gesture_.y = 13;
737 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13))); 742 EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13)));
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after
2525 testing::Mock::VerifyAndClearExpectations(&mock_input_handler); 2530 testing::Mock::VerifyAndClearExpectations(&mock_input_handler);
2526 testing::Mock::VerifyAndClearExpectations(&mock_client); 2531 testing::Mock::VerifyAndClearExpectations(&mock_client);
2527 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler); 2532 testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler);
2528 } 2533 }
2529 2534
2530 INSTANTIATE_TEST_CASE_P(AnimateInput, 2535 INSTANTIATE_TEST_CASE_P(AnimateInput,
2531 InputHandlerProxyTest, 2536 InputHandlerProxyTest,
2532 testing::ValuesIn(test_types)); 2537 testing::ValuesIn(test_types));
2533 } // namespace test 2538 } // namespace test
2534 } // namespace ui 2539 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698