| 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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 // which uses ObserverListThreadSafe, which furthermore remembers the | 438 // which uses ObserverListThreadSafe, which furthermore remembers the |
| 439 // message loop for the thread it was created in. Between tests, the | 439 // message loop for the thread it was created in. Between tests, the |
| 440 // RendererFrameManager singleton survives and and the MessageLoop gets | 440 // RendererFrameManager singleton survives and and the MessageLoop gets |
| 441 // destroyed. The correct fix would be to have ObserverListThreadSafe look | 441 // destroyed. The correct fix would be to have ObserverListThreadSafe look |
| 442 // up the proper message loop every time (see crbug.com/443824.) | 442 // up the proper message loop every time (see crbug.com/443824.) |
| 443 RendererFrameManager::GetInstance()->OnMemoryPressure(level); | 443 RendererFrameManager::GetInstance()->OnMemoryPressure(level); |
| 444 } | 444 } |
| 445 | 445 |
| 446 void SendInputEventACK(WebInputEvent::Type type, | 446 void SendInputEventACK(WebInputEvent::Type type, |
| 447 InputEventAckState ack_result) { | 447 InputEventAckState ack_result) { |
| 448 InputHostMsg_HandleInputEvent_ACK_Params ack; | 448 DCHECK(!WebInputEvent::isTouchEventType(type)); |
| 449 ack.type = type; | 449 InputEventAck ack(type, ack_result); |
| 450 ack.state = ack_result; | |
| 451 InputHostMsg_HandleInputEvent_ACK response(0, ack); | 450 InputHostMsg_HandleInputEvent_ACK response(0, ack); |
| 452 widget_host_->OnMessageReceived(response); | 451 widget_host_->OnMessageReceived(response); |
| 453 } | 452 } |
| 453 |
| 454 void SendTouchEventACK(WebInputEvent::Type type, |
| 455 InputEventAckState ack_result, |
| 456 uint32 event_id) { |
| 457 DCHECK(WebInputEvent::isTouchEventType(type)); |
| 458 InputEventAck ack(type, ack_result, event_id); |
| 459 InputHostMsg_HandleInputEvent_ACK response(0, ack); |
| 460 widget_host_->OnMessageReceived(response); |
| 461 } |
| 454 | 462 |
| 455 size_t GetSentMessageCountAndResetSink() { | 463 size_t GetSentMessageCountAndResetSink() { |
| 456 size_t count = sink_->message_count(); | 464 size_t count = sink_->message_count(); |
| 457 sink_->ClearMessages(); | 465 sink_->ClearMessages(); |
| 458 return count; | 466 return count; |
| 459 } | 467 } |
| 460 | 468 |
| 461 void AckLastSentInputEventIfNecessary(InputEventAckState ack_result) { | 469 void AckLastSentInputEventIfNecessary(InputEventAckState ack_result) { |
| 462 if (!sink_->message_count()) | 470 if (!sink_->message_count()) |
| 463 return; | 471 return; |
| 464 | 472 |
| 465 InputMsg_HandleInputEvent::Param params; | 473 InputMsg_HandleInputEvent::Param params; |
| 466 if (!InputMsg_HandleInputEvent::Read( | 474 if (!InputMsg_HandleInputEvent::Read( |
| 467 sink_->GetMessageAt(sink_->message_count() - 1), ¶ms)) { | 475 sink_->GetMessageAt(sink_->message_count() - 1), ¶ms)) { |
| 468 return; | 476 return; |
| 469 } | 477 } |
| 470 | 478 |
| 471 if (WebInputEventTraits::IgnoresAckDisposition(*get<0>(params))) | 479 if (!WebInputEventTraits::WillReceiveAckFromRenderer(*get<0>(params))) |
| 472 return; | 480 return; |
| 473 | 481 |
| 474 SendInputEventACK(get<0>(params)->type, ack_result); | 482 const blink::WebInputEvent* event = get<0>(params); |
| 483 SendTouchEventACK(event->type, ack_result, |
| 484 WebInputEventTraits::GetUniqueTouchEventId(*event)); |
| 475 } | 485 } |
| 476 | 486 |
| 477 protected: | 487 protected: |
| 478 // If true, then calls RWH::Shutdown() instead of deleting RWH. | 488 // If true, then calls RWH::Shutdown() instead of deleting RWH. |
| 479 bool widget_host_uses_shutdown_to_destroy_; | 489 bool widget_host_uses_shutdown_to_destroy_; |
| 480 | 490 |
| 481 bool is_guest_view_hack_; | 491 bool is_guest_view_hack_; |
| 482 | 492 |
| 483 base::MessageLoopForUI message_loop_; | 493 base::MessageLoopForUI message_loop_; |
| 484 BrowserThreadImpl browser_thread_for_ui_; | 494 BrowserThreadImpl browser_thread_for_ui_; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 } | 701 } |
| 692 | 702 |
| 693 float overscroll_delta_y() const { | 703 float overscroll_delta_y() const { |
| 694 return view_->overscroll_controller()->overscroll_delta_y_; | 704 return view_->overscroll_controller()->overscroll_delta_y_; |
| 695 } | 705 } |
| 696 | 706 |
| 697 TestOverscrollDelegate* overscroll_delegate() { | 707 TestOverscrollDelegate* overscroll_delegate() { |
| 698 return overscroll_delegate_.get(); | 708 return overscroll_delegate_.get(); |
| 699 } | 709 } |
| 700 | 710 |
| 701 void SendTouchEvent() { | 711 uint32 SendTouchEvent() { |
| 712 uint32 touch_event_id = touch_event_.uniqueTouchEventId; |
| 702 widget_host_->ForwardTouchEventWithLatencyInfo(touch_event_, | 713 widget_host_->ForwardTouchEventWithLatencyInfo(touch_event_, |
| 703 ui::LatencyInfo()); | 714 ui::LatencyInfo()); |
| 704 touch_event_.ResetPoints(); | 715 touch_event_.ResetPoints(); |
| 716 return touch_event_id; |
| 705 } | 717 } |
| 706 | 718 |
| 707 void PressTouchPoint(int x, int y) { | 719 void PressTouchPoint(int x, int y) { |
| 708 touch_event_.PressPoint(x, y); | 720 touch_event_.PressPoint(x, y); |
| 709 SendTouchEvent(); | |
| 710 } | 721 } |
| 711 | 722 |
| 712 void MoveTouchPoint(int index, int x, int y) { | 723 void MoveTouchPoint(int index, int x, int y) { |
| 713 touch_event_.MovePoint(index, x, y); | 724 touch_event_.MovePoint(index, x, y); |
| 714 SendTouchEvent(); | |
| 715 } | 725 } |
| 716 | 726 |
| 717 void ReleaseTouchPoint(int index) { | 727 void ReleaseTouchPoint(int index) { |
| 718 touch_event_.ReleasePoint(index); | 728 touch_event_.ReleasePoint(index); |
| 719 SendTouchEvent(); | |
| 720 } | 729 } |
| 721 | 730 |
| 722 SyntheticWebTouchEvent touch_event_; | 731 SyntheticWebTouchEvent touch_event_; |
| 723 | 732 |
| 724 scoped_ptr<TestOverscrollDelegate> overscroll_delegate_; | 733 scoped_ptr<TestOverscrollDelegate> overscroll_delegate_; |
| 725 | 734 |
| 726 private: | 735 private: |
| 727 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraOverscrollTest); | 736 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraOverscrollTest); |
| 728 }; | 737 }; |
| 729 | 738 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 view_->OnTouchEvent(&press); | 1106 view_->OnTouchEvent(&press); |
| 1098 EXPECT_TRUE(press.synchronous_handling_disabled()); | 1107 EXPECT_TRUE(press.synchronous_handling_disabled()); |
| 1099 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); | 1108 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); |
| 1100 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | 1109 EXPECT_EQ(1U, view_->touch_event_->touchesLength); |
| 1101 EXPECT_EQ(blink::WebTouchPoint::StatePressed, | 1110 EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
| 1102 view_->touch_event_->touches[0].state); | 1111 view_->touch_event_->touches[0].state); |
| 1103 | 1112 |
| 1104 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 1113 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); |
| 1105 | 1114 |
| 1106 // Ack'ing the outstanding event should flush the pending touch queue. | 1115 // Ack'ing the outstanding event should flush the pending touch queue. |
| 1107 InputHostMsg_HandleInputEvent_ACK_Params ack; | 1116 InputEventAck ack(blink::WebInputEvent::TouchStart, |
| 1108 ack.type = blink::WebInputEvent::TouchStart; | 1117 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, |
| 1109 ack.state = INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 1118 press.unique_event_id()); |
| 1110 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); | 1119 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); |
| 1111 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1120 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1112 | 1121 |
| 1113 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | 1122 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, |
| 1114 base::Time::NowFromSystemTime() - base::Time()); | 1123 base::Time::NowFromSystemTime() - base::Time()); |
| 1115 view_->OnTouchEvent(&move2); | 1124 view_->OnTouchEvent(&move2); |
| 1116 EXPECT_TRUE(press.synchronous_handling_disabled()); | 1125 EXPECT_TRUE(press.synchronous_handling_disabled()); |
| 1117 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | 1126 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); |
| 1118 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | 1127 EXPECT_EQ(1U, view_->touch_event_->touchesLength); |
| 1119 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 1128 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1131 TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) { | 1140 TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) { |
| 1132 view_->InitAsFullscreen(parent_view_); | 1141 view_->InitAsFullscreen(parent_view_); |
| 1133 view_->Show(); | 1142 view_->Show(); |
| 1134 view_->UseFakeDispatcher(); | 1143 view_->UseFakeDispatcher(); |
| 1135 GetSentMessageCountAndResetSink(); | 1144 GetSentMessageCountAndResetSink(); |
| 1136 | 1145 |
| 1137 ui::TouchEvent press0(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, | 1146 ui::TouchEvent press0(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, |
| 1138 ui::EventTimeForNow()); | 1147 ui::EventTimeForNow()); |
| 1139 | 1148 |
| 1140 view_->OnTouchEvent(&press0); | 1149 view_->OnTouchEvent(&press0); |
| 1141 SendInputEventACK(blink::WebInputEvent::TouchStart, | 1150 SendTouchEventACK(blink::WebInputEvent::TouchStart, |
| 1142 INPUT_EVENT_ACK_STATE_CONSUMED); | 1151 INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1152 press0.unique_event_id()); |
| 1143 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); | 1153 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); |
| 1144 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | 1154 EXPECT_EQ(1U, view_->touch_event_->touchesLength); |
| 1145 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1155 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 1146 | 1156 |
| 1147 ui::TouchEvent move0(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | 1157 ui::TouchEvent move0(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, |
| 1148 ui::EventTimeForNow()); | 1158 ui::EventTimeForNow()); |
| 1149 | 1159 |
| 1150 view_->OnTouchEvent(&move0); | 1160 view_->OnTouchEvent(&move0); |
| 1151 SendInputEventACK(blink::WebInputEvent::TouchMove, | 1161 SendTouchEventACK(blink::WebInputEvent::TouchMove, |
| 1152 INPUT_EVENT_ACK_STATE_CONSUMED); | 1162 INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1163 move0.unique_event_id()); |
| 1153 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | 1164 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); |
| 1154 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | 1165 EXPECT_EQ(1U, view_->touch_event_->touchesLength); |
| 1155 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1166 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 1156 | 1167 |
| 1157 // For the second touchstart, only the state of the second touch point is | 1168 // For the second touchstart, only the state of the second touch point is |
| 1158 // StatePressed, the state of the first touch point is StateStationary. | 1169 // StatePressed, the state of the first touch point is StateStationary. |
| 1159 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, | 1170 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, |
| 1160 ui::EventTimeForNow()); | 1171 ui::EventTimeForNow()); |
| 1161 | 1172 |
| 1162 view_->OnTouchEvent(&press1); | 1173 view_->OnTouchEvent(&press1); |
| 1163 SendInputEventACK(blink::WebInputEvent::TouchStart, | 1174 SendTouchEventACK(blink::WebInputEvent::TouchStart, |
| 1164 INPUT_EVENT_ACK_STATE_CONSUMED); | 1175 INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1176 press1.unique_event_id()); |
| 1165 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); | 1177 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); |
| 1166 EXPECT_EQ(2U, view_->touch_event_->touchesLength); | 1178 EXPECT_EQ(2U, view_->touch_event_->touchesLength); |
| 1167 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1179 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 1168 | 1180 |
| 1169 // For the touchmove of second point, the state of the second touch point is | 1181 // For the touchmove of second point, the state of the second touch point is |
| 1170 // StateMoved, the state of the first touch point is StateStationary. | 1182 // StateMoved, the state of the first touch point is StateStationary. |
| 1171 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, | 1183 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, |
| 1172 ui::EventTimeForNow()); | 1184 ui::EventTimeForNow()); |
| 1173 | 1185 |
| 1174 view_->OnTouchEvent(&move1); | 1186 view_->OnTouchEvent(&move1); |
| 1175 SendInputEventACK(blink::WebInputEvent::TouchMove, | 1187 SendTouchEventACK(blink::WebInputEvent::TouchMove, |
| 1176 INPUT_EVENT_ACK_STATE_CONSUMED); | 1188 INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1189 move1.unique_event_id()); |
| 1177 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | 1190 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); |
| 1178 EXPECT_EQ(2U, view_->touch_event_->touchesLength); | 1191 EXPECT_EQ(2U, view_->touch_event_->touchesLength); |
| 1179 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1192 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 1180 | 1193 |
| 1181 // For the touchmove of first point, the state of the first touch point is | 1194 // For the touchmove of first point, the state of the first touch point is |
| 1182 // StateMoved, the state of the second touch point is StateStationary. | 1195 // StateMoved, the state of the second touch point is StateStationary. |
| 1183 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 0, | 1196 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 0, |
| 1184 ui::EventTimeForNow()); | 1197 ui::EventTimeForNow()); |
| 1185 | 1198 |
| 1186 view_->OnTouchEvent(&move2); | 1199 view_->OnTouchEvent(&move2); |
| 1187 SendInputEventACK(blink::WebInputEvent::TouchMove, | 1200 SendTouchEventACK(blink::WebInputEvent::TouchMove, |
| 1188 INPUT_EVENT_ACK_STATE_CONSUMED); | 1201 INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1202 move2.unique_event_id()); |
| 1189 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | 1203 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); |
| 1190 EXPECT_EQ(2U, view_->touch_event_->touchesLength); | 1204 EXPECT_EQ(2U, view_->touch_event_->touchesLength); |
| 1191 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1205 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 1192 | 1206 |
| 1193 ui::TouchEvent cancel0(ui::ET_TOUCH_CANCELLED, gfx::Point(10, 10), 0, | 1207 ui::TouchEvent cancel0(ui::ET_TOUCH_CANCELLED, gfx::Point(10, 10), 0, |
| 1194 ui::EventTimeForNow()); | 1208 ui::EventTimeForNow()); |
| 1195 | 1209 |
| 1196 // For the touchcancel, only the state of the current touch point is | 1210 // For the touchcancel, only the state of the current touch point is |
| 1197 // StateCancelled, the state of the other touch point is StateStationary. | 1211 // StateCancelled, the state of the other touch point is StateStationary. |
| 1198 view_->OnTouchEvent(&cancel0); | 1212 view_->OnTouchEvent(&cancel0); |
| (...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2857 | 2871 |
| 2858 // Tests that when touch-events are dispatched to the renderer, the overscroll | 2872 // Tests that when touch-events are dispatched to the renderer, the overscroll |
| 2859 // gesture deals with them correctly. | 2873 // gesture deals with them correctly. |
| 2860 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) { | 2874 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) { |
| 2861 SetUpOverscrollEnvironmentWithDebounce(10); | 2875 SetUpOverscrollEnvironmentWithDebounce(10); |
| 2862 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 2876 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 2863 sink_->ClearMessages(); | 2877 sink_->ClearMessages(); |
| 2864 | 2878 |
| 2865 // The test sends an intermingled sequence of touch and gesture events. | 2879 // The test sends an intermingled sequence of touch and gesture events. |
| 2866 PressTouchPoint(0, 1); | 2880 PressTouchPoint(0, 1); |
| 2867 SendInputEventACK(WebInputEvent::TouchStart, | 2881 uint32 touch_press_event_id1 = SendTouchEvent(); |
| 2868 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2882 SendTouchEventACK(WebInputEvent::TouchStart, |
| 2883 INPUT_EVENT_ACK_STATE_NOT_CONSUMED, touch_press_event_id1); |
| 2869 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2884 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2870 | 2885 |
| 2871 MoveTouchPoint(0, 20, 5); | 2886 MoveTouchPoint(0, 20, 5); |
| 2887 uint32 touch_move_event_id1 = SendTouchEvent(); |
| 2888 SendTouchEventACK(WebInputEvent::TouchMove, |
| 2889 INPUT_EVENT_ACK_STATE_NOT_CONSUMED, touch_move_event_id1); |
| 2872 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2890 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2873 SendInputEventACK(WebInputEvent::TouchMove, | |
| 2874 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2875 | 2891 |
| 2876 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2892 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 2877 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2893 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 2878 | 2894 |
| 2879 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2895 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2880 blink::WebGestureDeviceTouchscreen); | 2896 blink::WebGestureDeviceTouchscreen); |
| 2881 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2897 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2882 SimulateGestureScrollUpdateEvent(20, 0, 0); | 2898 SimulateGestureScrollUpdateEvent(20, 0, 0); |
| 2883 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2899 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2884 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2900 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2885 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2901 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2886 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2902 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 2887 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2903 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 2888 | 2904 |
| 2889 // Another touch move event should reach the renderer since overscroll hasn't | 2905 // Another touch move event should reach the renderer since overscroll hasn't |
| 2890 // started yet. Note that touch events sent during the scroll period may | 2906 // started yet. Note that touch events sent during the scroll period may |
| 2891 // not require an ack (having been marked uncancelable). | 2907 // not require an ack (having been marked uncancelable). |
| 2892 MoveTouchPoint(0, 65, 10); | 2908 MoveTouchPoint(0, 65, 10); |
| 2909 SendTouchEvent(); |
| 2893 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2910 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2894 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2911 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2895 | 2912 |
| 2896 SimulateGestureScrollUpdateEvent(45, 0, 0); | 2913 SimulateGestureScrollUpdateEvent(45, 0, 0); |
| 2897 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2914 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2898 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2915 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2899 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); | 2916 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
| 2900 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 2917 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
| 2901 EXPECT_EQ(65.f, overscroll_delta_x()); | 2918 EXPECT_EQ(65.f, overscroll_delta_x()); |
| 2902 EXPECT_EQ(15.f, overscroll_delegate()->delta_x()); | 2919 EXPECT_EQ(15.f, overscroll_delegate()->delta_x()); |
| 2903 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); | 2920 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); |
| 2904 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2921 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2905 | 2922 |
| 2906 // Send another touch event. The page should get the touch-move event, even | 2923 // Send another touch event. The page should get the touch-move event, even |
| 2907 // though overscroll has started. | 2924 // though overscroll has started. |
| 2908 MoveTouchPoint(0, 55, 5); | 2925 MoveTouchPoint(0, 55, 5); |
| 2926 SendTouchEvent(); |
| 2909 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); | 2927 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
| 2910 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 2928 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
| 2911 EXPECT_EQ(65.f, overscroll_delta_x()); | 2929 EXPECT_EQ(65.f, overscroll_delta_x()); |
| 2912 EXPECT_EQ(15.f, overscroll_delegate()->delta_x()); | 2930 EXPECT_EQ(15.f, overscroll_delegate()->delta_x()); |
| 2913 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); | 2931 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); |
| 2914 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2932 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2915 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2933 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2916 | 2934 |
| 2917 SimulateGestureScrollUpdateEvent(-10, 0, 0); | 2935 SimulateGestureScrollUpdateEvent(-10, 0, 0); |
| 2918 EXPECT_EQ(0U, sink_->message_count()); | 2936 EXPECT_EQ(0U, sink_->message_count()); |
| 2919 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); | 2937 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
| 2920 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 2938 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
| 2921 EXPECT_EQ(55.f, overscroll_delta_x()); | 2939 EXPECT_EQ(55.f, overscroll_delta_x()); |
| 2922 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); | 2940 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); |
| 2923 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); | 2941 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); |
| 2924 | 2942 |
| 2925 PressTouchPoint(255, 5); | 2943 PressTouchPoint(255, 5); |
| 2944 SendTouchEvent(); |
| 2926 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2945 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2927 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2946 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2928 | 2947 |
| 2929 SimulateGestureScrollUpdateEvent(200, 0, 0); | 2948 SimulateGestureScrollUpdateEvent(200, 0, 0); |
| 2930 EXPECT_EQ(0U, sink_->message_count()); | 2949 EXPECT_EQ(0U, sink_->message_count()); |
| 2931 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); | 2950 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
| 2932 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 2951 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
| 2933 EXPECT_EQ(255.f, overscroll_delta_x()); | 2952 EXPECT_EQ(255.f, overscroll_delta_x()); |
| 2934 EXPECT_EQ(205.f, overscroll_delegate()->delta_x()); | 2953 EXPECT_EQ(205.f, overscroll_delegate()->delta_x()); |
| 2935 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); | 2954 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); |
| 2936 | 2955 |
| 2937 // The touch-end/cancel event should always reach the renderer if the page has | 2956 // The touch-end/cancel event should always reach the renderer if the page has |
| 2938 // touch handlers. | 2957 // touch handlers. |
| 2939 ReleaseTouchPoint(1); | 2958 ReleaseTouchPoint(1); |
| 2959 SendTouchEvent(); |
| 2940 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2960 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2941 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2961 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2942 ReleaseTouchPoint(0); | 2962 ReleaseTouchPoint(0); |
| 2963 SendTouchEvent(); |
| 2943 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2964 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2944 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2965 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2945 | 2966 |
| 2946 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 2967 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
| 2947 blink::WebGestureDeviceTouchscreen); | 2968 blink::WebGestureDeviceTouchscreen); |
| 2948 base::MessageLoop::current()->PostDelayedTask( | 2969 base::MessageLoop::current()->PostDelayedTask( |
| 2949 FROM_HERE, | 2970 FROM_HERE, |
| 2950 base::MessageLoop::QuitClosure(), | 2971 base::MessageLoop::QuitClosure(), |
| 2951 base::TimeDelta::FromMilliseconds(10)); | 2972 base::TimeDelta::FromMilliseconds(10)); |
| 2952 base::MessageLoop::current()->Run(); | 2973 base::MessageLoop::current()->Run(); |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3389 // lose track of the number of acks required. | 3410 // lose track of the number of acks required. |
| 3390 TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) { | 3411 TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) { |
| 3391 view_->InitAsFullscreen(parent_view_); | 3412 view_->InitAsFullscreen(parent_view_); |
| 3392 view_->Show(); | 3413 view_->Show(); |
| 3393 view_->UseFakeDispatcher(); | 3414 view_->UseFakeDispatcher(); |
| 3394 | 3415 |
| 3395 ui::TouchEvent press1( | 3416 ui::TouchEvent press1( |
| 3396 ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, ui::EventTimeForNow()); | 3417 ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, ui::EventTimeForNow()); |
| 3397 | 3418 |
| 3398 view_->OnTouchEvent(&press1); | 3419 view_->OnTouchEvent(&press1); |
| 3399 SendInputEventACK(blink::WebInputEvent::TouchStart, | 3420 SendTouchEventACK(blink::WebInputEvent::TouchStart, |
| 3400 INPUT_EVENT_ACK_STATE_CONSUMED); | 3421 INPUT_EVENT_ACK_STATE_CONSUMED, press1.unique_event_id()); |
| 3401 | 3422 |
| 3402 ui::TouchEvent press2( | 3423 ui::TouchEvent press2( |
| 3403 ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 1, ui::EventTimeForNow()); | 3424 ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 1, ui::EventTimeForNow()); |
| 3404 view_->OnTouchEvent(&press2); | 3425 view_->OnTouchEvent(&press2); |
| 3405 SendInputEventACK(blink::WebInputEvent::TouchStart, | 3426 SendTouchEventACK(blink::WebInputEvent::TouchStart, |
| 3406 INPUT_EVENT_ACK_STATE_CONSUMED); | 3427 INPUT_EVENT_ACK_STATE_CONSUMED, press2.unique_event_id()); |
| 3407 | 3428 |
| 3408 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 3429 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 3409 } | 3430 } |
| 3410 | 3431 |
| 3411 // Tests that the scroll deltas stored within the overscroll controller get | 3432 // Tests that the scroll deltas stored within the overscroll controller get |
| 3412 // reset at the end of the overscroll gesture even if the overscroll threshold | 3433 // reset at the end of the overscroll gesture even if the overscroll threshold |
| 3413 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE. | 3434 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE. |
| 3414 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ScrollDeltasResetOnEnd) { | 3435 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ScrollDeltasResetOnEnd) { |
| 3415 SetUpOverscrollEnvironment(); | 3436 SetUpOverscrollEnvironment(); |
| 3416 // Wheel event scroll ending with mouse move. | 3437 // Wheel event scroll ending with mouse move. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3447 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3468 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3448 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3469 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3449 EXPECT_EQ(15.f, overscroll_delta_x()); | 3470 EXPECT_EQ(15.f, overscroll_delta_x()); |
| 3450 EXPECT_EQ(-5.f, overscroll_delta_y()); | 3471 EXPECT_EQ(-5.f, overscroll_delta_y()); |
| 3451 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); | 3472 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); |
| 3452 EXPECT_EQ(0.f, overscroll_delta_x()); | 3473 EXPECT_EQ(0.f, overscroll_delta_x()); |
| 3453 EXPECT_EQ(0.f, overscroll_delta_y()); | 3474 EXPECT_EQ(0.f, overscroll_delta_y()); |
| 3454 } | 3475 } |
| 3455 | 3476 |
| 3456 } // namespace content | 3477 } // namespace content |
| OLD | NEW |