Chromium Code Reviews| 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, |
| 470 uint32 event_id) { | |
| 462 if (!sink_->message_count()) | 471 if (!sink_->message_count()) |
| 463 return; | 472 return; |
| 464 | 473 |
| 465 InputMsg_HandleInputEvent::Param params; | 474 InputMsg_HandleInputEvent::Param params; |
| 466 if (!InputMsg_HandleInputEvent::Read( | 475 if (!InputMsg_HandleInputEvent::Read( |
| 467 sink_->GetMessageAt(sink_->message_count() - 1), ¶ms)) { | 476 sink_->GetMessageAt(sink_->message_count() - 1), ¶ms)) { |
| 468 return; | 477 return; |
| 469 } | 478 } |
| 470 | 479 |
| 471 if (WebInputEventTraits::IgnoresAckDisposition(*get<0>(params))) | 480 if (!WebInputEventTraits::WillReceiveAckFromRenderer(*get<0>(params))) |
| 472 return; | 481 return; |
| 473 | 482 |
| 474 SendInputEventACK(get<0>(params)->type, ack_result); | 483 SendTouchEventACK(get<0>(params)->type, ack_result, event_id); |
|
jdduke (slow)
2015/05/14 21:00:06
Since we're already extracting the event from the
| |
| 475 } | 484 } |
| 476 | 485 |
| 477 protected: | 486 protected: |
| 478 // If true, then calls RWH::Shutdown() instead of deleting RWH. | 487 // If true, then calls RWH::Shutdown() instead of deleting RWH. |
| 479 bool widget_host_uses_shutdown_to_destroy_; | 488 bool widget_host_uses_shutdown_to_destroy_; |
| 480 | 489 |
| 481 bool is_guest_view_hack_; | 490 bool is_guest_view_hack_; |
| 482 | 491 |
| 483 base::MessageLoopForUI message_loop_; | 492 base::MessageLoopForUI message_loop_; |
| 484 BrowserThreadImpl browser_thread_for_ui_; | 493 BrowserThreadImpl browser_thread_for_ui_; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 } | 700 } |
| 692 | 701 |
| 693 float overscroll_delta_y() const { | 702 float overscroll_delta_y() const { |
| 694 return view_->overscroll_controller()->overscroll_delta_y_; | 703 return view_->overscroll_controller()->overscroll_delta_y_; |
| 695 } | 704 } |
| 696 | 705 |
| 697 TestOverscrollDelegate* overscroll_delegate() { | 706 TestOverscrollDelegate* overscroll_delegate() { |
| 698 return overscroll_delegate_.get(); | 707 return overscroll_delegate_.get(); |
| 699 } | 708 } |
| 700 | 709 |
| 701 void SendTouchEvent() { | 710 uint32 SendTouchEvent() { |
| 711 uint32 touch_event_id = touch_event_.uniqueTouchEventId; | |
| 702 widget_host_->ForwardTouchEventWithLatencyInfo(touch_event_, | 712 widget_host_->ForwardTouchEventWithLatencyInfo(touch_event_, |
| 703 ui::LatencyInfo()); | 713 ui::LatencyInfo()); |
| 704 touch_event_.ResetPoints(); | 714 touch_event_.ResetPoints(); |
| 715 return touch_event_id; | |
| 705 } | 716 } |
| 706 | 717 |
| 707 void PressTouchPoint(int x, int y) { | 718 void PressTouchPoint(int x, int y) { |
| 708 touch_event_.PressPoint(x, y); | 719 touch_event_.PressPoint(x, y); |
| 709 SendTouchEvent(); | |
| 710 } | 720 } |
| 711 | 721 |
| 712 void MoveTouchPoint(int index, int x, int y) { | 722 void MoveTouchPoint(int index, int x, int y) { |
| 713 touch_event_.MovePoint(index, x, y); | 723 touch_event_.MovePoint(index, x, y); |
| 714 SendTouchEvent(); | |
| 715 } | 724 } |
| 716 | 725 |
| 717 void ReleaseTouchPoint(int index) { | 726 void ReleaseTouchPoint(int index) { |
| 718 touch_event_.ReleasePoint(index); | 727 touch_event_.ReleasePoint(index); |
| 719 SendTouchEvent(); | |
| 720 } | 728 } |
| 721 | 729 |
| 722 SyntheticWebTouchEvent touch_event_; | 730 SyntheticWebTouchEvent touch_event_; |
| 723 | 731 |
| 724 scoped_ptr<TestOverscrollDelegate> overscroll_delegate_; | 732 scoped_ptr<TestOverscrollDelegate> overscroll_delegate_; |
| 725 | 733 |
| 726 private: | 734 private: |
| 727 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraOverscrollTest); | 735 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraOverscrollTest); |
| 728 }; | 736 }; |
| 729 | 737 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1097 view_->OnTouchEvent(&press); | 1105 view_->OnTouchEvent(&press); |
| 1098 EXPECT_TRUE(press.synchronous_handling_disabled()); | 1106 EXPECT_TRUE(press.synchronous_handling_disabled()); |
| 1099 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); | 1107 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); |
| 1100 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | 1108 EXPECT_EQ(1U, view_->touch_event_->touchesLength); |
| 1101 EXPECT_EQ(blink::WebTouchPoint::StatePressed, | 1109 EXPECT_EQ(blink::WebTouchPoint::StatePressed, |
| 1102 view_->touch_event_->touches[0].state); | 1110 view_->touch_event_->touches[0].state); |
| 1103 | 1111 |
| 1104 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 1112 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); |
| 1105 | 1113 |
| 1106 // Ack'ing the outstanding event should flush the pending touch queue. | 1114 // Ack'ing the outstanding event should flush the pending touch queue. |
| 1107 InputHostMsg_HandleInputEvent_ACK_Params ack; | 1115 InputEventAck ack(blink::WebInputEvent::TouchStart, |
| 1108 ack.type = blink::WebInputEvent::TouchStart; | 1116 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, |
| 1109 ack.state = INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 1117 press.unique_event_id()); |
| 1110 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); | 1118 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); |
| 1111 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1119 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 1112 | 1120 |
| 1113 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | 1121 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, |
| 1114 base::Time::NowFromSystemTime() - base::Time()); | 1122 base::Time::NowFromSystemTime() - base::Time()); |
| 1115 view_->OnTouchEvent(&move2); | 1123 view_->OnTouchEvent(&move2); |
| 1116 EXPECT_TRUE(press.synchronous_handling_disabled()); | 1124 EXPECT_TRUE(press.synchronous_handling_disabled()); |
| 1117 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | 1125 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); |
| 1118 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | 1126 EXPECT_EQ(1U, view_->touch_event_->touchesLength); |
| 1119 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 1127 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1131 TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) { | 1139 TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) { |
| 1132 view_->InitAsFullscreen(parent_view_); | 1140 view_->InitAsFullscreen(parent_view_); |
| 1133 view_->Show(); | 1141 view_->Show(); |
| 1134 view_->UseFakeDispatcher(); | 1142 view_->UseFakeDispatcher(); |
| 1135 GetSentMessageCountAndResetSink(); | 1143 GetSentMessageCountAndResetSink(); |
| 1136 | 1144 |
| 1137 ui::TouchEvent press0(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, | 1145 ui::TouchEvent press0(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, |
| 1138 ui::EventTimeForNow()); | 1146 ui::EventTimeForNow()); |
| 1139 | 1147 |
| 1140 view_->OnTouchEvent(&press0); | 1148 view_->OnTouchEvent(&press0); |
| 1141 SendInputEventACK(blink::WebInputEvent::TouchStart, | 1149 SendTouchEventACK(blink::WebInputEvent::TouchStart, |
| 1142 INPUT_EVENT_ACK_STATE_CONSUMED); | 1150 INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1151 press0.unique_event_id()); | |
| 1143 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); | 1152 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); |
| 1144 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | 1153 EXPECT_EQ(1U, view_->touch_event_->touchesLength); |
| 1145 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1154 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 1146 | 1155 |
| 1147 ui::TouchEvent move0(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | 1156 ui::TouchEvent move0(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, |
| 1148 ui::EventTimeForNow()); | 1157 ui::EventTimeForNow()); |
| 1149 | 1158 |
| 1150 view_->OnTouchEvent(&move0); | 1159 view_->OnTouchEvent(&move0); |
| 1151 SendInputEventACK(blink::WebInputEvent::TouchMove, | 1160 SendTouchEventACK(blink::WebInputEvent::TouchMove, |
| 1152 INPUT_EVENT_ACK_STATE_CONSUMED); | 1161 INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1162 move0.unique_event_id()); | |
| 1153 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | 1163 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); |
| 1154 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | 1164 EXPECT_EQ(1U, view_->touch_event_->touchesLength); |
| 1155 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1165 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 1156 | 1166 |
| 1157 // For the second touchstart, only the state of the second touch point is | 1167 // For the second touchstart, only the state of the second touch point is |
| 1158 // StatePressed, the state of the first touch point is StateStationary. | 1168 // StatePressed, the state of the first touch point is StateStationary. |
| 1159 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, | 1169 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, |
| 1160 ui::EventTimeForNow()); | 1170 ui::EventTimeForNow()); |
| 1161 | 1171 |
| 1162 view_->OnTouchEvent(&press1); | 1172 view_->OnTouchEvent(&press1); |
| 1163 SendInputEventACK(blink::WebInputEvent::TouchStart, | 1173 SendTouchEventACK(blink::WebInputEvent::TouchStart, |
| 1164 INPUT_EVENT_ACK_STATE_CONSUMED); | 1174 INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1175 press1.unique_event_id()); | |
| 1165 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); | 1176 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); |
| 1166 EXPECT_EQ(2U, view_->touch_event_->touchesLength); | 1177 EXPECT_EQ(2U, view_->touch_event_->touchesLength); |
| 1167 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1178 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 1168 | 1179 |
| 1169 // For the touchmove of second point, the state of the second touch point is | 1180 // 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. | 1181 // StateMoved, the state of the first touch point is StateStationary. |
| 1171 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, | 1182 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, |
| 1172 ui::EventTimeForNow()); | 1183 ui::EventTimeForNow()); |
| 1173 | 1184 |
| 1174 view_->OnTouchEvent(&move1); | 1185 view_->OnTouchEvent(&move1); |
| 1175 SendInputEventACK(blink::WebInputEvent::TouchMove, | 1186 SendTouchEventACK(blink::WebInputEvent::TouchMove, |
| 1176 INPUT_EVENT_ACK_STATE_CONSUMED); | 1187 INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1188 move1.unique_event_id()); | |
| 1177 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | 1189 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); |
| 1178 EXPECT_EQ(2U, view_->touch_event_->touchesLength); | 1190 EXPECT_EQ(2U, view_->touch_event_->touchesLength); |
| 1179 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1191 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 1180 | 1192 |
| 1181 // For the touchmove of first point, the state of the first touch point is | 1193 // 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. | 1194 // StateMoved, the state of the second touch point is StateStationary. |
| 1183 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 0, | 1195 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 0, |
| 1184 ui::EventTimeForNow()); | 1196 ui::EventTimeForNow()); |
| 1185 | 1197 |
| 1186 view_->OnTouchEvent(&move2); | 1198 view_->OnTouchEvent(&move2); |
| 1187 SendInputEventACK(blink::WebInputEvent::TouchMove, | 1199 SendTouchEventACK(blink::WebInputEvent::TouchMove, |
| 1188 INPUT_EVENT_ACK_STATE_CONSUMED); | 1200 INPUT_EVENT_ACK_STATE_CONSUMED, |
| 1201 move2.unique_event_id()); | |
| 1189 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | 1202 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); |
| 1190 EXPECT_EQ(2U, view_->touch_event_->touchesLength); | 1203 EXPECT_EQ(2U, view_->touch_event_->touchesLength); |
| 1191 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1204 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 1192 | 1205 |
| 1193 ui::TouchEvent cancel0(ui::ET_TOUCH_CANCELLED, gfx::Point(10, 10), 0, | 1206 ui::TouchEvent cancel0(ui::ET_TOUCH_CANCELLED, gfx::Point(10, 10), 0, |
| 1194 ui::EventTimeForNow()); | 1207 ui::EventTimeForNow()); |
| 1195 | 1208 |
| 1196 // For the touchcancel, only the state of the current touch point is | 1209 // For the touchcancel, only the state of the current touch point is |
| 1197 // StateCancelled, the state of the other touch point is StateStationary. | 1210 // StateCancelled, the state of the other touch point is StateStationary. |
| 1198 view_->OnTouchEvent(&cancel0); | 1211 view_->OnTouchEvent(&cancel0); |
| (...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2857 | 2870 |
| 2858 // Tests that when touch-events are dispatched to the renderer, the overscroll | 2871 // Tests that when touch-events are dispatched to the renderer, the overscroll |
| 2859 // gesture deals with them correctly. | 2872 // gesture deals with them correctly. |
| 2860 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) { | 2873 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) { |
| 2861 SetUpOverscrollEnvironmentWithDebounce(10); | 2874 SetUpOverscrollEnvironmentWithDebounce(10); |
| 2862 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 2875 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 2863 sink_->ClearMessages(); | 2876 sink_->ClearMessages(); |
| 2864 | 2877 |
| 2865 // The test sends an intermingled sequence of touch and gesture events. | 2878 // The test sends an intermingled sequence of touch and gesture events. |
| 2866 PressTouchPoint(0, 1); | 2879 PressTouchPoint(0, 1); |
| 2867 SendInputEventACK(WebInputEvent::TouchStart, | 2880 uint32 touch_press_event_id1 = SendTouchEvent(); |
| 2868 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2881 SendTouchEventACK(WebInputEvent::TouchStart, |
| 2882 INPUT_EVENT_ACK_STATE_NOT_CONSUMED, touch_press_event_id1); | |
| 2869 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2883 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2870 | 2884 |
| 2871 MoveTouchPoint(0, 20, 5); | 2885 MoveTouchPoint(0, 20, 5); |
| 2886 uint32 touch_move_event_id1 = SendTouchEvent(); | |
| 2887 SendTouchEventACK(WebInputEvent::TouchMove, | |
| 2888 INPUT_EVENT_ACK_STATE_NOT_CONSUMED, touch_move_event_id1); | |
| 2872 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2889 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2873 SendInputEventACK(WebInputEvent::TouchMove, | |
| 2874 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2875 | 2890 |
| 2876 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2891 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 2877 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2892 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 2878 | 2893 |
| 2879 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 2894 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 2880 blink::WebGestureDeviceTouchscreen); | 2895 blink::WebGestureDeviceTouchscreen); |
| 2881 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2896 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2882 SimulateGestureScrollUpdateEvent(20, 0, 0); | 2897 SimulateGestureScrollUpdateEvent(20, 0, 0); |
| 2883 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 2898 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2884 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2899 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2885 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2900 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2886 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2901 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 2887 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2902 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 2888 | 2903 |
| 2889 // Another touch move event should reach the renderer since overscroll hasn't | 2904 // 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 | 2905 // started yet. Note that touch events sent during the scroll period may |
| 2891 // not require an ack (having been marked uncancelable). | 2906 // not require an ack (having been marked uncancelable). |
| 2892 MoveTouchPoint(0, 65, 10); | 2907 MoveTouchPoint(0, 65, 10); |
| 2893 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2908 uint32 touch_move_event_id2 = SendTouchEvent(); |
| 2909 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, | |
| 2910 touch_move_event_id2); | |
| 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 uint32 touch_move_event_id3 = 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, |
| 2933 touch_move_event_id3); | |
| 2915 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2934 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2916 | 2935 |
| 2917 SimulateGestureScrollUpdateEvent(-10, 0, 0); | 2936 SimulateGestureScrollUpdateEvent(-10, 0, 0); |
| 2918 EXPECT_EQ(0U, sink_->message_count()); | 2937 EXPECT_EQ(0U, sink_->message_count()); |
| 2919 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); | 2938 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
| 2920 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 2939 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
| 2921 EXPECT_EQ(55.f, overscroll_delta_x()); | 2940 EXPECT_EQ(55.f, overscroll_delta_x()); |
| 2922 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); | 2941 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); |
| 2923 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); | 2942 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); |
| 2924 | 2943 |
| 2925 PressTouchPoint(255, 5); | 2944 PressTouchPoint(255, 5); |
| 2926 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2945 uint32 touch_press_event_id2 = SendTouchEvent(); |
| 2946 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, | |
| 2947 touch_press_event_id2); | |
| 2927 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2948 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2928 | 2949 |
| 2929 SimulateGestureScrollUpdateEvent(200, 0, 0); | 2950 SimulateGestureScrollUpdateEvent(200, 0, 0); |
| 2930 EXPECT_EQ(0U, sink_->message_count()); | 2951 EXPECT_EQ(0U, sink_->message_count()); |
| 2931 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); | 2952 EXPECT_EQ(OVERSCROLL_EAST, overscroll_mode()); |
| 2932 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); | 2953 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->current_mode()); |
| 2933 EXPECT_EQ(255.f, overscroll_delta_x()); | 2954 EXPECT_EQ(255.f, overscroll_delta_x()); |
| 2934 EXPECT_EQ(205.f, overscroll_delegate()->delta_x()); | 2955 EXPECT_EQ(205.f, overscroll_delegate()->delta_x()); |
| 2935 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); | 2956 EXPECT_EQ(0.f, overscroll_delegate()->delta_y()); |
| 2936 | 2957 |
| 2937 // The touch-end/cancel event should always reach the renderer if the page has | 2958 // The touch-end/cancel event should always reach the renderer if the page has |
| 2938 // touch handlers. | 2959 // touch handlers. |
| 2939 ReleaseTouchPoint(1); | 2960 ReleaseTouchPoint(1); |
| 2940 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2961 uint32 touch_release_event_id1 = SendTouchEvent(); |
| 2962 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, | |
| 2963 touch_release_event_id1); | |
| 2941 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2964 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2942 ReleaseTouchPoint(0); | 2965 ReleaseTouchPoint(0); |
| 2943 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2966 uint32 touch_release_event_id2 = SendTouchEvent(); |
| 2967 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, | |
| 2968 touch_release_event_id2); | |
| 2944 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 2969 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 2945 | 2970 |
| 2946 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 2971 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
| 2947 blink::WebGestureDeviceTouchscreen); | 2972 blink::WebGestureDeviceTouchscreen); |
| 2948 base::MessageLoop::current()->PostDelayedTask( | 2973 base::MessageLoop::current()->PostDelayedTask( |
| 2949 FROM_HERE, | 2974 FROM_HERE, |
| 2950 base::MessageLoop::QuitClosure(), | 2975 base::MessageLoop::QuitClosure(), |
| 2951 base::TimeDelta::FromMilliseconds(10)); | 2976 base::TimeDelta::FromMilliseconds(10)); |
| 2952 base::MessageLoop::current()->Run(); | 2977 base::MessageLoop::current()->Run(); |
| 2953 EXPECT_EQ(1U, sink_->message_count()); | 2978 EXPECT_EQ(1U, sink_->message_count()); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3298 ui::EventTimeForNow()); | 3323 ui::EventTimeForNow()); |
| 3299 | 3324 |
| 3300 // Construct a move with a touch id which doesn't exist. | 3325 // Construct a move with a touch id which doesn't exist. |
| 3301 ui::TouchEvent invalid_move(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, | 3326 ui::TouchEvent invalid_move(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, |
| 3302 ui::EventTimeForNow()); | 3327 ui::EventTimeForNow()); |
| 3303 | 3328 |
| 3304 // Valid press is handled asynchronously. | 3329 // Valid press is handled asynchronously. |
| 3305 view_->OnTouchEvent(&press); | 3330 view_->OnTouchEvent(&press); |
| 3306 EXPECT_TRUE(press.synchronous_handling_disabled()); | 3331 EXPECT_TRUE(press.synchronous_handling_disabled()); |
| 3307 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3332 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3308 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_CONSUMED); | 3333 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_CONSUMED, |
| 3334 press.unique_event_id()); | |
| 3309 | 3335 |
| 3310 // Invalid move is handled synchronously, but is consumed. It should not | 3336 // Invalid move is handled synchronously, but is consumed. It should not |
| 3311 // be forwarded to the renderer. | 3337 // be forwarded to the renderer. |
| 3312 view_->OnTouchEvent(&invalid_move); | 3338 view_->OnTouchEvent(&invalid_move); |
| 3313 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 3339 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
| 3314 EXPECT_FALSE(invalid_move.synchronous_handling_disabled()); | 3340 EXPECT_FALSE(invalid_move.synchronous_handling_disabled()); |
| 3315 EXPECT_TRUE(invalid_move.stopped_propagation()); | 3341 EXPECT_TRUE(invalid_move.stopped_propagation()); |
| 3316 } | 3342 } |
| 3317 | 3343 |
| 3318 // Checks key event codes. | 3344 // Checks key event codes. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3389 // lose track of the number of acks required. | 3415 // lose track of the number of acks required. |
| 3390 TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) { | 3416 TEST_F(RenderWidgetHostViewAuraTest, CorrectNumberOfAcksAreDispatched) { |
| 3391 view_->InitAsFullscreen(parent_view_); | 3417 view_->InitAsFullscreen(parent_view_); |
| 3392 view_->Show(); | 3418 view_->Show(); |
| 3393 view_->UseFakeDispatcher(); | 3419 view_->UseFakeDispatcher(); |
| 3394 | 3420 |
| 3395 ui::TouchEvent press1( | 3421 ui::TouchEvent press1( |
| 3396 ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, ui::EventTimeForNow()); | 3422 ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, ui::EventTimeForNow()); |
| 3397 | 3423 |
| 3398 view_->OnTouchEvent(&press1); | 3424 view_->OnTouchEvent(&press1); |
| 3399 SendInputEventACK(blink::WebInputEvent::TouchStart, | 3425 SendTouchEventACK(blink::WebInputEvent::TouchStart, |
| 3400 INPUT_EVENT_ACK_STATE_CONSUMED); | 3426 INPUT_EVENT_ACK_STATE_CONSUMED, press1.unique_event_id()); |
| 3401 | 3427 |
| 3402 ui::TouchEvent press2( | 3428 ui::TouchEvent press2( |
| 3403 ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 1, ui::EventTimeForNow()); | 3429 ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), 1, ui::EventTimeForNow()); |
| 3404 view_->OnTouchEvent(&press2); | 3430 view_->OnTouchEvent(&press2); |
| 3405 SendInputEventACK(blink::WebInputEvent::TouchStart, | 3431 SendTouchEventACK(blink::WebInputEvent::TouchStart, |
| 3406 INPUT_EVENT_ACK_STATE_CONSUMED); | 3432 INPUT_EVENT_ACK_STATE_CONSUMED, press2.unique_event_id()); |
| 3407 | 3433 |
| 3408 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 3434 EXPECT_EQ(2U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
| 3409 } | 3435 } |
| 3410 | 3436 |
| 3411 // Tests that the scroll deltas stored within the overscroll controller get | 3437 // 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 | 3438 // reset at the end of the overscroll gesture even if the overscroll threshold |
| 3413 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE. | 3439 // isn't surpassed and the overscroll mode stays OVERSCROLL_NONE. |
| 3414 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ScrollDeltasResetOnEnd) { | 3440 TEST_F(RenderWidgetHostViewAuraOverscrollTest, ScrollDeltasResetOnEnd) { |
| 3415 SetUpOverscrollEnvironment(); | 3441 SetUpOverscrollEnvironment(); |
| 3416 // Wheel event scroll ending with mouse move. | 3442 // Wheel event scroll ending with mouse move. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 3447 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3473 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3448 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3474 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3449 EXPECT_EQ(15.f, overscroll_delta_x()); | 3475 EXPECT_EQ(15.f, overscroll_delta_x()); |
| 3450 EXPECT_EQ(-5.f, overscroll_delta_y()); | 3476 EXPECT_EQ(-5.f, overscroll_delta_y()); |
| 3451 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); | 3477 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); |
| 3452 EXPECT_EQ(0.f, overscroll_delta_x()); | 3478 EXPECT_EQ(0.f, overscroll_delta_x()); |
| 3453 EXPECT_EQ(0.f, overscroll_delta_y()); | 3479 EXPECT_EQ(0.f, overscroll_delta_y()); |
| 3454 } | 3480 } |
| 3455 | 3481 |
| 3456 } // namespace content | 3482 } // namespace content |
| OLD | NEW |