| 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 "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #include "base/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( | 710 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( |
| 711 &delegate, process_host, MSG_ROUTING_NONE); | 711 &delegate, process_host, MSG_ROUTING_NONE); |
| 712 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host); | 712 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host); |
| 713 | 713 |
| 714 // Send an initial wheel event with NSEventPhaseBegan to the view. | 714 // Send an initial wheel event with NSEventPhaseBegan to the view. |
| 715 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0); | 715 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0); |
| 716 [view->cocoa_view() scrollWheel:event1]; | 716 [view->cocoa_view() scrollWheel:event1]; |
| 717 ASSERT_EQ(1U, process_host->sink().message_count()); | 717 ASSERT_EQ(1U, process_host->sink().message_count()); |
| 718 | 718 |
| 719 // Send an ACK for the first wheel event, so that the queue will be flushed. | 719 // Send an ACK for the first wheel event, so that the queue will be flushed. |
| 720 scoped_ptr<IPC::Message> response(new InputHostMsg_HandleInputEvent_ACK( | 720 InputHostMsg_HandleInputEvent_ACK_Params ack; |
| 721 0, blink::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED, | 721 ack.type = blink::WebInputEvent::MouseWheel; |
| 722 ui::LatencyInfo())); | 722 ack.state = INPUT_EVENT_ACK_STATE_CONSUMED; |
| 723 scoped_ptr<IPC::Message> response( |
| 724 new InputHostMsg_HandleInputEvent_ACK(0, ack)); |
| 723 host->OnMessageReceived(*response); | 725 host->OnMessageReceived(*response); |
| 724 | 726 |
| 725 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the | 727 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the |
| 726 // render view receives it. | 728 // render view receives it. |
| 727 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); | 729 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); |
| 728 [NSApp postEvent:event2 atStart:NO]; | 730 [NSApp postEvent:event2 atStart:NO]; |
| 729 base::MessageLoop::current()->RunUntilIdle(); | 731 base::MessageLoop::current()->RunUntilIdle(); |
| 730 ASSERT_EQ(2U, process_host->sink().message_count()); | 732 ASSERT_EQ(2U, process_host->sink().message_count()); |
| 731 | 733 |
| 732 // Clean up. | 734 // Clean up. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 754 [[MockRenderWidgetHostViewMacDelegate alloc] init]); | 756 [[MockRenderWidgetHostViewMacDelegate alloc] init]); |
| 755 view->SetDelegate(view_delegate.get()); | 757 view->SetDelegate(view_delegate.get()); |
| 756 | 758 |
| 757 // Send an initial wheel event for scrolling by 3 lines. | 759 // Send an initial wheel event for scrolling by 3 lines. |
| 758 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3); | 760 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3); |
| 759 [view->cocoa_view() scrollWheel:event1]; | 761 [view->cocoa_view() scrollWheel:event1]; |
| 760 ASSERT_EQ(1U, process_host->sink().message_count()); | 762 ASSERT_EQ(1U, process_host->sink().message_count()); |
| 761 process_host->sink().ClearMessages(); | 763 process_host->sink().ClearMessages(); |
| 762 | 764 |
| 763 // Indicate that the wheel event was unhandled. | 765 // Indicate that the wheel event was unhandled. |
| 764 scoped_ptr<IPC::Message> response1(new InputHostMsg_HandleInputEvent_ACK(0, | 766 InputHostMsg_HandleInputEvent_ACK_Params unhandled_ack; |
| 765 blink::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED, | 767 unhandled_ack.type = blink::WebInputEvent::MouseWheel; |
| 766 ui::LatencyInfo())); | 768 unhandled_ack.state = INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 769 scoped_ptr<IPC::Message> response1( |
| 770 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); |
| 767 host->OnMessageReceived(*response1); | 771 host->OnMessageReceived(*response1); |
| 768 | 772 |
| 769 // Check that the view delegate got an unhandled wheel event. | 773 // Check that the view delegate got an unhandled wheel event. |
| 770 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived); | 774 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived); |
| 771 view_delegate.get().unhandledWheelEventReceived = NO; | 775 view_delegate.get().unhandledWheelEventReceived = NO; |
| 772 | 776 |
| 773 // Send another wheel event, this time for scrolling by 0 lines (empty event). | 777 // Send another wheel event, this time for scrolling by 0 lines (empty event). |
| 774 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0); | 778 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0); |
| 775 [view->cocoa_view() scrollWheel:event2]; | 779 [view->cocoa_view() scrollWheel:event2]; |
| 776 ASSERT_EQ(1U, process_host->sink().message_count()); | 780 ASSERT_EQ(1U, process_host->sink().message_count()); |
| 777 | 781 |
| 778 // Indicate that the wheel event was also unhandled. | 782 // Indicate that the wheel event was also unhandled. |
| 779 scoped_ptr<IPC::Message> response2(new InputHostMsg_HandleInputEvent_ACK(0, | 783 scoped_ptr<IPC::Message> response2( |
| 780 blink::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED, | 784 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); |
| 781 ui::LatencyInfo())); | |
| 782 host->OnMessageReceived(*response2); | 785 host->OnMessageReceived(*response2); |
| 783 | 786 |
| 784 // Check that the view delegate ignored the empty unhandled wheel event. | 787 // Check that the view delegate ignored the empty unhandled wheel event. |
| 785 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived); | 788 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived); |
| 786 | 789 |
| 787 // Clean up. | 790 // Clean up. |
| 788 host->Shutdown(); | 791 host->Shutdown(); |
| 789 } | 792 } |
| 790 | 793 |
| 791 } // namespace content | 794 } // namespace content |
| OLD | NEW |