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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 // time out. | 293 // time out. |
| 294 class FakeResizeLock : public ResizeLock { | 294 class FakeResizeLock : public ResizeLock { |
| 295 public: | 295 public: |
| 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( |
|
jdduke (slow)
2015/05/07 15:20:28
Hmm, why do have separate bookkeeping here for tou
lanwei
2015/05/08 02:12:32
Tim, I saw that you added this touch_event_, can y
tdresser
2015/05/08 11:59:23
This was put here to avoid code churn (or out of l
| |
| 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 SetTouchPointStateStationary(touch_event_.get(), event->touch_id()); | |
| 306 } else { | 307 } else { |
| 307 // Never create a WebTouchEvent with 0 touch points. | 308 // Never create a WebTouchEvent with 0 touch points. |
| 308 touch_event_.reset(); | 309 touch_event_.reset(); |
| 309 } | 310 } |
| 310 } | 311 } |
| 311 | 312 |
| 312 bool has_resize_lock_; | 313 bool has_resize_lock_; |
| 313 gfx::Size last_frame_size_; | 314 gfx::Size last_frame_size_; |
| 314 scoped_ptr<cc::CopyOutputRequest> last_copy_request_; | 315 scoped_ptr<cc::CopyOutputRequest> last_copy_request_; |
| 315 // null if there are 0 active touch points. | 316 // 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, | 1118 EXPECT_EQ(blink::WebTouchPoint::StateMoved, |
| 1118 view_->touch_event_->touches[0].state); | 1119 view_->touch_event_->touches[0].state); |
| 1119 | 1120 |
| 1120 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, | 1121 ui::TouchEvent release2(ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), 0, |
| 1121 base::Time::NowFromSystemTime() - base::Time()); | 1122 base::Time::NowFromSystemTime() - base::Time()); |
| 1122 view_->OnTouchEvent(&release2); | 1123 view_->OnTouchEvent(&release2); |
| 1123 EXPECT_TRUE(press.synchronous_handling_disabled()); | 1124 EXPECT_TRUE(press.synchronous_handling_disabled()); |
| 1124 EXPECT_EQ(nullptr, view_->touch_event_); | 1125 EXPECT_EQ(nullptr, view_->touch_event_); |
| 1125 } | 1126 } |
| 1126 | 1127 |
| 1128 // Checks that touch-event state is maintained correctly for multiple touch | |
| 1129 // points. | |
| 1130 TEST_F(RenderWidgetHostViewAuraTest, MultiTouchPointsStates) { | |
| 1131 view_->InitAsChild(NULL); | |
| 1132 view_->Show(); | |
| 1133 GetSentMessageCountAndResetSink(); | |
| 1134 | |
| 1135 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), 0, | |
| 1136 ui::EventTimeForNow()); | |
| 1137 | |
| 1138 view_->OnTouchEvent(&press); | |
| 1139 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); | |
| 1140 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | |
| 1141 EXPECT_EQ(blink::WebTouchPoint::StatePressed, | |
| 1142 view_->touch_event_->touches[0].state); | |
| 1143 | |
| 1144 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(20, 20), 0, | |
| 1145 ui::EventTimeForNow()); | |
| 1146 | |
| 1147 view_->OnTouchEvent(&move); | |
| 1148 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | |
| 1149 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | |
| 1150 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | |
| 1151 view_->touch_event_->touches[0].state); | |
| 1152 | |
| 1153 // For the second touchstart, only the state of the second touch point is | |
| 1154 // StatePressed, the state of the first touch point is StateStationary. | |
| 1155 ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 1, | |
|
tdresser
2015/05/07 12:13:06
nit: Can we use press1/press2 (or press0/press1) i
lanwei
2015/05/08 02:12:32
Done.
| |
| 1156 ui::EventTimeForNow()); | |
| 1157 | |
| 1158 view_->OnTouchEvent(&press1); | |
| 1159 EXPECT_EQ(blink::WebInputEvent::TouchStart, view_->touch_event_->type); | |
| 1160 EXPECT_EQ(2U, view_->touch_event_->touchesLength); | |
| 1161 EXPECT_EQ(blink::WebTouchPoint::StateStationary, | |
| 1162 view_->touch_event_->touches[0].state); | |
| 1163 EXPECT_EQ(blink::WebTouchPoint::StatePressed, | |
| 1164 view_->touch_event_->touches[1].state); | |
| 1165 | |
| 1166 // For the second touchmove, only the state of the second touch point is | |
| 1167 // StateMoved, the state of the first touch point is StateStationary. | |
| 1168 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, gfx::Point(30, 30), 1, | |
| 1169 ui::EventTimeForNow()); | |
| 1170 | |
| 1171 view_->OnTouchEvent(&move1); | |
| 1172 EXPECT_EQ(blink::WebInputEvent::TouchMove, view_->touch_event_->type); | |
| 1173 EXPECT_EQ(2U, view_->touch_event_->touchesLength); | |
| 1174 EXPECT_EQ(blink::WebTouchPoint::StateStationary, | |
| 1175 view_->touch_event_->touches[0].state); | |
| 1176 EXPECT_EQ(blink::WebTouchPoint::StateMoved, | |
| 1177 view_->touch_event_->touches[1].state); | |
| 1178 | |
|
tdresser
2015/05/07 12:13:06
Can we add an additional move here, to test the ca
lanwei
2015/05/08 02:12:32
Done.
| |
| 1179 ui::TouchEvent cancel(ui::ET_TOUCH_CANCELLED, gfx::Point(20, 20), 0, | |
| 1180 ui::EventTimeForNow()); | |
| 1181 | |
| 1182 // For the touchcancel, only the state of the current touch point is | |
| 1183 // StateCancelled, the state of the other touch point is StateStationary. | |
| 1184 view_->OnTouchEvent(&cancel); | |
| 1185 EXPECT_EQ(blink::WebInputEvent::TouchCancel, view_->touch_event_->type); | |
| 1186 EXPECT_EQ(1U, view_->touch_event_->touchesLength); | |
| 1187 EXPECT_EQ(blink::WebTouchPoint::StateStationary, | |
| 1188 view_->touch_event_->touches[0].state); | |
| 1189 EXPECT_EQ(1, view_->touch_event_->touches[0].id); | |
| 1190 | |
| 1191 ui::TouchEvent cancel1(ui::ET_TOUCH_CANCELLED, gfx::Point(30, 30), 1, | |
| 1192 ui::EventTimeForNow()); | |
| 1193 | |
| 1194 view_->OnTouchEvent(&cancel1); | |
| 1195 EXPECT_EQ(nullptr, view_->touch_event_); | |
| 1196 } | |
| 1197 | |
| 1127 // Checks that touch-events are queued properly when there is a touch-event | 1198 // Checks that touch-events are queued properly when there is a touch-event |
| 1128 // handler on the page. | 1199 // handler on the page. |
| 1129 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { | 1200 TEST_F(RenderWidgetHostViewAuraTest, TouchEventSyncAsync) { |
| 1130 view_->InitAsChild(NULL); | 1201 view_->InitAsChild(NULL); |
| 1131 view_->Show(); | 1202 view_->Show(); |
| 1132 | 1203 |
| 1133 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); | 1204 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); |
| 1134 | 1205 |
| 1135 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 1206 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
| 1136 gfx::Point(30, 30), | 1207 gfx::Point(30, 30), |
| (...skipping 2226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3363 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3434 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3364 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3435 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3365 EXPECT_EQ(15.f, overscroll_delta_x()); | 3436 EXPECT_EQ(15.f, overscroll_delta_x()); |
| 3366 EXPECT_EQ(-5.f, overscroll_delta_y()); | 3437 EXPECT_EQ(-5.f, overscroll_delta_y()); |
| 3367 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); | 3438 SimulateGestureFlingStartEvent(0.f, 0.1f, blink::WebGestureDeviceTouchpad); |
| 3368 EXPECT_EQ(0.f, overscroll_delta_x()); | 3439 EXPECT_EQ(0.f, overscroll_delta_x()); |
| 3369 EXPECT_EQ(0.f, overscroll_delta_y()); | 3440 EXPECT_EQ(0.f, overscroll_delta_y()); |
| 3370 } | 3441 } |
| 3371 | 3442 |
| 3372 } // namespace content | 3443 } // namespace content |
| OLD | NEW |