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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 #if defined(OS_WIN) || defined(USE_AURA) | 42 #if defined(OS_WIN) || defined(USE_AURA) |
43 #include "content/browser/renderer_host/ui_events_helper.h" | 43 #include "content/browser/renderer_host/ui_events_helper.h" |
44 #include "ui/events/event.h" | 44 #include "ui/events/event.h" |
45 #endif | 45 #endif |
46 | 46 |
47 using base::TimeDelta; | 47 using base::TimeDelta; |
48 using blink::WebGestureEvent; | 48 using blink::WebGestureEvent; |
49 using blink::WebInputEvent; | 49 using blink::WebInputEvent; |
50 using blink::WebKeyboardEvent; | 50 using blink::WebKeyboardEvent; |
| 51 using blink::WebMouseEvent; |
51 using blink::WebMouseWheelEvent; | 52 using blink::WebMouseWheelEvent; |
52 using blink::WebTouchEvent; | 53 using blink::WebTouchEvent; |
53 using blink::WebTouchPoint; | 54 using blink::WebTouchPoint; |
54 | 55 |
55 namespace content { | 56 namespace content { |
56 | 57 |
57 // TestOverscrollDelegate ------------------------------------------------------ | 58 // TestOverscrollDelegate ------------------------------------------------------ |
58 | 59 |
59 class TestOverscrollDelegate : public OverscrollControllerDelegate { | 60 class TestOverscrollDelegate : public OverscrollControllerDelegate { |
60 public: | 61 public: |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 193 |
193 class MockRenderWidgetHost : public RenderWidgetHostImpl { | 194 class MockRenderWidgetHost : public RenderWidgetHostImpl { |
194 public: | 195 public: |
195 MockRenderWidgetHost( | 196 MockRenderWidgetHost( |
196 RenderWidgetHostDelegate* delegate, | 197 RenderWidgetHostDelegate* delegate, |
197 RenderProcessHost* process, | 198 RenderProcessHost* process, |
198 int routing_id) | 199 int routing_id) |
199 : RenderWidgetHostImpl(delegate, process, routing_id, false), | 200 : RenderWidgetHostImpl(delegate, process, routing_id, false), |
200 unresponsive_timer_fired_(false) { | 201 unresponsive_timer_fired_(false) { |
201 input_router_impl_ = static_cast<InputRouterImpl*>(input_router_.get()); | 202 input_router_impl_ = static_cast<InputRouterImpl*>(input_router_.get()); |
| 203 acked_touch_event_type_ = blink::WebInputEvent::Undefined; |
202 } | 204 } |
203 | 205 |
204 // Allow poking at a few private members. | 206 // Allow poking at a few private members. |
205 using RenderWidgetHostImpl::OnUpdateRect; | 207 using RenderWidgetHostImpl::OnUpdateRect; |
206 using RenderWidgetHostImpl::RendererExited; | 208 using RenderWidgetHostImpl::RendererExited; |
207 using RenderWidgetHostImpl::last_requested_size_; | 209 using RenderWidgetHostImpl::last_requested_size_; |
208 using RenderWidgetHostImpl::is_hidden_; | 210 using RenderWidgetHostImpl::is_hidden_; |
209 using RenderWidgetHostImpl::resize_ack_pending_; | 211 using RenderWidgetHostImpl::resize_ack_pending_; |
210 using RenderWidgetHostImpl::input_router_; | 212 using RenderWidgetHostImpl::input_router_; |
211 | 213 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 256 |
255 void set_debounce_interval_time_ms(int delay_ms) { | 257 void set_debounce_interval_time_ms(int delay_ms) { |
256 gesture_event_queue(). | 258 gesture_event_queue(). |
257 set_debounce_interval_time_ms_for_testing(delay_ms); | 259 set_debounce_interval_time_ms_for_testing(delay_ms); |
258 } | 260 } |
259 | 261 |
260 bool TouchEventQueueEmpty() const { | 262 bool TouchEventQueueEmpty() const { |
261 return touch_event_queue().empty(); | 263 return touch_event_queue().empty(); |
262 } | 264 } |
263 | 265 |
| 266 virtual void OnTouchEventAck( |
| 267 const TouchEventWithLatencyInfo& event, |
| 268 InputEventAckState ack_result) OVERRIDE { |
| 269 // Sniff touch acks. |
| 270 acked_touch_event_type_ = event.event.type; |
| 271 RenderWidgetHostImpl::OnTouchEventAck(event, ack_result); |
| 272 } |
| 273 |
| 274 WebInputEvent::Type acked_touch_event_type() const { |
| 275 return acked_touch_event_type_; |
| 276 } |
| 277 |
264 bool ScrollStateIsContentScrolling() const { | 278 bool ScrollStateIsContentScrolling() const { |
265 return scroll_state() == OverscrollController::STATE_CONTENT_SCROLLING; | 279 return scroll_state() == OverscrollController::STATE_CONTENT_SCROLLING; |
266 } | 280 } |
267 | 281 |
268 bool ScrollStateIsOverscrolling() const { | 282 bool ScrollStateIsOverscrolling() const { |
269 return scroll_state() == OverscrollController::STATE_OVERSCROLLING; | 283 return scroll_state() == OverscrollController::STATE_OVERSCROLLING; |
270 } | 284 } |
271 | 285 |
272 bool ScrollStateIsUnknown() const { | 286 bool ScrollStateIsUnknown() const { |
273 return scroll_state() == OverscrollController::STATE_UNKNOWN; | 287 return scroll_state() == OverscrollController::STATE_UNKNOWN; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 const GestureEventQueue& gesture_event_queue() const { | 328 const GestureEventQueue& gesture_event_queue() const { |
315 return input_router_impl_->gesture_event_queue_; | 329 return input_router_impl_->gesture_event_queue_; |
316 } | 330 } |
317 | 331 |
318 GestureEventQueue& gesture_event_queue() { | 332 GestureEventQueue& gesture_event_queue() { |
319 return input_router_impl_->gesture_event_queue_; | 333 return input_router_impl_->gesture_event_queue_; |
320 } | 334 } |
321 | 335 |
322 private: | 336 private: |
323 bool unresponsive_timer_fired_; | 337 bool unresponsive_timer_fired_; |
| 338 WebInputEvent::Type acked_touch_event_type_; |
324 | 339 |
325 // |input_router_impl_| and |mock_input_router_| are owned by | 340 // |input_router_impl_| and |mock_input_router_| are owned by |
326 // RenderWidgetHostImpl. The handles below are provided for convenience so | 341 // RenderWidgetHostImpl. The handles below are provided for convenience so |
327 // that we don't have to reinterpret_cast it all the time. | 342 // that we don't have to reinterpret_cast it all the time. |
328 InputRouterImpl* input_router_impl_; | 343 InputRouterImpl* input_router_impl_; |
329 MockInputRouter* mock_input_router_; | 344 MockInputRouter* mock_input_router_; |
330 | 345 |
331 scoped_ptr<TestOverscrollDelegate> overscroll_delegate_; | 346 scoped_ptr<TestOverscrollDelegate> overscroll_delegate_; |
332 | 347 |
333 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHost); | 348 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHost); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 | 654 |
640 void SendInputEventACK(WebInputEvent::Type type, | 655 void SendInputEventACK(WebInputEvent::Type type, |
641 InputEventAckState ack_result) { | 656 InputEventAckState ack_result) { |
642 scoped_ptr<IPC::Message> response( | 657 scoped_ptr<IPC::Message> response( |
643 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result, | 658 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result, |
644 ui::LatencyInfo())); | 659 ui::LatencyInfo())); |
645 host_->OnMessageReceived(*response); | 660 host_->OnMessageReceived(*response); |
646 } | 661 } |
647 | 662 |
648 void SimulateKeyboardEvent(WebInputEvent::Type type) { | 663 void SimulateKeyboardEvent(WebInputEvent::Type type) { |
649 WebKeyboardEvent event = SyntheticWebKeyboardEventBuilder::Build(type); | 664 SimulateKeyboardEvent(type, 0); |
650 NativeWebKeyboardEvent native_event; | 665 } |
651 memcpy(&native_event, &event, sizeof(event)); | 666 |
| 667 void SimulateKeyboardEvent(WebInputEvent::Type type, int modifiers) { |
| 668 WebKeyboardEvent event = SyntheticWebKeyboardEventBuilder::Build(type); |
| 669 event.modifiers = modifiers; |
| 670 NativeWebKeyboardEvent native_event; |
| 671 memcpy(&native_event, &event, sizeof(event)); |
652 host_->ForwardKeyboardEvent(native_event); | 672 host_->ForwardKeyboardEvent(native_event); |
653 } | 673 } |
654 | 674 |
655 void SimulateMouseEvent(WebInputEvent::Type type) { | 675 void SimulateMouseEvent(WebInputEvent::Type type) { |
656 host_->ForwardMouseEvent(SyntheticWebMouseEventBuilder::Build(type)); | 676 host_->ForwardMouseEvent(SyntheticWebMouseEventBuilder::Build(type)); |
657 } | 677 } |
658 | 678 |
659 void SimulateMouseEventWithLatencyInfo(WebInputEvent::Type type, | 679 void SimulateMouseEventWithLatencyInfo(WebInputEvent::Type type, |
660 const ui::LatencyInfo& ui_latency) { | 680 const ui::LatencyInfo& ui_latency) { |
661 host_->ForwardMouseEventWithLatencyInfo( | 681 host_->ForwardMouseEventWithLatencyInfo( |
(...skipping 10 matching lines...) Expand all Loading... |
672 float dY, | 692 float dY, |
673 int modifiers, | 693 int modifiers, |
674 bool precise, | 694 bool precise, |
675 const ui::LatencyInfo& ui_latency) { | 695 const ui::LatencyInfo& ui_latency) { |
676 host_->ForwardWheelEventWithLatencyInfo( | 696 host_->ForwardWheelEventWithLatencyInfo( |
677 SyntheticWebMouseWheelEventBuilder::Build(dX, dY, modifiers, precise), | 697 SyntheticWebMouseWheelEventBuilder::Build(dX, dY, modifiers, precise), |
678 ui_latency); | 698 ui_latency); |
679 } | 699 } |
680 | 700 |
681 void SimulateMouseMove(int x, int y, int modifiers) { | 701 void SimulateMouseMove(int x, int y, int modifiers) { |
682 host_->ForwardMouseEvent( | 702 SimulateMouseEvent(WebInputEvent::MouseMove, x, y, modifiers, false); |
683 SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseMove, | 703 } |
684 x, | 704 |
685 y, | 705 void SimulateMouseEvent( |
686 modifiers)); | 706 WebInputEvent::Type type, int x, int y, int modifiers, bool pressed) { |
| 707 WebMouseEvent event = |
| 708 SyntheticWebMouseEventBuilder::Build(type, x, y, modifiers); |
| 709 if (pressed) |
| 710 event.button = WebMouseEvent::ButtonLeft; |
| 711 event.timeStampSeconds = base::Time::Now().ToDoubleT(); |
| 712 host_->ForwardMouseEvent(event); |
687 } | 713 } |
688 | 714 |
689 void SimulateWheelEventWithPhase(WebMouseWheelEvent::Phase phase) { | 715 void SimulateWheelEventWithPhase(WebMouseWheelEvent::Phase phase) { |
690 host_->ForwardWheelEvent(SyntheticWebMouseWheelEventBuilder::Build(phase)); | 716 host_->ForwardWheelEvent(SyntheticWebMouseWheelEventBuilder::Build(phase)); |
691 } | 717 } |
692 | 718 |
693 // Inject provided synthetic WebGestureEvent instance. | 719 // Inject provided synthetic WebGestureEvent instance. |
694 void SimulateGestureEventCore(const WebGestureEvent& gesture_event) { | 720 void SimulateGestureEventCore(const WebGestureEvent& gesture_event) { |
695 host_->ForwardGestureEvent(gesture_event); | 721 host_->ForwardGestureEvent(gesture_event); |
696 } | 722 } |
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2374 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); | 2400 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); |
2375 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); | 2401 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); |
2376 | 2402 |
2377 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, | 2403 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, |
2378 WebGestureEvent::Touchscreen); | 2404 WebGestureEvent::Touchscreen); |
2379 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); | 2405 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); |
2380 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); | 2406 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); |
2381 process_->sink().ClearMessages(); | 2407 process_->sink().ClearMessages(); |
2382 } | 2408 } |
2383 | 2409 |
| 2410 std::string GetInputMessageTypes(RenderWidgetHostProcess* process) { |
| 2411 const WebInputEvent* event = NULL; |
| 2412 ui::LatencyInfo latency_info; |
| 2413 bool is_keyboard_shortcut; |
| 2414 std::string result; |
| 2415 for (size_t i = 0; i < process->sink().message_count(); ++i) { |
| 2416 const IPC::Message *message = process->sink().GetMessageAt(i); |
| 2417 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); |
| 2418 EXPECT_TRUE(InputMsg_HandleInputEvent::Read( |
| 2419 message, &event, &latency_info, &is_keyboard_shortcut)); |
| 2420 if (i != 0) |
| 2421 result += " "; |
| 2422 result += WebInputEventTraits::GetName(event->type); |
| 2423 } |
| 2424 process->sink().ClearMessages(); |
| 2425 return result; |
| 2426 } |
| 2427 |
| 2428 TEST_F(RenderWidgetHostTest, TouchEmulator) { |
| 2429 host_->DisableGestureDebounce(); |
| 2430 // Immediately ack all touches instead of sending them to the renderer. |
| 2431 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); |
| 2432 host_->OnMessageReceived( |
| 2433 ViewHostMsg_SetTouchEventEmulationEnabled(0, true, true)); |
| 2434 process_->sink().ClearMessages(); |
| 2435 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
| 2436 view_->Show(); |
| 2437 |
| 2438 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false); |
| 2439 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2440 |
| 2441 // Mouse press becomes touch start which in turn becomes tap. |
| 2442 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true); |
| 2443 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type()); |
| 2444 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_)); |
| 2445 SendInputEventACK(WebInputEvent::GestureTapDown, |
| 2446 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2447 |
| 2448 // Mouse drag generates touch move, cancels tap and starts scroll. |
| 2449 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true); |
| 2450 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2451 EXPECT_EQ( |
| 2452 "GestureTapCancel GestureScrollBegin GestureScrollUpdate", |
| 2453 GetInputMessageTypes(process_)); |
| 2454 SendInputEventACK(WebInputEvent::GestureTapCancel, |
| 2455 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2456 SendInputEventACK(WebInputEvent::GestureScrollBegin, |
| 2457 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2458 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2459 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2460 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2461 |
| 2462 // Mouse drag with shift becomes pinch. |
| 2463 SimulateMouseEvent( |
| 2464 WebInputEvent::MouseMove, 10, 40, WebInputEvent::ShiftKey, true); |
| 2465 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2466 EXPECT_EQ("GesturePinchBegin", |
| 2467 GetInputMessageTypes(process_)); |
| 2468 SendInputEventACK(WebInputEvent::GesturePinchBegin, |
| 2469 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2470 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2471 |
| 2472 SimulateMouseEvent( |
| 2473 WebInputEvent::MouseMove, 10, 50, WebInputEvent::ShiftKey, true); |
| 2474 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2475 EXPECT_EQ("GesturePinchUpdate", |
| 2476 GetInputMessageTypes(process_)); |
| 2477 SendInputEventACK(WebInputEvent::GesturePinchUpdate, |
| 2478 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2479 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2480 |
| 2481 // Mouse drag without shift becomes scroll again. |
| 2482 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 60, 0, true); |
| 2483 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2484 EXPECT_EQ("GesturePinchEnd GestureScrollUpdate", |
| 2485 GetInputMessageTypes(process_)); |
| 2486 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2487 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2488 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2489 |
| 2490 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 70, 0, true); |
| 2491 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2492 EXPECT_EQ("GestureScrollUpdate", |
| 2493 GetInputMessageTypes(process_)); |
| 2494 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2495 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2496 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2497 |
| 2498 SimulateMouseEvent(WebInputEvent::MouseUp, 10, 70, 0, true); |
| 2499 EXPECT_EQ(WebInputEvent::TouchEnd, host_->acked_touch_event_type()); |
| 2500 EXPECT_EQ("GestureScrollEnd", GetInputMessageTypes(process_)); |
| 2501 SendInputEventACK(WebInputEvent::GestureScrollEnd, |
| 2502 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2503 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2504 |
| 2505 // Mouse move does nothing. |
| 2506 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 80, 0, false); |
| 2507 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2508 |
| 2509 // Another mouse down continues scroll. |
| 2510 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 80, 0, true); |
| 2511 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type()); |
| 2512 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_)); |
| 2513 SendInputEventACK(WebInputEvent::GestureTapDown, |
| 2514 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2515 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2516 |
| 2517 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 100, 0, true); |
| 2518 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2519 EXPECT_EQ( |
| 2520 "GestureTapCancel GestureScrollBegin GestureScrollUpdate", |
| 2521 GetInputMessageTypes(process_)); |
| 2522 SendInputEventACK(WebInputEvent::GestureTapCancel, |
| 2523 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2524 SendInputEventACK(WebInputEvent::GestureScrollBegin, |
| 2525 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2526 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2527 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2528 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2529 |
| 2530 // Another pinch. |
| 2531 SimulateMouseEvent( |
| 2532 WebInputEvent::MouseMove, 10, 110, WebInputEvent::ShiftKey, true); |
| 2533 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2534 EXPECT_EQ("GesturePinchBegin", |
| 2535 GetInputMessageTypes(process_)); |
| 2536 SendInputEventACK(WebInputEvent::GesturePinchBegin, |
| 2537 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2538 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2539 |
| 2540 SimulateMouseEvent( |
| 2541 WebInputEvent::MouseMove, 10, 120, WebInputEvent::ShiftKey, true); |
| 2542 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2543 EXPECT_EQ("GesturePinchUpdate", |
| 2544 GetInputMessageTypes(process_)); |
| 2545 SendInputEventACK(WebInputEvent::GesturePinchUpdate, |
| 2546 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2547 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2548 |
| 2549 // Turn off emulation during a pinch. |
| 2550 host_->OnMessageReceived( |
| 2551 ViewHostMsg_SetTouchEventEmulationEnabled(0, false, false)); |
| 2552 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type()); |
| 2553 EXPECT_EQ("GesturePinchEnd GestureScrollEnd", |
| 2554 GetInputMessageTypes(process_)); |
| 2555 SendInputEventACK(WebInputEvent::GesturePinchEnd, |
| 2556 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2557 SendInputEventACK(WebInputEvent::GestureScrollEnd, |
| 2558 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2559 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2560 |
| 2561 // Mouse event should pass untouched. |
| 2562 SimulateMouseEvent( |
| 2563 WebInputEvent::MouseMove, 10, 10, WebInputEvent::ShiftKey, true); |
| 2564 EXPECT_EQ("MouseMove", GetInputMessageTypes(process_)); |
| 2565 SendInputEventACK(WebInputEvent::MouseMove, |
| 2566 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2567 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2568 |
| 2569 // Turn on emulation. |
| 2570 host_->OnMessageReceived( |
| 2571 ViewHostMsg_SetTouchEventEmulationEnabled(0, true, true)); |
| 2572 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2573 |
| 2574 // Another touch. |
| 2575 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true); |
| 2576 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type()); |
| 2577 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_)); |
| 2578 SendInputEventACK(WebInputEvent::GestureTapDown, |
| 2579 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2580 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2581 |
| 2582 // Scroll. |
| 2583 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true); |
| 2584 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type()); |
| 2585 EXPECT_EQ( |
| 2586 "GestureTapCancel GestureScrollBegin GestureScrollUpdate", |
| 2587 GetInputMessageTypes(process_)); |
| 2588 SendInputEventACK(WebInputEvent::GestureTapCancel, |
| 2589 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 2590 SendInputEventACK(WebInputEvent::GestureScrollBegin, |
| 2591 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2592 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
| 2593 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2594 |
| 2595 // Turn off emulation during a scroll. |
| 2596 host_->OnMessageReceived( |
| 2597 ViewHostMsg_SetTouchEventEmulationEnabled(0, false, false)); |
| 2598 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type()); |
| 2599 |
| 2600 EXPECT_EQ("GestureScrollEnd", GetInputMessageTypes(process_)); |
| 2601 SendInputEventACK(WebInputEvent::GestureScrollEnd, |
| 2602 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 2603 EXPECT_EQ(0U, process_->sink().message_count()); |
| 2604 } |
| 2605 |
2384 #define TEST_InputRouterRoutes_NOARGS(INPUTMSG) \ | 2606 #define TEST_InputRouterRoutes_NOARGS(INPUTMSG) \ |
2385 TEST_F(RenderWidgetHostTest, InputRouterRoutes##INPUTMSG) { \ | 2607 TEST_F(RenderWidgetHostTest, InputRouterRoutes##INPUTMSG) { \ |
2386 host_->SetupForInputRouterTest(); \ | 2608 host_->SetupForInputRouterTest(); \ |
2387 host_->INPUTMSG(); \ | 2609 host_->INPUTMSG(); \ |
2388 EXPECT_TRUE(host_->mock_input_router()->send_event_called_); \ | 2610 EXPECT_TRUE(host_->mock_input_router()->send_event_called_); \ |
2389 } | 2611 } |
2390 | 2612 |
2391 TEST_InputRouterRoutes_NOARGS(Focus); | 2613 TEST_InputRouterRoutes_NOARGS(Focus); |
2392 TEST_InputRouterRoutes_NOARGS(Blur); | 2614 TEST_InputRouterRoutes_NOARGS(Blur); |
2393 TEST_InputRouterRoutes_NOARGS(LostCapture); | 2615 TEST_InputRouterRoutes_NOARGS(LostCapture); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2614 | 2836 |
2615 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). | 2837 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). |
2616 PressTouchPoint(0, 1); | 2838 PressTouchPoint(0, 1); |
2617 SendTouchEvent(); | 2839 SendTouchEvent(); |
2618 CheckLatencyInfoComponentInMessage( | 2840 CheckLatencyInfoComponentInMessage( |
2619 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); | 2841 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); |
2620 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | 2842 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); |
2621 } | 2843 } |
2622 | 2844 |
2623 } // namespace content | 2845 } // namespace content |
OLD | NEW |