Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: trunk/src/content/browser/renderer_host/render_widget_host_unittest.cc

Issue 237353003: Revert 263644 "[DevTools] Touch emulation in content." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
41 41
42 #if defined(USE_AURA) 42 #if 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;
52 using blink::WebMouseWheelEvent; 51 using blink::WebMouseWheelEvent;
53 using blink::WebTouchEvent; 52 using blink::WebTouchEvent;
54 using blink::WebTouchPoint; 53 using blink::WebTouchPoint;
55 54
56 namespace content { 55 namespace content {
57 56
58 // TestOverscrollDelegate ------------------------------------------------------ 57 // TestOverscrollDelegate ------------------------------------------------------
59 58
60 class TestOverscrollDelegate : public OverscrollControllerDelegate { 59 class TestOverscrollDelegate : public OverscrollControllerDelegate {
61 public: 60 public:
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 192
194 class MockRenderWidgetHost : public RenderWidgetHostImpl { 193 class MockRenderWidgetHost : public RenderWidgetHostImpl {
195 public: 194 public:
196 MockRenderWidgetHost( 195 MockRenderWidgetHost(
197 RenderWidgetHostDelegate* delegate, 196 RenderWidgetHostDelegate* delegate,
198 RenderProcessHost* process, 197 RenderProcessHost* process,
199 int routing_id) 198 int routing_id)
200 : RenderWidgetHostImpl(delegate, process, routing_id, false), 199 : RenderWidgetHostImpl(delegate, process, routing_id, false),
201 unresponsive_timer_fired_(false) { 200 unresponsive_timer_fired_(false) {
202 input_router_impl_ = static_cast<InputRouterImpl*>(input_router_.get()); 201 input_router_impl_ = static_cast<InputRouterImpl*>(input_router_.get());
203 acked_touch_event_type_ = blink::WebInputEvent::Undefined;
204 } 202 }
205 203
206 // Allow poking at a few private members. 204 // Allow poking at a few private members.
207 using RenderWidgetHostImpl::OnUpdateRect; 205 using RenderWidgetHostImpl::OnUpdateRect;
208 using RenderWidgetHostImpl::RendererExited; 206 using RenderWidgetHostImpl::RendererExited;
209 using RenderWidgetHostImpl::last_requested_size_; 207 using RenderWidgetHostImpl::last_requested_size_;
210 using RenderWidgetHostImpl::is_hidden_; 208 using RenderWidgetHostImpl::is_hidden_;
211 using RenderWidgetHostImpl::resize_ack_pending_; 209 using RenderWidgetHostImpl::resize_ack_pending_;
212 using RenderWidgetHostImpl::input_router_; 210 using RenderWidgetHostImpl::input_router_;
213 211
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 254
257 void set_debounce_interval_time_ms(int delay_ms) { 255 void set_debounce_interval_time_ms(int delay_ms) {
258 gesture_event_queue(). 256 gesture_event_queue().
259 set_debounce_interval_time_ms_for_testing(delay_ms); 257 set_debounce_interval_time_ms_for_testing(delay_ms);
260 } 258 }
261 259
262 bool TouchEventQueueEmpty() const { 260 bool TouchEventQueueEmpty() const {
263 return touch_event_queue().empty(); 261 return touch_event_queue().empty();
264 } 262 }
265 263
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
278 bool ScrollStateIsContentScrolling() const { 264 bool ScrollStateIsContentScrolling() const {
279 return scroll_state() == OverscrollController::STATE_CONTENT_SCROLLING; 265 return scroll_state() == OverscrollController::STATE_CONTENT_SCROLLING;
280 } 266 }
281 267
282 bool ScrollStateIsOverscrolling() const { 268 bool ScrollStateIsOverscrolling() const {
283 return scroll_state() == OverscrollController::STATE_OVERSCROLLING; 269 return scroll_state() == OverscrollController::STATE_OVERSCROLLING;
284 } 270 }
285 271
286 bool ScrollStateIsUnknown() const { 272 bool ScrollStateIsUnknown() const {
287 return scroll_state() == OverscrollController::STATE_UNKNOWN; 273 return scroll_state() == OverscrollController::STATE_UNKNOWN;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 const GestureEventQueue& gesture_event_queue() const { 314 const GestureEventQueue& gesture_event_queue() const {
329 return input_router_impl_->gesture_event_queue_; 315 return input_router_impl_->gesture_event_queue_;
330 } 316 }
331 317
332 GestureEventQueue& gesture_event_queue() { 318 GestureEventQueue& gesture_event_queue() {
333 return input_router_impl_->gesture_event_queue_; 319 return input_router_impl_->gesture_event_queue_;
334 } 320 }
335 321
336 private: 322 private:
337 bool unresponsive_timer_fired_; 323 bool unresponsive_timer_fired_;
338 WebInputEvent::Type acked_touch_event_type_;
339 324
340 // |input_router_impl_| and |mock_input_router_| are owned by 325 // |input_router_impl_| and |mock_input_router_| are owned by
341 // RenderWidgetHostImpl. The handles below are provided for convenience so 326 // RenderWidgetHostImpl. The handles below are provided for convenience so
342 // that we don't have to reinterpret_cast it all the time. 327 // that we don't have to reinterpret_cast it all the time.
343 InputRouterImpl* input_router_impl_; 328 InputRouterImpl* input_router_impl_;
344 MockInputRouter* mock_input_router_; 329 MockInputRouter* mock_input_router_;
345 330
346 scoped_ptr<TestOverscrollDelegate> overscroll_delegate_; 331 scoped_ptr<TestOverscrollDelegate> overscroll_delegate_;
347 332
348 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHost); 333 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHost);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 bool handle_wheel_event_called_; 575 bool handle_wheel_event_called_;
591 }; 576 };
592 577
593 // RenderWidgetHostTest -------------------------------------------------------- 578 // RenderWidgetHostTest --------------------------------------------------------
594 579
595 class RenderWidgetHostTest : public testing::Test { 580 class RenderWidgetHostTest : public testing::Test {
596 public: 581 public:
597 RenderWidgetHostTest() 582 RenderWidgetHostTest()
598 : process_(NULL), 583 : process_(NULL),
599 handle_key_press_event_(false), 584 handle_key_press_event_(false),
600 handle_mouse_event_(false), 585 handle_mouse_event_(false) {
601 simulated_event_time_delta_seconds_(0) {
602 last_simulated_event_time_seconds_ =
603 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
604 } 586 }
605 virtual ~RenderWidgetHostTest() { 587 virtual ~RenderWidgetHostTest() {
606 } 588 }
607 589
608 bool KeyPressEventCallback(const NativeWebKeyboardEvent& /* event */) { 590 bool KeyPressEventCallback(const NativeWebKeyboardEvent& /* event */) {
609 return handle_key_press_event_; 591 return handle_key_press_event_;
610 } 592 }
611 bool MouseEventCallback(const blink::WebMouseEvent& /* event */) { 593 bool MouseEventCallback(const blink::WebMouseEvent& /* event */) {
612 return handle_mouse_event_; 594 return handle_mouse_event_;
613 } 595 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 } 638 }
657 639
658 void SendInputEventACK(WebInputEvent::Type type, 640 void SendInputEventACK(WebInputEvent::Type type,
659 InputEventAckState ack_result) { 641 InputEventAckState ack_result) {
660 scoped_ptr<IPC::Message> response( 642 scoped_ptr<IPC::Message> response(
661 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result, 643 new InputHostMsg_HandleInputEvent_ACK(0, type, ack_result,
662 ui::LatencyInfo())); 644 ui::LatencyInfo()));
663 host_->OnMessageReceived(*response); 645 host_->OnMessageReceived(*response);
664 } 646 }
665 647
666 double GetNextSimulatedEventTimeSeconds() {
667 last_simulated_event_time_seconds_ += simulated_event_time_delta_seconds_;
668 return last_simulated_event_time_seconds_;
669 }
670
671 void SimulateKeyboardEvent(WebInputEvent::Type type) { 648 void SimulateKeyboardEvent(WebInputEvent::Type type) {
672 SimulateKeyboardEvent(type, 0); 649 WebKeyboardEvent event = SyntheticWebKeyboardEventBuilder::Build(type);
673 } 650 NativeWebKeyboardEvent native_event;
674 651 memcpy(&native_event, &event, sizeof(event));
675 void SimulateKeyboardEvent(WebInputEvent::Type type, int modifiers) {
676 WebKeyboardEvent event = SyntheticWebKeyboardEventBuilder::Build(type);
677 event.modifiers = modifiers;
678 NativeWebKeyboardEvent native_event;
679 memcpy(&native_event, &event, sizeof(event));
680 host_->ForwardKeyboardEvent(native_event); 652 host_->ForwardKeyboardEvent(native_event);
681 } 653 }
682 654
683 void SimulateMouseEvent(WebInputEvent::Type type) { 655 void SimulateMouseEvent(WebInputEvent::Type type) {
684 host_->ForwardMouseEvent(SyntheticWebMouseEventBuilder::Build(type)); 656 host_->ForwardMouseEvent(SyntheticWebMouseEventBuilder::Build(type));
685 } 657 }
686 658
687 void SimulateMouseEventWithLatencyInfo(WebInputEvent::Type type, 659 void SimulateMouseEventWithLatencyInfo(WebInputEvent::Type type,
688 const ui::LatencyInfo& ui_latency) { 660 const ui::LatencyInfo& ui_latency) {
689 host_->ForwardMouseEventWithLatencyInfo( 661 host_->ForwardMouseEventWithLatencyInfo(
(...skipping 10 matching lines...) Expand all
700 float dY, 672 float dY,
701 int modifiers, 673 int modifiers,
702 bool precise, 674 bool precise,
703 const ui::LatencyInfo& ui_latency) { 675 const ui::LatencyInfo& ui_latency) {
704 host_->ForwardWheelEventWithLatencyInfo( 676 host_->ForwardWheelEventWithLatencyInfo(
705 SyntheticWebMouseWheelEventBuilder::Build(dX, dY, modifiers, precise), 677 SyntheticWebMouseWheelEventBuilder::Build(dX, dY, modifiers, precise),
706 ui_latency); 678 ui_latency);
707 } 679 }
708 680
709 void SimulateMouseMove(int x, int y, int modifiers) { 681 void SimulateMouseMove(int x, int y, int modifiers) {
710 SimulateMouseEvent(WebInputEvent::MouseMove, x, y, modifiers, false); 682 host_->ForwardMouseEvent(
711 } 683 SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseMove,
712 684 x,
713 void SimulateMouseEvent( 685 y,
714 WebInputEvent::Type type, int x, int y, int modifiers, bool pressed) { 686 modifiers));
715 WebMouseEvent event =
716 SyntheticWebMouseEventBuilder::Build(type, x, y, modifiers);
717 if (pressed)
718 event.button = WebMouseEvent::ButtonLeft;
719 event.timeStampSeconds = GetNextSimulatedEventTimeSeconds();
720 host_->ForwardMouseEvent(event);
721 } 687 }
722 688
723 void SimulateWheelEventWithPhase(WebMouseWheelEvent::Phase phase) { 689 void SimulateWheelEventWithPhase(WebMouseWheelEvent::Phase phase) {
724 host_->ForwardWheelEvent(SyntheticWebMouseWheelEventBuilder::Build(phase)); 690 host_->ForwardWheelEvent(SyntheticWebMouseWheelEventBuilder::Build(phase));
725 } 691 }
726 692
727 // Inject provided synthetic WebGestureEvent instance. 693 // Inject provided synthetic WebGestureEvent instance.
728 void SimulateGestureEventCore(const WebGestureEvent& gesture_event) { 694 void SimulateGestureEventCore(const WebGestureEvent& gesture_event) {
729 host_->ForwardGestureEvent(gesture_event); 695 host_->ForwardGestureEvent(gesture_event);
730 } 696 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 base::MessageLoopForUI message_loop_; 781 base::MessageLoopForUI message_loop_;
816 782
817 scoped_ptr<TestBrowserContext> browser_context_; 783 scoped_ptr<TestBrowserContext> browser_context_;
818 RenderWidgetHostProcess* process_; // Deleted automatically by the widget. 784 RenderWidgetHostProcess* process_; // Deleted automatically by the widget.
819 scoped_ptr<MockRenderWidgetHostDelegate> delegate_; 785 scoped_ptr<MockRenderWidgetHostDelegate> delegate_;
820 scoped_ptr<MockRenderWidgetHost> host_; 786 scoped_ptr<MockRenderWidgetHost> host_;
821 scoped_ptr<TestView> view_; 787 scoped_ptr<TestView> view_;
822 scoped_ptr<gfx::Screen> screen_; 788 scoped_ptr<gfx::Screen> screen_;
823 bool handle_key_press_event_; 789 bool handle_key_press_event_;
824 bool handle_mouse_event_; 790 bool handle_mouse_event_;
825 double last_simulated_event_time_seconds_;
826 double simulated_event_time_delta_seconds_;
827 791
828 private: 792 private:
829 SyntheticWebTouchEvent touch_event_; 793 SyntheticWebTouchEvent touch_event_;
830 794
831 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); 795 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest);
832 }; 796 };
833 797
834 #if GTEST_HAS_PARAM_TEST 798 #if GTEST_HAS_PARAM_TEST
835 // RenderWidgetHostWithSourceTest ---------------------------------------------- 799 // RenderWidgetHostWithSourceTest ----------------------------------------------
836 800
(...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 2374 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
2411 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); 2375 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode());
2412 2376
2413 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 2377 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
2414 WebGestureEvent::Touchscreen); 2378 WebGestureEvent::Touchscreen);
2415 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 2379 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
2416 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); 2380 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode());
2417 process_->sink().ClearMessages(); 2381 process_->sink().ClearMessages();
2418 } 2382 }
2419 2383
2420 std::string GetInputMessageTypes(RenderWidgetHostProcess* process) {
2421 const WebInputEvent* event = NULL;
2422 ui::LatencyInfo latency_info;
2423 bool is_keyboard_shortcut;
2424 std::string result;
2425 for (size_t i = 0; i < process->sink().message_count(); ++i) {
2426 const IPC::Message *message = process->sink().GetMessageAt(i);
2427 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type());
2428 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(
2429 message, &event, &latency_info, &is_keyboard_shortcut));
2430 if (i != 0)
2431 result += " ";
2432 result += WebInputEventTraits::GetName(event->type);
2433 }
2434 process->sink().ClearMessages();
2435 return result;
2436 }
2437
2438 TEST_F(RenderWidgetHostTest, TouchEmulator) {
2439 simulated_event_time_delta_seconds_ = 0.1;
2440 host_->DisableGestureDebounce();
2441 // Immediately ack all touches instead of sending them to the renderer.
2442 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false));
2443 host_->OnMessageReceived(
2444 ViewHostMsg_SetTouchEventEmulationEnabled(0, true, true));
2445 process_->sink().ClearMessages();
2446 view_->set_bounds(gfx::Rect(0, 0, 400, 200));
2447 view_->Show();
2448
2449 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 10, 0, false);
2450 EXPECT_EQ(0U, process_->sink().message_count());
2451
2452 // Mouse press becomes touch start which in turn becomes tap.
2453 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true);
2454 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type());
2455 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_));
2456 SendInputEventACK(WebInputEvent::GestureTapDown,
2457 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2458
2459 // Mouse drag generates touch move, cancels tap and starts scroll.
2460 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true);
2461 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
2462 EXPECT_EQ(
2463 "GestureTapCancel GestureScrollBegin GestureScrollUpdate",
2464 GetInputMessageTypes(process_));
2465 SendInputEventACK(WebInputEvent::GestureTapCancel,
2466 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2467 SendInputEventACK(WebInputEvent::GestureScrollBegin,
2468 INPUT_EVENT_ACK_STATE_CONSUMED);
2469 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2470 INPUT_EVENT_ACK_STATE_CONSUMED);
2471 EXPECT_EQ(0U, process_->sink().message_count());
2472
2473 // Mouse drag with shift becomes pinch.
2474 SimulateMouseEvent(
2475 WebInputEvent::MouseMove, 10, 40, WebInputEvent::ShiftKey, true);
2476 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
2477 EXPECT_EQ("GesturePinchBegin",
2478 GetInputMessageTypes(process_));
2479 SendInputEventACK(WebInputEvent::GesturePinchBegin,
2480 INPUT_EVENT_ACK_STATE_CONSUMED);
2481 EXPECT_EQ(0U, process_->sink().message_count());
2482
2483 SimulateMouseEvent(
2484 WebInputEvent::MouseMove, 10, 50, WebInputEvent::ShiftKey, true);
2485 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
2486 EXPECT_EQ("GesturePinchUpdate",
2487 GetInputMessageTypes(process_));
2488 SendInputEventACK(WebInputEvent::GesturePinchUpdate,
2489 INPUT_EVENT_ACK_STATE_CONSUMED);
2490 EXPECT_EQ(0U, process_->sink().message_count());
2491
2492 // Mouse drag without shift becomes scroll again.
2493 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 60, 0, true);
2494 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
2495 EXPECT_EQ("GesturePinchEnd GestureScrollUpdate",
2496 GetInputMessageTypes(process_));
2497 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2498 INPUT_EVENT_ACK_STATE_CONSUMED);
2499 EXPECT_EQ(0U, process_->sink().message_count());
2500
2501 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 70, 0, true);
2502 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
2503 EXPECT_EQ("GestureScrollUpdate",
2504 GetInputMessageTypes(process_));
2505 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2506 INPUT_EVENT_ACK_STATE_CONSUMED);
2507 EXPECT_EQ(0U, process_->sink().message_count());
2508
2509 SimulateMouseEvent(WebInputEvent::MouseUp, 10, 70, 0, true);
2510 EXPECT_EQ(WebInputEvent::TouchEnd, host_->acked_touch_event_type());
2511 EXPECT_EQ("GestureScrollEnd", GetInputMessageTypes(process_));
2512 SendInputEventACK(WebInputEvent::GestureScrollEnd,
2513 INPUT_EVENT_ACK_STATE_CONSUMED);
2514 EXPECT_EQ(0U, process_->sink().message_count());
2515
2516 // Mouse move does nothing.
2517 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 80, 0, false);
2518 EXPECT_EQ(0U, process_->sink().message_count());
2519
2520 // Another mouse down continues scroll.
2521 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 80, 0, true);
2522 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type());
2523 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_));
2524 SendInputEventACK(WebInputEvent::GestureTapDown,
2525 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2526 EXPECT_EQ(0U, process_->sink().message_count());
2527
2528 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 100, 0, true);
2529 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
2530 EXPECT_EQ(
2531 "GestureTapCancel GestureScrollBegin GestureScrollUpdate",
2532 GetInputMessageTypes(process_));
2533 SendInputEventACK(WebInputEvent::GestureTapCancel,
2534 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2535 SendInputEventACK(WebInputEvent::GestureScrollBegin,
2536 INPUT_EVENT_ACK_STATE_CONSUMED);
2537 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2538 INPUT_EVENT_ACK_STATE_CONSUMED);
2539 EXPECT_EQ(0U, process_->sink().message_count());
2540
2541 // Another pinch.
2542 SimulateMouseEvent(
2543 WebInputEvent::MouseMove, 10, 110, WebInputEvent::ShiftKey, true);
2544 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
2545 EXPECT_EQ("GesturePinchBegin",
2546 GetInputMessageTypes(process_));
2547 SendInputEventACK(WebInputEvent::GesturePinchBegin,
2548 INPUT_EVENT_ACK_STATE_CONSUMED);
2549 EXPECT_EQ(0U, process_->sink().message_count());
2550
2551 SimulateMouseEvent(
2552 WebInputEvent::MouseMove, 10, 120, WebInputEvent::ShiftKey, true);
2553 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
2554 EXPECT_EQ("GesturePinchUpdate",
2555 GetInputMessageTypes(process_));
2556 SendInputEventACK(WebInputEvent::GesturePinchUpdate,
2557 INPUT_EVENT_ACK_STATE_CONSUMED);
2558 EXPECT_EQ(0U, process_->sink().message_count());
2559
2560 // Turn off emulation during a pinch.
2561 host_->OnMessageReceived(
2562 ViewHostMsg_SetTouchEventEmulationEnabled(0, false, false));
2563 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type());
2564 EXPECT_EQ("GesturePinchEnd GestureScrollEnd",
2565 GetInputMessageTypes(process_));
2566 SendInputEventACK(WebInputEvent::GesturePinchEnd,
2567 INPUT_EVENT_ACK_STATE_CONSUMED);
2568 SendInputEventACK(WebInputEvent::GestureScrollEnd,
2569 INPUT_EVENT_ACK_STATE_CONSUMED);
2570 EXPECT_EQ(0U, process_->sink().message_count());
2571
2572 // Mouse event should pass untouched.
2573 SimulateMouseEvent(
2574 WebInputEvent::MouseMove, 10, 10, WebInputEvent::ShiftKey, true);
2575 EXPECT_EQ("MouseMove", GetInputMessageTypes(process_));
2576 SendInputEventACK(WebInputEvent::MouseMove,
2577 INPUT_EVENT_ACK_STATE_CONSUMED);
2578 EXPECT_EQ(0U, process_->sink().message_count());
2579
2580 // Turn on emulation.
2581 host_->OnMessageReceived(
2582 ViewHostMsg_SetTouchEventEmulationEnabled(0, true, true));
2583 EXPECT_EQ(0U, process_->sink().message_count());
2584
2585 // Another touch.
2586 SimulateMouseEvent(WebInputEvent::MouseDown, 10, 10, 0, true);
2587 EXPECT_EQ(WebInputEvent::TouchStart, host_->acked_touch_event_type());
2588 EXPECT_EQ("GestureTapDown", GetInputMessageTypes(process_));
2589 SendInputEventACK(WebInputEvent::GestureTapDown,
2590 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2591 EXPECT_EQ(0U, process_->sink().message_count());
2592
2593 // Scroll.
2594 SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true);
2595 EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
2596 EXPECT_EQ(
2597 "GestureTapCancel GestureScrollBegin GestureScrollUpdate",
2598 GetInputMessageTypes(process_));
2599 SendInputEventACK(WebInputEvent::GestureTapCancel,
2600 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2601 SendInputEventACK(WebInputEvent::GestureScrollBegin,
2602 INPUT_EVENT_ACK_STATE_CONSUMED);
2603 SendInputEventACK(WebInputEvent::GestureScrollUpdate,
2604 INPUT_EVENT_ACK_STATE_CONSUMED);
2605
2606 // Turn off emulation during a scroll.
2607 host_->OnMessageReceived(
2608 ViewHostMsg_SetTouchEventEmulationEnabled(0, false, false));
2609 EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type());
2610
2611 EXPECT_EQ("GestureScrollEnd", GetInputMessageTypes(process_));
2612 SendInputEventACK(WebInputEvent::GestureScrollEnd,
2613 INPUT_EVENT_ACK_STATE_CONSUMED);
2614 EXPECT_EQ(0U, process_->sink().message_count());
2615 }
2616
2617 #define TEST_InputRouterRoutes_NOARGS(INPUTMSG) \ 2384 #define TEST_InputRouterRoutes_NOARGS(INPUTMSG) \
2618 TEST_F(RenderWidgetHostTest, InputRouterRoutes##INPUTMSG) { \ 2385 TEST_F(RenderWidgetHostTest, InputRouterRoutes##INPUTMSG) { \
2619 host_->SetupForInputRouterTest(); \ 2386 host_->SetupForInputRouterTest(); \
2620 host_->INPUTMSG(); \ 2387 host_->INPUTMSG(); \
2621 EXPECT_TRUE(host_->mock_input_router()->send_event_called_); \ 2388 EXPECT_TRUE(host_->mock_input_router()->send_event_called_); \
2622 } 2389 }
2623 2390
2624 TEST_InputRouterRoutes_NOARGS(Focus); 2391 TEST_InputRouterRoutes_NOARGS(Focus);
2625 TEST_InputRouterRoutes_NOARGS(Blur); 2392 TEST_InputRouterRoutes_NOARGS(Blur);
2626 TEST_InputRouterRoutes_NOARGS(LostCapture); 2393 TEST_InputRouterRoutes_NOARGS(LostCapture);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2847 2614
2848 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). 2615 // Tests RWHI::ForwardTouchEventWithLatencyInfo().
2849 PressTouchPoint(0, 1); 2616 PressTouchPoint(0, 1);
2850 SendTouchEvent(); 2617 SendTouchEvent();
2851 CheckLatencyInfoComponentInMessage( 2618 CheckLatencyInfoComponentInMessage(
2852 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); 2619 process_, GetLatencyComponentId(), WebInputEvent::TouchStart);
2853 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); 2620 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED);
2854 } 2621 }
2855 2622
2856 } // namespace content 2623 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698