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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 FakeResizeLock(const gfx::Size new_size, bool defer_compositor_lock) | 296 FakeResizeLock(const gfx::Size new_size, bool defer_compositor_lock) |
297 : ResizeLock(new_size, defer_compositor_lock) {} | 297 : ResizeLock(new_size, defer_compositor_lock) {} |
298 }; | 298 }; |
299 | 299 |
300 void OnTouchEvent(ui::TouchEvent* event) override { | 300 void OnTouchEvent(ui::TouchEvent* event) override { |
301 RenderWidgetHostViewAura::OnTouchEvent(event); | 301 RenderWidgetHostViewAura::OnTouchEvent(event); |
302 if (pointer_state().GetPointerCount() > 0) { | 302 if (pointer_state().GetPointerCount() > 0) { |
303 touch_event_.reset( | 303 touch_event_.reset( |
304 new blink::WebTouchEvent(ui::CreateWebTouchEventFromMotionEvent( | 304 new blink::WebTouchEvent(ui::CreateWebTouchEventFromMotionEvent( |
305 pointer_state(), event->may_cause_scrolling()))); | 305 pointer_state(), event->may_cause_scrolling()))); |
306 MarkUnchangedTouchPointsAsStationary(touch_event_.get(), | |
307 event->touch_id()); | |
306 } else { | 308 } else { |
307 // Never create a WebTouchEvent with 0 touch points. | 309 // Never create a WebTouchEvent with 0 touch points. |
308 touch_event_.reset(); | 310 touch_event_.reset(); |
309 } | 311 } |
310 } | 312 } |
311 | 313 |
312 bool has_resize_lock_; | 314 bool has_resize_lock_; |
313 gfx::Size last_frame_size_; | 315 gfx::Size last_frame_size_; |
314 scoped_ptr<cc::CopyOutputRequest> last_copy_request_; | 316 scoped_ptr<cc::CopyOutputRequest> last_copy_request_; |
315 // null if there are 0 active touch points. | 317 // null if there are 0 active touch points. |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1117 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | 1119 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
1118 view_->touch_event_->touches[0].state); | 1120 view_->touch_event_->touches[0].state); |
1119 | 1121 |
1120 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, | 1122 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, |
1121 base::Time::NowFromSystemTime() - base::Time()); | 1123 base::Time::NowFromSystemTime() - base::Time()); |
1122 view_->OnTouchEvent(&release2); | 1124 view_->OnTouchEvent(&release2); |
1123 EXPECT_TRUE(press.synchronous_handling_disabled()); | 1125 EXPECT_TRUE(press.synchronous_handling_disabled()); |
1124 EXPECT_EQ(nullptr, view_->touch_event_); | 1126 EXPECT_EQ(nullptr, view_->touch_event_); |
1125 } | 1127 } |
1126 | 1128 |
1129 // Checks that touch-event state is maintained correctly for multiple touch | |
1130 // points. | |
1131 TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) { | |
jdduke (slow)
2015/05/08 15:28:56
I guess I'm wondering why we can't validate the re
tdresser
2015/05/08 15:34:26
That would be an improvement.
lanwei
2015/05/08 20:47:05
Thanks for the good suggestion, it is better to us
| |
1132 view_->InitAsChild(NULL); | |
1133 view_->Show(); | |
1134 GetSentMessageCountAndResetSink(); | |
1135 | |
1136 ui::TouchEvent press0(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, | |
1137 ui::EventTimeForNow()); | |
1138 | |
1139 view_->OnTouchEvent(&press0); | |
1140 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); | |
1141 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | |
1142 EXPECT_EQ(blink::WebTouchPoint::StatePressed, | |
1143 view_->touch_event_->touches[0].state); | |
1144 | |
1145 ui::TouchEvent move0(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | |
1146 ui::EventTimeForNow()); | |
1147 | |
1148 view_->OnTouchEvent(&move0); | |
1149 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | |
1150 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | |
1151 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | |
1152 view_->touch_event_->touches[0].state); | |
1153 | |
1154 // For the second touchstart, only the state of the second touch point is | |
1155 // StatePressed, the state of the first touch point is StateStationary. | |
1156 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, | |
1157 ui::EventTimeForNow()); | |
1158 | |
1159 view_->OnTouchEvent(&press1); | |
1160 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); | |
1161 EXPECT_EQ(2U, view_->touch_event_->touchesLength); | |
1162 EXPECT_EQ(blink::WebTouchPoint::StateStationary, | |
1163 view_->touch_event_->touches[0].state); | |
1164 EXPECT_EQ(blink::WebTouchPoint::StatePressed, | |
1165 view_->touch_event_->touches[1].state); | |
1166 | |
1167 // For the touchmove of second point, the state of the second touch point is | |
1168 // StateMoved, the state of the first touch point is StateStationary. | |
1169 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, | |
1170 ui::EventTimeForNow()); | |
1171 | |
1172 view_->OnTouchEvent(&move1); | |
1173 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | |
1174 EXPECT_EQ(2U, view_->touch_event_->touchesLength); | |
1175 EXPECT_EQ(blink::WebTouchPoint::StateStationary, | |
1176 view_->touch_event_->touches[0].state); | |
1177 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | |
1178 view_->touch_event_->touches[1].state); | |
1179 | |
1180 // For the touchmove of first point, the state of the first touch point is | |
1181 // StateMoved, the state of the second touch point is StateStationary. | |
1182 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 0, | |
1183 ui::EventTimeForNow()); | |
1184 | |
1185 view_->OnTouchEvent(&move2); | |
1186 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | |
1187 EXPECT_EQ(2U, view_->touch_event_->touchesLength); | |
1188 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | |
1189 view_->touch_event_->touches[0].state); | |
1190 EXPECT_EQ(blink::WebTouchPoint::StateStationary, | |
1191 view_->touch_event_->touches[1].state); | |
1192 | |
1193 ui::TouchEvent cancel0(ui::ET_TOUCH_CANCELLED, gfx::Point(10, 10), 0, | |
1194 ui::EventTimeForNow()); | |
1195 | |
1196 // For the touchcancel, only the state of the current touch point is | |
1197 // StateCancelled, the state of the other touch point is StateStationary. | |
1198 view_->OnTouchEvent(&cancel0); | |
1199 EXPECT_EQ(blink::WebInputEvent::TouchCancel, view_->touch_event_->type); | |
1200 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | |
1201 EXPECT_EQ(blink::WebTouchPoint::StateStationary, | |
1202 view_->touch_event_->touches[0].state); | |
1203 EXPECT_EQ(1, view_->touch_event_->touches[0].id); | |
1204 | |
1205 ui::TouchEvent cancel1(ui::ET_TOUCH_CANCELLED, gfx::Point(30, 30), 1, | |
1206 ui::EventTimeForNow()); | |
1207 | |
1208 view_->OnTouchEvent(&cancel1); | |
1209 EXPECT_EQ(nullptr, view_->touch_event_); | |
1210 } | |
1211 | |
1127 // Checks that touch-events are queued properly when there is a touch-event | 1212 // Checks that touch-events are queued properly when there is a touch-event |
1128 // handler on the page. | 1213 // handler on the page. |
1129 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { | 1214 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { |
1130 view_->InitAsChild(NULL); | 1215 view_->InitAsChild(NULL); |
1131 view_->Show(); | 1216 view_->Show(); |
1132 | 1217 |
1133 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1218 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
1134 | 1219 |
1135 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 1220 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
1136 gfx::Point(30, 30), | 1221 gfx::Point(30, 30), |
(...skipping 2226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3363 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3448 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
3364 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3449 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
3365 EXPECT_EQ(15.f, overscroll_delta_x()); | 3450 EXPECT_EQ(15.f, overscroll_delta_x()); |
3366 EXPECT_EQ(-5.f, overscroll_delta_y()); | 3451 EXPECT_EQ(-5.f, overscroll_delta_y()); |
3367 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); | 3452 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); |
3368 EXPECT_EQ(0.f, overscroll_delta_x()); | 3453 EXPECT_EQ(0.f, overscroll_delta_x()); |
3369 EXPECT_EQ(0.f, overscroll_delta_y()); | 3454 EXPECT_EQ(0.f, overscroll_delta_y()); |
3370 } | 3455 } |
3371 | 3456 |
3372 } // namespace content | 3457 } // namespace content |
OLD | NEW |