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 21 matching lines...) Expand all Loading... |
32 #include "content/browser/compositor/image_transport_factory.h" | 32 #include "content/browser/compositor/image_transport_factory.h" |
33 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 33 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
34 #include "content/browser/renderer_host/ui_events_helper.h" | 34 #include "content/browser/renderer_host/ui_events_helper.h" |
35 #include "ui/aura/env.h" | 35 #include "ui/aura/env.h" |
36 #include "ui/aura/test/test_screen.h" | 36 #include "ui/aura/test/test_screen.h" |
37 #include "ui/compositor/test/in_process_context_factory.h" | 37 #include "ui/compositor/test/in_process_context_factory.h" |
38 #include "ui/events/event.h" | 38 #include "ui/events/event.h" |
39 #endif | 39 #endif |
40 | 40 |
41 using base::TimeDelta; | 41 using base::TimeDelta; |
| 42 using blink::WebGestureDevice; |
42 using blink::WebGestureEvent; | 43 using blink::WebGestureEvent; |
43 using blink::WebInputEvent; | 44 using blink::WebInputEvent; |
44 using blink::WebKeyboardEvent; | 45 using blink::WebKeyboardEvent; |
45 using blink::WebMouseEvent; | 46 using blink::WebMouseEvent; |
46 using blink::WebMouseWheelEvent; | 47 using blink::WebMouseWheelEvent; |
47 using blink::WebTouchEvent; | 48 using blink::WebTouchEvent; |
48 using blink::WebTouchPoint; | 49 using blink::WebTouchPoint; |
49 | 50 |
50 namespace content { | 51 namespace content { |
51 | 52 |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 WebMouseEvent event = | 545 WebMouseEvent event = |
545 SyntheticWebMouseEventBuilder::Build(type, x, y, modifiers); | 546 SyntheticWebMouseEventBuilder::Build(type, x, y, modifiers); |
546 if (pressed) | 547 if (pressed) |
547 event.button = WebMouseEvent::ButtonLeft; | 548 event.button = WebMouseEvent::ButtonLeft; |
548 event.timeStampSeconds = GetNextSimulatedEventTimeSeconds(); | 549 event.timeStampSeconds = GetNextSimulatedEventTimeSeconds(); |
549 host_->ForwardMouseEvent(event); | 550 host_->ForwardMouseEvent(event); |
550 } | 551 } |
551 | 552 |
552 // Inject simple synthetic WebGestureEvent instances. | 553 // Inject simple synthetic WebGestureEvent instances. |
553 void SimulateGestureEvent(WebInputEvent::Type type, | 554 void SimulateGestureEvent(WebInputEvent::Type type, |
554 WebGestureEvent::SourceDevice sourceDevice) { | 555 WebGestureDevice sourceDevice) { |
555 host_->ForwardGestureEvent( | 556 host_->ForwardGestureEvent( |
556 SyntheticWebGestureEventBuilder::Build(type, sourceDevice)); | 557 SyntheticWebGestureEventBuilder::Build(type, sourceDevice)); |
557 } | 558 } |
558 | 559 |
559 void SimulateGestureEventWithLatencyInfo( | 560 void SimulateGestureEventWithLatencyInfo(WebInputEvent::Type type, |
560 WebInputEvent::Type type, | 561 WebGestureDevice sourceDevice, |
561 WebGestureEvent::SourceDevice sourceDevice, | 562 const ui::LatencyInfo& ui_latency) { |
562 const ui::LatencyInfo& ui_latency) { | |
563 host_->ForwardGestureEventWithLatencyInfo( | 563 host_->ForwardGestureEventWithLatencyInfo( |
564 SyntheticWebGestureEventBuilder::Build(type, sourceDevice), | 564 SyntheticWebGestureEventBuilder::Build(type, sourceDevice), |
565 ui_latency); | 565 ui_latency); |
566 } | 566 } |
567 | 567 |
568 // Set the timestamp for the touch-event. | 568 // Set the timestamp for the touch-event. |
569 void SetTouchTimestamp(base::TimeDelta timestamp) { | 569 void SetTouchTimestamp(base::TimeDelta timestamp) { |
570 touch_event_.SetTimestamp(timestamp); | 570 touch_event_.SetTimestamp(timestamp); |
571 } | 571 } |
572 | 572 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 | 617 |
618 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); | 618 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest); |
619 }; | 619 }; |
620 | 620 |
621 #if GTEST_HAS_PARAM_TEST | 621 #if GTEST_HAS_PARAM_TEST |
622 // RenderWidgetHostWithSourceTest ---------------------------------------------- | 622 // RenderWidgetHostWithSourceTest ---------------------------------------------- |
623 | 623 |
624 // This is for tests that are to be run for all source devices. | 624 // This is for tests that are to be run for all source devices. |
625 class RenderWidgetHostWithSourceTest | 625 class RenderWidgetHostWithSourceTest |
626 : public RenderWidgetHostTest, | 626 : public RenderWidgetHostTest, |
627 public testing::WithParamInterface<WebGestureEvent::SourceDevice> { | 627 public testing::WithParamInterface<WebGestureDevice> {}; |
628 }; | |
629 #endif // GTEST_HAS_PARAM_TEST | 628 #endif // GTEST_HAS_PARAM_TEST |
630 | 629 |
631 } // namespace | 630 } // namespace |
632 | 631 |
633 // ----------------------------------------------------------------------------- | 632 // ----------------------------------------------------------------------------- |
634 | 633 |
635 TEST_F(RenderWidgetHostTest, Resize) { | 634 TEST_F(RenderWidgetHostTest, Resize) { |
636 // The initial bounds is the empty rect, and the screen info hasn't been sent | 635 // The initial bounds is the empty rect, and the screen info hasn't been sent |
637 // yet, so setting it to the same thing shouldn't send the resize message. | 636 // yet, so setting it to the same thing shouldn't send the resize message. |
638 view_->set_bounds(gfx::Rect()); | 637 view_->set_bounds(gfx::Rect()); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 | 915 |
917 // ensure the wheel event handler was invoked | 916 // ensure the wheel event handler was invoked |
918 EXPECT_TRUE(delegate_->handle_wheel_event_called()); | 917 EXPECT_TRUE(delegate_->handle_wheel_event_called()); |
919 | 918 |
920 // and that it suppressed the unhandled wheel event handler. | 919 // and that it suppressed the unhandled wheel event handler. |
921 EXPECT_EQ(0, view_->unhandled_wheel_event_count()); | 920 EXPECT_EQ(0, view_->unhandled_wheel_event_count()); |
922 } | 921 } |
923 | 922 |
924 TEST_F(RenderWidgetHostTest, UnhandledGestureEvent) { | 923 TEST_F(RenderWidgetHostTest, UnhandledGestureEvent) { |
925 SimulateGestureEvent(WebInputEvent::GestureTwoFingerTap, | 924 SimulateGestureEvent(WebInputEvent::GestureTwoFingerTap, |
926 WebGestureEvent::Touchscreen); | 925 blink::WebGestureDeviceTouchscreen); |
927 | 926 |
928 // Make sure we sent the input event to the renderer. | 927 // Make sure we sent the input event to the renderer. |
929 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( | 928 EXPECT_TRUE(process_->sink().GetUniqueMessageMatching( |
930 InputMsg_HandleInputEvent::ID)); | 929 InputMsg_HandleInputEvent::ID)); |
931 process_->sink().ClearMessages(); | 930 process_->sink().ClearMessages(); |
932 | 931 |
933 // Send the simulated response from the renderer back. | 932 // Send the simulated response from the renderer back. |
934 SendInputEventACK(WebInputEvent::GestureTwoFingerTap, | 933 SendInputEventACK(WebInputEvent::GestureTwoFingerTap, |
935 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 934 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
936 EXPECT_EQ(WebInputEvent::GestureTwoFingerTap, view_->gesture_event_type()); | 935 EXPECT_EQ(WebInputEvent::GestureTwoFingerTap, view_->gesture_event_type()); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); | 1237 SimulateKeyboardEvent(WebInputEvent::RawKeyDown); |
1239 EXPECT_FALSE(host_->mock_input_router()->sent_keyboard_event_); | 1238 EXPECT_FALSE(host_->mock_input_router()->sent_keyboard_event_); |
1240 | 1239 |
1241 SimulateMouseEvent(WebInputEvent::MouseMove); | 1240 SimulateMouseEvent(WebInputEvent::MouseMove); |
1242 EXPECT_FALSE(host_->mock_input_router()->sent_mouse_event_); | 1241 EXPECT_FALSE(host_->mock_input_router()->sent_mouse_event_); |
1243 | 1242 |
1244 SimulateWheelEvent(0, 100, 0, true); | 1243 SimulateWheelEvent(0, 100, 0, true); |
1245 EXPECT_FALSE(host_->mock_input_router()->sent_wheel_event_); | 1244 EXPECT_FALSE(host_->mock_input_router()->sent_wheel_event_); |
1246 | 1245 |
1247 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1246 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
1248 WebGestureEvent::Touchscreen); | 1247 blink::WebGestureDeviceTouchpad); |
1249 EXPECT_FALSE(host_->mock_input_router()->sent_gesture_event_); | 1248 EXPECT_FALSE(host_->mock_input_router()->sent_gesture_event_); |
1250 | 1249 |
1251 PressTouchPoint(100, 100); | 1250 PressTouchPoint(100, 100); |
1252 SendTouchEvent(); | 1251 SendTouchEvent(); |
1253 EXPECT_FALSE(host_->mock_input_router()->send_touch_event_not_cancelled_); | 1252 EXPECT_FALSE(host_->mock_input_router()->send_touch_event_not_cancelled_); |
1254 } | 1253 } |
1255 | 1254 |
1256 TEST_F(RenderWidgetHostTest, KeyboardListenerIgnoresEvent) { | 1255 TEST_F(RenderWidgetHostTest, KeyboardListenerIgnoresEvent) { |
1257 host_->SetupForInputRouterTest(); | 1256 host_->SetupForInputRouterTest(); |
1258 host_->AddKeyPressEventCallback( | 1257 host_->AddKeyPressEventCallback( |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 | 1388 |
1390 // Tests RWHI::ForwardMouseEventWithLatencyInfo(). | 1389 // Tests RWHI::ForwardMouseEventWithLatencyInfo(). |
1391 SimulateMouseEventWithLatencyInfo(WebInputEvent::MouseMove, | 1390 SimulateMouseEventWithLatencyInfo(WebInputEvent::MouseMove, |
1392 ui::LatencyInfo()); | 1391 ui::LatencyInfo()); |
1393 CheckLatencyInfoComponentInMessage( | 1392 CheckLatencyInfoComponentInMessage( |
1394 process_, GetLatencyComponentId(), WebInputEvent::MouseMove); | 1393 process_, GetLatencyComponentId(), WebInputEvent::MouseMove); |
1395 SendInputEventACK(WebInputEvent::MouseMove, INPUT_EVENT_ACK_STATE_CONSUMED); | 1394 SendInputEventACK(WebInputEvent::MouseMove, INPUT_EVENT_ACK_STATE_CONSUMED); |
1396 | 1395 |
1397 // Tests RWHI::ForwardGestureEvent(). | 1396 // Tests RWHI::ForwardGestureEvent(). |
1398 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 1397 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
1399 WebGestureEvent::Touchscreen); | 1398 blink::WebGestureDeviceTouchscreen); |
1400 CheckLatencyInfoComponentInMessage( | 1399 CheckLatencyInfoComponentInMessage( |
1401 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollBegin); | 1400 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollBegin); |
1402 | 1401 |
1403 // Tests RWHI::ForwardGestureEventWithLatencyInfo(). | 1402 // Tests RWHI::ForwardGestureEventWithLatencyInfo(). |
1404 SimulateGestureEventWithLatencyInfo(WebInputEvent::GestureScrollUpdate, | 1403 SimulateGestureEventWithLatencyInfo(WebInputEvent::GestureScrollUpdate, |
1405 WebGestureEvent::Touchscreen, | 1404 blink::WebGestureDeviceTouchscreen, |
1406 ui::LatencyInfo()); | 1405 ui::LatencyInfo()); |
1407 CheckLatencyInfoComponentInMessage( | 1406 CheckLatencyInfoComponentInMessage( |
1408 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollUpdate); | 1407 process_, GetLatencyComponentId(), WebInputEvent::GestureScrollUpdate); |
1409 SendInputEventACK(WebInputEvent::GestureScrollUpdate, | 1408 SendInputEventACK(WebInputEvent::GestureScrollUpdate, |
1410 INPUT_EVENT_ACK_STATE_CONSUMED); | 1409 INPUT_EVENT_ACK_STATE_CONSUMED); |
1411 | 1410 |
1412 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). | 1411 // Tests RWHI::ForwardTouchEventWithLatencyInfo(). |
1413 PressTouchPoint(0, 1); | 1412 PressTouchPoint(0, 1); |
1414 SendTouchEvent(); | 1413 SendTouchEvent(); |
1415 CheckLatencyInfoComponentInMessage( | 1414 CheckLatencyInfoComponentInMessage( |
1416 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); | 1415 process_, GetLatencyComponentId(), WebInputEvent::TouchStart); |
1417 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); | 1416 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); |
1418 } | 1417 } |
1419 | 1418 |
1420 } // namespace content | 1419 } // namespace content |
OLD | NEW |