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/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 } | 1106 } |
1107 } | 1107 } |
1108 | 1108 |
1109 // Checks that touch-event state is maintained correctly. | 1109 // Checks that touch-event state is maintained correctly. |
1110 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { | 1110 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { |
1111 view_->InitAsChild(NULL); | 1111 view_->InitAsChild(NULL); |
1112 view_->Show(); | 1112 view_->Show(); |
1113 GetSentMessageCountAndResetSink(); | 1113 GetSentMessageCountAndResetSink(); |
1114 | 1114 |
1115 // Start with no touch-event handler in the renderer. | 1115 // Start with no touch-event handler in the renderer. |
1116 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 1116 widget_host_->OnMessageReceived(InputHostMsg_HasTouchEventHandlers(0, false)); |
1117 | 1117 |
1118 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 1118 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
1119 gfx::Point(30, 30), | 1119 gfx::Point(30, 30), |
1120 0, | 1120 0, |
1121 ui::EventTimeForNow()); | 1121 ui::EventTimeForNow()); |
1122 ui::TouchEvent move(ui::ET_TOUCH_MOVED, | 1122 ui::TouchEvent move(ui::ET_TOUCH_MOVED, |
1123 gfx::Point(20, 20), | 1123 gfx::Point(20, 20), |
1124 0, | 1124 0, |
1125 ui::EventTimeForNow()); | 1125 ui::EventTimeForNow()); |
1126 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, | 1126 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, |
(...skipping 15 matching lines...) Expand all Loading... |
1142 EXPECT_EQ(1U, pointer_state().GetPointerCount()); | 1142 EXPECT_EQ(1U, pointer_state().GetPointerCount()); |
1143 | 1143 |
1144 view_->OnTouchEvent(&release); | 1144 view_->OnTouchEvent(&release); |
1145 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1145 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1146 EXPECT_TRUE(press.synchronous_handling_disabled()); | 1146 EXPECT_TRUE(press.synchronous_handling_disabled()); |
1147 EXPECT_EQ(0U, pointer_state().GetPointerCount()); | 1147 EXPECT_EQ(0U, pointer_state().GetPointerCount()); |
1148 | 1148 |
1149 // Now install some touch-event handlers and do the same steps. The touch | 1149 // Now install some touch-event handlers and do the same steps. The touch |
1150 // events should now be consumed. However, the touch-event state should be | 1150 // events should now be consumed. However, the touch-event state should be |
1151 // updated as before. | 1151 // updated as before. |
1152 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1152 widget_host_->OnMessageReceived(InputHostMsg_HasTouchEventHandlers(0, true)); |
1153 | 1153 |
1154 view_->OnTouchEvent(&press); | 1154 view_->OnTouchEvent(&press); |
1155 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1155 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1156 EXPECT_TRUE(press.synchronous_handling_disabled()); | 1156 EXPECT_TRUE(press.synchronous_handling_disabled()); |
1157 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); | 1157 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); |
1158 EXPECT_EQ(1U, pointer_state().GetPointerCount()); | 1158 EXPECT_EQ(1U, pointer_state().GetPointerCount()); |
1159 | 1159 |
1160 view_->OnTouchEvent(&move); | 1160 view_->OnTouchEvent(&move); |
1161 EXPECT_TRUE(move.synchronous_handling_disabled()); | 1161 EXPECT_TRUE(move.synchronous_handling_disabled()); |
1162 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); | 1162 EXPECT_EQ(ui::MotionEvent::ACTION_MOVE, pointer_state().GetAction()); |
1163 EXPECT_EQ(1U, pointer_state().GetPointerCount()); | 1163 EXPECT_EQ(1U, pointer_state().GetPointerCount()); |
1164 view_->OnTouchEvent(&release); | 1164 view_->OnTouchEvent(&release); |
1165 EXPECT_TRUE(release.synchronous_handling_disabled()); | 1165 EXPECT_TRUE(release.synchronous_handling_disabled()); |
1166 EXPECT_EQ(0U, pointer_state().GetPointerCount()); | 1166 EXPECT_EQ(0U, pointer_state().GetPointerCount()); |
1167 | 1167 |
1168 // Now start a touch event, and remove the event-handlers before the release. | 1168 // Now start a touch event, and remove the event-handlers before the release. |
1169 view_->OnTouchEvent(&press); | 1169 view_->OnTouchEvent(&press); |
1170 EXPECT_TRUE(press.synchronous_handling_disabled()); | 1170 EXPECT_TRUE(press.synchronous_handling_disabled()); |
1171 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); | 1171 EXPECT_EQ(ui::MotionEvent::ACTION_DOWN, pointer_state().GetAction()); |
1172 EXPECT_EQ(1U, pointer_state().GetPointerCount()); | 1172 EXPECT_EQ(1U, pointer_state().GetPointerCount()); |
1173 | 1173 |
1174 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 1174 widget_host_->OnMessageReceived(InputHostMsg_HasTouchEventHandlers(0, false)); |
1175 | 1175 |
1176 // Ack'ing the outstanding event should flush the pending touch queue. | 1176 // Ack'ing the outstanding event should flush the pending touch queue. |
1177 InputEventAck ack(blink::WebInputEvent::TouchStart, | 1177 InputEventAck ack(blink::WebInputEvent::TouchStart, |
1178 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, | 1178 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, |
1179 press.unique_event_id()); | 1179 press.unique_event_id()); |
1180 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); | 1180 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); |
1181 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1181 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1182 | 1182 |
1183 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | 1183 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, |
1184 base::Time::NowFromSystemTime() - base::Time()); | 1184 base::Time::NowFromSystemTime() - base::Time()); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); | 1280 EXPECT_EQ(1U, view_->dispatcher_->GetAndResetProcessedTouchEventCount()); |
1281 EXPECT_EQ(0U, pointer_state().GetPointerCount()); | 1281 EXPECT_EQ(0U, pointer_state().GetPointerCount()); |
1282 } | 1282 } |
1283 | 1283 |
1284 // Checks that touch-events are queued properly when there is a touch-event | 1284 // Checks that touch-events are queued properly when there is a touch-event |
1285 // handler on the page. | 1285 // handler on the page. |
1286 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { | 1286 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { |
1287 view_->InitAsChild(NULL); | 1287 view_->InitAsChild(NULL); |
1288 view_->Show(); | 1288 view_->Show(); |
1289 | 1289 |
1290 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1290 widget_host_->OnMessageReceived(InputHostMsg_HasTouchEventHandlers(0, true)); |
1291 | 1291 |
1292 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 1292 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
1293 gfx::Point(30, 30), | 1293 gfx::Point(30, 30), |
1294 0, | 1294 0, |
1295 ui::EventTimeForNow()); | 1295 ui::EventTimeForNow()); |
1296 ui::TouchEvent move(ui::ET_TOUCH_MOVED, | 1296 ui::TouchEvent move(ui::ET_TOUCH_MOVED, |
1297 gfx::Point(20, 20), | 1297 gfx::Point(20, 20), |
1298 0, | 1298 0, |
1299 ui::EventTimeForNow()); | 1299 ui::EventTimeForNow()); |
1300 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, | 1300 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, |
(...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2991 | 2991 |
2992 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 2992 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
2993 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 2993 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
2994 EXPECT_EQ(1U, sink_->message_count()); | 2994 EXPECT_EQ(1U, sink_->message_count()); |
2995 } | 2995 } |
2996 | 2996 |
2997 // Tests that when touch-events are dispatched to the renderer, the overscroll | 2997 // Tests that when touch-events are dispatched to the renderer, the overscroll |
2998 // gesture deals with them correctly. | 2998 // gesture deals with them correctly. |
2999 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) { | 2999 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) { |
3000 SetUpOverscrollEnvironmentWithDebounce(10); | 3000 SetUpOverscrollEnvironmentWithDebounce(10); |
3001 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 3001 widget_host_->OnMessageReceived(InputHostMsg_HasTouchEventHandlers(0, true)); |
3002 sink_->ClearMessages(); | 3002 sink_->ClearMessages(); |
3003 | 3003 |
3004 // The test sends an intermingled sequence of touch and gesture events. | 3004 // The test sends an intermingled sequence of touch and gesture events. |
3005 PressTouchPoint(0, 1); | 3005 PressTouchPoint(0, 1); |
3006 uint32 touch_press_event_id1 = SendTouchEvent(); | 3006 uint32 touch_press_event_id1 = SendTouchEvent(); |
3007 SendTouchEventACK(WebInputEvent::TouchStart, | 3007 SendTouchEventACK(WebInputEvent::TouchStart, |
3008 INPUT_EVENT_ACK_STATE_NOT_CONSUMED, touch_press_event_id1); | 3008 INPUT_EVENT_ACK_STATE_NOT_CONSUMED, touch_press_event_id1); |
3009 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3009 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3010 | 3010 |
3011 MoveTouchPoint(0, 20, 5); | 3011 MoveTouchPoint(0, 20, 5); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3100 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3100 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3101 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3101 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
3102 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 3102 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
3103 } | 3103 } |
3104 | 3104 |
3105 // Tests that touch-gesture end is dispatched to the renderer at the end of a | 3105 // Tests that touch-gesture end is dispatched to the renderer at the end of a |
3106 // touch-gesture initiated overscroll. | 3106 // touch-gesture initiated overscroll. |
3107 TEST_F(RenderWidgetHostViewAuraOverscrollTest, | 3107 TEST_F(RenderWidgetHostViewAuraOverscrollTest, |
3108 TouchGestureEndDispatchedAfterOverscrollComplete) { | 3108 TouchGestureEndDispatchedAfterOverscrollComplete) { |
3109 SetUpOverscrollEnvironmentWithDebounce(10); | 3109 SetUpOverscrollEnvironmentWithDebounce(10); |
3110 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 3110 widget_host_->OnMessageReceived(InputHostMsg_HasTouchEventHandlers(0, true)); |
3111 sink_->ClearMessages(); | 3111 sink_->ClearMessages(); |
3112 | 3112 |
3113 // Start scrolling. Receive ACK as it being processed. | 3113 // Start scrolling. Receive ACK as it being processed. |
3114 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 3114 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
3115 blink::WebGestureDeviceTouchscreen); | 3115 blink::WebGestureDeviceTouchscreen); |
3116 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3116 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
3117 // The scroll begin event will have received a synthetic ack from the input | 3117 // The scroll begin event will have received a synthetic ack from the input |
3118 // router. | 3118 // router. |
3119 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3119 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3120 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3120 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3436 } | 3436 } |
3437 | 3437 |
3438 // Tests that invalid touch events are consumed and handled | 3438 // Tests that invalid touch events are consumed and handled |
3439 // synchronously. | 3439 // synchronously. |
3440 TEST_F(RenderWidgetHostViewAuraTest, | 3440 TEST_F(RenderWidgetHostViewAuraTest, |
3441 InvalidEventsHaveSyncHandlingDisabled) { | 3441 InvalidEventsHaveSyncHandlingDisabled) { |
3442 view_->InitAsChild(NULL); | 3442 view_->InitAsChild(NULL); |
3443 view_->Show(); | 3443 view_->Show(); |
3444 GetSentMessageCountAndResetSink(); | 3444 GetSentMessageCountAndResetSink(); |
3445 | 3445 |
3446 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 3446 widget_host_->OnMessageReceived(InputHostMsg_HasTouchEventHandlers(0, true)); |
3447 | 3447 |
3448 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, | 3448 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, |
3449 ui::EventTimeForNow()); | 3449 ui::EventTimeForNow()); |
3450 | 3450 |
3451 // Construct a move with a touch id which doesn't exist. | 3451 // Construct a move with a touch id which doesn't exist. |
3452 ui::TouchEvent invalid_move(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, | 3452 ui::TouchEvent invalid_move(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, |
3453 ui::EventTimeForNow()); | 3453 ui::EventTimeForNow()); |
3454 | 3454 |
3455 // Valid press is handled asynchronously. | 3455 // Valid press is handled asynchronously. |
3456 view_->OnTouchEvent(&press); | 3456 view_->OnTouchEvent(&press); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3616 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); | 3616 ViewMsg_SetSurfaceIdNamespace::Read(msg, ¶ms); |
3617 view_->InitAsChild(NULL); | 3617 view_->InitAsChild(NULL); |
3618 view_->Show(); | 3618 view_->Show(); |
3619 view_->SetSize(size); | 3619 view_->SetSize(size); |
3620 view_->OnSwapCompositorFrame(0, | 3620 view_->OnSwapCompositorFrame(0, |
3621 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); | 3621 MakeDelegatedFrame(1.f, size, gfx::Rect(size))); |
3622 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); | 3622 EXPECT_EQ(view_->GetSurfaceIdNamespace(), base::get<0>(params)); |
3623 } | 3623 } |
3624 | 3624 |
3625 } // namespace content | 3625 } // namespace content |
OLD | NEW |