| 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 | 10 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 @implementation MockRenderWidgetHostViewMacDelegate | 73 @implementation MockRenderWidgetHostViewMacDelegate |
| 74 | 74 |
| 75 @synthesize unhandledWheelEventReceived = unhandledWheelEventReceived_; | 75 @synthesize unhandledWheelEventReceived = unhandledWheelEventReceived_; |
| 76 | 76 |
| 77 - (void)rendererHandledWheelEvent:(const blink::WebMouseWheelEvent&)event | 77 - (void)rendererHandledWheelEvent:(const blink::WebMouseWheelEvent&)event |
| 78 consumed:(BOOL)consumed { | 78 consumed:(BOOL)consumed { |
| 79 if (!consumed) | 79 if (!consumed) |
| 80 unhandledWheelEventReceived_ = true; | 80 unhandledWheelEventReceived_ = true; |
| 81 } | 81 } |
| 82 - (void)rendererHandledGestureScrollEvent:(const blink::WebGestureEvent&)event |
| 83 consumed:(BOOL)consumed { |
| 84 if (!consumed && event.type == blink::WebInputEvent::GestureScrollUpdate) |
| 85 unhandledWheelEventReceived_ = true; |
| 86 } |
| 82 - (void)touchesBeganWithEvent:(NSEvent*)event {} | 87 - (void)touchesBeganWithEvent:(NSEvent*)event {} |
| 83 - (void)touchesMovedWithEvent:(NSEvent*)event {} | 88 - (void)touchesMovedWithEvent:(NSEvent*)event {} |
| 84 - (void)touchesCancelledWithEvent:(NSEvent*)event {} | 89 - (void)touchesCancelledWithEvent:(NSEvent*)event {} |
| 85 - (void)touchesEndedWithEvent:(NSEvent*)event {} | 90 - (void)touchesEndedWithEvent:(NSEvent*)event {} |
| 86 - (void)beginGestureWithEvent:(NSEvent*)event {} | 91 - (void)beginGestureWithEvent:(NSEvent*)event {} |
| 87 - (void)endGestureWithEvent:(NSEvent*)event {} | 92 - (void)endGestureWithEvent:(NSEvent*)event {} |
| 88 - (BOOL)canRubberbandLeft:(NSView*)view { | 93 - (BOOL)canRubberbandLeft:(NSView*)view { |
| 89 return true; | 94 return true; |
| 90 } | 95 } |
| 91 - (BOOL)canRubberbandRight:(NSView*)view { | 96 - (BOOL)canRubberbandRight:(NSView*)view { |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 | 956 |
| 952 // Indicate that the wheel event was unhandled. | 957 // Indicate that the wheel event was unhandled. |
| 953 InputEventAck unhandled_ack(blink::WebInputEvent::MouseWheel, | 958 InputEventAck unhandled_ack(blink::WebInputEvent::MouseWheel, |
| 954 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 959 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 955 scoped_ptr<IPC::Message> response1( | 960 scoped_ptr<IPC::Message> response1( |
| 956 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); | 961 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); |
| 957 host->OnMessageReceived(*response1); | 962 host->OnMessageReceived(*response1); |
| 958 ASSERT_EQ(2U, process_host->sink().message_count()); | 963 ASSERT_EQ(2U, process_host->sink().message_count()); |
| 959 process_host->sink().ClearMessages(); | 964 process_host->sink().ClearMessages(); |
| 960 | 965 |
| 966 InputEventAck unhandled_scroll_ack(blink::WebInputEvent::GestureScrollUpdate, |
| 967 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 968 scoped_ptr<IPC::Message> scroll_response1( |
| 969 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_scroll_ack)); |
| 970 host->OnMessageReceived(*scroll_response1); |
| 971 |
| 961 // Check that the view delegate got an unhandled wheel event. | 972 // Check that the view delegate got an unhandled wheel event. |
| 962 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived); | 973 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived); |
| 963 view_delegate.get().unhandledWheelEventReceived = NO; | 974 view_delegate.get().unhandledWheelEventReceived = NO; |
| 964 | 975 |
| 965 // Send another wheel event, this time for scrolling by 0 lines (empty event). | 976 // Send another wheel event, this time for scrolling by 0 lines (empty event). |
| 966 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0); | 977 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0); |
| 967 [view->cocoa_view() scrollWheel:event2]; | 978 [view->cocoa_view() scrollWheel:event2]; |
| 968 ASSERT_EQ(1U, process_host->sink().message_count()); | 979 ASSERT_EQ(2U, process_host->sink().message_count()); |
| 969 | 980 |
| 970 // Indicate that the wheel event was also unhandled. | 981 // Indicate that the wheel event was also unhandled. |
| 971 scoped_ptr<IPC::Message> response2( | 982 scoped_ptr<IPC::Message> response2( |
| 972 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); | 983 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); |
| 973 host->OnMessageReceived(*response2); | 984 host->OnMessageReceived(*response2); |
| 974 | 985 |
| 975 // Check that the view delegate ignored the empty unhandled wheel event. | 986 // Check that the view delegate ignored the empty unhandled wheel event. |
| 976 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived); | 987 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived); |
| 977 | 988 |
| 978 // Clean up. | 989 // Clean up. |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 EXPECT_EQ(1U, process_host_->sink().message_count()); | 1226 EXPECT_EQ(1U, process_host_->sink().message_count()); |
| 1216 process_host_->sink().ClearMessages(); | 1227 process_host_->sink().ClearMessages(); |
| 1217 } | 1228 } |
| 1218 | 1229 |
| 1219 // Clean up. | 1230 // Clean up. |
| 1220 host->ShutdownAndDestroyWidget(true); | 1231 host->ShutdownAndDestroyWidget(true); |
| 1221 } | 1232 } |
| 1222 | 1233 |
| 1223 | 1234 |
| 1224 } // namespace content | 1235 } // namespace content |
| OLD | NEW |