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

Side by Side Diff: content/renderer/input/input_handler_proxy_unittest.cc

Issue 304793003: use enum to specify deviceSource for fling animation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased for parallel breaking changes Created 6 years, 6 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 | Annotate | Revision Log
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 "content/renderer/input/input_handler_proxy.h" 5 #include "content/renderer/input/input_handler_proxy.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/base/swap_promise_monitor.h" 9 #include "cc/base/swap_promise_monitor.h"
10 #include "content/common/input/did_overscroll_params.h" 10 #include "content/common/input/did_overscroll_params.h"
11 #include "content/renderer/input/input_handler_proxy_client.h" 11 #include "content/renderer/input/input_handler_proxy_client.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 14 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
15 #include "third_party/WebKit/public/platform/WebFloatSize.h" 15 #include "third_party/WebKit/public/platform/WebFloatSize.h"
16 #include "third_party/WebKit/public/platform/WebGestureCurve.h" 16 #include "third_party/WebKit/public/platform/WebGestureCurve.h"
17 #include "third_party/WebKit/public/platform/WebPoint.h" 17 #include "third_party/WebKit/public/platform/WebPoint.h"
18 #include "third_party/WebKit/public/web/WebInputEvent.h" 18 #include "third_party/WebKit/public/web/WebInputEvent.h"
19 #include "ui/events/latency_info.h" 19 #include "ui/events/latency_info.h"
20 20
21 using blink::WebActiveWheelFlingParameters; 21 using blink::WebActiveWheelFlingParameters;
22 using blink::WebFloatPoint; 22 using blink::WebFloatPoint;
23 using blink::WebFloatSize; 23 using blink::WebFloatSize;
24 using blink::WebGestureDevice;
24 using blink::WebGestureEvent; 25 using blink::WebGestureEvent;
25 using blink::WebInputEvent; 26 using blink::WebInputEvent;
26 using blink::WebKeyboardEvent; 27 using blink::WebKeyboardEvent;
27 using blink::WebMouseWheelEvent; 28 using blink::WebMouseWheelEvent;
28 using blink::WebPoint; 29 using blink::WebPoint;
29 using blink::WebSize; 30 using blink::WebSize;
30 using blink::WebTouchEvent; 31 using blink::WebTouchEvent;
31 using blink::WebTouchPoint; 32 using blink::WebTouchPoint;
32 33
33 namespace content { 34 namespace content {
34 namespace { 35 namespace {
35 36
36 double InSecondsF(const base::TimeTicks& time) { 37 double InSecondsF(const base::TimeTicks& time) {
37 return (time - base::TimeTicks()).InSecondsF(); 38 return (time - base::TimeTicks()).InSecondsF();
38 } 39 }
39 40
40 WebGestureEvent CreateFling(base::TimeTicks timestamp, 41 WebGestureEvent CreateFling(base::TimeTicks timestamp,
41 WebGestureEvent::SourceDevice source_device, 42 WebGestureDevice source_device,
42 WebFloatPoint velocity, 43 WebFloatPoint velocity,
43 WebPoint point, 44 WebPoint point,
44 WebPoint global_point, 45 WebPoint global_point,
45 int modifiers) { 46 int modifiers) {
46 WebGestureEvent fling; 47 WebGestureEvent fling;
47 fling.type = WebInputEvent::GestureFlingStart; 48 fling.type = WebInputEvent::GestureFlingStart;
48 fling.sourceDevice = source_device; 49 fling.sourceDevice = source_device;
49 fling.timeStampSeconds = (timestamp - base::TimeTicks()).InSecondsF(); 50 fling.timeStampSeconds = (timestamp - base::TimeTicks()).InSecondsF();
50 fling.data.flingStart.velocityX = velocity.x; 51 fling.data.flingStart.velocityX = velocity.x;
51 fling.data.flingStart.velocityY = velocity.y; 52 fling.data.flingStart.velocityY = velocity.y;
52 fling.x = point.x; 53 fling.x = point.x;
53 fling.y = point.y; 54 fling.y = point.y;
54 fling.globalX = global_point.x; 55 fling.globalX = global_point.x;
55 fling.globalY = global_point.y; 56 fling.globalY = global_point.y;
56 fling.modifiers = modifiers; 57 fling.modifiers = modifiers;
57 return fling; 58 return fling;
58 } 59 }
59 60
60 WebGestureEvent CreateFling(WebGestureEvent::SourceDevice source_device, 61 WebGestureEvent CreateFling(WebGestureDevice source_device,
61 WebFloatPoint velocity, 62 WebFloatPoint velocity,
62 WebPoint point, 63 WebPoint point,
63 WebPoint global_point, 64 WebPoint global_point,
64 int modifiers) { 65 int modifiers) {
65 return CreateFling(base::TimeTicks(), 66 return CreateFling(base::TimeTicks(),
66 source_device, 67 source_device,
67 velocity, 68 velocity,
68 point, 69 point,
69 global_point, 70 global_point,
70 modifiers); 71 modifiers);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 public: 159 public:
159 MockInputHandlerProxyClient() {} 160 MockInputHandlerProxyClient() {}
160 virtual ~MockInputHandlerProxyClient() {} 161 virtual ~MockInputHandlerProxyClient() {}
161 162
162 virtual void WillShutdown() OVERRIDE {} 163 virtual void WillShutdown() OVERRIDE {}
163 164
164 MOCK_METHOD1(TransferActiveWheelFlingAnimation, 165 MOCK_METHOD1(TransferActiveWheelFlingAnimation,
165 void(const WebActiveWheelFlingParameters&)); 166 void(const WebActiveWheelFlingParameters&));
166 167
167 virtual blink::WebGestureCurve* CreateFlingAnimationCurve( 168 virtual blink::WebGestureCurve* CreateFlingAnimationCurve(
168 int deviceSource, 169 WebGestureDevice deviceSource,
169 const WebFloatPoint& velocity, 170 const WebFloatPoint& velocity,
170 const WebSize& cumulative_scroll) OVERRIDE { 171 const WebSize& cumulative_scroll) OVERRIDE {
171 return new FakeWebGestureCurve( 172 return new FakeWebGestureCurve(
172 blink::WebFloatSize(velocity.x, velocity.y), 173 blink::WebFloatSize(velocity.x, velocity.y),
173 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height)); 174 blink::WebFloatSize(cumulative_scroll.width, cumulative_scroll.height));
174 } 175 }
175 176
176 MOCK_METHOD1(DidOverscroll, void(const DidOverscrollParams&)); 177 MOCK_METHOD1(DidOverscroll, void(const DidOverscrollParams&));
177 virtual void DidStopFlinging() OVERRIDE {} 178 virtual void DidStopFlinging() OVERRIDE {}
178 179
(...skipping 25 matching lines...) Expand all
204 // This is defined as a macro because when an expectation is not satisfied the 205 // This is defined as a macro because when an expectation is not satisfied the
205 // only output you get 206 // only output you get
206 // out of gmock is the line number that set the expectation. 207 // out of gmock is the line number that set the expectation.
207 #define VERIFY_AND_RESET_MOCKS() \ 208 #define VERIFY_AND_RESET_MOCKS() \
208 do { \ 209 do { \
209 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); \ 210 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); \
210 testing::Mock::VerifyAndClearExpectations(&mock_client_); \ 211 testing::Mock::VerifyAndClearExpectations(&mock_client_); \
211 } while (false) 212 } while (false)
212 213
213 void StartFling(base::TimeTicks timestamp, 214 void StartFling(base::TimeTicks timestamp,
214 WebGestureEvent::SourceDevice source_device, 215 WebGestureDevice source_device,
215 WebFloatPoint velocity, 216 WebFloatPoint velocity,
216 WebPoint position) { 217 WebPoint position) {
217 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 218 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
218 VERIFY_AND_RESET_MOCKS(); 219 VERIFY_AND_RESET_MOCKS();
219 220
220 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 221 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
221 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 222 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
222 gesture_.type = WebInputEvent::GestureScrollBegin; 223 gesture_.type = WebInputEvent::GestureScrollBegin;
223 gesture_.sourceDevice = source_device; 224 gesture_.sourceDevice = source_device;
224 EXPECT_EQ(expected_disposition_, 225 EXPECT_EQ(expected_disposition_,
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 480 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
480 VERIFY_AND_RESET_MOCKS(); 481 VERIFY_AND_RESET_MOCKS();
481 482
482 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 483 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
483 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 484 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
484 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 485 EXPECT_CALL(mock_input_handler_, ScrollEnd());
485 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 486 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
486 487
487 gesture_.type = WebInputEvent::GestureFlingStart; 488 gesture_.type = WebInputEvent::GestureFlingStart;
488 gesture_.data.flingStart.velocityX = 10; 489 gesture_.data.flingStart.velocityX = 10;
489 gesture_.sourceDevice = WebGestureEvent::Touchpad; 490 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
490 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 491 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
491 492
492 VERIFY_AND_RESET_MOCKS(); 493 VERIFY_AND_RESET_MOCKS();
493 494
494 // Verify that a GestureFlingCancel during an animation cancels it. 495 // Verify that a GestureFlingCancel during an animation cancels it.
495 gesture_.type = WebInputEvent::GestureFlingCancel; 496 gesture_.type = WebInputEvent::GestureFlingCancel;
496 gesture_.sourceDevice = WebGestureEvent::Touchpad; 497 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
497 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 498 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
498 } 499 }
499 500
500 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchpad) { 501 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchpad) {
501 // We should send all events to the widget for this gesture. 502 // We should send all events to the widget for this gesture.
502 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 503 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
503 VERIFY_AND_RESET_MOCKS(); 504 VERIFY_AND_RESET_MOCKS();
504 505
505 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 506 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
506 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); 507 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread));
507 508
508 gesture_.type = WebInputEvent::GestureFlingStart; 509 gesture_.type = WebInputEvent::GestureFlingStart;
509 gesture_.sourceDevice = WebGestureEvent::Touchpad; 510 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
510 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 511 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
511 512
512 // Since we returned ScrollStatusOnMainThread from scrollBegin, ensure the 513 // Since we returned ScrollStatusOnMainThread from scrollBegin, ensure the
513 // input handler knows it's scrolling off the impl thread 514 // input handler knows it's scrolling off the impl thread
514 ASSERT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 515 ASSERT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
515 516
516 VERIFY_AND_RESET_MOCKS(); 517 VERIFY_AND_RESET_MOCKS();
517 518
518 // Even if we didn't start a fling ourselves, we still need to send the cancel 519 // Even if we didn't start a fling ourselves, we still need to send the cancel
519 // event to the widget. 520 // event to the widget.
520 gesture_.type = WebInputEvent::GestureFlingCancel; 521 gesture_.type = WebInputEvent::GestureFlingCancel;
521 gesture_.sourceDevice = WebGestureEvent::Touchpad; 522 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
522 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 523 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
523 } 524 }
524 525
525 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) { 526 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchpad) {
526 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 527 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
527 VERIFY_AND_RESET_MOCKS(); 528 VERIFY_AND_RESET_MOCKS();
528 529
529 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 530 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
530 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); 531 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored));
531 532
532 gesture_.type = WebInputEvent::GestureFlingStart; 533 gesture_.type = WebInputEvent::GestureFlingStart;
533 gesture_.sourceDevice = WebGestureEvent::Touchpad; 534 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
534 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 535 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
535 536
536 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 537 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
537 VERIFY_AND_RESET_MOCKS(); 538 VERIFY_AND_RESET_MOCKS();
538 539
539 // Since the previous fling was ignored, we should also be dropping the next 540 // Since the previous fling was ignored, we should also be dropping the next
540 // fling_cancel. 541 // fling_cancel.
541 gesture_.type = WebInputEvent::GestureFlingCancel; 542 gesture_.type = WebInputEvent::GestureFlingCancel;
542 gesture_.sourceDevice = WebGestureEvent::Touchpad; 543 gesture_.sourceDevice = blink::WebGestureDeviceTouchpad;
543 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 544 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
544 } 545 }
545 546
546 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) { 547 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchpad) {
547 // We shouldn't send any events to the widget for this gesture. 548 // We shouldn't send any events to the widget for this gesture.
548 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 549 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
549 VERIFY_AND_RESET_MOCKS(); 550 VERIFY_AND_RESET_MOCKS();
550 551
551 // On the fling start, we should schedule an animation but not actually start 552 // On the fling start, we should schedule an animation but not actually start
552 // scrolling. 553 // scrolling.
553 gesture_.type = WebInputEvent::GestureFlingStart; 554 gesture_.type = WebInputEvent::GestureFlingStart;
554 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 555 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
555 WebPoint fling_point = WebPoint(7, 13); 556 WebPoint fling_point = WebPoint(7, 13);
556 WebPoint fling_global_point = WebPoint(17, 23); 557 WebPoint fling_global_point = WebPoint(17, 23);
557 // Note that for trackpad, wheel events with the Control modifier are 558 // Note that for trackpad, wheel events with the Control modifier are
558 // special (reserved for zoom), so don't set that here. 559 // special (reserved for zoom), so don't set that here.
559 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; 560 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
560 gesture_ = CreateFling(WebGestureEvent::Touchpad, 561 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad,
561 fling_delta, 562 fling_delta,
562 fling_point, 563 fling_point,
563 fling_global_point, 564 fling_global_point,
564 modifiers); 565 modifiers);
565 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 566 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
566 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 567 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
567 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 568 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
568 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 569 EXPECT_CALL(mock_input_handler_, ScrollEnd());
569 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 570 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
570 571
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 656 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
656 VERIFY_AND_RESET_MOCKS(); 657 VERIFY_AND_RESET_MOCKS();
657 658
658 // Start a gesture fling in the -X direction with zero Y movement. 659 // Start a gesture fling in the -X direction with zero Y movement.
659 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 660 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
660 WebPoint fling_point = WebPoint(7, 13); 661 WebPoint fling_point = WebPoint(7, 13);
661 WebPoint fling_global_point = WebPoint(17, 23); 662 WebPoint fling_global_point = WebPoint(17, 23);
662 // Note that for trackpad, wheel events with the Control modifier are 663 // Note that for trackpad, wheel events with the Control modifier are
663 // special (reserved for zoom), so don't set that here. 664 // special (reserved for zoom), so don't set that here.
664 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; 665 int modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey;
665 gesture_ = CreateFling(WebGestureEvent::Touchpad, 666 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad,
666 fling_delta, 667 fling_delta,
667 fling_point, 668 fling_point,
668 fling_global_point, 669 fling_global_point,
669 modifiers); 670 modifiers);
670 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 671 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
671 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 672 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
672 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 673 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
673 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 674 EXPECT_CALL(mock_input_handler_, ScrollEnd());
674 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 675 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
675 676
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 757 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
757 758
758 VERIFY_AND_RESET_MOCKS(); 759 VERIFY_AND_RESET_MOCKS();
759 input_handler_->MainThreadHasStoppedFlinging(); 760 input_handler_->MainThreadHasStoppedFlinging();
760 761
761 // Start a second gesture fling, this time in the +Y direction with no X. 762 // Start a second gesture fling, this time in the +Y direction with no X.
762 fling_delta = WebFloatPoint(0, -1000); 763 fling_delta = WebFloatPoint(0, -1000);
763 fling_point = WebPoint(95, 87); 764 fling_point = WebPoint(95, 87);
764 fling_global_point = WebPoint(32, 71); 765 fling_global_point = WebPoint(32, 71);
765 modifiers = WebInputEvent::AltKey; 766 modifiers = WebInputEvent::AltKey;
766 gesture_ = CreateFling(WebGestureEvent::Touchpad, 767 gesture_ = CreateFling(blink::WebGestureDeviceTouchpad,
767 fling_delta, 768 fling_delta,
768 fling_point, 769 fling_point,
769 fling_global_point, 770 fling_global_point,
770 modifiers); 771 modifiers);
771 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 772 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
772 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 773 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
773 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 774 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
774 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 775 EXPECT_CALL(mock_input_handler_, ScrollEnd());
775 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 776 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
776 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 777 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 } 829 }
829 830
830 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchscreen) { 831 TEST_F(InputHandlerProxyTest, GestureFlingStartedTouchscreen) {
831 // We shouldn't send any events to the widget for this gesture. 832 // We shouldn't send any events to the widget for this gesture.
832 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 833 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
833 VERIFY_AND_RESET_MOCKS(); 834 VERIFY_AND_RESET_MOCKS();
834 835
835 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 836 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
836 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 837 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
837 gesture_.type = WebInputEvent::GestureScrollBegin; 838 gesture_.type = WebInputEvent::GestureScrollBegin;
838 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 839 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
839 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 840 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
840 841
841 VERIFY_AND_RESET_MOCKS(); 842 VERIFY_AND_RESET_MOCKS();
842 843
843 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 844 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
844 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 845 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
845 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 846 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
846 847
847 gesture_.type = WebInputEvent::GestureFlingStart; 848 gesture_.type = WebInputEvent::GestureFlingStart;
848 gesture_.data.flingStart.velocityX = 10; 849 gesture_.data.flingStart.velocityX = 10;
849 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 850 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
850 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 851 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
851 852
852 VERIFY_AND_RESET_MOCKS(); 853 VERIFY_AND_RESET_MOCKS();
853 854
854 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 855 EXPECT_CALL(mock_input_handler_, ScrollEnd());
855 856
856 // Verify that a GestureFlingCancel during an animation cancels it. 857 // Verify that a GestureFlingCancel during an animation cancels it.
857 gesture_.type = WebInputEvent::GestureFlingCancel; 858 gesture_.type = WebInputEvent::GestureFlingCancel;
858 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 859 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
859 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 860 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
860 } 861 }
861 862
862 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchscreen) { 863 TEST_F(InputHandlerProxyTest, GestureFlingOnMainThreadTouchscreen) {
863 // We should send all events to the widget for this gesture. 864 // We should send all events to the widget for this gesture.
864 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE; 865 expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
865 VERIFY_AND_RESET_MOCKS(); 866 VERIFY_AND_RESET_MOCKS();
866 867
867 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 868 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
868 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread)); 869 .WillOnce(testing::Return(cc::InputHandler::ScrollOnMainThread));
869 870
870 gesture_.type = WebInputEvent::GestureScrollBegin; 871 gesture_.type = WebInputEvent::GestureScrollBegin;
871 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 872 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
872 873
873 VERIFY_AND_RESET_MOCKS(); 874 VERIFY_AND_RESET_MOCKS();
874 875
875 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()).Times(0); 876 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()).Times(0);
876 877
877 gesture_.type = WebInputEvent::GestureFlingStart; 878 gesture_.type = WebInputEvent::GestureFlingStart;
878 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 879 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
879 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 880 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
880 881
881 VERIFY_AND_RESET_MOCKS(); 882 VERIFY_AND_RESET_MOCKS();
882 883
883 // Even if we didn't start a fling ourselves, we still need to send the cancel 884 // Even if we didn't start a fling ourselves, we still need to send the cancel
884 // event to the widget. 885 // event to the widget.
885 gesture_.type = WebInputEvent::GestureFlingCancel; 886 gesture_.type = WebInputEvent::GestureFlingCancel;
886 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 887 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
887 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 888 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
888 } 889 }
889 890
890 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchscreen) { 891 TEST_F(InputHandlerProxyTest, GestureFlingIgnoredTouchscreen) {
891 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 892 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
892 VERIFY_AND_RESET_MOCKS(); 893 VERIFY_AND_RESET_MOCKS();
893 894
894 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 895 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
895 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 896 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
896 897
897 gesture_.type = WebInputEvent::GestureScrollBegin; 898 gesture_.type = WebInputEvent::GestureScrollBegin;
898 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 899 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
899 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 900 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
900 901
901 expected_disposition_ = InputHandlerProxy::DROP_EVENT; 902 expected_disposition_ = InputHandlerProxy::DROP_EVENT;
902 VERIFY_AND_RESET_MOCKS(); 903 VERIFY_AND_RESET_MOCKS();
903 904
904 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 905 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
905 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored)); 906 .WillOnce(testing::Return(cc::InputHandler::ScrollIgnored));
906 907
907 gesture_.type = WebInputEvent::GestureFlingStart; 908 gesture_.type = WebInputEvent::GestureFlingStart;
908 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 909 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
909 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 910 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
910 911
911 VERIFY_AND_RESET_MOCKS(); 912 VERIFY_AND_RESET_MOCKS();
912 913
913 // Even if we didn't start a fling ourselves, we still need to send the cancel 914 // Even if we didn't start a fling ourselves, we still need to send the cancel
914 // event to the widget. 915 // event to the widget.
915 gesture_.type = WebInputEvent::GestureFlingCancel; 916 gesture_.type = WebInputEvent::GestureFlingCancel;
916 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 917 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
917 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 918 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
918 } 919 }
919 920
920 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchscreen) { 921 TEST_F(InputHandlerProxyTest, GestureFlingAnimatesTouchscreen) {
921 // We shouldn't send any events to the widget for this gesture. 922 // We shouldn't send any events to the widget for this gesture.
922 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 923 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
923 VERIFY_AND_RESET_MOCKS(); 924 VERIFY_AND_RESET_MOCKS();
924 925
925 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 926 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
926 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 927 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
927 928
928 gesture_.type = WebInputEvent::GestureScrollBegin; 929 gesture_.type = WebInputEvent::GestureScrollBegin;
929 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 930 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
930 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 931 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
931 932
932 VERIFY_AND_RESET_MOCKS(); 933 VERIFY_AND_RESET_MOCKS();
933 934
934 // On the fling start, we should schedule an animation but not actually start 935 // On the fling start, we should schedule an animation but not actually start
935 // scrolling. 936 // scrolling.
936 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 937 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
937 WebPoint fling_point = WebPoint(7, 13); 938 WebPoint fling_point = WebPoint(7, 13);
938 WebPoint fling_global_point = WebPoint(17, 23); 939 WebPoint fling_global_point = WebPoint(17, 23);
939 // Note that for touchscreen the control modifier is not special. 940 // Note that for touchscreen the control modifier is not special.
940 int modifiers = WebInputEvent::ControlKey; 941 int modifiers = WebInputEvent::ControlKey;
941 gesture_ = CreateFling(WebGestureEvent::Touchscreen, 942 gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen,
942 fling_delta, 943 fling_delta,
943 fling_point, 944 fling_point,
944 fling_global_point, 945 fling_global_point,
945 modifiers); 946 modifiers);
946 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 947 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
947 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 948 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
948 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 949 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
949 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 950 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
950 951
951 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 952 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
(...skipping 26 matching lines...) Expand all
978 979
979 TEST_F(InputHandlerProxyTest, GestureFlingWithValidTimestamp) { 980 TEST_F(InputHandlerProxyTest, GestureFlingWithValidTimestamp) {
980 // We shouldn't send any events to the widget for this gesture. 981 // We shouldn't send any events to the widget for this gesture.
981 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 982 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
982 VERIFY_AND_RESET_MOCKS(); 983 VERIFY_AND_RESET_MOCKS();
983 984
984 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 985 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
985 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 986 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
986 987
987 gesture_.type = WebInputEvent::GestureScrollBegin; 988 gesture_.type = WebInputEvent::GestureScrollBegin;
988 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 989 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
989 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 990 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
990 991
991 VERIFY_AND_RESET_MOCKS(); 992 VERIFY_AND_RESET_MOCKS();
992 993
993 // On the fling start, we should schedule an animation but not actually start 994 // On the fling start, we should schedule an animation but not actually start
994 // scrolling. 995 // scrolling.
995 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 996 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
996 base::TimeTicks time = base::TimeTicks() + dt; 997 base::TimeTicks time = base::TimeTicks() + dt;
997 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 998 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
998 WebPoint fling_point = WebPoint(7, 13); 999 WebPoint fling_point = WebPoint(7, 13);
999 WebPoint fling_global_point = WebPoint(17, 23); 1000 WebPoint fling_global_point = WebPoint(17, 23);
1000 int modifiers = WebInputEvent::ControlKey; 1001 int modifiers = WebInputEvent::ControlKey;
1001 gesture_ = CreateFling(time, 1002 gesture_ = CreateFling(time,
1002 WebGestureEvent::Touchscreen, 1003 blink::WebGestureDeviceTouchscreen,
1003 fling_delta, 1004 fling_delta,
1004 fling_point, 1005 fling_point,
1005 fling_global_point, 1006 fling_global_point,
1006 modifiers); 1007 modifiers);
1007 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1008 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1008 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1009 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1009 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1010 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1010 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1011 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1011 1012
1012 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1013 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
(...skipping 19 matching lines...) Expand all
1032 1033
1033 TEST_F(InputHandlerProxyTest, GestureFlingWithInvalidTimestamp) { 1034 TEST_F(InputHandlerProxyTest, GestureFlingWithInvalidTimestamp) {
1034 // We shouldn't send any events to the widget for this gesture. 1035 // We shouldn't send any events to the widget for this gesture.
1035 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1036 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1036 VERIFY_AND_RESET_MOCKS(); 1037 VERIFY_AND_RESET_MOCKS();
1037 1038
1038 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1039 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1039 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1040 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1040 1041
1041 gesture_.type = WebInputEvent::GestureScrollBegin; 1042 gesture_.type = WebInputEvent::GestureScrollBegin;
1042 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 1043 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1043 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1044 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1044 1045
1045 VERIFY_AND_RESET_MOCKS(); 1046 VERIFY_AND_RESET_MOCKS();
1046 1047
1047 // On the fling start, we should schedule an animation but not actually start 1048 // On the fling start, we should schedule an animation but not actually start
1048 // scrolling. 1049 // scrolling.
1049 base::TimeDelta start_time_offset = base::TimeDelta::FromMilliseconds(10); 1050 base::TimeDelta start_time_offset = base::TimeDelta::FromMilliseconds(10);
1050 gesture_.type = WebInputEvent::GestureFlingStart; 1051 gesture_.type = WebInputEvent::GestureFlingStart;
1051 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1052 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
1052 WebPoint fling_point = WebPoint(7, 13); 1053 WebPoint fling_point = WebPoint(7, 13);
1053 WebPoint fling_global_point = WebPoint(17, 23); 1054 WebPoint fling_global_point = WebPoint(17, 23);
1054 int modifiers = WebInputEvent::ControlKey; 1055 int modifiers = WebInputEvent::ControlKey;
1055 gesture_.timeStampSeconds = start_time_offset.InSecondsF(); 1056 gesture_.timeStampSeconds = start_time_offset.InSecondsF();
1056 gesture_.data.flingStart.velocityX = fling_delta.x; 1057 gesture_.data.flingStart.velocityX = fling_delta.x;
1057 gesture_.data.flingStart.velocityY = fling_delta.y; 1058 gesture_.data.flingStart.velocityY = fling_delta.y;
1058 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 1059 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1059 gesture_.x = fling_point.x; 1060 gesture_.x = fling_point.x;
1060 gesture_.y = fling_point.y; 1061 gesture_.y = fling_point.y;
1061 gesture_.globalX = fling_global_point.x; 1062 gesture_.globalX = fling_global_point.x;
1062 gesture_.globalY = fling_global_point.y; 1063 gesture_.globalY = fling_global_point.y;
1063 gesture_.modifiers = modifiers; 1064 gesture_.modifiers = modifiers;
1064 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1065 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1065 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1066 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1066 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1067 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1067 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1068 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1068 1069
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 1112
1112 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1113 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1113 VERIFY_AND_RESET_MOCKS(); 1114 VERIFY_AND_RESET_MOCKS();
1114 1115
1115 // On the fling start, we should schedule an animation but not actually start 1116 // On the fling start, we should schedule an animation but not actually start
1116 // scrolling. 1117 // scrolling.
1117 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1118 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
1118 WebPoint fling_point = WebPoint(7, 13); 1119 WebPoint fling_point = WebPoint(7, 13);
1119 WebPoint fling_global_point = WebPoint(17, 23); 1120 WebPoint fling_global_point = WebPoint(17, 23);
1120 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey; 1121 int modifiers = WebInputEvent::ControlKey | WebInputEvent::AltKey;
1121 gesture_ = CreateFling(WebGestureEvent::Touchscreen, 1122 gesture_ = CreateFling(blink::WebGestureDeviceTouchscreen,
1122 fling_delta, 1123 fling_delta,
1123 fling_point, 1124 fling_point,
1124 fling_global_point, 1125 fling_global_point,
1125 modifiers); 1126 modifiers);
1126 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1127 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1127 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1128 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1128 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1129 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1129 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1130 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1130 1131
1131 // |gesture_scroll_on_impl_thread_| should still be true after 1132 // |gesture_scroll_on_impl_thread_| should still be true after
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 1233
1233 TEST_F(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) { 1234 TEST_F(InputHandlerProxyTest, GestureFlingNotCancelledBySmallTimeDelta) {
1234 // We shouldn't send any events to the widget for this gesture. 1235 // We shouldn't send any events to the widget for this gesture.
1235 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1236 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1236 VERIFY_AND_RESET_MOCKS(); 1237 VERIFY_AND_RESET_MOCKS();
1237 1238
1238 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1239 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1239 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1240 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1240 1241
1241 gesture_.type = WebInputEvent::GestureScrollBegin; 1242 gesture_.type = WebInputEvent::GestureScrollBegin;
1242 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 1243 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1243 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1244 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1244 1245
1245 VERIFY_AND_RESET_MOCKS(); 1246 VERIFY_AND_RESET_MOCKS();
1246 1247
1247 // On the fling start, we should schedule an animation but not actually start 1248 // On the fling start, we should schedule an animation but not actually start
1248 // scrolling. 1249 // scrolling.
1249 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1250 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1250 base::TimeTicks time = base::TimeTicks() + dt; 1251 base::TimeTicks time = base::TimeTicks() + dt;
1251 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1252 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
1252 WebPoint fling_point = WebPoint(7, 13); 1253 WebPoint fling_point = WebPoint(7, 13);
1253 WebPoint fling_global_point = WebPoint(17, 23); 1254 WebPoint fling_global_point = WebPoint(17, 23);
1254 int modifiers = WebInputEvent::ControlKey; 1255 int modifiers = WebInputEvent::ControlKey;
1255 gesture_ = CreateFling(time, 1256 gesture_ = CreateFling(time,
1256 WebGestureEvent::Touchscreen, 1257 blink::WebGestureDeviceTouchscreen,
1257 fling_delta, 1258 fling_delta,
1258 fling_point, 1259 fling_point,
1259 fling_global_point, 1260 fling_global_point,
1260 modifiers); 1261 modifiers);
1261 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1262 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1262 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1263 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1263 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1264 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1264 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1265 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1265 1266
1266 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1267 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 } 1309 }
1309 1310
1310 TEST_F(InputHandlerProxyTest, GestureFlingCancelledAfterBothAxesStopScrolling) { 1311 TEST_F(InputHandlerProxyTest, GestureFlingCancelledAfterBothAxesStopScrolling) {
1311 // We shouldn't send any events to the widget for this gesture. 1312 // We shouldn't send any events to the widget for this gesture.
1312 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1313 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1313 VERIFY_AND_RESET_MOCKS(); 1314 VERIFY_AND_RESET_MOCKS();
1314 1315
1315 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1316 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1316 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1317 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1317 gesture_.type = WebInputEvent::GestureScrollBegin; 1318 gesture_.type = WebInputEvent::GestureScrollBegin;
1318 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 1319 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1319 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1320 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1320 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1321 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1321 1322
1322 // On the fling start, we should schedule an animation but not actually start 1323 // On the fling start, we should schedule an animation but not actually start
1323 // scrolling. 1324 // scrolling.
1324 gesture_.type = WebInputEvent::GestureFlingStart; 1325 gesture_.type = WebInputEvent::GestureFlingStart;
1325 WebFloatPoint fling_delta = WebFloatPoint(100, 100); 1326 WebFloatPoint fling_delta = WebFloatPoint(100, 100);
1326 gesture_.data.flingStart.velocityX = fling_delta.x; 1327 gesture_.data.flingStart.velocityX = fling_delta.x;
1327 gesture_.data.flingStart.velocityY = fling_delta.y; 1328 gesture_.data.flingStart.velocityY = fling_delta.y;
1328 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1329 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 } 1451 }
1451 1452
1452 TEST_F(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) { 1453 TEST_F(InputHandlerProxyTest, GestureFlingCancelledByKeyboardEvent) {
1453 // We shouldn't send any events to the widget for this gesture. 1454 // We shouldn't send any events to the widget for this gesture.
1454 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1455 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1455 VERIFY_AND_RESET_MOCKS(); 1456 VERIFY_AND_RESET_MOCKS();
1456 1457
1457 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1458 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1458 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1459 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1459 gesture_.type = WebInputEvent::GestureScrollBegin; 1460 gesture_.type = WebInputEvent::GestureScrollBegin;
1460 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 1461 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1461 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1462 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1462 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1463 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
1463 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1464 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
1464 1465
1465 // Keyboard events received during a scroll should have no effect. 1466 // Keyboard events received during a scroll should have no effect.
1466 WebKeyboardEvent key_event; 1467 WebKeyboardEvent key_event;
1467 key_event.type = WebInputEvent::KeyDown; 1468 key_event.type = WebInputEvent::KeyDown;
1468 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE, 1469 EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
1469 input_handler_->HandleInputEvent(key_event)); 1470 input_handler_->HandleInputEvent(key_event));
1470 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing()); 1471 EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 1504
1504 TEST_F(InputHandlerProxyTest, GestureFlingWithNegativeTimeDelta) { 1505 TEST_F(InputHandlerProxyTest, GestureFlingWithNegativeTimeDelta) {
1505 // We shouldn't send any events to the widget for this gesture. 1506 // We shouldn't send any events to the widget for this gesture.
1506 expected_disposition_ = InputHandlerProxy::DID_HANDLE; 1507 expected_disposition_ = InputHandlerProxy::DID_HANDLE;
1507 VERIFY_AND_RESET_MOCKS(); 1508 VERIFY_AND_RESET_MOCKS();
1508 1509
1509 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1510 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1510 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1511 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1511 1512
1512 gesture_.type = WebInputEvent::GestureScrollBegin; 1513 gesture_.type = WebInputEvent::GestureScrollBegin;
1513 gesture_.sourceDevice = WebGestureEvent::Touchscreen; 1514 gesture_.sourceDevice = blink::WebGestureDeviceTouchscreen;
1514 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1515 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1515 1516
1516 VERIFY_AND_RESET_MOCKS(); 1517 VERIFY_AND_RESET_MOCKS();
1517 1518
1518 // On the fling start, we should schedule an animation but not actually start 1519 // On the fling start, we should schedule an animation but not actually start
1519 // scrolling. 1520 // scrolling.
1520 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1521 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1521 base::TimeTicks time = base::TimeTicks() + dt; 1522 base::TimeTicks time = base::TimeTicks() + dt;
1522 WebFloatPoint fling_delta = WebFloatPoint(100, 0); 1523 WebFloatPoint fling_delta = WebFloatPoint(100, 0);
1523 WebPoint fling_point = WebPoint(7, 13); 1524 WebPoint fling_point = WebPoint(7, 13);
1524 WebPoint fling_global_point = WebPoint(17, 23); 1525 WebPoint fling_global_point = WebPoint(17, 23);
1525 int modifiers = WebInputEvent::ControlKey; 1526 int modifiers = WebInputEvent::ControlKey;
1526 gesture_ = CreateFling(time, 1527 gesture_ = CreateFling(time,
1527 WebGestureEvent::Touchscreen, 1528 blink::WebGestureDeviceTouchscreen,
1528 fling_delta, 1529 fling_delta,
1529 fling_point, 1530 fling_point,
1530 fling_global_point, 1531 fling_global_point,
1531 modifiers); 1532 modifiers);
1532 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1533 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1533 EXPECT_CALL(mock_input_handler_, FlingScrollBegin()) 1534 EXPECT_CALL(mock_input_handler_, FlingScrollBegin())
1534 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1535 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1535 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1536 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1536 1537
1537 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); 1538 testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
(...skipping 26 matching lines...) Expand all
1564 gesture_.type = WebInputEvent::GestureFlingCancel; 1565 gesture_.type = WebInputEvent::GestureFlingCancel;
1565 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1566 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1566 } 1567 }
1567 1568
1568 TEST_F(InputHandlerProxyTest, FlingBoost) { 1569 TEST_F(InputHandlerProxyTest, FlingBoost) {
1569 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1570 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1570 base::TimeTicks time = base::TimeTicks() + dt; 1571 base::TimeTicks time = base::TimeTicks() + dt;
1571 base::TimeTicks last_animate_time = time; 1572 base::TimeTicks last_animate_time = time;
1572 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1573 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1573 WebPoint fling_point = WebPoint(7, 13); 1574 WebPoint fling_point = WebPoint(7, 13);
1574 StartFling(time, WebGestureEvent::Touchscreen, fling_delta, fling_point); 1575 StartFling(
1576 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);
1575 1577
1576 // Now cancel the fling. The fling cancellation should be deferred to allow 1578 // Now cancel the fling. The fling cancellation should be deferred to allow
1577 // fling boosting events to arrive. 1579 // fling boosting events to arrive.
1578 time += dt; 1580 time += dt;
1579 CancelFling(time); 1581 CancelFling(time);
1580 1582
1581 // The GestureScrollBegin should be swallowed by the fling if it hits the same 1583 // The GestureScrollBegin should be swallowed by the fling if it hits the same
1582 // scrolling layer. 1584 // scrolling layer.
1583 EXPECT_CALL(mock_input_handler_, 1585 EXPECT_CALL(mock_input_handler_,
1584 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) 1586 IsCurrentlyScrollingLayerAt(testing::_, testing::_))
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 .WillOnce(testing::Return(true)); 1629 .WillOnce(testing::Return(true));
1628 input_handler_->Animate(time); 1630 input_handler_->Animate(time);
1629 last_animate_time = time; 1631 last_animate_time = time;
1630 1632
1631 VERIFY_AND_RESET_MOCKS(); 1633 VERIFY_AND_RESET_MOCKS();
1632 1634
1633 // GestureFlingStart in the same direction and at sufficient speed should 1635 // GestureFlingStart in the same direction and at sufficient speed should
1634 // boost the active fling. 1636 // boost the active fling.
1635 1637
1636 gesture_ = CreateFling(time, 1638 gesture_ = CreateFling(time,
1637 WebGestureEvent::Touchscreen, 1639 blink::WebGestureDeviceTouchscreen,
1638 fling_delta, 1640 fling_delta,
1639 fling_point, 1641 fling_point,
1640 fling_point, 1642 fling_point,
1641 0); 1643 0);
1642 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1644 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1643 VERIFY_AND_RESET_MOCKS(); 1645 VERIFY_AND_RESET_MOCKS();
1644 1646
1645 time += dt; 1647 time += dt;
1646 // Note we get *2x* as much delta because 2 flings have combined. 1648 // Note we get *2x* as much delta because 2 flings have combined.
1647 expected_delta = 2 * (time - last_animate_time).InSecondsF() * -fling_delta.x; 1649 expected_delta = 2 * (time - last_animate_time).InSecondsF() * -fling_delta.x;
1648 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1650 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1649 EXPECT_CALL(mock_input_handler_, 1651 EXPECT_CALL(mock_input_handler_,
1650 ScrollBy(testing::_, 1652 ScrollBy(testing::_,
1651 testing::Property(&gfx::Vector2dF::x, 1653 testing::Property(&gfx::Vector2dF::x,
1652 testing::Eq(expected_delta)))) 1654 testing::Eq(expected_delta))))
1653 .WillOnce(testing::Return(true)); 1655 .WillOnce(testing::Return(true));
1654 input_handler_->Animate(time); 1656 input_handler_->Animate(time);
1655 last_animate_time = time; 1657 last_animate_time = time;
1656 1658
1657 VERIFY_AND_RESET_MOCKS(); 1659 VERIFY_AND_RESET_MOCKS();
1658 1660
1659 // Repeated GestureFlingStarts should accumulate. 1661 // Repeated GestureFlingStarts should accumulate.
1660 1662
1661 CancelFling(time); 1663 CancelFling(time);
1662 gesture_ = CreateFling(time, 1664 gesture_ = CreateFling(time,
1663 WebGestureEvent::Touchscreen, 1665 blink::WebGestureDeviceTouchscreen,
1664 fling_delta, 1666 fling_delta,
1665 fling_point, 1667 fling_point,
1666 fling_point, 1668 fling_point,
1667 0); 1669 0);
1668 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1670 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1669 VERIFY_AND_RESET_MOCKS(); 1671 VERIFY_AND_RESET_MOCKS();
1670 1672
1671 time += dt; 1673 time += dt;
1672 // Note we get *3x* as much delta because 3 flings have combined. 1674 // Note we get *3x* as much delta because 3 flings have combined.
1673 expected_delta = 3 * (time - last_animate_time).InSecondsF() * -fling_delta.x; 1675 expected_delta = 3 * (time - last_animate_time).InSecondsF() * -fling_delta.x;
(...skipping 23 matching lines...) Expand all
1697 input_handler_->Animate(time); 1699 input_handler_->Animate(time);
1698 1700
1699 VERIFY_AND_RESET_MOCKS(); 1701 VERIFY_AND_RESET_MOCKS();
1700 } 1702 }
1701 1703
1702 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollTargetsDifferentLayer) { 1704 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollTargetsDifferentLayer) {
1703 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1705 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1704 base::TimeTicks time = base::TimeTicks() + dt; 1706 base::TimeTicks time = base::TimeTicks() + dt;
1705 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1707 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1706 WebPoint fling_point = WebPoint(7, 13); 1708 WebPoint fling_point = WebPoint(7, 13);
1707 StartFling(time, WebGestureEvent::Touchscreen, fling_delta, fling_point); 1709 StartFling(
1710 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);
1708 1711
1709 // Cancel the fling. The fling cancellation should be deferred to allow 1712 // Cancel the fling. The fling cancellation should be deferred to allow
1710 // fling boosting events to arrive. 1713 // fling boosting events to arrive.
1711 time += dt; 1714 time += dt;
1712 CancelFling(time); 1715 CancelFling(time);
1713 1716
1714 // If the GestureScrollBegin targets a different layer, the fling should be 1717 // If the GestureScrollBegin targets a different layer, the fling should be
1715 // cancelled and the scroll should be handled as usual. 1718 // cancelled and the scroll should be handled as usual.
1716 EXPECT_CALL(mock_input_handler_, 1719 EXPECT_CALL(mock_input_handler_,
1717 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) 1720 IsCurrentlyScrollingLayerAt(testing::_, testing::_))
1718 .WillOnce(testing::Return(false)); 1721 .WillOnce(testing::Return(false));
1719 EXPECT_CALL(mock_input_handler_, ScrollEnd()); 1722 EXPECT_CALL(mock_input_handler_, ScrollEnd());
1720 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_)) 1723 EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
1721 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted)); 1724 .WillOnce(testing::Return(cc::InputHandler::ScrollStarted));
1722 1725
1723 time += dt; 1726 time += dt;
1724 gesture_.timeStampSeconds = InSecondsF(time); 1727 gesture_.timeStampSeconds = InSecondsF(time);
1725 gesture_.type = WebInputEvent::GestureScrollBegin; 1728 gesture_.type = WebInputEvent::GestureScrollBegin;
1726 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1729 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1727 1730
1728 VERIFY_AND_RESET_MOCKS(); 1731 VERIFY_AND_RESET_MOCKS();
1729 } 1732 }
1730 1733
1731 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollDelayed) { 1734 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollDelayed) {
1732 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1735 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1733 base::TimeTicks time = base::TimeTicks() + dt; 1736 base::TimeTicks time = base::TimeTicks() + dt;
1734 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1737 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1735 WebPoint fling_point = WebPoint(7, 13); 1738 WebPoint fling_point = WebPoint(7, 13);
1736 StartFling(time, WebGestureEvent::Touchscreen, fling_delta, fling_point); 1739 StartFling(
1740 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);
1737 1741
1738 // Cancel the fling. The fling cancellation should be deferred to allow 1742 // Cancel the fling. The fling cancellation should be deferred to allow
1739 // fling boosting events to arrive. 1743 // fling boosting events to arrive.
1740 time += dt; 1744 time += dt;
1741 CancelFling(time); 1745 CancelFling(time);
1742 1746
1743 // The GestureScrollBegin should be swallowed by the fling if it hits the same 1747 // The GestureScrollBegin should be swallowed by the fling if it hits the same
1744 // scrolling layer. 1748 // scrolling layer.
1745 EXPECT_CALL(mock_input_handler_, 1749 EXPECT_CALL(mock_input_handler_,
1746 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) 1750 IsCurrentlyScrollingLayerAt(testing::_, testing::_))
(...skipping 15 matching lines...) Expand all
1762 input_handler_->Animate(time); 1766 input_handler_->Animate(time);
1763 1767
1764 VERIFY_AND_RESET_MOCKS(); 1768 VERIFY_AND_RESET_MOCKS();
1765 } 1769 }
1766 1770
1767 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollInDifferentDirection) { 1771 TEST_F(InputHandlerProxyTest, NoFlingBoostIfScrollInDifferentDirection) {
1768 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1772 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1769 base::TimeTicks time = base::TimeTicks() + dt; 1773 base::TimeTicks time = base::TimeTicks() + dt;
1770 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1774 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1771 WebPoint fling_point = WebPoint(7, 13); 1775 WebPoint fling_point = WebPoint(7, 13);
1772 StartFling(time, WebGestureEvent::Touchscreen, fling_delta, fling_point); 1776 StartFling(
1777 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);
1773 1778
1774 // Cancel the fling. The fling cancellation should be deferred to allow 1779 // Cancel the fling. The fling cancellation should be deferred to allow
1775 // fling boosting events to arrive. 1780 // fling boosting events to arrive.
1776 time += dt; 1781 time += dt;
1777 CancelFling(time); 1782 CancelFling(time);
1778 1783
1779 // The GestureScrollBegin should be swallowed by the fling if it hits the same 1784 // The GestureScrollBegin should be swallowed by the fling if it hits the same
1780 // scrolling layer. 1785 // scrolling layer.
1781 EXPECT_CALL(mock_input_handler_, 1786 EXPECT_CALL(mock_input_handler_,
1782 IsCurrentlyScrollingLayerAt(testing::_, testing::_)) 1787 IsCurrentlyScrollingLayerAt(testing::_, testing::_))
(...skipping 23 matching lines...) Expand all
1806 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1811 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1807 1812
1808 VERIFY_AND_RESET_MOCKS(); 1813 VERIFY_AND_RESET_MOCKS();
1809 } 1814 }
1810 1815
1811 TEST_F(InputHandlerProxyTest, NoFlingBoostIfFlingTooSlow) { 1816 TEST_F(InputHandlerProxyTest, NoFlingBoostIfFlingTooSlow) {
1812 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10); 1817 base::TimeDelta dt = base::TimeDelta::FromMilliseconds(10);
1813 base::TimeTicks time = base::TimeTicks() + dt; 1818 base::TimeTicks time = base::TimeTicks() + dt;
1814 WebFloatPoint fling_delta = WebFloatPoint(1000, 0); 1819 WebFloatPoint fling_delta = WebFloatPoint(1000, 0);
1815 WebPoint fling_point = WebPoint(7, 13); 1820 WebPoint fling_point = WebPoint(7, 13);
1816 StartFling(time, WebGestureEvent::Touchscreen, fling_delta, fling_point); 1821 StartFling(
1822 time, blink::WebGestureDeviceTouchscreen, fling_delta, fling_point);
1817 1823
1818 // Cancel the fling. The fling cancellation should be deferred to allow 1824 // Cancel the fling. The fling cancellation should be deferred to allow
1819 // fling boosting events to arrive. 1825 // fling boosting events to arrive.
1820 time += dt; 1826 time += dt;
1821 CancelFling(time); 1827 CancelFling(time);
1822 1828
1823 // If the new fling is too slow, no boosting should take place, with the new 1829 // If the new fling is too slow, no boosting should take place, with the new
1824 // fling replacing the old. 1830 // fling replacing the old.
1825 WebFloatPoint small_fling_delta = WebFloatPoint(100, 0); 1831 WebFloatPoint small_fling_delta = WebFloatPoint(100, 0);
1826 gesture_ = CreateFling(time, 1832 gesture_ = CreateFling(time,
1827 WebGestureEvent::Touchscreen, 1833 blink::WebGestureDeviceTouchscreen,
1828 small_fling_delta, 1834 small_fling_delta,
1829 fling_point, 1835 fling_point,
1830 fling_point, 1836 fling_point,
1831 0); 1837 0);
1832 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_)); 1838 EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(gesture_));
1833 1839
1834 VERIFY_AND_RESET_MOCKS(); 1840 VERIFY_AND_RESET_MOCKS();
1835 1841
1836 // Note that the new fling delta uses the *slow*, unboosted fling velocity. 1842 // Note that the new fling delta uses the *slow*, unboosted fling velocity.
1837 time += dt; 1843 time += dt;
1838 float expected_delta = dt.InSecondsF() * -small_fling_delta.x; 1844 float expected_delta = dt.InSecondsF() * -small_fling_delta.x;
1839 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate()); 1845 EXPECT_CALL(mock_input_handler_, SetNeedsAnimate());
1840 EXPECT_CALL(mock_input_handler_, 1846 EXPECT_CALL(mock_input_handler_,
1841 ScrollBy(testing::_, 1847 ScrollBy(testing::_,
1842 testing::Property(&gfx::Vector2dF::x, 1848 testing::Property(&gfx::Vector2dF::x,
1843 testing::Eq(expected_delta)))) 1849 testing::Eq(expected_delta))))
1844 .WillOnce(testing::Return(true)); 1850 .WillOnce(testing::Return(true));
1845 input_handler_->Animate(time); 1851 input_handler_->Animate(time);
1846 1852
1847 VERIFY_AND_RESET_MOCKS(); 1853 VERIFY_AND_RESET_MOCKS();
1848 } 1854 }
1849 1855
1850 } // namespace 1856 } // namespace
1851 } // namespace content 1857 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_proxy_client.h ('k') | content/renderer/input/input_handler_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698