| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 } | 711 } |
| 712 | 712 |
| 713 void SimulateGestureEventCoreWithLatencyInfo( | 713 void SimulateGestureEventCoreWithLatencyInfo( |
| 714 const WebGestureEvent& gesture_event, | 714 const WebGestureEvent& gesture_event, |
| 715 const ui::LatencyInfo& ui_latency) { | 715 const ui::LatencyInfo& ui_latency) { |
| 716 host_->ForwardGestureEventWithLatencyInfo(gesture_event, ui_latency); | 716 host_->ForwardGestureEventWithLatencyInfo(gesture_event, ui_latency); |
| 717 } | 717 } |
| 718 | 718 |
| 719 // Inject simple synthetic WebGestureEvent instances. | 719 // Inject simple synthetic WebGestureEvent instances. |
| 720 void SimulateGestureEvent(WebInputEvent::Type type, | 720 void SimulateGestureEvent(WebInputEvent::Type type, |
| 721 WebGestureEvent::SourceDevice sourceDevice) { | 721 WebGestureDevice sourceDevice) { |
| 722 SimulateGestureEventCore( | 722 SimulateGestureEventCore( |
| 723 SyntheticWebGestureEventBuilder::Build(type, sourceDevice)); | 723 SyntheticWebGestureEventBuilder::Build(type, sourceDevice)); |
| 724 } | 724 } |
| 725 | 725 |
| 726 void SimulateGestureEventWithLatencyInfo( | 726 void SimulateGestureEventWithLatencyInfo(WebInputEvent::Type type, |
| 727 WebInputEvent::Type type, | 727 WebGestureDevice sourceDevice, |
| 728 WebGestureEvent::SourceDevice sourceDevice, | 728 const ui::LatencyInfo& ui_latency) { |
| 729 const ui::LatencyInfo& ui_latency) { | |
| 730 SimulateGestureEventCoreWithLatencyInfo( | 729 SimulateGestureEventCoreWithLatencyInfo( |
| 731 SyntheticWebGestureEventBuilder::Build(type, sourceDevice), | 730 SyntheticWebGestureEventBuilder::Build(type, sourceDevice), |
| 732 ui_latency); | 731 ui_latency); |
| 733 } | 732 } |
| 734 | 733 |
| 735 void SimulateGestureScrollUpdateEvent(float dX, float dY, int modifiers) { | 734 void SimulateGestureScrollUpdateEvent(float dX, float dY, int modifiers) { |
| 736 SimulateGestureEventCore( | 735 SimulateGestureEventCore( |
| 737 SyntheticWebGestureEventBuilder::BuildScrollUpdate(dX, dY, modifiers)); | 736 SyntheticWebGestureEventBuilder::BuildScrollUpdate(dX, dY, modifiers)); |
| 738 } | 737 } |
| 739 | 738 |
| 740 void SimulateGesturePinchUpdateEvent(float scale, | 739 void SimulateGesturePinchUpdateEvent(float scale, |
| 741 float anchorX, | 740 float anchorX, |
| 742 float anchorY, | 741 float anchorY, |
| 743 int modifiers) { | 742 int modifiers) { |
| 744 SimulateGestureEventCore(SyntheticWebGestureEventBuilder::BuildPinchUpdate( | 743 SimulateGestureEventCore(SyntheticWebGestureEventBuilder::BuildPinchUpdate( |
| 745 scale, anchorX, anchorY, modifiers, WebGestureEvent::Touchscreen)); | 744 scale, anchorX, anchorY, modifiers, blink::WebGestureDeviceTouchpad)); |
| 746 } | 745 } |
| 747 | 746 |
| 748 // Inject synthetic GestureFlingStart events. | 747 // Inject synthetic GestureFlingStart events. |
| 749 void SimulateGestureFlingStartEvent( | 748 void SimulateGestureFlingStartEvent(float velocityX, |
| 750 float velocityX, | 749 float velocityY, |
| 751 float velocityY, | 750 WebGestureDevice sourceDevice) { |
| 752 WebGestureEvent::SourceDevice sourceDevice) { | |
| 753 SimulateGestureEventCore( | 751 SimulateGestureEventCore( |
| 754 SyntheticWebGestureEventBuilder::BuildFling(velocityX, | 752 SyntheticWebGestureEventBuilder::BuildFling(velocityX, |
| 755 velocityY, | 753 velocityY, |
| 756 sourceDevice)); | 754 sourceDevice)); |
| 757 } | 755 } |
| 758 | 756 |
| 759 // Set the timestamp for the touch-event. | 757 // Set the timestamp for the touch-event. |
| 760 void SetTouchTimestamp(base::TimeDelta timestamp) { | 758 void SetTouchTimestamp(base::TimeDelta timestamp) { |
| 761 touch_event_.SetTimestamp(timestamp); | 759 touch_event_.SetTimestamp(timestamp); |
| 762 } | 760 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 | 806 |
| 809 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); | 807 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); |
| 810 }; | 808 }; |
| 811 | 809 |
| 812 #if GTEST_HAS_PARAM_TEST | 810 #if GTEST_HAS_PARAM_TEST |
| 813 // RenderWidgetHostWithSourceTest ---------------------------------------------- | 811 // RenderWidgetHostWithSourceTest ---------------------------------------------- |
| 814 | 812 |
| 815 // This is for tests that are to be run for all source devices. | 813 // This is for tests that are to be run for all source devices. |
| 816 class RenderWidgetHostWithSourceTest | 814 class RenderWidgetHostWithSourceTest |
| 817 : public RenderWidgetHostTest, | 815 : public RenderWidgetHostTest, |
| 818 public testing::WithParamInterface<WebGestureEvent::SourceDevice> { | 816 public testing::WithParamInterface<WebGestureDevice> {}; |
| 819 }; | |
| 820 #endif // GTEST_HAS_PARAM_TEST | 817 #endif // GTEST_HAS_PARAM_TEST |
| 821 | 818 |
| 822 } // namespace | 819 } // namespace |
| 823 | 820 |
| 824 // ----------------------------------------------------------------------------- | 821 // ----------------------------------------------------------------------------- |
| 825 | 822 |
| 826 TEST_F(RenderWidgetHostTest, Resize) { | 823 TEST_F(RenderWidgetHostTest, Resize) { |
| 827 // The initial bounds is the empty rect, and the screen info hasn't been sent | 824 // The initial bounds is the empty rect, and the screen info hasn't been sent |
| 828 // yet, so setting it to the same thing shouldn't send the resize message. | 825 // yet, so setting it to the same thing shouldn't send the resize message. |
| 829 view_->set_bounds(gfx::Rect()); | 826 view_->set_bounds(gfx::Rect()); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 | 1104 |
| 1108 // ensure the wheel event handler was invoked | 1105 // ensure the wheel event handler was invoked |
| 1109 EXPECT_TRUE(delegate_->handle_wheel_event_called()); | 1106 EXPECT_TRUE(delegate_->handle_wheel_event_called()); |
| 1110 | 1107 |
| 1111 // and that it suppressed the unhandled wheel event handler. | 1108 // and that it suppressed the unhandled wheel event handler. |
| 1112 EXPECT_EQ(0, view_->unhandled_wheel_event_count()); | 1109 EXPECT_EQ(0, view_->unhandled_wheel_event_count()); |
| 1113 } | 1110 } |
| 1114 | 1111 |
| 1115 TEST_F(RenderWidgetHostTest, UnhandledGestureEvent) { | 1112 TEST_F(RenderWidgetHostTest, UnhandledGestureEvent) { |
| 1116 SimulateGestureEvent(WebInputEvent::GestureTwoFingerTap, | 1113 SimulateGestureEvent(WebInputEvent::GestureTwoFingerTap, |
| 1117 WebGestureEvent::Touchscreen); | 1114 blink::WebGestureDeviceTouchpad); |
| 1118 | 1115 |
| 1119 // Make sure we sent the input event to the renderer. | 1116 // Make sure we sent the input event to the renderer. |
| 1120 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 1117 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
| 1121 InputMsg_HandleInputEvent::ID)); | 1118 InputMsg_HandleInputEvent::ID)); |
| 1122 process_->sink().ClearMessages(); | 1119 process_->sink().ClearMessages(); |
| 1123 | 1120 |
| 1124 // Send the simulated response from the renderer back. | 1121 // Send the simulated response from the renderer back. |
| 1125 SendInputEventACK(WebInputEvent::GestureTwoFingerTap, | 1122 SendInputEventACK(WebInputEvent::GestureTwoFingerTap, |
| 1126 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1123 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1127 EXPECT_EQ(WebInputEvent::GestureTwoFingerTap, view_->gesture_event_type()); | 1124 EXPECT_EQ(WebInputEvent::GestureTwoFingerTap, view_->gesture_event_type()); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1287 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1291 EXPECT_EQ(1U, process_->sink().message_count()); | 1288 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1292 | 1289 |
| 1293 process_->sink().ClearMessages(); | 1290 process_->sink().ClearMessages(); |
| 1294 SendInputEventACK(WebInputEvent::MouseWheel, | 1291 SendInputEventACK(WebInputEvent::MouseWheel, |
| 1295 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1292 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1296 EXPECT_EQ(0U, process_->sink().message_count()); | 1293 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1297 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1294 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1298 | 1295 |
| 1299 // Indicate the end of the scrolling from the touchpad. | 1296 // Indicate the end of the scrolling from the touchpad. |
| 1300 SimulateGestureFlingStartEvent(-1200.f, 0.f, WebGestureEvent::Touchpad); | 1297 SimulateGestureFlingStartEvent(-1200.f, 0.f, blink::WebGestureDeviceTouchpad); |
| 1301 EXPECT_EQ(1U, process_->sink().message_count()); | 1298 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1302 | 1299 |
| 1303 // Start another scroll. This time, do not consume any scroll events. | 1300 // Start another scroll. This time, do not consume any scroll events. |
| 1304 process_->sink().ClearMessages(); | 1301 process_->sink().ClearMessages(); |
| 1305 SimulateWheelEvent(0, -5, 0, true); // sent directly | 1302 SimulateWheelEvent(0, -5, 0, true); // sent directly |
| 1306 SimulateWheelEvent(0, -1, 0, true); // enqueued | 1303 SimulateWheelEvent(0, -1, 0, true); // enqueued |
| 1307 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event | 1304 SimulateWheelEvent(-10, -3, 0, true); // coalesced into previous event |
| 1308 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event | 1305 SimulateWheelEvent(-15, -1, 0, true); // coalesced into previous event |
| 1309 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event | 1306 SimulateWheelEvent(-30, -3, 0, true); // coalesced into previous event |
| 1310 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers | 1307 SimulateWheelEvent(-20, 6, 1, true); // enqueued, different modifiers |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 1418 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 1422 EXPECT_EQ(60.f, host_->overscroll_delta_x()); | 1419 EXPECT_EQ(60.f, host_->overscroll_delta_x()); |
| 1423 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x()); | 1420 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x()); |
| 1424 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); | 1421 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); |
| 1425 process_->sink().ClearMessages(); | 1422 process_->sink().ClearMessages(); |
| 1426 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1423 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1427 | 1424 |
| 1428 // Send a fling start, but with a small velocity, so that the overscroll is | 1425 // Send a fling start, but with a small velocity, so that the overscroll is |
| 1429 // aborted. The fling should proceed to the renderer, through the gesture | 1426 // aborted. The fling should proceed to the renderer, through the gesture |
| 1430 // event filter. | 1427 // event filter. |
| 1431 SimulateGestureFlingStartEvent(0.f, 0.1f, WebGestureEvent::Touchpad); | 1428 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); |
| 1432 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1429 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1433 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1430 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1434 EXPECT_EQ(1U, process_->sink().message_count()); | 1431 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1435 } | 1432 } |
| 1436 | 1433 |
| 1437 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that | 1434 // Same as ScrollEventsOverscrollWithFling, but with zero velocity. Checks that |
| 1438 // the zero-velocity fling does not reach the renderer. | 1435 // the zero-velocity fling does not reach the renderer. |
| 1439 TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithZeroFling) { | 1436 TEST_F(RenderWidgetHostTest, ScrollEventsOverscrollWithZeroFling) { |
| 1440 host_->SetupForOverscrollControllerTest(); | 1437 host_->SetupForOverscrollControllerTest(); |
| 1441 process_->sink().ClearMessages(); | 1438 process_->sink().ClearMessages(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1468 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 1465 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 1469 EXPECT_EQ(60.f, host_->overscroll_delta_x()); | 1466 EXPECT_EQ(60.f, host_->overscroll_delta_x()); |
| 1470 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x()); | 1467 EXPECT_EQ(10.f, host_->overscroll_delegate()->delta_x()); |
| 1471 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); | 1468 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); |
| 1472 process_->sink().ClearMessages(); | 1469 process_->sink().ClearMessages(); |
| 1473 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1470 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1474 | 1471 |
| 1475 // Send a fling start, but with a small velocity, so that the overscroll is | 1472 // Send a fling start, but with a small velocity, so that the overscroll is |
| 1476 // aborted. The fling should proceed to the renderer, through the gesture | 1473 // aborted. The fling should proceed to the renderer, through the gesture |
| 1477 // event filter. | 1474 // event filter. |
| 1478 SimulateGestureFlingStartEvent(10.f, 0.f, WebGestureEvent::Touchpad); | 1475 SimulateGestureFlingStartEvent(10.f, 0.f, blink::WebGestureDeviceTouchpad); |
| 1479 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1476 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1480 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1477 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1481 EXPECT_EQ(1U, process_->sink().message_count()); | 1478 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1482 } | 1479 } |
| 1483 | 1480 |
| 1484 // Tests that a fling in the opposite direction of the overscroll cancels the | 1481 // Tests that a fling in the opposite direction of the overscroll cancels the |
| 1485 // overscroll nav instead of completing it. | 1482 // overscroll nav instead of completing it. |
| 1486 TEST_F(RenderWidgetHostTest, ReverseFlingCancelsOverscroll) { | 1483 TEST_F(RenderWidgetHostTest, ReverseFlingCancelsOverscroll) { |
| 1487 host_->SetupForOverscrollControllerTest(); | 1484 host_->SetupForOverscrollControllerTest(); |
| 1488 process_->sink().ClearMessages(); | 1485 process_->sink().ClearMessages(); |
| 1489 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 1486 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
| 1490 view_->Show(); | 1487 view_->Show(); |
| 1491 | 1488 |
| 1492 { | 1489 { |
| 1493 // Start and end a gesture in the same direction without processing the | 1490 // Start and end a gesture in the same direction without processing the |
| 1494 // gesture events in the renderer. This should initiate and complete an | 1491 // gesture events in the renderer. This should initiate and complete an |
| 1495 // overscroll navigation. | 1492 // overscroll navigation. |
| 1496 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1493 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1497 WebGestureEvent::Touchscreen); | 1494 blink::WebGestureDeviceTouchpad); |
| 1498 SimulateGestureScrollUpdateEvent(300, -5, 0); | 1495 SimulateGestureScrollUpdateEvent(300, -5, 0); |
| 1499 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1496 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1500 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1497 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1501 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 1498 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 1502 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 1499 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 1503 process_->sink().ClearMessages(); | 1500 process_->sink().ClearMessages(); |
| 1504 | 1501 |
| 1505 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 1502 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 1506 WebGestureEvent::Touchscreen); | 1503 blink::WebGestureDeviceTouchpad); |
| 1507 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 1504 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
| 1508 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1505 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1509 EXPECT_EQ(1U, process_->sink().message_count()); | 1506 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1510 } | 1507 } |
| 1511 | 1508 |
| 1512 { | 1509 { |
| 1513 // Start over, except instead of ending the gesture with ScrollEnd, end it | 1510 // Start over, except instead of ending the gesture with ScrollEnd, end it |
| 1514 // with a FlingStart, with velocity in the reverse direction. This should | 1511 // with a FlingStart, with velocity in the reverse direction. This should |
| 1515 // initiate an overscroll navigation, but it should be cancelled because of | 1512 // initiate an overscroll navigation, but it should be cancelled because of |
| 1516 // the fling in the opposite direction. | 1513 // the fling in the opposite direction. |
| 1517 host_->overscroll_delegate()->Reset(); | 1514 host_->overscroll_delegate()->Reset(); |
| 1518 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1515 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1519 WebGestureEvent::Touchscreen); | 1516 blink::WebGestureDeviceTouchpad); |
| 1520 SimulateGestureScrollUpdateEvent(-300, -5, 0); | 1517 SimulateGestureScrollUpdateEvent(-300, -5, 0); |
| 1521 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1518 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1522 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1519 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1523 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); | 1520 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); |
| 1524 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode()); | 1521 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->current_mode()); |
| 1525 process_->sink().ClearMessages(); | 1522 process_->sink().ClearMessages(); |
| 1526 | 1523 |
| 1527 SimulateGestureFlingStartEvent(100, 0, WebGestureEvent::Touchscreen); | 1524 SimulateGestureFlingStartEvent(100, 0, blink::WebGestureDeviceTouchpad); |
| 1528 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); | 1525 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); |
| 1529 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1526 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1530 EXPECT_EQ(1U, process_->sink().message_count()); | 1527 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1531 } | 1528 } |
| 1532 } | 1529 } |
| 1533 | 1530 |
| 1534 // Tests that touch-scroll events are handled correctly by the overscroll | 1531 // Tests that touch-scroll events are handled correctly by the overscroll |
| 1535 // controller. This also tests that the overscroll controller and the | 1532 // controller. This also tests that the overscroll controller and the |
| 1536 // gesture-event filter play nice with each other. | 1533 // gesture-event filter play nice with each other. |
| 1537 TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) { | 1534 TEST_F(RenderWidgetHostTest, GestureScrollOverscrolls) { |
| 1538 // Turn off debounce handling for test isolation. | 1535 // Turn off debounce handling for test isolation. |
| 1539 host_->SetupForOverscrollControllerTest(); | 1536 host_->SetupForOverscrollControllerTest(); |
| 1540 process_->sink().ClearMessages(); | 1537 process_->sink().ClearMessages(); |
| 1541 | 1538 |
| 1542 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1539 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1543 WebGestureEvent::Touchscreen); | 1540 blink::WebGestureDeviceTouchpad); |
| 1544 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1541 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1545 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1542 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1546 | 1543 |
| 1547 // Send another gesture event and ACK as not being processed. This should | 1544 // Send another gesture event and ACK as not being processed. This should |
| 1548 // initiate the navigation gesture. | 1545 // initiate the navigation gesture. |
| 1549 SimulateGestureScrollUpdateEvent(55, -5, 0); | 1546 SimulateGestureScrollUpdateEvent(55, -5, 0); |
| 1550 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1547 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1551 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1548 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1552 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 1549 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 1553 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 1550 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1568 EXPECT_EQ(-10.f, host_->overscroll_delta_y()); | 1565 EXPECT_EQ(-10.f, host_->overscroll_delta_y()); |
| 1569 EXPECT_EQ(15.f, host_->overscroll_delegate()->delta_x()); | 1566 EXPECT_EQ(15.f, host_->overscroll_delegate()->delta_x()); |
| 1570 EXPECT_EQ(-10.f, host_->overscroll_delegate()->delta_y()); | 1567 EXPECT_EQ(-10.f, host_->overscroll_delegate()->delta_y()); |
| 1571 EXPECT_EQ(0U, process_->sink().message_count()); | 1568 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1572 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1569 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1573 | 1570 |
| 1574 // Now send a scroll end. This should cancel the overscroll gesture, and send | 1571 // Now send a scroll end. This should cancel the overscroll gesture, and send |
| 1575 // the event to the renderer. The gesture-event filter should receive this | 1572 // the event to the renderer. The gesture-event filter should receive this |
| 1576 // event. | 1573 // event. |
| 1577 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 1574 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 1578 WebGestureEvent::Touchscreen); | 1575 blink::WebGestureDeviceTouchpad); |
| 1579 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1576 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1580 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1577 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1581 EXPECT_EQ(1U, process_->sink().message_count()); | 1578 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1582 // The scroll end event will have received a synthetic ack from the input | 1579 // The scroll end event will have received a synthetic ack from the input |
| 1583 // router. | 1580 // router. |
| 1584 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1581 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1585 } | 1582 } |
| 1586 | 1583 |
| 1587 // Tests that if the page is scrolled because of a scroll-gesture, then that | 1584 // Tests that if the page is scrolled because of a scroll-gesture, then that |
| 1588 // particular scroll sequence never generates overscroll if the scroll direction | 1585 // particular scroll sequence never generates overscroll if the scroll direction |
| 1589 // is horizontal. | 1586 // is horizontal. |
| 1590 TEST_F(RenderWidgetHostTest, GestureScrollConsumedHorizontal) { | 1587 TEST_F(RenderWidgetHostTest, GestureScrollConsumedHorizontal) { |
| 1591 // Turn off debounce handling for test isolation. | 1588 // Turn off debounce handling for test isolation. |
| 1592 host_->SetupForOverscrollControllerTest(); | 1589 host_->SetupForOverscrollControllerTest(); |
| 1593 process_->sink().ClearMessages(); | 1590 process_->sink().ClearMessages(); |
| 1594 | 1591 |
| 1595 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1592 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1596 WebGestureEvent::Touchscreen); | 1593 blink::WebGestureDeviceTouchpad); |
| 1597 SimulateGestureScrollUpdateEvent(10, 0, 0); | 1594 SimulateGestureScrollUpdateEvent(10, 0, 0); |
| 1598 | 1595 |
| 1599 // Start scrolling on content. ACK both events as being processed. | 1596 // Start scrolling on content. ACK both events as being processed. |
| 1600 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1597 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1601 INPUT_EVENT_ACK_STATE_CONSUMED); | 1598 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1602 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1599 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1603 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1600 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1604 process_->sink().ClearMessages(); | 1601 process_->sink().ClearMessages(); |
| 1605 | 1602 |
| 1606 // Send another gesture event and ACK as not being processed. This should | 1603 // Send another gesture event and ACK as not being processed. This should |
| 1607 // not initiate overscroll because the beginning of the scroll event did | 1604 // not initiate overscroll because the beginning of the scroll event did |
| 1608 // scroll some content on the page. Since there was no overscroll, the event | 1605 // scroll some content on the page. Since there was no overscroll, the event |
| 1609 // should reach the renderer. | 1606 // should reach the renderer. |
| 1610 SimulateGestureScrollUpdateEvent(55, 0, 0); | 1607 SimulateGestureScrollUpdateEvent(55, 0, 0); |
| 1611 EXPECT_EQ(1U, process_->sink().message_count()); | 1608 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1612 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1609 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1613 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1610 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1614 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1611 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1615 } | 1612 } |
| 1616 | 1613 |
| 1617 // Tests that the overscroll controller plays nice with touch-scrolls and the | 1614 // Tests that the overscroll controller plays nice with touch-scrolls and the |
| 1618 // gesture event filter with debounce filtering turned on. | 1615 // gesture event filter with debounce filtering turned on. |
| 1619 TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) { | 1616 TEST_F(RenderWidgetHostTest, GestureScrollDebounceOverscrolls) { |
| 1620 host_->SetupForOverscrollControllerTest(); | 1617 host_->SetupForOverscrollControllerTest(); |
| 1621 host_->set_debounce_interval_time_ms(100); | 1618 host_->set_debounce_interval_time_ms(100); |
| 1622 process_->sink().ClearMessages(); | 1619 process_->sink().ClearMessages(); |
| 1623 | 1620 |
| 1624 // Start scrolling. Receive ACK as it being processed. | 1621 // Start scrolling. Receive ACK as it being processed. |
| 1625 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1622 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1626 WebGestureEvent::Touchscreen); | 1623 blink::WebGestureDeviceTouchpad); |
| 1627 EXPECT_EQ(1U, process_->sink().message_count()); | 1624 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1628 process_->sink().ClearMessages(); | 1625 process_->sink().ClearMessages(); |
| 1629 | 1626 |
| 1630 // Send update events. | 1627 // Send update events. |
| 1631 SimulateGestureScrollUpdateEvent(25, 0, 0); | 1628 SimulateGestureScrollUpdateEvent(25, 0, 0); |
| 1632 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1629 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1633 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 1630 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 1634 EXPECT_TRUE(host_->ScrollingInProgress()); | 1631 EXPECT_TRUE(host_->ScrollingInProgress()); |
| 1635 EXPECT_EQ(1U, process_->sink().message_count()); | 1632 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1636 process_->sink().ClearMessages(); | 1633 process_->sink().ClearMessages(); |
| 1637 | 1634 |
| 1638 // Quickly end and restart the scroll gesture. These two events should get | 1635 // Quickly end and restart the scroll gesture. These two events should get |
| 1639 // discarded. | 1636 // discarded. |
| 1640 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 1637 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 1641 WebGestureEvent::Touchscreen); | 1638 blink::WebGestureDeviceTouchpad); |
| 1642 EXPECT_EQ(0U, process_->sink().message_count()); | 1639 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1643 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1640 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1644 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); | 1641 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); |
| 1645 | 1642 |
| 1646 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1643 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1647 WebGestureEvent::Touchscreen); | 1644 blink::WebGestureDeviceTouchpad); |
| 1648 EXPECT_EQ(0U, process_->sink().message_count()); | 1645 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1649 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1646 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1650 EXPECT_EQ(2U, host_->GestureEventDebouncingQueueSize()); | 1647 EXPECT_EQ(2U, host_->GestureEventDebouncingQueueSize()); |
| 1651 | 1648 |
| 1652 // Send another update event. This should get into the queue. | 1649 // Send another update event. This should get into the queue. |
| 1653 SimulateGestureScrollUpdateEvent(30, 0, 0); | 1650 SimulateGestureScrollUpdateEvent(30, 0, 0); |
| 1654 EXPECT_EQ(0U, process_->sink().message_count()); | 1651 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1655 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); | 1652 EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize()); |
| 1656 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 1653 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 1657 EXPECT_TRUE(host_->ScrollingInProgress()); | 1654 EXPECT_TRUE(host_->ScrollingInProgress()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 | 1691 |
| 1695 // Tests that the gesture debounce timer plays nice with the overscroll | 1692 // Tests that the gesture debounce timer plays nice with the overscroll |
| 1696 // controller. | 1693 // controller. |
| 1697 TEST_F(RenderWidgetHostTest, GestureScrollDebounceTimerOverscroll) { | 1694 TEST_F(RenderWidgetHostTest, GestureScrollDebounceTimerOverscroll) { |
| 1698 host_->SetupForOverscrollControllerTest(); | 1695 host_->SetupForOverscrollControllerTest(); |
| 1699 host_->set_debounce_interval_time_ms(10); | 1696 host_->set_debounce_interval_time_ms(10); |
| 1700 process_->sink().ClearMessages(); | 1697 process_->sink().ClearMessages(); |
| 1701 | 1698 |
| 1702 // Start scrolling. Receive ACK as it being processed. | 1699 // Start scrolling. Receive ACK as it being processed. |
| 1703 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1700 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1704 WebGestureEvent::Touchscreen); | 1701 blink::WebGestureDeviceTouchpad); |
| 1705 EXPECT_EQ(1U, process_->sink().message_count()); | 1702 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1706 process_->sink().ClearMessages(); | 1703 process_->sink().ClearMessages(); |
| 1707 | 1704 |
| 1708 // Send update events. | 1705 // Send update events. |
| 1709 SimulateGestureScrollUpdateEvent(55, 0, 0); | 1706 SimulateGestureScrollUpdateEvent(55, 0, 0); |
| 1710 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1707 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1711 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 1708 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 1712 EXPECT_TRUE(host_->ScrollingInProgress()); | 1709 EXPECT_TRUE(host_->ScrollingInProgress()); |
| 1713 EXPECT_EQ(1U, process_->sink().message_count()); | 1710 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1714 process_->sink().ClearMessages(); | 1711 process_->sink().ClearMessages(); |
| 1715 | 1712 |
| 1716 // Send an end event. This should get in the debounce queue. | 1713 // Send an end event. This should get in the debounce queue. |
| 1717 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 1714 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 1718 WebGestureEvent::Touchscreen); | 1715 blink::WebGestureDeviceTouchpad); |
| 1719 EXPECT_EQ(0U, process_->sink().message_count()); | 1716 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1720 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 1717 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 1721 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); | 1718 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); |
| 1722 | 1719 |
| 1723 // Receive ACK for the scroll-update event. | 1720 // Receive ACK for the scroll-update event. |
| 1724 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1721 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1725 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1722 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1726 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 1723 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 1727 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 1724 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 1728 EXPECT_EQ(55.f, host_->overscroll_delta_x()); | 1725 EXPECT_EQ(55.f, host_->overscroll_delta_x()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1775 SendTouchEvent(); | 1772 SendTouchEvent(); |
| 1776 EXPECT_EQ(1U, process_->sink().message_count()); | 1773 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1777 process_->sink().ClearMessages(); | 1774 process_->sink().ClearMessages(); |
| 1778 SendInputEventACK(WebInputEvent::TouchMove, | 1775 SendInputEventACK(WebInputEvent::TouchMove, |
| 1779 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1776 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1780 | 1777 |
| 1781 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1778 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1782 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1779 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1783 | 1780 |
| 1784 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1781 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1785 WebGestureEvent::Touchscreen); | 1782 blink::WebGestureDeviceTouchpad); |
| 1786 SimulateGestureScrollUpdateEvent(20, 0, 0); | 1783 SimulateGestureScrollUpdateEvent(20, 0, 0); |
| 1787 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1784 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 1788 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1785 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1789 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1786 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1790 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1787 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1791 process_->sink().ClearMessages(); | 1788 process_->sink().ClearMessages(); |
| 1792 | 1789 |
| 1793 // Another touch move event should reach the renderer since overscroll hasn't | 1790 // Another touch move event should reach the renderer since overscroll hasn't |
| 1794 // started yet. | 1791 // started yet. |
| 1795 MoveTouchPoint(0, 65, 10); | 1792 MoveTouchPoint(0, 65, 10); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1860 EXPECT_EQ(1U, process_->sink().message_count()); | 1857 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1861 EXPECT_FALSE(host_->TouchEventQueueEmpty()); | 1858 EXPECT_FALSE(host_->TouchEventQueueEmpty()); |
| 1862 process_->sink().ClearMessages(); | 1859 process_->sink().ClearMessages(); |
| 1863 | 1860 |
| 1864 SendInputEventACK(WebInputEvent::TouchEnd, | 1861 SendInputEventACK(WebInputEvent::TouchEnd, |
| 1865 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1862 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1866 EXPECT_EQ(0U, process_->sink().message_count()); | 1863 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1867 EXPECT_TRUE(host_->TouchEventQueueEmpty()); | 1864 EXPECT_TRUE(host_->TouchEventQueueEmpty()); |
| 1868 | 1865 |
| 1869 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 1866 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
| 1870 WebGestureEvent::Touchscreen); | 1867 blink::WebGestureDeviceTouchpad); |
| 1871 base::MessageLoop::current()->PostDelayedTask( | 1868 base::MessageLoop::current()->PostDelayedTask( |
| 1872 FROM_HERE, | 1869 FROM_HERE, |
| 1873 base::MessageLoop::QuitClosure(), | 1870 base::MessageLoop::QuitClosure(), |
| 1874 TimeDelta::FromMilliseconds(10)); | 1871 TimeDelta::FromMilliseconds(10)); |
| 1875 base::MessageLoop::current()->Run(); | 1872 base::MessageLoop::current()->Run(); |
| 1876 EXPECT_EQ(1U, process_->sink().message_count()); | 1873 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1877 EXPECT_TRUE(host_->TouchEventQueueEmpty()); | 1874 EXPECT_TRUE(host_->TouchEventQueueEmpty()); |
| 1878 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1875 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1879 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1876 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1880 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 1877 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
| 1881 } | 1878 } |
| 1882 | 1879 |
| 1883 // Tests that touch-gesture end is dispatched to the renderer at the end of a | 1880 // Tests that touch-gesture end is dispatched to the renderer at the end of a |
| 1884 // touch-gesture initiated overscroll. | 1881 // touch-gesture initiated overscroll. |
| 1885 TEST_F(RenderWidgetHostTest, TouchGestureEndDispatchedAfterOverscrollComplete) { | 1882 TEST_F(RenderWidgetHostTest, TouchGestureEndDispatchedAfterOverscrollComplete) { |
| 1886 host_->SetupForOverscrollControllerTest(); | 1883 host_->SetupForOverscrollControllerTest(); |
| 1887 host_->set_debounce_interval_time_ms(10); | 1884 host_->set_debounce_interval_time_ms(10); |
| 1888 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1885 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 1889 process_->sink().ClearMessages(); | 1886 process_->sink().ClearMessages(); |
| 1890 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 1887 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
| 1891 view_->Show(); | 1888 view_->Show(); |
| 1892 | 1889 |
| 1893 // Start scrolling. Receive ACK as it being processed. | 1890 // Start scrolling. Receive ACK as it being processed. |
| 1894 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1891 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1895 WebGestureEvent::Touchscreen); | 1892 blink::WebGestureDeviceTouchpad); |
| 1896 EXPECT_EQ(1U, process_->sink().message_count()); | 1893 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1897 // The scroll begin event will have received a synthetic ack from the input | 1894 // The scroll begin event will have received a synthetic ack from the input |
| 1898 // router. | 1895 // router. |
| 1899 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1896 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1900 process_->sink().ClearMessages(); | 1897 process_->sink().ClearMessages(); |
| 1901 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1898 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1902 EXPECT_EQ(0U, process_->sink().message_count()); | 1899 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1903 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1900 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1904 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1901 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1905 | 1902 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1918 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1915 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1919 EXPECT_EQ(0U, process_->sink().message_count()); | 1916 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1920 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 1917 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 1921 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 1918 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 1922 EXPECT_EQ(55.f, host_->overscroll_delta_x()); | 1919 EXPECT_EQ(55.f, host_->overscroll_delta_x()); |
| 1923 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x()); | 1920 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x()); |
| 1924 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y()); | 1921 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y()); |
| 1925 | 1922 |
| 1926 // Send end event. | 1923 // Send end event. |
| 1927 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 1924 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
| 1928 WebGestureEvent::Touchscreen); | 1925 blink::WebGestureDeviceTouchpad); |
| 1929 EXPECT_EQ(0U, process_->sink().message_count()); | 1926 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1930 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1927 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1931 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1928 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1932 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); | 1929 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); |
| 1933 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1930 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1934 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); | 1931 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); |
| 1935 base::MessageLoop::current()->PostDelayedTask( | 1932 base::MessageLoop::current()->PostDelayedTask( |
| 1936 FROM_HERE, | 1933 FROM_HERE, |
| 1937 base::MessageLoop::QuitClosure(), | 1934 base::MessageLoop::QuitClosure(), |
| 1938 TimeDelta::FromMilliseconds(10)); | 1935 TimeDelta::FromMilliseconds(10)); |
| 1939 base::MessageLoop::current()->Run(); | 1936 base::MessageLoop::current()->Run(); |
| 1940 EXPECT_EQ(1U, process_->sink().message_count()); | 1937 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1941 process_->sink().ClearMessages(); | 1938 process_->sink().ClearMessages(); |
| 1942 // The scroll end event will have received a synthetic ack from the input | 1939 // The scroll end event will have received a synthetic ack from the input |
| 1943 // router. | 1940 // router. |
| 1944 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1941 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1945 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 1942 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 1946 EXPECT_EQ(0U, process_->sink().message_count()); | 1943 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1947 | 1944 |
| 1948 // Start scrolling. Receive ACK as it being processed. | 1945 // Start scrolling. Receive ACK as it being processed. |
| 1949 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1946 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 1950 WebGestureEvent::Touchscreen); | 1947 blink::WebGestureDeviceTouchpad); |
| 1951 EXPECT_EQ(1U, process_->sink().message_count()); | 1948 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1952 // The scroll begin event will have received a synthetic ack from the input | 1949 // The scroll begin event will have received a synthetic ack from the input |
| 1953 // router. | 1950 // router. |
| 1954 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1951 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1955 process_->sink().ClearMessages(); | 1952 process_->sink().ClearMessages(); |
| 1956 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1953 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1957 EXPECT_EQ(0U, process_->sink().message_count()); | 1954 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1958 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1955 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1959 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1956 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1960 | 1957 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1973 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1970 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1974 EXPECT_EQ(0U, process_->sink().message_count()); | 1971 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1975 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 1972 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 1976 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 1973 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 1977 EXPECT_EQ(235.f, host_->overscroll_delta_x()); | 1974 EXPECT_EQ(235.f, host_->overscroll_delta_x()); |
| 1978 EXPECT_EQ(185.f, host_->overscroll_delegate()->delta_x()); | 1975 EXPECT_EQ(185.f, host_->overscroll_delegate()->delta_x()); |
| 1979 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y()); | 1976 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y()); |
| 1980 | 1977 |
| 1981 // Send end event. | 1978 // Send end event. |
| 1982 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 1979 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
| 1983 WebGestureEvent::Touchscreen); | 1980 blink::WebGestureDeviceTouchpad); |
| 1984 EXPECT_EQ(0U, process_->sink().message_count()); | 1981 EXPECT_EQ(0U, process_->sink().message_count()); |
| 1985 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 1982 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 1986 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 1983 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 1987 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 1984 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
| 1988 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1985 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 1989 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); | 1986 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); |
| 1990 | 1987 |
| 1991 base::MessageLoop::current()->PostDelayedTask( | 1988 base::MessageLoop::current()->PostDelayedTask( |
| 1992 FROM_HERE, | 1989 FROM_HERE, |
| 1993 base::MessageLoop::QuitClosure(), | 1990 base::MessageLoop::QuitClosure(), |
| 1994 TimeDelta::FromMilliseconds(10)); | 1991 TimeDelta::FromMilliseconds(10)); |
| 1995 base::MessageLoop::current()->Run(); | 1992 base::MessageLoop::current()->Run(); |
| 1996 EXPECT_EQ(1U, process_->sink().message_count()); | 1993 EXPECT_EQ(1U, process_->sink().message_count()); |
| 1997 process_->sink().ClearMessages(); | 1994 process_->sink().ClearMessages(); |
| 1998 // The scroll end event will have received a synthetic ack from the input | 1995 // The scroll end event will have received a synthetic ack from the input |
| 1999 // router. | 1996 // router. |
| 2000 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); | 1997 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); |
| 2001 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 1998 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 2002 EXPECT_EQ(0U, process_->sink().message_count()); | 1999 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2003 } | 2000 } |
| 2004 | 2001 |
| 2005 TEST_F(RenderWidgetHostTest, OverscrollDirectionChange) { | 2002 TEST_F(RenderWidgetHostTest, OverscrollDirectionChange) { |
| 2006 host_->SetupForOverscrollControllerTest(); | 2003 host_->SetupForOverscrollControllerTest(); |
| 2007 host_->set_debounce_interval_time_ms(100); | 2004 host_->set_debounce_interval_time_ms(100); |
| 2008 process_->sink().ClearMessages(); | 2005 process_->sink().ClearMessages(); |
| 2009 | 2006 |
| 2010 // Start scrolling. Receive ACK as it being processed. | 2007 // Start scrolling. Receive ACK as it being processed. |
| 2011 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2008 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2012 WebGestureEvent::Touchscreen); | 2009 blink::WebGestureDeviceTouchpad); |
| 2013 EXPECT_EQ(1U, process_->sink().message_count()); | 2010 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2014 process_->sink().ClearMessages(); | 2011 process_->sink().ClearMessages(); |
| 2015 | 2012 |
| 2016 // Send update events and receive ack as not consumed. | 2013 // Send update events and receive ack as not consumed. |
| 2017 SimulateGestureScrollUpdateEvent(125, -5, 0); | 2014 SimulateGestureScrollUpdateEvent(125, -5, 0); |
| 2018 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); | 2015 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); |
| 2019 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); | 2016 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); |
| 2020 EXPECT_TRUE(host_->ScrollingInProgress()); | 2017 EXPECT_TRUE(host_->ScrollingInProgress()); |
| 2021 EXPECT_EQ(1U, process_->sink().message_count()); | 2018 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2022 process_->sink().ClearMessages(); | 2019 process_->sink().ClearMessages(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 | 2085 |
| 2089 // Moving the mouse more should continue to send the events to the renderer. | 2086 // Moving the mouse more should continue to send the events to the renderer. |
| 2090 SimulateMouseMove(5, 10, 0); | 2087 SimulateMouseMove(5, 10, 0); |
| 2091 SendInputEventACK(WebInputEvent::MouseMove, | 2088 SendInputEventACK(WebInputEvent::MouseMove, |
| 2092 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2089 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2093 EXPECT_EQ(1U, process_->sink().message_count()); | 2090 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2094 process_->sink().ClearMessages(); | 2091 process_->sink().ClearMessages(); |
| 2095 | 2092 |
| 2096 // Now try with gestures. | 2093 // Now try with gestures. |
| 2097 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2094 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2098 WebGestureEvent::Touchscreen); | 2095 blink::WebGestureDeviceTouchpad); |
| 2099 SimulateGestureScrollUpdateEvent(300, -5, 0); | 2096 SimulateGestureScrollUpdateEvent(300, -5, 0); |
| 2100 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2097 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2101 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2098 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2102 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 2099 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 2103 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 2100 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 2104 process_->sink().ClearMessages(); | 2101 process_->sink().ClearMessages(); |
| 2105 | 2102 |
| 2106 // Overscroll gesture is in progress. Send a mouse-move now. This should | 2103 // Overscroll gesture is in progress. Send a mouse-move now. This should |
| 2107 // complete the gesture (because the amount overscrolled is above the | 2104 // complete the gesture (because the amount overscrolled is above the |
| 2108 // threshold). | 2105 // threshold). |
| 2109 SimulateMouseMove(5, 10, 0); | 2106 SimulateMouseMove(5, 10, 0); |
| 2110 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 2107 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
| 2111 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 2108 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 2112 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2109 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 2113 EXPECT_EQ(1U, process_->sink().message_count()); | 2110 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2114 process_->sink().ClearMessages(); | 2111 process_->sink().ClearMessages(); |
| 2115 SendInputEventACK(WebInputEvent::MouseMove, | 2112 SendInputEventACK(WebInputEvent::MouseMove, |
| 2116 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2113 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2117 | 2114 |
| 2118 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 2115 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 2119 WebGestureEvent::Touchscreen); | 2116 blink::WebGestureDeviceTouchpad); |
| 2120 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2117 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 2121 EXPECT_EQ(1U, process_->sink().message_count()); | 2118 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2122 process_->sink().ClearMessages(); | 2119 process_->sink().ClearMessages(); |
| 2123 | 2120 |
| 2124 // Move mouse some more. The mouse-move events should reach the renderer. | 2121 // Move mouse some more. The mouse-move events should reach the renderer. |
| 2125 SimulateMouseMove(5, 10, 0); | 2122 SimulateMouseMove(5, 10, 0); |
| 2126 EXPECT_EQ(1U, process_->sink().message_count()); | 2123 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2127 | 2124 |
| 2128 SendInputEventACK(WebInputEvent::MouseMove, | 2125 SendInputEventACK(WebInputEvent::MouseMove, |
| 2129 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2126 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2153 EXPECT_EQ(1U, process_->sink().message_count()); | 2150 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2154 process_->sink().ClearMessages(); | 2151 process_->sink().ClearMessages(); |
| 2155 | 2152 |
| 2156 // The second wheel event is consumed. | 2153 // The second wheel event is consumed. |
| 2157 SendInputEventACK(WebInputEvent::MouseWheel, | 2154 SendInputEventACK(WebInputEvent::MouseWheel, |
| 2158 INPUT_EVENT_ACK_STATE_CONSUMED); | 2155 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2159 EXPECT_TRUE(host_->ScrollStateIsContentScrolling()); | 2156 EXPECT_TRUE(host_->ScrollStateIsContentScrolling()); |
| 2160 | 2157 |
| 2161 // Touchpad scroll can end with a zero-velocity fling. But it is not | 2158 // Touchpad scroll can end with a zero-velocity fling. But it is not |
| 2162 // dispatched, but it should still reset the overscroll controller state. | 2159 // dispatched, but it should still reset the overscroll controller state. |
| 2163 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad); | 2160 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad); |
| 2164 EXPECT_TRUE(host_->ScrollStateIsUnknown()); | 2161 EXPECT_TRUE(host_->ScrollStateIsUnknown()); |
| 2165 EXPECT_EQ(0U, process_->sink().message_count()); | 2162 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2166 | 2163 |
| 2167 SimulateWheelEvent(-5, 0, 0, true); // sent directly | 2164 SimulateWheelEvent(-5, 0, 0, true); // sent directly |
| 2168 SimulateWheelEvent(-60, 0, 0, true); // enqueued | 2165 SimulateWheelEvent(-60, 0, 0, true); // enqueued |
| 2169 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event | 2166 SimulateWheelEvent(-100, 0, 0, true); // coalesced into previous event |
| 2170 EXPECT_EQ(1U, process_->sink().message_count()); | 2167 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2171 EXPECT_TRUE(host_->ScrollStateIsUnknown()); | 2168 EXPECT_TRUE(host_->ScrollStateIsUnknown()); |
| 2172 process_->sink().ClearMessages(); | 2169 process_->sink().ClearMessages(); |
| 2173 | 2170 |
| 2174 // The first wheel scroll did not scroll content. Overscroll should not start | 2171 // The first wheel scroll did not scroll content. Overscroll should not start |
| 2175 // yet, since enough hasn't been scrolled. | 2172 // yet, since enough hasn't been scrolled. |
| 2176 SendInputEventACK(WebInputEvent::MouseWheel, | 2173 SendInputEventACK(WebInputEvent::MouseWheel, |
| 2177 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2174 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2178 EXPECT_TRUE(host_->ScrollStateIsUnknown()); | 2175 EXPECT_TRUE(host_->ScrollStateIsUnknown()); |
| 2179 EXPECT_EQ(1U, process_->sink().message_count()); | 2176 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2180 process_->sink().ClearMessages(); | 2177 process_->sink().ClearMessages(); |
| 2181 | 2178 |
| 2182 SendInputEventACK(WebInputEvent::MouseWheel, | 2179 SendInputEventACK(WebInputEvent::MouseWheel, |
| 2183 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2180 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2184 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); | 2181 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_mode()); |
| 2185 EXPECT_TRUE(host_->ScrollStateIsOverscrolling()); | 2182 EXPECT_TRUE(host_->ScrollStateIsOverscrolling()); |
| 2186 EXPECT_EQ(0U, process_->sink().message_count()); | 2183 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2187 | 2184 |
| 2188 SimulateGestureFlingStartEvent(0.f, 0.f, WebGestureEvent::Touchpad); | 2185 SimulateGestureFlingStartEvent(0.f, 0.f, blink::WebGestureDeviceTouchpad); |
| 2189 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 2186 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 2190 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->completed_mode()); | 2187 EXPECT_EQ(OVERSCROLL_WEST, host_->overscroll_delegate()->completed_mode()); |
| 2191 EXPECT_TRUE(host_->ScrollStateIsUnknown()); | 2188 EXPECT_TRUE(host_->ScrollStateIsUnknown()); |
| 2192 EXPECT_EQ(0U, process_->sink().message_count()); | 2189 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2193 process_->sink().ClearMessages(); | 2190 process_->sink().ClearMessages(); |
| 2194 } | 2191 } |
| 2195 | 2192 |
| 2196 TEST_F(RenderWidgetHostTest, OverscrollResetsOnBlur) { | 2193 TEST_F(RenderWidgetHostTest, OverscrollResetsOnBlur) { |
| 2197 host_->SetupForOverscrollControllerTest(); | 2194 host_->SetupForOverscrollControllerTest(); |
| 2198 process_->sink().ClearMessages(); | 2195 process_->sink().ClearMessages(); |
| 2199 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 2196 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
| 2200 view_->Show(); | 2197 view_->Show(); |
| 2201 | 2198 |
| 2202 // Start an overscroll with gesture scroll. In the middle of the scroll, blur | 2199 // Start an overscroll with gesture scroll. In the middle of the scroll, blur |
| 2203 // the host. | 2200 // the host. |
| 2204 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2201 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2205 WebGestureEvent::Touchscreen); | 2202 blink::WebGestureDeviceTouchpad); |
| 2206 SimulateGestureScrollUpdateEvent(300, -5, 0); | 2203 SimulateGestureScrollUpdateEvent(300, -5, 0); |
| 2207 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2204 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2208 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2205 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2209 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 2206 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 2210 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 2207 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 2211 EXPECT_EQ(2U, process_->sink().message_count()); | 2208 EXPECT_EQ(2U, process_->sink().message_count()); |
| 2212 | 2209 |
| 2213 host_->Blur(); | 2210 host_->Blur(); |
| 2214 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); | 2211 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); |
| 2215 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2212 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 2216 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); | 2213 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); |
| 2217 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_x()); | 2214 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_x()); |
| 2218 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); | 2215 EXPECT_EQ(0.f, host_->overscroll_delegate()->delta_y()); |
| 2219 process_->sink().ClearMessages(); | 2216 process_->sink().ClearMessages(); |
| 2220 | 2217 |
| 2221 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 2218 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 2222 WebGestureEvent::Touchscreen); | 2219 blink::WebGestureDeviceTouchpad); |
| 2223 EXPECT_EQ(1U, process_->sink().message_count()); | 2220 EXPECT_EQ(1U, process_->sink().message_count()); |
| 2224 process_->sink().ClearMessages(); | 2221 process_->sink().ClearMessages(); |
| 2225 | 2222 |
| 2226 // Start a scroll gesture again. This should correctly start the overscroll | 2223 // Start a scroll gesture again. This should correctly start the overscroll |
| 2227 // after the threshold. | 2224 // after the threshold. |
| 2228 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2225 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2229 WebGestureEvent::Touchscreen); | 2226 blink::WebGestureDeviceTouchpad); |
| 2230 SimulateGestureScrollUpdateEvent(300, -5, 0); | 2227 SimulateGestureScrollUpdateEvent(300, -5, 0); |
| 2231 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2228 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2232 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2229 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2233 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); | 2230 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); |
| 2234 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 2231 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
| 2235 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); | 2232 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); |
| 2236 | 2233 |
| 2237 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 2234 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
| 2238 WebGestureEvent::Touchscreen); | 2235 blink::WebGestureDeviceTouchpad); |
| 2239 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2236 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
| 2240 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 2237 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
| 2241 EXPECT_EQ(3U, process_->sink().message_count()); | 2238 EXPECT_EQ(3U, process_->sink().message_count()); |
| 2242 } | 2239 } |
| 2243 | 2240 |
| 2244 std::string GetInputMessageTypes(RenderWidgetHostProcess* process) { | 2241 std::string GetInputMessageTypes(RenderWidgetHostProcess* process) { |
| 2245 std::string result; | 2242 std::string result; |
| 2246 for (size_t i = 0; i < process->sink().message_count(); ++i) { | 2243 for (size_t i = 0; i < process->sink().message_count(); ++i) { |
| 2247 const IPC::Message *message = process->sink().GetMessageAt(i); | 2244 const IPC::Message *message = process->sink().GetMessageAt(i); |
| 2248 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); | 2245 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2461 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 2458 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
| 2462 EXPECT_FALSE(host_->mock_input_router()->sent_keyboard_event_); | 2459 EXPECT_FALSE(host_->mock_input_router()->sent_keyboard_event_); |
| 2463 | 2460 |
| 2464 SimulateMouseEvent(WebInputEvent::MouseMove); | 2461 SimulateMouseEvent(WebInputEvent::MouseMove); |
| 2465 EXPECT_FALSE(host_->mock_input_router()->sent_mouse_event_); | 2462 EXPECT_FALSE(host_->mock_input_router()->sent_mouse_event_); |
| 2466 | 2463 |
| 2467 SimulateWheelEvent(0, 100, 0, true); | 2464 SimulateWheelEvent(0, 100, 0, true); |
| 2468 EXPECT_FALSE(host_->mock_input_router()->sent_wheel_event_); | 2465 EXPECT_FALSE(host_->mock_input_router()->sent_wheel_event_); |
| 2469 | 2466 |
| 2470 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2467 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2471 WebGestureEvent::Touchscreen); | 2468 blink::WebGestureDeviceTouchpad); |
| 2472 EXPECT_FALSE(host_->mock_input_router()->sent_gesture_event_); | 2469 EXPECT_FALSE(host_->mock_input_router()->sent_gesture_event_); |
| 2473 | 2470 |
| 2474 PressTouchPoint(100, 100); | 2471 PressTouchPoint(100, 100); |
| 2475 SendTouchEvent(); | 2472 SendTouchEvent(); |
| 2476 EXPECT_FALSE(host_->mock_input_router()->send_touch_event_not_cancelled_); | 2473 EXPECT_FALSE(host_->mock_input_router()->send_touch_event_not_cancelled_); |
| 2477 } | 2474 } |
| 2478 | 2475 |
| 2479 TEST_F(RenderWidgetHostTest, KeyboardListenerIgnoresEvent) { | 2476 TEST_F(RenderWidgetHostTest, KeyboardListenerIgnoresEvent) { |
| 2480 host_->SetupForInputRouterTest(); | 2477 host_->SetupForInputRouterTest(); |
| 2481 host_->AddKeyPressEventCallback( | 2478 host_->AddKeyPressEventCallback( |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2612 | 2609 |
| 2613 // Tests RWHI::ForwardMouseEventWithLatencyInfo(). | 2610 // Tests RWHI::ForwardMouseEventWithLatencyInfo(). |
| 2614 SimulateMouseEventWithLatencyInfo(WebInputEvent::MouseMove, | 2611 SimulateMouseEventWithLatencyInfo(WebInputEvent::MouseMove, |
| 2615 ui::LatencyInfo()); | 2612 ui::LatencyInfo()); |
| 2616 CheckLatencyInfoComponentInMessage( | 2613 CheckLatencyInfoComponentInMessage( |
| 2617 process_, GetLatencyComponentId(), WebInputEvent::MouseMove); | 2614 process_, GetLatencyComponentId(), WebInputEvent::MouseMove); |
| 2618 SendInputEventACK(WebInputEvent::MouseMove, INPUT_EVENT_ACK_STATE_CONSUMED); | 2615 SendInputEventACK(WebInputEvent::MouseMove, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2619 | 2616 |
| 2620 // Tests RWHI::ForwardGestureEvent(). | 2617 // Tests RWHI::ForwardGestureEvent(). |
| 2621 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2618 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2622 WebGestureEvent::Touchscreen); | 2619 blink::WebGestureDeviceTouchpad); |
| 2623 CheckLatencyInfoComponentInMessage( | 2620 CheckLatencyInfoComponentInMessage( |
| 2624 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollBegin); | 2621 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollBegin); |
| 2625 | 2622 |
| 2626 // Tests RWHI::ForwardGestureEventWithLatencyInfo(). | 2623 // Tests RWHI::ForwardGestureEventWithLatencyInfo(). |
| 2627 SimulateGestureEventWithLatencyInfo(WebInputEvent::GestureScrollUpdate, | 2624 SimulateGestureEventWithLatencyInfo(WebInputEvent::GestureScrollUpdate, |
| 2628 WebGestureEvent::Touchscreen, | 2625 blink::WebGestureDeviceTouchpad, |
| 2629 ui::LatencyInfo()); | 2626 ui::LatencyInfo()); |
| 2630 CheckLatencyInfoComponentInMessage( | 2627 CheckLatencyInfoComponentInMessage( |
| 2631 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollUpdate); | 2628 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollUpdate); |
| 2632 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2629 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2633 INPUT_EVENT_ACK_STATE_CONSUMED); | 2630 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2634 | 2631 |
| 2635 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). | 2632 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). |
| 2636 PressTouchPoint(0, 1); | 2633 PressTouchPoint(0, 1); |
| 2637 SendTouchEvent(); | 2634 SendTouchEvent(); |
| 2638 CheckLatencyInfoComponentInMessage( | 2635 CheckLatencyInfoComponentInMessage( |
| 2639 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); | 2636 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); |
| 2640 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | 2637 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2641 } | 2638 } |
| 2642 | 2639 |
| 2643 } // namespace content | 2640 } // namespace content |
| OLD | NEW |