| 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_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #include <Cocoa/Cocoa.h> | 7 #include <Cocoa/Cocoa.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 // Send an initial wheel event with NSEventPhaseBegan to the view. | 947 // Send an initial wheel event with NSEventPhaseBegan to the view. |
| 948 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0); | 948 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0); |
| 949 [view->cocoa_view() scrollWheel:event1]; | 949 [view->cocoa_view() scrollWheel:event1]; |
| 950 ASSERT_EQ(1U, process_host->sink().message_count()); | 950 ASSERT_EQ(1U, process_host->sink().message_count()); |
| 951 | 951 |
| 952 // Flush and clear other messages (e.g. begin frames) the RWHVMac also sends. | 952 // Flush and clear other messages (e.g. begin frames) the RWHVMac also sends. |
| 953 base::RunLoop().RunUntilIdle(); | 953 base::RunLoop().RunUntilIdle(); |
| 954 process_host->sink().ClearMessages(); | 954 process_host->sink().ClearMessages(); |
| 955 | 955 |
| 956 // Send an ACK for the first wheel event, so that the queue will be flushed. | 956 // Send an ACK for the first wheel event, so that the queue will be flushed. |
| 957 InputEventAck ack(blink::WebInputEvent::MouseWheel, | 957 InputEventAck ack(InputEventAckSource::COMPOSITOR_THREAD, |
| 958 blink::WebInputEvent::MouseWheel, |
| 958 INPUT_EVENT_ACK_STATE_CONSUMED); | 959 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 959 std::unique_ptr<IPC::Message> response( | 960 std::unique_ptr<IPC::Message> response( |
| 960 new InputHostMsg_HandleInputEvent_ACK(0, ack)); | 961 new InputHostMsg_HandleInputEvent_ACK(0, ack)); |
| 961 host->OnMessageReceived(*response); | 962 host->OnMessageReceived(*response); |
| 962 | 963 |
| 963 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the | 964 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the |
| 964 // render view receives it. | 965 // render view receives it. |
| 965 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); | 966 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); |
| 966 [NSApp postEvent:event2 atStart:NO]; | 967 [NSApp postEvent:event2 atStart:NO]; |
| 967 base::RunLoop().RunUntilIdle(); | 968 base::RunLoop().RunUntilIdle(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 992 [[MockRenderWidgetHostViewMacDelegate alloc] init]); | 993 [[MockRenderWidgetHostViewMacDelegate alloc] init]); |
| 993 view->SetDelegate(view_delegate.get()); | 994 view->SetDelegate(view_delegate.get()); |
| 994 | 995 |
| 995 // Send an initial wheel event for scrolling by 3 lines. | 996 // Send an initial wheel event for scrolling by 3 lines. |
| 996 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3); | 997 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3); |
| 997 [view->cocoa_view() scrollWheel:event1]; | 998 [view->cocoa_view() scrollWheel:event1]; |
| 998 ASSERT_EQ(1U, process_host->sink().message_count()); | 999 ASSERT_EQ(1U, process_host->sink().message_count()); |
| 999 process_host->sink().ClearMessages(); | 1000 process_host->sink().ClearMessages(); |
| 1000 | 1001 |
| 1001 // Indicate that the wheel event was unhandled. | 1002 // Indicate that the wheel event was unhandled. |
| 1002 InputEventAck unhandled_ack(blink::WebInputEvent::MouseWheel, | 1003 InputEventAck unhandled_ack(InputEventAckSource::COMPOSITOR_THREAD, |
| 1004 blink::WebInputEvent::MouseWheel, |
| 1003 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1005 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1004 std::unique_ptr<IPC::Message> response1( | 1006 std::unique_ptr<IPC::Message> response1( |
| 1005 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); | 1007 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); |
| 1006 host->OnMessageReceived(*response1); | 1008 host->OnMessageReceived(*response1); |
| 1007 ASSERT_EQ(2U, process_host->sink().message_count()); | 1009 ASSERT_EQ(2U, process_host->sink().message_count()); |
| 1008 process_host->sink().ClearMessages(); | 1010 process_host->sink().ClearMessages(); |
| 1009 | 1011 |
| 1010 InputEventAck unhandled_scroll_ack(blink::WebInputEvent::GestureScrollUpdate, | 1012 InputEventAck unhandled_scroll_ack(InputEventAckSource::COMPOSITOR_THREAD, |
| 1013 blink::WebInputEvent::GestureScrollUpdate, |
| 1011 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1014 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 1012 std::unique_ptr<IPC::Message> scroll_response1( | 1015 std::unique_ptr<IPC::Message> scroll_response1( |
| 1013 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_scroll_ack)); | 1016 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_scroll_ack)); |
| 1014 host->OnMessageReceived(*scroll_response1); | 1017 host->OnMessageReceived(*scroll_response1); |
| 1015 | 1018 |
| 1016 // Check that the view delegate got an unhandled wheel event. | 1019 // Check that the view delegate got an unhandled wheel event. |
| 1017 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived); | 1020 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived); |
| 1018 view_delegate.get().unhandledWheelEventReceived = NO; | 1021 view_delegate.get().unhandledWheelEventReceived = NO; |
| 1019 | 1022 |
| 1020 // Send another wheel event, this time for scrolling by 0 lines (empty event). | 1023 // Send another wheel event, this time for scrolling by 0 lines (empty event). |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 process_host_ = new MockRenderProcessHost(&browser_context); | 1164 process_host_ = new MockRenderProcessHost(&browser_context); |
| 1162 process_host_->Init(); | 1165 process_host_->Init(); |
| 1163 MockRenderWidgetHostDelegate delegate; | 1166 MockRenderWidgetHostDelegate delegate; |
| 1164 int32_t routing_id = process_host_->GetNextRoutingID(); | 1167 int32_t routing_id = process_host_->GetNextRoutingID(); |
| 1165 MockRenderWidgetHostImpl* host = | 1168 MockRenderWidgetHostImpl* host = |
| 1166 new MockRenderWidgetHostImpl(&delegate, process_host_, routing_id); | 1169 new MockRenderWidgetHostImpl(&delegate, process_host_, routing_id); |
| 1167 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); | 1170 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); |
| 1168 process_host_->sink().ClearMessages(); | 1171 process_host_->sink().ClearMessages(); |
| 1169 | 1172 |
| 1170 // We'll use this IPC message to ack events. | 1173 // We'll use this IPC message to ack events. |
| 1171 InputEventAck ack(blink::WebInputEvent::GesturePinchUpdate, | 1174 InputEventAck ack(InputEventAckSource::COMPOSITOR_THREAD, |
| 1175 blink::WebInputEvent::GesturePinchUpdate, |
| 1172 INPUT_EVENT_ACK_STATE_CONSUMED); | 1176 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1173 std::unique_ptr<IPC::Message> response( | 1177 std::unique_ptr<IPC::Message> response( |
| 1174 new InputHostMsg_HandleInputEvent_ACK(0, ack)); | 1178 new InputHostMsg_HandleInputEvent_ACK(0, ack)); |
| 1175 | 1179 |
| 1176 // Do a gesture that crosses the threshold. | 1180 // Do a gesture that crosses the threshold. |
| 1177 { | 1181 { |
| 1178 NSEvent* pinchBeginEvent = | 1182 NSEvent* pinchBeginEvent = |
| 1179 MockGestureEvent(NSEventTypeBeginGesture, 0); | 1183 MockGestureEvent(NSEventTypeBeginGesture, 0); |
| 1180 NSEvent* pinchUpdateEvents[3] = { | 1184 NSEvent* pinchUpdateEvents[3] = { |
| 1181 MockGestureEvent(NSEventTypeMagnify, 0.25), | 1185 MockGestureEvent(NSEventTypeMagnify, 0.25), |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 // Verify that this IPC is asking for no monitoring or immediate updates. | 1582 // Verify that this IPC is asking for no monitoring or immediate updates. |
| 1579 InputMsg_RequestCompositionUpdate::Read(composition_request_msg_for_child, | 1583 InputMsg_RequestCompositionUpdate::Read(composition_request_msg_for_child, |
| 1580 &child_msg_params); | 1584 &child_msg_params); |
| 1581 is_child_msg_for_immediate_request = std::get<0>(child_msg_params); | 1585 is_child_msg_for_immediate_request = std::get<0>(child_msg_params); |
| 1582 is_child_msg_for_monitor_request = std::get<1>(child_msg_params); | 1586 is_child_msg_for_monitor_request = std::get<1>(child_msg_params); |
| 1583 EXPECT_FALSE(is_child_msg_for_immediate_request); | 1587 EXPECT_FALSE(is_child_msg_for_immediate_request); |
| 1584 EXPECT_FALSE(is_child_msg_for_monitor_request); | 1588 EXPECT_FALSE(is_child_msg_for_monitor_request); |
| 1585 } | 1589 } |
| 1586 | 1590 |
| 1587 } // namespace content | 1591 } // namespace content |
| OLD | NEW |