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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac_unittest.mm

Issue 997283002: Coalesce async touch move events until the ack back from render (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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 "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 8
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #include "base/mac/scoped_nsautorelease_pool.h" 10 #include "base/mac/scoped_nsautorelease_pool.h"
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( 703 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl(
704 &delegate, process_host, MSG_ROUTING_NONE); 704 &delegate, process_host, MSG_ROUTING_NONE);
705 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); 705 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false);
706 706
707 // Send an initial wheel event with NSEventPhaseBegan to the view. 707 // Send an initial wheel event with NSEventPhaseBegan to the view.
708 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0); 708 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0);
709 [view->cocoa_view() scrollWheel:event1]; 709 [view->cocoa_view() scrollWheel:event1];
710 ASSERT_EQ(1U, process_host->sink().message_count()); 710 ASSERT_EQ(1U, process_host->sink().message_count());
711 711
712 // Send an ACK for the first wheel event, so that the queue will be flushed. 712 // Send an ACK for the first wheel event, so that the queue will be flushed.
713 InputHostMsg_HandleInputEvent_ACK_Params ack; 713 InputEventAck ack(blink::WebInputEvent::MouseWheel,
714 ack.type = blink::WebInputEvent::MouseWheel; 714 INPUT_EVENT_ACK_STATE_CONSUMED);
715 ack.state = INPUT_EVENT_ACK_STATE_CONSUMED;
716 scoped_ptr<IPC::Message> response( 715 scoped_ptr<IPC::Message> response(
717 new InputHostMsg_HandleInputEvent_ACK(0, ack)); 716 new InputHostMsg_HandleInputEvent_ACK(0, ack));
718 host->OnMessageReceived(*response); 717 host->OnMessageReceived(*response);
719 718
720 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the 719 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the
721 // render view receives it. 720 // render view receives it.
722 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); 721 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0);
723 [NSApp postEvent:event2 atStart:NO]; 722 [NSApp postEvent:event2 atStart:NO];
724 base::MessageLoop::current()->RunUntilIdle(); 723 base::MessageLoop::current()->RunUntilIdle();
725 ASSERT_EQ(2U, process_host->sink().message_count()); 724 ASSERT_EQ(2U, process_host->sink().message_count());
(...skipping 23 matching lines...) Expand all
749 [[MockRenderWidgetHostViewMacDelegate alloc] init]); 748 [[MockRenderWidgetHostViewMacDelegate alloc] init]);
750 view->SetDelegate(view_delegate.get()); 749 view->SetDelegate(view_delegate.get());
751 750
752 // Send an initial wheel event for scrolling by 3 lines. 751 // Send an initial wheel event for scrolling by 3 lines.
753 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3); 752 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3);
754 [view->cocoa_view() scrollWheel:event1]; 753 [view->cocoa_view() scrollWheel:event1];
755 ASSERT_EQ(1U, process_host->sink().message_count()); 754 ASSERT_EQ(1U, process_host->sink().message_count());
756 process_host->sink().ClearMessages(); 755 process_host->sink().ClearMessages();
757 756
758 // Indicate that the wheel event was unhandled. 757 // Indicate that the wheel event was unhandled.
759 InputHostMsg_HandleInputEvent_ACK_Params unhandled_ack; 758 InputEventAck unhandled_ack(blink::WebInputEvent::MouseWheel,
760 unhandled_ack.type = blink::WebInputEvent::MouseWheel; 759 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
761 unhandled_ack.state = INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
762 scoped_ptr<IPC::Message> response1( 760 scoped_ptr<IPC::Message> response1(
763 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack)); 761 new InputHostMsg_HandleInputEvent_ACK(0, unhandled_ack));
764 host->OnMessageReceived(*response1); 762 host->OnMessageReceived(*response1);
765 763
766 // Check that the view delegate got an unhandled wheel event. 764 // Check that the view delegate got an unhandled wheel event.
767 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived); 765 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived);
768 view_delegate.get().unhandledWheelEventReceived = NO; 766 view_delegate.get().unhandledWheelEventReceived = NO;
769 767
770 // Send another wheel event, this time for scrolling by 0 lines (empty event). 768 // Send another wheel event, this time for scrolling by 0 lines (empty event).
771 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0); 769 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 // out |OnMessageReceived()|. 874 // out |OnMessageReceived()|.
877 TestBrowserContext browser_context; 875 TestBrowserContext browser_context;
878 MockRenderProcessHost* process_host = 876 MockRenderProcessHost* process_host =
879 new MockRenderProcessHost(&browser_context); 877 new MockRenderProcessHost(&browser_context);
880 MockRenderWidgetHostDelegate delegate; 878 MockRenderWidgetHostDelegate delegate;
881 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( 879 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl(
882 &delegate, process_host, MSG_ROUTING_NONE); 880 &delegate, process_host, MSG_ROUTING_NONE);
883 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); 881 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false);
884 882
885 // We'll use this IPC message to ack events. 883 // We'll use this IPC message to ack events.
886 InputHostMsg_HandleInputEvent_ACK_Params ack; 884 InputEventAck ack(blink::WebInputEvent::GesturePinchUpdate,
887 ack.type = blink::WebInputEvent::GesturePinchUpdate; 885 INPUT_EVENT_ACK_STATE_CONSUMED);
888 ack.state = INPUT_EVENT_ACK_STATE_CONSUMED;
889 scoped_ptr<IPC::Message> response( 886 scoped_ptr<IPC::Message> response(
890 new InputHostMsg_HandleInputEvent_ACK(0, ack)); 887 new InputHostMsg_HandleInputEvent_ACK(0, ack));
891 888
892 // Do a gesture that crosses the threshold. 889 // Do a gesture that crosses the threshold.
893 { 890 {
894 NSEvent* pinchBeginEvent = 891 NSEvent* pinchBeginEvent =
895 MockGestureEvent(NSEventTypeBeginGesture, 100.1, 0); 892 MockGestureEvent(NSEventTypeBeginGesture, 100.1, 0);
896 NSEvent* pinchUpdateEvents[3] = { 893 NSEvent* pinchUpdateEvents[3] = {
897 MockGestureEvent(NSEventTypeMagnify, 100.2, 0.25), 894 MockGestureEvent(NSEventTypeMagnify, 100.2, 0.25),
898 MockGestureEvent(NSEventTypeMagnify, 100.3, 0.25), 895 MockGestureEvent(NSEventTypeMagnify, 100.3, 0.25),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 971
975 process_host->sink().ClearMessages(); 972 process_host->sink().ClearMessages();
976 } 973 }
977 974
978 // Clean up. 975 // Clean up.
979 host->Shutdown(); 976 host->Shutdown();
980 } 977 }
981 978
982 979
983 } // namespace content 980 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698